| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110 |
- !function(e, t) {
- "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define("babylonjs", [], t) : "object" == typeof exports ? exports.babylonjs = t() : e.BABYLON = t()
- }("undefined" != typeof self ? self : "undefined" != typeof global ? global : this, (function() {
- return (()=>{
- "use strict";
- var e = {
- d: (t,i)=>{
- for (var n in i)
- e.o(i, n) && !e.o(t, n) && Object.defineProperty(t, n, {
- enumerable: !0,
- get: i[n]
- })
- }
- };
- e.g = function() {
- if ("object" == typeof globalThis)
- return globalThis;
- try {
- return this || new Function("return this")()
- } catch (e) {
- if ("object" == typeof window)
- return window
- }
- }(),
- e.o = (e,t)=>Object.prototype.hasOwnProperty.call(e, t),
- e.r = e=>{
- "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
- value: "Module"
- }),
- Object.defineProperty(e, "__esModule", {
- value: !0
- })
- }
- ;
- var t = {};
- e.d(t, {
- default: ()=>XE
- });
- var i = {};
- e.r(i),
- e.d(i, {
- AxesViewer: ()=>xl,
- BoneAxesViewer: ()=>Rl,
- DebugLayer: ()=>Cl,
- DebugLayerTab: ()=>bl,
- DirectionalLightFrustumViewer: ()=>uc,
- PhysicsViewer: ()=>Wl,
- RayHelper: ()=>tc,
- SkeletonViewer: ()=>cc
- });
- var n = {};
- e.r(n),
- e.d(n, {
- AbstractActionManager: ()=>s,
- AbstractAssetTask: ()=>jb,
- AbstractMesh: ()=>Sr,
- AbstractScene: ()=>o,
- AcquireNativeObjectAsync: ()=>ru,
- Action: ()=>F,
- ActionEvent: ()=>w,
- ActionManager: ()=>_e,
- AddBlock: ()=>Hm,
- AddressMode: ()=>Tu,
- AdvancedTimer: ()=>Uf,
- AlphaState: ()=>Dt,
- AmmoJSPlugin: ()=>I_,
- AnaglyphArcRotateCamera: ()=>za,
- AnaglyphFreeCamera: ()=>Wa,
- AnaglyphGamepadCamera: ()=>Ha,
- AnaglyphPostProcess: ()=>ka,
- AnaglyphUniversalCamera: ()=>Xa,
- Analyser: ()=>Wr,
- AndOrNotEvaluator: ()=>ve,
- Angle: ()=>An,
- Animatable: ()=>bn,
- AnimatedInputBlockTypes: ()=>qp,
- Animation: ()=>Qe,
- AnimationEvent: ()=>zn,
- AnimationGroup: ()=>Hn,
- AnimationKeyInterpolation: ()=>ke,
- AnimationPropertiesOverride: ()=>En,
- AnimationRange: ()=>We,
- AnisotropyBlock: ()=>Og,
- ApplyPostProcess: ()=>Ic,
- Arc2: ()=>xn,
- ArcFollowCamera: ()=>Ea,
- ArcRotateCamera: ()=>_a,
- ArcRotateCameraGamepadInput: ()=>Ho,
- ArcRotateCameraInputsManager: ()=>Ko,
- ArcRotateCameraKeyboardMoveInput: ()=>Xo,
- ArcRotateCameraMouseWheelInput: ()=>jo,
- ArcRotateCameraPointersInput: ()=>Yo,
- ArcRotateCameraVRDeviceOrientationInput: ()=>Qo,
- ArcTan2Block: ()=>pg,
- AssetContainer: ()=>zr,
- AssetTaskState: ()=>Wb,
- AssetsManager: ()=>nT,
- AssetsProgressEvent: ()=>Yb,
- AsyncLoop: ()=>yi,
- AttachToBoxBehavior: ()=>po,
- AudioEngine: ()=>Hr,
- AudioSceneComponent: ()=>Yr,
- AutoReleaseWorkerPool: ()=>vp,
- AutoRotationBehavior: ()=>lo,
- AxesViewer: ()=>xl,
- Axis: ()=>vn,
- AxisDragGizmo: ()=>Al,
- AxisScaleGizmo: ()=>fd,
- BRDFTextureTools: ()=>Xd,
- BabylonFileLoaderConfiguration: ()=>N_,
- BackEase: ()=>On,
- BackgroundMaterial: ()=>Vd,
- BakedVertexAnimationManager: ()=>Qr,
- BaseCameraMouseWheelInput: ()=>Bo,
- BaseCameraPointersInput: ()=>Uo,
- BaseError: ()=>dt,
- BaseParticleSystem: ()=>Tf,
- BaseSixDofDragBehavior: ()=>Ro,
- BaseTexture: ()=>Zr,
- BasisTools: ()=>um,
- BasisToolsOptions: ()=>nm,
- BasisTranscodeConfiguration: ()=>im,
- BezierCurve: ()=>Sn,
- BezierCurveEase: ()=>Gn,
- BinaryFileAssetTask: ()=>Zb,
- BlackAndWhitePostProcess: ()=>Uy,
- BlendFactor: ()=>Lu,
- BlendOperation: ()=>Fu,
- BloomEffect: ()=>zy,
- BloomMergePostProcess: ()=>Gy,
- BlurPostProcess: ()=>Fd,
- Bone: ()=>yn,
- BoneAxesViewer: ()=>Rl,
- BoneIKController: ()=>No,
- BoneLookController: ()=>Lo,
- BonesBlock: ()=>Em,
- BounceEase: ()=>Dn,
- BouncingBehavior: ()=>co,
- BoundingBox: ()=>tr,
- BoundingBoxGizmo: ()=>_d,
- BoundingBoxRenderer: ()=>Ab,
- BoundingInfo: ()=>sr,
- BoundingSphere: ()=>ir,
- BoxBuilder: ()=>Il,
- BoxParticleEmitter: ()=>hf,
- Buffer: ()=>wi,
- BufferBindingType: ()=>xu,
- BufferUsage: ()=>fu,
- CSG: ()=>cv,
- Camera: ()=>Rr,
- CameraGizmo: ()=>Ld,
- CameraInputTypes: ()=>Vo,
- CameraInputsManager: ()=>ko,
- CannonJSPlugin: ()=>P_,
- CanvasCompositingAlphaMode: ()=>Xu,
- CapsuleBuilder: ()=>zl,
- CascadedShadowGenerator: ()=>p_,
- ChromaticAberrationPostProcess: ()=>Wy,
- CircleEase: ()=>In,
- CircleOfConfusionPostProcess: ()=>Hy,
- ClampBlock: ()=>jm,
- ClearCoatBlock: ()=>Ng,
- ClipPlanesBlock: ()=>Wm,
- ClipboardEventTypes: ()=>nd,
- ClipboardInfo: ()=>rd,
- CloudBlock: ()=>zg,
- CloudPoint: ()=>Ay,
- Collider: ()=>pl,
- Color3: ()=>D,
- Color3Gradient: ()=>cy,
- Color4: ()=>N,
- ColorCorrectionPostProcess: ()=>Xy,
- ColorCurves: ()=>Ai,
- ColorGradient: ()=>ly,
- ColorGradingTexture: ()=>Y_,
- ColorMergerBlock: ()=>Zm,
- ColorSplitterBlock: ()=>Ef,
- ColorWrite: ()=>Nu,
- CombineAction: ()=>ie,
- CompareFunction: ()=>Su,
- CompatibilityOptions: ()=>pr,
- CompilationMessageType: ()=>Mu,
- ComputeBindingType: ()=>_l,
- ComputeEffect: ()=>ml,
- ComputePassTimestampLocation: ()=>ku,
- ComputePressureObserverWrapper: ()=>_n,
- ComputeShader: ()=>gl,
- ComputeShaderParticleSystem: ()=>ay,
- Condition: ()=>H,
- ConditionalBlock: ()=>Gg,
- ConditionalBlockConditions: ()=>Vg,
- ConeParticleEmitter: ()=>df,
- Constants: ()=>a,
- ContainerAssetTask: ()=>Kb,
- ConvolutionPostProcess: ()=>jy,
- Coordinate: ()=>gn,
- CopyTools: ()=>to,
- CreateBox: ()=>Ml,
- CreateBoxVertexData: ()=>Pl,
- CreateCapsule: ()=>Gl,
- CreateCapsuleVertexData: ()=>kl,
- CreateCylinder: ()=>Ys,
- CreateCylinderVertexData: ()=>js,
- CreateDashedLines: ()=>$l,
- CreateDashedLinesVertexData: ()=>ql,
- CreateDecal: ()=>wv,
- CreateDisc: ()=>Pd,
- CreateEnvTextureAsync: ()=>Gc,
- CreateGeodesic: ()=>zv,
- CreateGoldberg: ()=>Hv,
- CreateGoldbergVertexData: ()=>Wv,
- CreateGround: ()=>il,
- CreateGroundFromHeightMap: ()=>rl,
- CreateGroundFromHeightMapVertexData: ()=>tl,
- CreateGroundVertexData: ()=>$s,
- CreateHemisphere: ()=>Id,
- CreateIcoSphere: ()=>Lv,
- CreateIcoSphereVertexData: ()=>Nv,
- CreateImageDataArrayBufferViews: ()=>Wc,
- CreateLathe: ()=>Mv,
- CreateLineSystem: ()=>Zl,
- CreateLineSystemVertexData: ()=>Ql,
- CreateLines: ()=>Jl,
- CreatePlane: ()=>vo,
- CreatePlaneVertexData: ()=>go,
- CreatePolygon: ()=>Rv,
- CreatePolygonVertexData: ()=>xv,
- CreatePolyhedron: ()=>Td,
- CreatePolyhedronVertexData: ()=>bd,
- CreateResizedCopy: ()=>Mc,
- CreateRibbon: ()=>nc,
- CreateRibbonVertexData: ()=>ic,
- CreateScreenshot: ()=>AT,
- CreateScreenshotAsync: ()=>xT,
- CreateScreenshotUsingRenderTarget: ()=>CT,
- CreateScreenshotUsingRenderTargetAsync: ()=>PT,
- CreateScreenshotWithResizeAsync: ()=>RT,
- CreateSphere: ()=>Dl,
- CreateSphereVertexData: ()=>Ol,
- CreateTiledBox: ()=>mv,
- CreateTiledBoxVertexData: ()=>_v,
- CreateTiledGround: ()=>nl,
- CreateTiledGroundVertexData: ()=>el,
- CreateTiledPlane: ()=>pv,
- CreateTiledPlaneVertexData: ()=>dv,
- CreateTorus: ()=>qs,
- CreateTorusKnot: ()=>yv,
- CreateTorusKnotVertexData: ()=>vv,
- CreateTorusVertexData: ()=>Qs,
- CreateTube: ()=>Ov,
- CrossBlock: ()=>Ym,
- CubeMapToSphericalPolynomialTools: ()=>wc,
- CubeTexture: ()=>Bd,
- CubeTextureAssetTask: ()=>eT,
- CubicEase: ()=>Nn,
- CullMode: ()=>Du,
- CurrentScreenBlock: ()=>nf,
- Curve3: ()=>Pn,
- CustomBlock: ()=>Km,
- CustomOptimization: ()=>pT,
- CustomParticleEmitter: ()=>yf,
- CustomProceduralTexture: ()=>mm,
- CylinderBuilder: ()=>Ks,
- CylinderDirectedParticleEmitter: ()=>ff,
- CylinderParticleEmitter: ()=>pf,
- DDSTools: ()=>pp,
- DataBuffer: ()=>Bt,
- DataReader: ()=>NT,
- DataStorage: ()=>LT,
- Database: ()=>ny,
- DaydreamController: ()=>ad,
- DebugLayer: ()=>Cl,
- DebugLayerTab: ()=>bl,
- DecalBuilder: ()=>Bv,
- Decode: ()=>se,
- DecodeBase64ToBinary: ()=>ue,
- DecodeBase64ToString: ()=>ce,
- DecodeBase64UrlToBinary: ()=>oi,
- DecodeBase64UrlToString: ()=>si,
- DeepCopier: ()=>fe,
- DefaultCollisionCoordinator: ()=>fl,
- DefaultLoadingScreen: ()=>m_,
- DefaultRenderingPipeline: ()=>db,
- Deferred: ()=>rT,
- DepthCullingState: ()=>It,
- DepthOfFieldBlurPostProcess: ()=>Yy,
- DepthOfFieldEffect: ()=>Zy,
- DepthOfFieldEffectBlurLevel: ()=>Ky,
- DepthOfFieldMergePostProcess: ()=>qy,
- DepthOfFieldMergePostProcessOptions: ()=>Qy,
- DepthPeelingRenderer: ()=>Cb,
- DepthPeelingSceneComponent: ()=>Pb,
- DepthReducer: ()=>s_,
- DepthRenderer: ()=>o_,
- DepthRendererSceneComponent: ()=>xb,
- DepthSortedParticle: ()=>Ty,
- DerivativeBlock: ()=>Im,
- DesaturateBlock: ()=>Mg,
- DetailMapConfiguration: ()=>Ps,
- DeviceInputEventType: ()=>Li,
- DeviceLostReason: ()=>ju,
- DeviceOrientationCamera: ()=>ma,
- DeviceSource: ()=>on,
- DeviceSourceManager: ()=>sn,
- DeviceType: ()=>Ci,
- DirectionalLight: ()=>Rd,
- DirectionalLightFrustumViewer: ()=>uc,
- DiscBuilder: ()=>Md,
- DiscardBlock: ()=>Pm,
- DisplayPassPostProcess: ()=>Jy,
- DistanceBlock: ()=>lg,
- DistanceJoint: ()=>Fl,
- DivideBlock: ()=>eg,
- DoNothingAction: ()=>te,
- DomManagement: ()=>lt,
- DotBlock: ()=>Qm,
- DracoCompression: ()=>iv,
- DrawWrapper: ()=>Gt,
- DualSenseInput: ()=>Oi,
- DualShockButton: ()=>Ca,
- DualShockDpad: ()=>Pa,
- DualShockInput: ()=>Ii,
- DualShockPad: ()=>Ia,
- DynamicFloat32Array: ()=>zT,
- DynamicTexture: ()=>Ds,
- EasingFunction: ()=>Mn,
- EdgesRenderer: ()=>Ib,
- Effect: ()=>Mt,
- EffectFallbacks: ()=>ys,
- EffectLayer: ()=>Kf,
- EffectLayerSceneComponent: ()=>Qf,
- EffectRenderer: ()=>y_,
- EffectWrapper: ()=>b_,
- ElasticEase: ()=>Ln,
- ElbowBlock: ()=>Hg,
- EncodeArrayBufferToBase64: ()=>le,
- EndsWith: ()=>oe,
- Engine: ()=>vr,
- EngineFactory: ()=>id,
- EngineInstrumentation: ()=>jf,
- EngineStore: ()=>E,
- EngineView: ()=>mc,
- EnvironmentHelper: ()=>kd,
- EnvironmentTextureTools: ()=>Qc,
- Epsilon: ()=>m,
- EquiRectangularCubeTexture: ()=>K_,
- EquiRectangularCubeTextureAssetTask: ()=>iT,
- ErrorCodes: ()=>pt,
- ErrorFilter: ()=>Yu,
- EventConstants: ()=>$i,
- EventState: ()=>l,
- ExecuteCodeAction: ()=>ne,
- ExponentialEase: ()=>Fn,
- ExternalTexture: ()=>Mh,
- ExtractHighlightsPostProcess: ()=>ky,
- ExtrudePolygon: ()=>Cv,
- ExtrudeShape: ()=>oc,
- ExtrudeShapeCustom: ()=>ac,
- FactorGradient: ()=>uy,
- FadeInOutBehavior: ()=>fo,
- FeatureName: ()=>pu,
- FileTools: ()=>ai,
- FileToolsOptions: ()=>qt,
- FilesInput: ()=>aT,
- FilesInputStore: ()=>ut,
- FilterMode: ()=>Eu,
- FilterPostProcess: ()=>$y,
- FlyCamera: ()=>va,
- FlyCameraInputsManager: ()=>ga,
- FlyCameraKeyboardInput: ()=>qo,
- FlyCameraMouseInput: ()=>Zo,
- FogBlock: ()=>Fm,
- FollowBehavior: ()=>Mo,
- FollowCamera: ()=>Ta,
- FollowCameraInputsManager: ()=>ya,
- FollowCameraKeyboardMoveInput: ()=>Jo,
- FollowCameraMouseWheelInput: ()=>$o,
- FollowCameraPointersInput: ()=>ea,
- FragCoordBlock: ()=>Om,
- FragmentOutputBlock: ()=>Zp,
- FramingBehavior: ()=>uo,
- FreeCamera: ()=>pa,
- FreeCameraDeviceOrientationInput: ()=>sa,
- FreeCameraGamepadInput: ()=>ca,
- FreeCameraInputsManager: ()=>aa,
- FreeCameraKeyboardMoveInput: ()=>ta,
- FreeCameraMouseInput: ()=>na,
- FreeCameraMouseWheelInput: ()=>ra,
- FreeCameraTouchInput: ()=>oa,
- FreeCameraVirtualJoystickInput: ()=>ha,
- FresnelBlock: ()=>og,
- FresnelParameters: ()=>z_,
- FromHalfFloat: ()=>Dc,
- FrontFace: ()=>Ou,
- FrontFacingBlock: ()=>Mm,
- Frustum: ()=>dn,
- FxaaPostProcess: ()=>eb,
- GPUParticleSystem: ()=>_y,
- GUID: ()=>_i,
- Gamepad: ()=>zo,
- GamepadCamera: ()=>La,
- GamepadManager: ()=>Oa,
- GamepadSystemSceneComponent: ()=>Da,
- GearVRController: ()=>sd,
- GenerateBase64StringFromPixelData: ()=>Jr,
- GenerateBase64StringFromTexture: ()=>$r,
- GenerateBase64StringFromTextureAsync: ()=>eo,
- GenericController: ()=>ld,
- GenericPad: ()=>Wo,
- GeodesicData: ()=>Gv,
- Geometry: ()=>fr,
- GeometryBufferRenderer: ()=>nb,
- GeometryBufferRendererSceneComponent: ()=>ob,
- GetClass: ()=>b,
- GetDOMTextContent: ()=>at,
- GetEnvInfo: ()=>Vc,
- GetEnvironmentBRDFTexture: ()=>Hd,
- GetInternalFormatFromBasisFormat: ()=>rm,
- GetTGAHeader: ()=>q_,
- Gizmo: ()=>Sl,
- GizmoManager: ()=>Ad,
- GlowLayer: ()=>qf,
- GoldbergMesh: ()=>uv,
- GradientBlock: ()=>Tg,
- GradientBlockColorStep: ()=>bg,
- GradientHelper: ()=>hy,
- GrainPostProcess: ()=>tb,
- GroundBuilder: ()=>ol,
- GroundMesh: ()=>Js,
- HDRCubeTexture: ()=>E_,
- HDRCubeTextureAssetTask: ()=>tT,
- HDRFiltering: ()=>T_,
- HDRTools: ()=>v_,
- HandConstraintBehavior: ()=>Do,
- HandConstraintOrientation: ()=>Eo,
- HandConstraintVisibility: ()=>So,
- HandConstraintZone: ()=>To,
- HardwareScalingOptimization: ()=>cT,
- HemisphereBuilder: ()=>Od,
- HemisphericLight: ()=>ds,
- HemisphericParticleEmitter: ()=>_f,
- HighlightLayer: ()=>Jf,
- HighlightsPostProcess: ()=>ib,
- Hinge2Joint: ()=>Ul,
- HingeJoint: ()=>Bl,
- HtmlElementTexture: ()=>Q_,
- IWebXRControllerPhysicsOptions: ()=>nE,
- IcoSphereBuilder: ()=>Fv,
- ImageAssetTask: ()=>Jb,
- ImageProcessingBlock: ()=>Rm,
- ImageProcessingConfiguration: ()=>Ri,
- ImageProcessingConfigurationDefines: ()=>xi,
- ImageProcessingPostProcess: ()=>Fs,
- ImageSourceBlock: ()=>Um,
- IncrementValueAction: ()=>J,
- IndexFormat: ()=>Bu,
- InputBlock: ()=>tf,
- InputStepMode: ()=>Vu,
- InspectableType: ()=>IT,
- InstancedLinesMesh: ()=>Kl,
- InstancedMesh: ()=>Hl,
- InstancesBlock: ()=>Sm,
- InstantiatedEntries: ()=>Gr,
- InternalTexture: ()=>Lt,
- InternalTextureSource: ()=>At,
- InterpolateValueAction: ()=>qe,
- IntersectionInfo: ()=>er,
- IsBase64DataUrl: ()=>ri,
- IsDocumentAvailable: ()=>ot,
- IsFileURL: ()=>ni,
- IsNavigatorAvailable: ()=>rt,
- IsWindowObjectExist: ()=>nt,
- JoystickAxis: ()=>la,
- KeepAssets: ()=>kr,
- KeyboardEventTypes: ()=>Qi,
- KeyboardInfo: ()=>qi,
- KeyboardInfoPre: ()=>Zi,
- KhronosTextureContainer: ()=>mp,
- KhronosTextureContainer2: ()=>yp,
- LatheBuilder: ()=>Iv,
- Layer: ()=>e_,
- LayerSceneComponent: ()=>$f,
- LengthBlock: ()=>cg,
- LensFlare: ()=>t_,
- LensFlareSystem: ()=>i_,
- LensFlareSystemSceneComponent: ()=>n_,
- LensFlaresOptimization: ()=>dT,
- LensRenderingPipeline: ()=>pb,
- LerpBlock: ()=>$m,
- Light: ()=>Cr,
- LightBlock: ()=>wm,
- LightGizmo: ()=>Nd,
- LightInformationBlock: ()=>xm,
- LineEdgesRenderer: ()=>Ob,
- LinesBuilder: ()=>ec,
- LinesMesh: ()=>Yl,
- LoadFile: ()=>ti,
- LoadFileError: ()=>Yt,
- LoadImage: ()=>$t,
- LoadOp: ()=>zu,
- LoadTextureFromTranscodeResult: ()=>cm,
- Logger: ()=>K,
- MapMode: ()=>_u,
- Material: ()=>Or,
- MaterialAnisotropicDefines: ()=>qd,
- MaterialClearCoatDefines: ()=>Kd,
- MaterialDefines: ()=>Si,
- MaterialDetailMapDefines: ()=>Cs,
- MaterialFlags: ()=>vs,
- MaterialHelper: ()=>Mr,
- MaterialPluginBase: ()=>Rs,
- MaterialPluginManager: ()=>bs,
- MaterialSheenDefines: ()=>Jd,
- MaterialSubSurfaceDefines: ()=>ep,
- Matrix: ()=>P,
- MatrixBuilderBlock: ()=>kg,
- MaxBlock: ()=>ag,
- MergeMeshesOptimization: ()=>mT,
- Mesh: ()=>Vr,
- MeshAssetTask: ()=>Qb,
- MeshBuilder: ()=>jv,
- MeshExploder: ()=>oT,
- MeshLODLevel: ()=>Nr,
- MeshParticleEmitter: ()=>bf,
- MeshoptCompression: ()=>nv,
- MinBlock: ()=>sg,
- MinMaxReducer: ()=>a_,
- MirrorTexture: ()=>wd,
- ModBlock: ()=>Ug,
- ModelShape: ()=>by,
- MorphTarget: ()=>S_,
- MorphTargetManager: ()=>x_,
- MorphTargetsBlock: ()=>Am,
- MotionBlurPostProcess: ()=>ab,
- MotorEnabledJoint: ()=>wl,
- MultiMaterial: ()=>Dr,
- MultiObserver: ()=>u,
- MultiPointerScaleBehavior: ()=>xo,
- MultiRenderTarget: ()=>pm,
- MultiplyBlock: ()=>uf,
- NLerpBlock: ()=>Eg,
- NativeDataStream: ()=>bc,
- NativeEngine: ()=>uu,
- NativePointerInput: ()=>Mi,
- NativeXRFrame: ()=>VE,
- NativeXRLayerRenderTargetTextureProvider: ()=>Ws,
- NativeXRLayerWrapper: ()=>zs,
- NativeXRRenderTarget: ()=>Hs,
- NegateBlock: ()=>ug,
- Node: ()=>Xe,
- NodeMaterial: ()=>Of,
- NodeMaterialBlock: ()=>Wp,
- NodeMaterialBlockConnectionPointMode: ()=>Kp,
- NodeMaterialBlockConnectionPointTypes: ()=>Op,
- NodeMaterialBlockTargets: ()=>Dp,
- NodeMaterialConnectionPoint: ()=>zp,
- NodeMaterialConnectionPointCompatibilityStates: ()=>Up,
- NodeMaterialConnectionPointDirection: ()=>Vp,
- NodeMaterialDefines: ()=>If,
- NodeMaterialModes: ()=>cf,
- NodeMaterialOptimizer: ()=>Xg,
- NodeMaterialSystemValues: ()=>Qp,
- NoiseProceduralTexture: ()=>gm,
- NormalBlendBlock: ()=>xg,
- NormalizeBlock: ()=>qm,
- NullEngine: ()=>dc,
- NullEngineOptions: ()=>hc,
- Observable: ()=>h,
- Observer: ()=>c,
- OcclusionMaterial: ()=>W_,
- Octree: ()=>yl,
- OctreeBlock: ()=>vl,
- OctreeSceneComponent: ()=>Tl,
- OculusTouchController: ()=>cd,
- OimoJSPlugin: ()=>M_,
- OnAfterEnteringVRObservableEvent: ()=>ul,
- OneMinusBlock: ()=>ng,
- Orientation: ()=>Tn,
- OutlineRenderer: ()=>Ub,
- PBRAnisotropicConfiguration: ()=>Zd,
- PBRBaseMaterial: ()=>rp,
- PBRBaseSimpleMaterial: ()=>H_,
- PBRClearCoatConfiguration: ()=>Qd,
- PBRMaterial: ()=>op,
- PBRMaterialDefines: ()=>np,
- PBRMetallicRoughnessBlock: ()=>Bg,
- PBRMetallicRoughnessMaterial: ()=>X_,
- PBRSheenConfiguration: ()=>$d,
- PBRSpecularGlossinessMaterial: ()=>j_,
- PBRSubSurfaceConfiguration: ()=>tp,
- PHI: ()=>_,
- PadNumber: ()=>he,
- PanoramaToCubeMapTools: ()=>g_,
- Particle: ()=>dy,
- ParticleBlendMultiplyBlock: ()=>af,
- ParticleHelper: ()=>gy,
- ParticleRampGradientBlock: ()=>of,
- ParticleSystem: ()=>fy,
- ParticleSystemSet: ()=>my,
- ParticleTextureBlock: ()=>rf,
- ParticlesOptimization: ()=>fT,
- PassCubePostProcess: ()=>Va,
- PassPostProcess: ()=>Ua,
- Path2: ()=>Rn,
- Path3D: ()=>Cn,
- PathCursor: ()=>Xn,
- PerfCollectionStrategy: ()=>qT,
- PerfCounter: ()=>un,
- PerformanceConfigurator: ()=>T,
- PerformanceMonitor: ()=>_r,
- PerformanceViewerCollector: ()=>KT,
- PerturbNormalBlock: ()=>Cm,
- PhotoDome: ()=>zd,
- PhysicsEngine: ()=>R_,
- PhysicsEngineSceneComponent: ()=>My,
- PhysicsHelper: ()=>Iy,
- PhysicsImpostor: ()=>Vl,
- PhysicsJoint: ()=>Ll,
- PhysicsRadialExplosionEventOptions: ()=>Fy,
- PhysicsRadialImpulseFalloff: ()=>Cy,
- PhysicsUpdraftEventOptions: ()=>wy,
- PhysicsUpdraftMode: ()=>Py,
- PhysicsViewer: ()=>Wl,
- PhysicsVortexEventOptions: ()=>By,
- PickingInfo: ()=>Ui,
- PivotTools: ()=>mo,
- Plane: ()=>hn,
- PlaneBuilder: ()=>yo,
- PlaneDragGizmo: ()=>vd,
- PlaneRotationGizmo: ()=>md,
- PlayAnimationAction: ()=>$,
- PlaySoundAction: ()=>me,
- PointColor: ()=>vy,
- PointLight: ()=>__,
- PointParticleEmitter: ()=>mf,
- PointerDragBehavior: ()=>Ao,
- PointerEventTypes: ()=>Xi,
- PointerInfo: ()=>Ki,
- PointerInfoBase: ()=>ji,
- PointerInfoPre: ()=>Yi,
- PointerInput: ()=>Pi,
- PointsCloudSystem: ()=>Ry,
- PointsGroup: ()=>xy,
- Polygon: ()=>Sv,
- PolygonBuilder: ()=>Pv,
- PolygonMeshBuilder: ()=>Av,
- PolyhedronBuilder: ()=>Ed,
- PolyhedronData: ()=>kv,
- PoseEnabledController: ()=>Ra,
- PoseEnabledControllerHelper: ()=>xa,
- PoseEnabledControllerType: ()=>ba,
- PositionGizmo: ()=>yd,
- PositionNormalTextureVertex: ()=>Ec,
- PositionNormalVertex: ()=>Tc,
- PostProcess: ()=>Ba,
- PostProcessManager: ()=>Vi,
- PostProcessRenderEffect: ()=>Vy,
- PostProcessRenderPipeline: ()=>cb,
- PostProcessRenderPipelineManager: ()=>ub,
- PostProcessRenderPipelineManagerSceneComponent: ()=>hb,
- PostProcessesOptimization: ()=>hT,
- PosterizeBlock: ()=>vg,
- PowBlock: ()=>hg,
- PowerEase: ()=>wn,
- PowerPreference: ()=>du,
- PrePassRenderer: ()=>Nb,
- PrePassRendererSceneComponent: ()=>Lb,
- PrecisionDate: ()=>ct,
- PredefinedColorSpace: ()=>hu,
- PredicateCondition: ()=>j,
- PrimitiveTopology: ()=>Iu,
- ProceduralTexture: ()=>xf,
- ProceduralTextureSceneComponent: ()=>Sf,
- PromisePolyfill: ()=>di,
- PropertyTypeForEdition: ()=>Xp,
- PushMaterial: ()=>gs,
- QuadraticEase: ()=>Bn,
- QuadraticErrorSimplification: ()=>$v,
- QuarticEase: ()=>Un,
- Quaternion: ()=>C,
- QueryType: ()=>Hu,
- QuinticEase: ()=>Vn,
- RGBDTextureTools: ()=>Lc,
- RandomGUID: ()=>fi,
- RandomNumberBlock: ()=>dg,
- RawCubeTexture: ()=>vm,
- RawTexture: ()=>ao,
- RawTexture2DArray: ()=>A_,
- RawTexture3D: ()=>ym,
- Ray: ()=>_o,
- RayHelper: ()=>tc,
- ReadFile: ()=>ei,
- ReadFileError: ()=>Qt,
- RecastJSCrowd: ()=>iy,
- RecastJSPlugin: ()=>ty,
- ReciprocalBlock: ()=>_g,
- ReflectBlock: ()=>Cg,
- ReflectionBlock: ()=>Dg,
- ReflectionProbe: ()=>O_,
- ReflectionTextureBlock: ()=>Gm,
- Reflector: ()=>GT,
- RefractBlock: ()=>Pg,
- RefractionBlock: ()=>Lg,
- RefractionPostProcess: ()=>sb,
- RefractionTexture: ()=>bm,
- RegisterClass: ()=>y,
- RegisterMaterialPlugin: ()=>Ss,
- RegisterNativeTypeAsync: ()=>ou,
- RemapBlock: ()=>lf,
- RenderPassTimestampLocation: ()=>Gu,
- RenderTargetTexture: ()=>ns,
- RenderTargetWrapper: ()=>Fa,
- RenderTargetsOptimization: ()=>_T,
- RenderingGroup: ()=>ki,
- RenderingGroupInfo: ()=>Gi,
- RenderingManager: ()=>zi,
- ReplaceColorBlock: ()=>mg,
- RequestFile: ()=>ii,
- RequestFileError: ()=>Kt,
- RetryStrategy: ()=>ht,
- RibbonBuilder: ()=>rc,
- RollingAverage: ()=>mr,
- Rotate2dBlock: ()=>Rg,
- RotationGizmo: ()=>gd,
- RuntimeAnimation: ()=>it,
- RuntimeError: ()=>ft,
- SSAO2RenderingPipeline: ()=>_b,
- SSAORenderingPipeline: ()=>mb,
- SamplerBindingType: ()=>Ru,
- Scalar: ()=>d,
- ScaleBlock: ()=>Xm,
- ScaleGizmo: ()=>Sd,
- Scene: ()=>mn,
- SceneComponentConstants: ()=>Wi,
- SceneDepthBlock: ()=>zm,
- SceneInstrumentation: ()=>Yf,
- SceneLoader: ()=>od,
- SceneLoaderAnimationGroupLoadingMode: ()=>td,
- SceneLoaderFlags: ()=>dr,
- SceneOptimization: ()=>sT,
- SceneOptimizer: ()=>vT,
- SceneOptimizerOptions: ()=>gT,
- SceneRecorder: ()=>FT,
- SceneSerializer: ()=>ET,
- ScreenSizeBlock: ()=>Dm,
- ScreenSpaceBlock: ()=>Nm,
- ScreenSpaceCurvaturePostProcess: ()=>Sb,
- ScreenSpaceReflectionPostProcess: ()=>vb,
- ScreenshotTools: ()=>OT,
- SerializationHelper: ()=>Ge,
- SetCorsBehavior: ()=>Jt,
- SetParentAction: ()=>re,
- SetStateAction: ()=>q,
- SetValueAction: ()=>Z,
- ShaderCodeInliner: ()=>iu,
- ShaderLanguage: ()=>st,
- ShaderMaterial: ()=>jl,
- ShaderStage: ()=>Au,
- ShaderStore: ()=>Pt,
- ShadowDepthWrapper: ()=>Yg,
- ShadowGenerator: ()=>r_,
- ShadowGeneratorSceneComponent: ()=>f_,
- ShadowLight: ()=>xd,
- ShadowsOptimization: ()=>uT,
- ShapeBuilder: ()=>lc,
- SharpenPostProcess: ()=>lb,
- SheenBlock: ()=>Ig,
- SimplexPerlin3DBlock: ()=>Ag,
- SimplicationQueueSceneComponent: ()=>ey,
- SimplificationQueue: ()=>Kv,
- SimplificationSettings: ()=>Yv,
- SimplificationType: ()=>Xv,
- SineEase: ()=>kn,
- SixDofDragBehavior: ()=>Co,
- Size: ()=>je,
- Skeleton: ()=>Fo,
- SkeletonViewer: ()=>cc,
- SmartArray: ()=>bi,
- SmartArrayNoDuplicate: ()=>Ti,
- SmoothStepBlock: ()=>fg,
- SolidParticle: ()=>yy,
- SolidParticleSystem: ()=>Sy,
- SolidParticleVertex: ()=>Ey,
- Sound: ()=>Xr,
- SoundTrack: ()=>jr,
- Space: ()=>Ji,
- SphereBuilder: ()=>Nl,
- SphereDirectedParticleEmitter: ()=>vf,
- SphereParticleEmitter: ()=>gf,
- SphericalHarmonics: ()=>Cc,
- SphericalPolynomial: ()=>Pc,
- SpotLight: ()=>Dd,
- Sprite: ()=>Vb,
- SpriteManager: ()=>zb,
- SpriteMap: ()=>Hb,
- SpritePackedManager: ()=>Xb,
- SpriteSceneComponent: ()=>kb,
- Stage: ()=>Hi,
- StandardMaterial: ()=>Os,
- StandardMaterialDefines: ()=>Is,
- StandardRenderingPipeline: ()=>yb,
- StartsWith: ()=>ae,
- StateCondition: ()=>Y,
- StencilOperation: ()=>wu,
- StencilState: ()=>Ot,
- StencilStateComposer: ()=>zt,
- StepBlock: ()=>ig,
- StereoscopicArcRotateCamera: ()=>Qa,
- StereoscopicFreeCamera: ()=>qa,
- StereoscopicGamepadCamera: ()=>Za,
- StereoscopicInterlacePostProcess: ()=>Ya,
- StereoscopicInterlacePostProcessI: ()=>ja,
- StereoscopicScreenUniversalCamera: ()=>$a,
- StereoscopicUniversalCamera: ()=>Ja,
- StickValues: ()=>Go,
- StopAnimationAction: ()=>ee,
- StopSoundAction: ()=>ge,
- StorageBuffer: ()=>wo,
- StorageTextureAccess: ()=>Pu,
- StoreOp: ()=>Wu,
- StringDictionary: ()=>Ei,
- StringTools: ()=>de,
- SubEmitter: ()=>py,
- SubEmitterType: ()=>sy,
- SubMesh: ()=>hr,
- SubSurfaceBlock: ()=>Fg,
- SubSurfaceSceneComponent: ()=>Bb,
- SubtractBlock: ()=>tg,
- SurfaceMagnetismBehavior: ()=>Po,
- SwitchBooleanAction: ()=>Q,
- SwitchInput: ()=>Ni,
- TGATools: ()=>J_,
- Tags: ()=>ye,
- TargetCamera: ()=>da,
- TargetedAnimation: ()=>Wn,
- TextFileAssetTask: ()=>qb,
- Texture: ()=>io,
- TextureAspect: ()=>yu,
- TextureAssetTask: ()=>$b,
- TextureBlock: ()=>Vm,
- TextureDimension: ()=>mu,
- TextureFormat: ()=>bu,
- TextureOptimization: ()=>lT,
- TexturePacker: ()=>_m,
- TexturePackerFrame: ()=>fm,
- TextureSampleType: ()=>Cu,
- TextureSampler: ()=>Nt,
- TextureTools: ()=>Nc,
- TextureUsage: ()=>gu,
- TextureViewDimension: ()=>vu,
- ThinEngine: ()=>Ht,
- ThinMaterialHelper: ()=>Pr,
- ThinRenderTargetTexture: ()=>Tm,
- ThinTexture: ()=>qr,
- TiledBoxBuilder: ()=>gv,
- TiledPlaneBuilder: ()=>fv,
- TimerState: ()=>Nf,
- TmpColors: ()=>L,
- TmpVectors: ()=>I,
- ToGammaSpace: ()=>p,
- ToHalfFloat: ()=>Oc,
- ToLinearSpace: ()=>f,
- TonemapPostProcess: ()=>Tb,
- TonemappingOperator: ()=>bb,
- Tools: ()=>gi,
- TorusBuilder: ()=>Zs,
- TorusKnotBuilder: ()=>bv,
- TouchCamera: ()=>fa,
- TrailMesh: ()=>hv,
- Trajectory: ()=>wT,
- TrajectoryClassifier: ()=>kT,
- TranscodeAsync: ()=>lm,
- TransformBlock: ()=>Hp,
- TransformNode: ()=>yr,
- TrigonometryBlock: ()=>Rf,
- TrigonometryBlockOperations: ()=>Af,
- TubeBuilder: ()=>Dv,
- TwirlBlock: ()=>Lm,
- UniformBuffer: ()=>Fi,
- UniversalCamera: ()=>Na,
- UnregisterAllMaterialPlugins: ()=>xs,
- UnregisterMaterialPlugin: ()=>As,
- UploadContent: ()=>Z_,
- UploadEnvLevelsAsync: ()=>Hc,
- UploadEnvSpherical: ()=>Yc,
- UploadLevelsAsync: ()=>jc,
- UtilityLayerRenderer: ()=>El,
- VRCameraMetrics: ()=>ts,
- VRDeviceOrientationArcRotateCamera: ()=>cs,
- VRDeviceOrientationFreeCamera: ()=>us,
- VRDeviceOrientationGamepadCamera: ()=>hs,
- VRDistortionCorrectionPostProcess: ()=>is,
- VRExperienceHelper: ()=>hl,
- VRMultiviewToSingleviewPostProcess: ()=>ss,
- ValidatedNativeDataStream: ()=>Ku,
- ValueCondition: ()=>X,
- Vector2: ()=>A,
- Vector3: ()=>x,
- Vector4: ()=>R,
- VectorMergerBlock: ()=>sf,
- VectorSplitterBlock: ()=>Jm,
- VertexAnimationBaker: ()=>so,
- VertexBuffer: ()=>Bi,
- VertexData: ()=>$n,
- VertexFormat: ()=>Uu,
- VertexOutputBlock: ()=>jp,
- VideoDome: ()=>Xf,
- VideoRecorder: ()=>ST,
- VideoTexture: ()=>Hf,
- ViewDirectionBlock: ()=>rg,
- Viewport: ()=>xr,
- VirtualJoystick: ()=>ua,
- VirtualJoysticksCamera: ()=>es,
- ViveController: ()=>ud,
- VolumetricLightScatteringPostProcess: ()=>Eb,
- VoronoiNoiseBlock: ()=>Wg,
- WaveBlock: ()=>yg,
- WaveBlockKind: ()=>gg,
- WebGL2ParticleSystem: ()=>oy,
- WebGL2ShaderProcessor: ()=>wt,
- WebGLDataBuffer: ()=>Ut,
- WebGLHardwareTexture: ()=>kt,
- WebGLPipelineContext: ()=>Vt,
- WebGPUCacheBindGroups: ()=>Nh,
- WebGPUCacheRenderPipeline: ()=>Ah,
- WebGPUCacheRenderPipelineTree: ()=>Rh,
- WebGPUCacheSampler: ()=>Th,
- WebGPUDataBuffer: ()=>_h,
- WebGPUDrawContext: ()=>Oh,
- WebGPUEngine: ()=>Qh,
- WebGPUTintWASM: ()=>Yh,
- WebRequest: ()=>Ye,
- WebVRController: ()=>_s,
- WebVRFreeCamera: ()=>fs,
- WebXRAbstractFeature: ()=>wp,
- WebXRAbstractMotionController: ()=>xp,
- WebXRAnchorSystem: ()=>$T,
- WebXRBackgroundRemover: ()=>iE,
- WebXRCamera: ()=>Ep,
- WebXRCompositionLayerWrapper: ()=>AE,
- WebXRControllerComponent: ()=>Ap,
- WebXRControllerMovement: ()=>mE,
- WebXRControllerPhysics: ()=>rE,
- WebXRControllerPointerSelection: ()=>Bp,
- WebXRDefaultExperience: ()=>Gf,
- WebXRDefaultExperienceOptions: ()=>kf,
- WebXRDomOverlay: ()=>_E,
- WebXREnterExitUI: ()=>wf,
- WebXREnterExitUIButton: ()=>Lf,
- WebXREnterExitUIOptions: ()=>Ff,
- WebXRExperienceHelper: ()=>Sp,
- WebXREyeTracking: ()=>vE,
- WebXRFeatureName: ()=>Io,
- WebXRFeaturePointSystem: ()=>sE,
- WebXRFeaturesManager: ()=>Oo,
- WebXRGenericHandController: ()=>OE,
- WebXRGenericTriggerMotionController: ()=>Rp,
- WebXRHTCViveMotionController: ()=>BE,
- WebXRHand: ()=>uE,
- WebXRHandTracking: ()=>hE,
- WebXRHitTest: ()=>oE,
- WebXRHitTestLegacy: ()=>ZT,
- WebXRImageTracking: ()=>fE,
- WebXRInput: ()=>Fp,
- WebXRInputSource: ()=>Lp,
- WebXRLayers: ()=>IE,
- WebXRLightEstimation: ()=>gE,
- WebXRManagedOutputCanvas: ()=>Gs,
- WebXRManagedOutputCanvasOptions: ()=>ks,
- WebXRMeshDetector: ()=>pE,
- WebXRMicrosoftMixedRealityController: ()=>NE,
- WebXRMotionControllerManager: ()=>Ip,
- WebXRMotionControllerTeleportation: ()=>Vf,
- WebXRNearControllerMode: ()=>Pf,
- WebXRNearInteraction: ()=>Df,
- WebXROculusTouchMotionController: ()=>FE,
- WebXRPlaneDetector: ()=>tE,
- WebXRProfiledMotionController: ()=>Pp,
- WebXRProjectionLayerWrapper: ()=>RE,
- WebXRSessionManager: ()=>Xs,
- WebXRState: ()=>Ns,
- WebXRTrackingState: ()=>Ls,
- WebXRWalkingLocomotion: ()=>SE,
- WeightedSound: ()=>Kr,
- WindowsMotionController: ()=>dd,
- WorkerPool: ()=>gp,
- WorleyNoise3DBlock: ()=>Sg,
- XRWindowsMotionController: ()=>pd,
- Xbox360Button: ()=>Sa,
- Xbox360Dpad: ()=>Aa,
- Xbox360Pad: ()=>Ma,
- XboxInput: ()=>Di,
- _BabylonLoaderRegistered: ()=>D_,
- _BasisTextureLoader: ()=>dm,
- _CreationDataStorage: ()=>Lr,
- _DDSTextureLoader: ()=>fp,
- _ENVTextureLoader: ()=>_p,
- _HDRTextureLoader: ()=>em,
- _IAnimationState: ()=>Ke,
- _InstancesBatch: ()=>wr,
- _KTXTextureLoader: ()=>Tp,
- _MeshCollisionData: ()=>br,
- _OcclusionDataStorage: ()=>fc,
- _PrimaryIsoTriangle: ()=>Vv,
- _TGATextureLoader: ()=>$_,
- _TimeToken: ()=>pc,
- _UpdateRGBDAsync: ()=>Kc,
- _forceSceneHelpersToBundle: ()=>zf,
- _forceTransformFeedbackToBundle: ()=>_c,
- _injectLTSFileTools: ()=>ci,
- allocateAndCopyTypedBuffer: ()=>gr,
- className: ()=>vi,
- createDetailMapPlugin: ()=>$g,
- createPBRAnisotropicPlugin: ()=>Kg,
- createPBRBRDFPlugin: ()=>Qg,
- createPBRClearCoatPlugin: ()=>qg,
- createPBRSheenPlugin: ()=>Zg,
- createPBRSubSurfacePlugin: ()=>Jg,
- createYieldingScheduler: ()=>Yn,
- editableInPropertyPage: ()=>Yp,
- expandToProperty: ()=>Re,
- extractMinAndMax: ()=>ur,
- extractMinAndMaxIndexed: ()=>cr,
- inlineScheduler: ()=>jn,
- makeAsyncFunction: ()=>Jn,
- makeSyncFunction: ()=>Zn,
- nativeOverride: ()=>ze,
- normalizeEnvInfo: ()=>kc,
- runCoroutine: ()=>Kn,
- runCoroutineAsync: ()=>qn,
- runCoroutineSync: ()=>Qn,
- serialize: ()=>Ce,
- serializeAsCameraReference: ()=>Ve,
- serializeAsColor3: ()=>Me,
- serializeAsColor4: ()=>Fe,
- serializeAsColorCurves: ()=>Le,
- serializeAsFresnelParameters: ()=>Ie,
- serializeAsImageProcessingConfiguration: ()=>we,
- serializeAsMatrix: ()=>Ue,
- serializeAsMeshReference: ()=>Ne,
- serializeAsQuaternion: ()=>Be,
- serializeAsTexture: ()=>Pe,
- serializeAsVector2: ()=>Oe,
- serializeAsVector3: ()=>De,
- setAndStartTimer: ()=>Bf,
- setStereoscopicAnaglyphRigMode: ()=>Ga,
- setStereoscopicRigMode: ()=>Ka,
- setVRRigMode: ()=>ls,
- setWebVRRigMode: ()=>ps
- });
- var r = {};
- e.r(r),
- e.d(r, {
- AbstractActionManager: ()=>s,
- AbstractAssetTask: ()=>jb,
- AbstractMesh: ()=>Sr,
- AbstractScene: ()=>o,
- AcquireNativeObjectAsync: ()=>ru,
- Action: ()=>F,
- ActionEvent: ()=>w,
- ActionManager: ()=>_e,
- AddBlock: ()=>Hm,
- AddressMode: ()=>Tu,
- AdvancedTimer: ()=>Uf,
- AlphaState: ()=>Dt,
- AmmoJSPlugin: ()=>I_,
- AnaglyphArcRotateCamera: ()=>za,
- AnaglyphFreeCamera: ()=>Wa,
- AnaglyphGamepadCamera: ()=>Ha,
- AnaglyphPostProcess: ()=>ka,
- AnaglyphUniversalCamera: ()=>Xa,
- Analyser: ()=>Wr,
- AndOrNotEvaluator: ()=>ve,
- Angle: ()=>An,
- Animatable: ()=>bn,
- AnimatedInputBlockTypes: ()=>qp,
- Animation: ()=>Qe,
- AnimationEvent: ()=>zn,
- AnimationGroup: ()=>Hn,
- AnimationKeyInterpolation: ()=>ke,
- AnimationPropertiesOverride: ()=>En,
- AnimationRange: ()=>We,
- AnisotropyBlock: ()=>Og,
- ApplyPostProcess: ()=>Ic,
- Arc2: ()=>xn,
- ArcFollowCamera: ()=>Ea,
- ArcRotateCamera: ()=>_a,
- ArcRotateCameraGamepadInput: ()=>Ho,
- ArcRotateCameraInputsManager: ()=>Ko,
- ArcRotateCameraKeyboardMoveInput: ()=>Xo,
- ArcRotateCameraMouseWheelInput: ()=>jo,
- ArcRotateCameraPointersInput: ()=>Yo,
- ArcRotateCameraVRDeviceOrientationInput: ()=>Qo,
- ArcTan2Block: ()=>pg,
- AssetContainer: ()=>zr,
- AssetTaskState: ()=>Wb,
- AssetsManager: ()=>nT,
- AssetsProgressEvent: ()=>Yb,
- AsyncLoop: ()=>yi,
- AttachToBoxBehavior: ()=>po,
- AudioEngine: ()=>Hr,
- AudioSceneComponent: ()=>Yr,
- AutoReleaseWorkerPool: ()=>vp,
- AutoRotationBehavior: ()=>lo,
- AxesViewer: ()=>xl,
- Axis: ()=>vn,
- AxisDragGizmo: ()=>Al,
- AxisScaleGizmo: ()=>fd,
- BRDFTextureTools: ()=>Xd,
- BabylonFileLoaderConfiguration: ()=>N_,
- BackEase: ()=>On,
- BackgroundMaterial: ()=>Vd,
- BakedVertexAnimationManager: ()=>Qr,
- BaseCameraMouseWheelInput: ()=>Bo,
- BaseCameraPointersInput: ()=>Uo,
- BaseError: ()=>dt,
- BaseParticleSystem: ()=>Tf,
- BaseSixDofDragBehavior: ()=>Ro,
- BaseTexture: ()=>Zr,
- BasisTools: ()=>um,
- BasisToolsOptions: ()=>nm,
- BasisTranscodeConfiguration: ()=>im,
- BezierCurve: ()=>Sn,
- BezierCurveEase: ()=>Gn,
- BinaryFileAssetTask: ()=>Zb,
- BlackAndWhitePostProcess: ()=>Uy,
- BlendFactor: ()=>Lu,
- BlendOperation: ()=>Fu,
- BloomEffect: ()=>zy,
- BloomMergePostProcess: ()=>Gy,
- BlurPostProcess: ()=>Fd,
- Bone: ()=>yn,
- BoneAxesViewer: ()=>Rl,
- BoneIKController: ()=>No,
- BoneLookController: ()=>Lo,
- BonesBlock: ()=>Em,
- BounceEase: ()=>Dn,
- BouncingBehavior: ()=>co,
- BoundingBox: ()=>tr,
- BoundingBoxGizmo: ()=>_d,
- BoundingBoxRenderer: ()=>Ab,
- BoundingInfo: ()=>sr,
- BoundingSphere: ()=>ir,
- BoxBuilder: ()=>Il,
- BoxParticleEmitter: ()=>hf,
- Buffer: ()=>wi,
- BufferBindingType: ()=>xu,
- BufferUsage: ()=>fu,
- CSG: ()=>cv,
- Camera: ()=>Rr,
- CameraGizmo: ()=>Ld,
- CameraInputTypes: ()=>Vo,
- CameraInputsManager: ()=>ko,
- CannonJSPlugin: ()=>P_,
- CanvasCompositingAlphaMode: ()=>Xu,
- CapsuleBuilder: ()=>zl,
- CascadedShadowGenerator: ()=>p_,
- ChromaticAberrationPostProcess: ()=>Wy,
- CircleEase: ()=>In,
- CircleOfConfusionPostProcess: ()=>Hy,
- ClampBlock: ()=>jm,
- ClearCoatBlock: ()=>Ng,
- ClipPlanesBlock: ()=>Wm,
- ClipboardEventTypes: ()=>nd,
- ClipboardInfo: ()=>rd,
- CloudBlock: ()=>zg,
- CloudPoint: ()=>Ay,
- Collider: ()=>pl,
- Color3: ()=>D,
- Color3Gradient: ()=>cy,
- Color4: ()=>N,
- ColorCorrectionPostProcess: ()=>Xy,
- ColorCurves: ()=>Ai,
- ColorGradient: ()=>ly,
- ColorGradingTexture: ()=>Y_,
- ColorMergerBlock: ()=>Zm,
- ColorSplitterBlock: ()=>Ef,
- ColorWrite: ()=>Nu,
- CombineAction: ()=>ie,
- CompareFunction: ()=>Su,
- CompatibilityOptions: ()=>pr,
- CompilationMessageType: ()=>Mu,
- ComputeBindingType: ()=>_l,
- ComputeEffect: ()=>ml,
- ComputePassTimestampLocation: ()=>ku,
- ComputePressureObserverWrapper: ()=>_n,
- ComputeShader: ()=>gl,
- ComputeShaderParticleSystem: ()=>ay,
- Condition: ()=>H,
- ConditionalBlock: ()=>Gg,
- ConditionalBlockConditions: ()=>Vg,
- ConeParticleEmitter: ()=>df,
- Constants: ()=>a,
- ContainerAssetTask: ()=>Kb,
- ConvolutionPostProcess: ()=>jy,
- Coordinate: ()=>gn,
- CopyTools: ()=>to,
- CreateBox: ()=>Ml,
- CreateBoxVertexData: ()=>Pl,
- CreateCapsule: ()=>Gl,
- CreateCapsuleVertexData: ()=>kl,
- CreateCylinder: ()=>Ys,
- CreateCylinderVertexData: ()=>js,
- CreateDashedLines: ()=>$l,
- CreateDashedLinesVertexData: ()=>ql,
- CreateDecal: ()=>wv,
- CreateDisc: ()=>Pd,
- CreateEnvTextureAsync: ()=>Gc,
- CreateGeodesic: ()=>zv,
- CreateGoldberg: ()=>Hv,
- CreateGoldbergVertexData: ()=>Wv,
- CreateGround: ()=>il,
- CreateGroundFromHeightMap: ()=>rl,
- CreateGroundFromHeightMapVertexData: ()=>tl,
- CreateGroundVertexData: ()=>$s,
- CreateHemisphere: ()=>Id,
- CreateIcoSphere: ()=>Lv,
- CreateIcoSphereVertexData: ()=>Nv,
- CreateImageDataArrayBufferViews: ()=>Wc,
- CreateLathe: ()=>Mv,
- CreateLineSystem: ()=>Zl,
- CreateLineSystemVertexData: ()=>Ql,
- CreateLines: ()=>Jl,
- CreatePlane: ()=>vo,
- CreatePlaneVertexData: ()=>go,
- CreatePolygon: ()=>Rv,
- CreatePolygonVertexData: ()=>xv,
- CreatePolyhedron: ()=>Td,
- CreatePolyhedronVertexData: ()=>bd,
- CreateResizedCopy: ()=>Mc,
- CreateRibbon: ()=>nc,
- CreateRibbonVertexData: ()=>ic,
- CreateScreenshot: ()=>AT,
- CreateScreenshotAsync: ()=>xT,
- CreateScreenshotUsingRenderTarget: ()=>CT,
- CreateScreenshotUsingRenderTargetAsync: ()=>PT,
- CreateScreenshotWithResizeAsync: ()=>RT,
- CreateSphere: ()=>Dl,
- CreateSphereVertexData: ()=>Ol,
- CreateTiledBox: ()=>mv,
- CreateTiledBoxVertexData: ()=>_v,
- CreateTiledGround: ()=>nl,
- CreateTiledGroundVertexData: ()=>el,
- CreateTiledPlane: ()=>pv,
- CreateTiledPlaneVertexData: ()=>dv,
- CreateTorus: ()=>qs,
- CreateTorusKnot: ()=>yv,
- CreateTorusKnotVertexData: ()=>vv,
- CreateTorusVertexData: ()=>Qs,
- CreateTube: ()=>Ov,
- CrossBlock: ()=>Ym,
- CubeMapToSphericalPolynomialTools: ()=>wc,
- CubeTexture: ()=>Bd,
- CubeTextureAssetTask: ()=>eT,
- CubicEase: ()=>Nn,
- CullMode: ()=>Du,
- CurrentScreenBlock: ()=>nf,
- Curve3: ()=>Pn,
- CustomBlock: ()=>Km,
- CustomOptimization: ()=>pT,
- CustomParticleEmitter: ()=>yf,
- CustomProceduralTexture: ()=>mm,
- CylinderBuilder: ()=>Ks,
- CylinderDirectedParticleEmitter: ()=>ff,
- CylinderParticleEmitter: ()=>pf,
- DDSTools: ()=>pp,
- DataBuffer: ()=>Bt,
- DataReader: ()=>NT,
- DataStorage: ()=>LT,
- Database: ()=>ny,
- DaydreamController: ()=>ad,
- Debug: ()=>HE,
- DebugLayer: ()=>Cl,
- DebugLayerTab: ()=>bl,
- DecalBuilder: ()=>Bv,
- Decode: ()=>se,
- DecodeBase64ToBinary: ()=>ue,
- DecodeBase64ToString: ()=>ce,
- DecodeBase64UrlToBinary: ()=>oi,
- DecodeBase64UrlToString: ()=>si,
- DeepCopier: ()=>fe,
- DefaultCollisionCoordinator: ()=>fl,
- DefaultLoadingScreen: ()=>m_,
- DefaultRenderingPipeline: ()=>db,
- Deferred: ()=>rT,
- DepthCullingState: ()=>It,
- DepthOfFieldBlurPostProcess: ()=>Yy,
- DepthOfFieldEffect: ()=>Zy,
- DepthOfFieldEffectBlurLevel: ()=>Ky,
- DepthOfFieldMergePostProcess: ()=>qy,
- DepthOfFieldMergePostProcessOptions: ()=>Qy,
- DepthPeelingRenderer: ()=>Cb,
- DepthPeelingSceneComponent: ()=>Pb,
- DepthReducer: ()=>s_,
- DepthRenderer: ()=>o_,
- DepthRendererSceneComponent: ()=>xb,
- DepthSortedParticle: ()=>Ty,
- DerivativeBlock: ()=>Im,
- DesaturateBlock: ()=>Mg,
- DetailMapConfiguration: ()=>Ps,
- DeviceInputEventType: ()=>Li,
- DeviceLostReason: ()=>ju,
- DeviceOrientationCamera: ()=>ma,
- DeviceSource: ()=>on,
- DeviceSourceManager: ()=>sn,
- DeviceType: ()=>Ci,
- DirectionalLight: ()=>Rd,
- DirectionalLightFrustumViewer: ()=>uc,
- DiscBuilder: ()=>Md,
- DiscardBlock: ()=>Pm,
- DisplayPassPostProcess: ()=>Jy,
- DistanceBlock: ()=>lg,
- DistanceJoint: ()=>Fl,
- DivideBlock: ()=>eg,
- DoNothingAction: ()=>te,
- DomManagement: ()=>lt,
- DotBlock: ()=>Qm,
- DracoCompression: ()=>iv,
- DrawWrapper: ()=>Gt,
- DualSenseInput: ()=>Oi,
- DualShockButton: ()=>Ca,
- DualShockDpad: ()=>Pa,
- DualShockInput: ()=>Ii,
- DualShockPad: ()=>Ia,
- DynamicFloat32Array: ()=>zT,
- DynamicTexture: ()=>Ds,
- EasingFunction: ()=>Mn,
- EdgesRenderer: ()=>Ib,
- Effect: ()=>Mt,
- EffectFallbacks: ()=>ys,
- EffectLayer: ()=>Kf,
- EffectLayerSceneComponent: ()=>Qf,
- EffectRenderer: ()=>y_,
- EffectWrapper: ()=>b_,
- ElasticEase: ()=>Ln,
- ElbowBlock: ()=>Hg,
- EncodeArrayBufferToBase64: ()=>le,
- EndsWith: ()=>oe,
- Engine: ()=>vr,
- EngineFactory: ()=>id,
- EngineInstrumentation: ()=>jf,
- EngineStore: ()=>E,
- EngineView: ()=>mc,
- EnvironmentHelper: ()=>kd,
- EnvironmentTextureTools: ()=>Qc,
- Epsilon: ()=>m,
- EquiRectangularCubeTexture: ()=>K_,
- EquiRectangularCubeTextureAssetTask: ()=>iT,
- ErrorCodes: ()=>pt,
- ErrorFilter: ()=>Yu,
- EventConstants: ()=>$i,
- EventState: ()=>l,
- ExecuteCodeAction: ()=>ne,
- ExponentialEase: ()=>Fn,
- ExternalTexture: ()=>Mh,
- ExtractHighlightsPostProcess: ()=>ky,
- ExtrudePolygon: ()=>Cv,
- ExtrudeShape: ()=>oc,
- ExtrudeShapeCustom: ()=>ac,
- FactorGradient: ()=>uy,
- FadeInOutBehavior: ()=>fo,
- FeatureName: ()=>pu,
- FileTools: ()=>ai,
- FileToolsOptions: ()=>qt,
- FilesInput: ()=>aT,
- FilesInputStore: ()=>ut,
- FilterMode: ()=>Eu,
- FilterPostProcess: ()=>$y,
- FlyCamera: ()=>va,
- FlyCameraInputsManager: ()=>ga,
- FlyCameraKeyboardInput: ()=>qo,
- FlyCameraMouseInput: ()=>Zo,
- FogBlock: ()=>Fm,
- FollowBehavior: ()=>Mo,
- FollowCamera: ()=>Ta,
- FollowCameraInputsManager: ()=>ya,
- FollowCameraKeyboardMoveInput: ()=>Jo,
- FollowCameraMouseWheelInput: ()=>$o,
- FollowCameraPointersInput: ()=>ea,
- FragCoordBlock: ()=>Om,
- FragmentOutputBlock: ()=>Zp,
- FramingBehavior: ()=>uo,
- FreeCamera: ()=>pa,
- FreeCameraDeviceOrientationInput: ()=>sa,
- FreeCameraGamepadInput: ()=>ca,
- FreeCameraInputsManager: ()=>aa,
- FreeCameraKeyboardMoveInput: ()=>ta,
- FreeCameraMouseInput: ()=>na,
- FreeCameraMouseWheelInput: ()=>ra,
- FreeCameraTouchInput: ()=>oa,
- FreeCameraVirtualJoystickInput: ()=>ha,
- FresnelBlock: ()=>og,
- FresnelParameters: ()=>z_,
- FromHalfFloat: ()=>Dc,
- FrontFace: ()=>Ou,
- FrontFacingBlock: ()=>Mm,
- Frustum: ()=>dn,
- FxaaPostProcess: ()=>eb,
- GPUParticleSystem: ()=>_y,
- GUID: ()=>_i,
- Gamepad: ()=>zo,
- GamepadCamera: ()=>La,
- GamepadManager: ()=>Oa,
- GamepadSystemSceneComponent: ()=>Da,
- GearVRController: ()=>sd,
- GenerateBase64StringFromPixelData: ()=>Jr,
- GenerateBase64StringFromTexture: ()=>$r,
- GenerateBase64StringFromTextureAsync: ()=>eo,
- GenericController: ()=>ld,
- GenericPad: ()=>Wo,
- GeodesicData: ()=>Gv,
- Geometry: ()=>fr,
- GeometryBufferRenderer: ()=>nb,
- GeometryBufferRendererSceneComponent: ()=>ob,
- GetClass: ()=>b,
- GetDOMTextContent: ()=>at,
- GetEnvInfo: ()=>Vc,
- GetEnvironmentBRDFTexture: ()=>Hd,
- GetInternalFormatFromBasisFormat: ()=>rm,
- GetTGAHeader: ()=>q_,
- Gizmo: ()=>Sl,
- GizmoManager: ()=>Ad,
- GlowLayer: ()=>qf,
- GoldbergMesh: ()=>uv,
- GradientBlock: ()=>Tg,
- GradientBlockColorStep: ()=>bg,
- GradientHelper: ()=>hy,
- GrainPostProcess: ()=>tb,
- GroundBuilder: ()=>ol,
- GroundMesh: ()=>Js,
- HDRCubeTexture: ()=>E_,
- HDRCubeTextureAssetTask: ()=>tT,
- HDRFiltering: ()=>T_,
- HDRTools: ()=>v_,
- HandConstraintBehavior: ()=>Do,
- HandConstraintOrientation: ()=>Eo,
- HandConstraintVisibility: ()=>So,
- HandConstraintZone: ()=>To,
- HardwareScalingOptimization: ()=>cT,
- HemisphereBuilder: ()=>Od,
- HemisphericLight: ()=>ds,
- HemisphericParticleEmitter: ()=>_f,
- HighlightLayer: ()=>Jf,
- HighlightsPostProcess: ()=>ib,
- Hinge2Joint: ()=>Ul,
- HingeJoint: ()=>Bl,
- HtmlElementTexture: ()=>Q_,
- IWebXRControllerPhysicsOptions: ()=>nE,
- IcoSphereBuilder: ()=>Fv,
- ImageAssetTask: ()=>Jb,
- ImageProcessingBlock: ()=>Rm,
- ImageProcessingConfiguration: ()=>Ri,
- ImageProcessingConfigurationDefines: ()=>xi,
- ImageProcessingPostProcess: ()=>Fs,
- ImageSourceBlock: ()=>Um,
- IncrementValueAction: ()=>J,
- IndexFormat: ()=>Bu,
- InputBlock: ()=>tf,
- InputStepMode: ()=>Vu,
- InspectableType: ()=>IT,
- InstancedLinesMesh: ()=>Kl,
- InstancedMesh: ()=>Hl,
- InstancesBlock: ()=>Sm,
- InstantiatedEntries: ()=>Gr,
- InternalTexture: ()=>Lt,
- InternalTextureSource: ()=>At,
- InterpolateValueAction: ()=>qe,
- IntersectionInfo: ()=>er,
- IsBase64DataUrl: ()=>ri,
- IsDocumentAvailable: ()=>ot,
- IsFileURL: ()=>ni,
- IsNavigatorAvailable: ()=>rt,
- IsWindowObjectExist: ()=>nt,
- JoystickAxis: ()=>la,
- KeepAssets: ()=>kr,
- KeyboardEventTypes: ()=>Qi,
- KeyboardInfo: ()=>qi,
- KeyboardInfoPre: ()=>Zi,
- KhronosTextureContainer: ()=>mp,
- KhronosTextureContainer2: ()=>yp,
- LatheBuilder: ()=>Iv,
- Layer: ()=>e_,
- LayerSceneComponent: ()=>$f,
- LengthBlock: ()=>cg,
- LensFlare: ()=>t_,
- LensFlareSystem: ()=>i_,
- LensFlareSystemSceneComponent: ()=>n_,
- LensFlaresOptimization: ()=>dT,
- LensRenderingPipeline: ()=>pb,
- LerpBlock: ()=>$m,
- Light: ()=>Cr,
- LightBlock: ()=>wm,
- LightGizmo: ()=>Nd,
- LightInformationBlock: ()=>xm,
- LineEdgesRenderer: ()=>Ob,
- LinesBuilder: ()=>ec,
- LinesMesh: ()=>Yl,
- LoadFile: ()=>ti,
- LoadFileError: ()=>Yt,
- LoadImage: ()=>$t,
- LoadOp: ()=>zu,
- LoadTextureFromTranscodeResult: ()=>cm,
- Logger: ()=>K,
- MapMode: ()=>_u,
- Material: ()=>Or,
- MaterialAnisotropicDefines: ()=>qd,
- MaterialClearCoatDefines: ()=>Kd,
- MaterialDefines: ()=>Si,
- MaterialDetailMapDefines: ()=>Cs,
- MaterialFlags: ()=>vs,
- MaterialHelper: ()=>Mr,
- MaterialPluginBase: ()=>Rs,
- MaterialPluginManager: ()=>bs,
- MaterialSheenDefines: ()=>Jd,
- MaterialSubSurfaceDefines: ()=>ep,
- Matrix: ()=>P,
- MatrixBuilderBlock: ()=>kg,
- MaxBlock: ()=>ag,
- MergeMeshesOptimization: ()=>mT,
- Mesh: ()=>Vr,
- MeshAssetTask: ()=>Qb,
- MeshBuilder: ()=>jv,
- MeshExploder: ()=>oT,
- MeshLODLevel: ()=>Nr,
- MeshParticleEmitter: ()=>bf,
- MeshoptCompression: ()=>nv,
- MinBlock: ()=>sg,
- MinMaxReducer: ()=>a_,
- MirrorTexture: ()=>wd,
- ModBlock: ()=>Ug,
- ModelShape: ()=>by,
- MorphTarget: ()=>S_,
- MorphTargetManager: ()=>x_,
- MorphTargetsBlock: ()=>Am,
- MotionBlurPostProcess: ()=>ab,
- MotorEnabledJoint: ()=>wl,
- MultiMaterial: ()=>Dr,
- MultiObserver: ()=>u,
- MultiPointerScaleBehavior: ()=>xo,
- MultiRenderTarget: ()=>pm,
- MultiplyBlock: ()=>uf,
- NLerpBlock: ()=>Eg,
- NativeDataStream: ()=>bc,
- NativeEngine: ()=>uu,
- NativePointerInput: ()=>Mi,
- NativeXRFrame: ()=>VE,
- NativeXRLayerRenderTargetTextureProvider: ()=>Ws,
- NativeXRLayerWrapper: ()=>zs,
- NativeXRRenderTarget: ()=>Hs,
- NegateBlock: ()=>ug,
- Node: ()=>Xe,
- NodeMaterial: ()=>Of,
- NodeMaterialBlock: ()=>Wp,
- NodeMaterialBlockConnectionPointMode: ()=>Kp,
- NodeMaterialBlockConnectionPointTypes: ()=>Op,
- NodeMaterialBlockTargets: ()=>Dp,
- NodeMaterialConnectionPoint: ()=>zp,
- NodeMaterialConnectionPointCompatibilityStates: ()=>Up,
- NodeMaterialConnectionPointDirection: ()=>Vp,
- NodeMaterialDefines: ()=>If,
- NodeMaterialModes: ()=>cf,
- NodeMaterialOptimizer: ()=>Xg,
- NodeMaterialSystemValues: ()=>Qp,
- NoiseProceduralTexture: ()=>gm,
- NormalBlendBlock: ()=>xg,
- NormalizeBlock: ()=>qm,
- NullEngine: ()=>dc,
- NullEngineOptions: ()=>hc,
- Observable: ()=>h,
- Observer: ()=>c,
- OcclusionMaterial: ()=>W_,
- Octree: ()=>yl,
- OctreeBlock: ()=>vl,
- OctreeSceneComponent: ()=>Tl,
- OculusTouchController: ()=>cd,
- OimoJSPlugin: ()=>M_,
- OnAfterEnteringVRObservableEvent: ()=>ul,
- OneMinusBlock: ()=>ng,
- Orientation: ()=>Tn,
- OutlineRenderer: ()=>Ub,
- PBRAnisotropicConfiguration: ()=>Zd,
- PBRBaseMaterial: ()=>rp,
- PBRBaseSimpleMaterial: ()=>H_,
- PBRClearCoatConfiguration: ()=>Qd,
- PBRMaterial: ()=>op,
- PBRMaterialDefines: ()=>np,
- PBRMetallicRoughnessBlock: ()=>Bg,
- PBRMetallicRoughnessMaterial: ()=>X_,
- PBRSheenConfiguration: ()=>$d,
- PBRSpecularGlossinessMaterial: ()=>j_,
- PBRSubSurfaceConfiguration: ()=>tp,
- PHI: ()=>_,
- PadNumber: ()=>he,
- PanoramaToCubeMapTools: ()=>g_,
- Particle: ()=>dy,
- ParticleBlendMultiplyBlock: ()=>af,
- ParticleHelper: ()=>gy,
- ParticleRampGradientBlock: ()=>of,
- ParticleSystem: ()=>fy,
- ParticleSystemSet: ()=>my,
- ParticleTextureBlock: ()=>rf,
- ParticlesOptimization: ()=>fT,
- PassCubePostProcess: ()=>Va,
- PassPostProcess: ()=>Ua,
- Path2: ()=>Rn,
- Path3D: ()=>Cn,
- PathCursor: ()=>Xn,
- PerfCollectionStrategy: ()=>qT,
- PerfCounter: ()=>un,
- PerformanceConfigurator: ()=>T,
- PerformanceMonitor: ()=>_r,
- PerformanceViewerCollector: ()=>KT,
- PerturbNormalBlock: ()=>Cm,
- PhotoDome: ()=>zd,
- PhysicsEngine: ()=>R_,
- PhysicsEngineSceneComponent: ()=>My,
- PhysicsHelper: ()=>Iy,
- PhysicsImpostor: ()=>Vl,
- PhysicsJoint: ()=>Ll,
- PhysicsRadialExplosionEventOptions: ()=>Fy,
- PhysicsRadialImpulseFalloff: ()=>Cy,
- PhysicsUpdraftEventOptions: ()=>wy,
- PhysicsUpdraftMode: ()=>Py,
- PhysicsViewer: ()=>Wl,
- PhysicsVortexEventOptions: ()=>By,
- PickingInfo: ()=>Ui,
- PivotTools: ()=>mo,
- Plane: ()=>hn,
- PlaneBuilder: ()=>yo,
- PlaneDragGizmo: ()=>vd,
- PlaneRotationGizmo: ()=>md,
- PlayAnimationAction: ()=>$,
- PlaySoundAction: ()=>me,
- PointColor: ()=>vy,
- PointLight: ()=>__,
- PointParticleEmitter: ()=>mf,
- PointerDragBehavior: ()=>Ao,
- PointerEventTypes: ()=>Xi,
- PointerInfo: ()=>Ki,
- PointerInfoBase: ()=>ji,
- PointerInfoPre: ()=>Yi,
- PointerInput: ()=>Pi,
- PointsCloudSystem: ()=>Ry,
- PointsGroup: ()=>xy,
- Polygon: ()=>Sv,
- PolygonBuilder: ()=>Pv,
- PolygonMeshBuilder: ()=>Av,
- PolyhedronBuilder: ()=>Ed,
- PolyhedronData: ()=>kv,
- PoseEnabledController: ()=>Ra,
- PoseEnabledControllerHelper: ()=>xa,
- PoseEnabledControllerType: ()=>ba,
- PositionGizmo: ()=>yd,
- PositionNormalTextureVertex: ()=>Ec,
- PositionNormalVertex: ()=>Tc,
- PostProcess: ()=>Ba,
- PostProcessManager: ()=>Vi,
- PostProcessRenderEffect: ()=>Vy,
- PostProcessRenderPipeline: ()=>cb,
- PostProcessRenderPipelineManager: ()=>ub,
- PostProcessRenderPipelineManagerSceneComponent: ()=>hb,
- PostProcessesOptimization: ()=>hT,
- PosterizeBlock: ()=>vg,
- PowBlock: ()=>hg,
- PowerEase: ()=>wn,
- PowerPreference: ()=>du,
- PrePassRenderer: ()=>Nb,
- PrePassRendererSceneComponent: ()=>Lb,
- PrecisionDate: ()=>ct,
- PredefinedColorSpace: ()=>hu,
- PredicateCondition: ()=>j,
- PrimitiveTopology: ()=>Iu,
- ProceduralTexture: ()=>xf,
- ProceduralTextureSceneComponent: ()=>Sf,
- PromisePolyfill: ()=>di,
- PropertyTypeForEdition: ()=>Xp,
- PushMaterial: ()=>gs,
- QuadraticEase: ()=>Bn,
- QuadraticErrorSimplification: ()=>$v,
- QuarticEase: ()=>Un,
- Quaternion: ()=>C,
- QueryType: ()=>Hu,
- QuinticEase: ()=>Vn,
- RGBDTextureTools: ()=>Lc,
- RandomGUID: ()=>fi,
- RandomNumberBlock: ()=>dg,
- RawCubeTexture: ()=>vm,
- RawTexture: ()=>ao,
- RawTexture2DArray: ()=>A_,
- RawTexture3D: ()=>ym,
- Ray: ()=>_o,
- RayHelper: ()=>tc,
- ReadFile: ()=>ei,
- ReadFileError: ()=>Qt,
- RecastJSCrowd: ()=>iy,
- RecastJSPlugin: ()=>ty,
- ReciprocalBlock: ()=>_g,
- ReflectBlock: ()=>Cg,
- ReflectionBlock: ()=>Dg,
- ReflectionProbe: ()=>O_,
- ReflectionTextureBlock: ()=>Gm,
- Reflector: ()=>GT,
- RefractBlock: ()=>Pg,
- RefractionBlock: ()=>Lg,
- RefractionPostProcess: ()=>sb,
- RefractionTexture: ()=>bm,
- RegisterClass: ()=>y,
- RegisterMaterialPlugin: ()=>Ss,
- RegisterNativeTypeAsync: ()=>ou,
- RemapBlock: ()=>lf,
- RenderPassTimestampLocation: ()=>Gu,
- RenderTargetTexture: ()=>ns,
- RenderTargetWrapper: ()=>Fa,
- RenderTargetsOptimization: ()=>_T,
- RenderingGroup: ()=>ki,
- RenderingGroupInfo: ()=>Gi,
- RenderingManager: ()=>zi,
- ReplaceColorBlock: ()=>mg,
- RequestFile: ()=>ii,
- RequestFileError: ()=>Kt,
- RetryStrategy: ()=>ht,
- RibbonBuilder: ()=>rc,
- RollingAverage: ()=>mr,
- Rotate2dBlock: ()=>Rg,
- RotationGizmo: ()=>gd,
- RuntimeAnimation: ()=>it,
- RuntimeError: ()=>ft,
- SSAO2RenderingPipeline: ()=>_b,
- SSAORenderingPipeline: ()=>mb,
- SamplerBindingType: ()=>Ru,
- Scalar: ()=>d,
- ScaleBlock: ()=>Xm,
- ScaleGizmo: ()=>Sd,
- Scene: ()=>mn,
- SceneComponentConstants: ()=>Wi,
- SceneDepthBlock: ()=>zm,
- SceneInstrumentation: ()=>Yf,
- SceneLoader: ()=>od,
- SceneLoaderAnimationGroupLoadingMode: ()=>td,
- SceneLoaderFlags: ()=>dr,
- SceneOptimization: ()=>sT,
- SceneOptimizer: ()=>vT,
- SceneOptimizerOptions: ()=>gT,
- SceneRecorder: ()=>FT,
- SceneSerializer: ()=>ET,
- ScreenSizeBlock: ()=>Dm,
- ScreenSpaceBlock: ()=>Nm,
- ScreenSpaceCurvaturePostProcess: ()=>Sb,
- ScreenSpaceReflectionPostProcess: ()=>vb,
- ScreenshotTools: ()=>OT,
- SerializationHelper: ()=>Ge,
- SetCorsBehavior: ()=>Jt,
- SetParentAction: ()=>re,
- SetStateAction: ()=>q,
- SetValueAction: ()=>Z,
- ShaderCodeInliner: ()=>iu,
- ShaderLanguage: ()=>st,
- ShaderMaterial: ()=>jl,
- ShaderStage: ()=>Au,
- ShaderStore: ()=>Pt,
- ShadowDepthWrapper: ()=>Yg,
- ShadowGenerator: ()=>r_,
- ShadowGeneratorSceneComponent: ()=>f_,
- ShadowLight: ()=>xd,
- ShadowsOptimization: ()=>uT,
- ShapeBuilder: ()=>lc,
- SharpenPostProcess: ()=>lb,
- SheenBlock: ()=>Ig,
- SimplexPerlin3DBlock: ()=>Ag,
- SimplicationQueueSceneComponent: ()=>ey,
- SimplificationQueue: ()=>Kv,
- SimplificationSettings: ()=>Yv,
- SimplificationType: ()=>Xv,
- SineEase: ()=>kn,
- SixDofDragBehavior: ()=>Co,
- Size: ()=>je,
- Skeleton: ()=>Fo,
- SkeletonViewer: ()=>cc,
- SmartArray: ()=>bi,
- SmartArrayNoDuplicate: ()=>Ti,
- SmoothStepBlock: ()=>fg,
- SolidParticle: ()=>yy,
- SolidParticleSystem: ()=>Sy,
- SolidParticleVertex: ()=>Ey,
- Sound: ()=>Xr,
- SoundTrack: ()=>jr,
- Space: ()=>Ji,
- SphereBuilder: ()=>Nl,
- SphereDirectedParticleEmitter: ()=>vf,
- SphereParticleEmitter: ()=>gf,
- SphericalHarmonics: ()=>Cc,
- SphericalPolynomial: ()=>Pc,
- SpotLight: ()=>Dd,
- Sprite: ()=>Vb,
- SpriteManager: ()=>zb,
- SpriteMap: ()=>Hb,
- SpritePackedManager: ()=>Xb,
- SpriteSceneComponent: ()=>kb,
- Stage: ()=>Hi,
- StandardMaterial: ()=>Os,
- StandardMaterialDefines: ()=>Is,
- StandardRenderingPipeline: ()=>yb,
- StartsWith: ()=>ae,
- StateCondition: ()=>Y,
- StencilOperation: ()=>wu,
- StencilState: ()=>Ot,
- StencilStateComposer: ()=>zt,
- StepBlock: ()=>ig,
- StereoscopicArcRotateCamera: ()=>Qa,
- StereoscopicFreeCamera: ()=>qa,
- StereoscopicGamepadCamera: ()=>Za,
- StereoscopicInterlacePostProcess: ()=>Ya,
- StereoscopicInterlacePostProcessI: ()=>ja,
- StereoscopicScreenUniversalCamera: ()=>$a,
- StereoscopicUniversalCamera: ()=>Ja,
- StickValues: ()=>Go,
- StopAnimationAction: ()=>ee,
- StopSoundAction: ()=>ge,
- StorageBuffer: ()=>wo,
- StorageTextureAccess: ()=>Pu,
- StoreOp: ()=>Wu,
- StringDictionary: ()=>Ei,
- StringTools: ()=>de,
- SubEmitter: ()=>py,
- SubEmitterType: ()=>sy,
- SubMesh: ()=>hr,
- SubSurfaceBlock: ()=>Fg,
- SubSurfaceSceneComponent: ()=>Bb,
- SubtractBlock: ()=>tg,
- SurfaceMagnetismBehavior: ()=>Po,
- SwitchBooleanAction: ()=>Q,
- SwitchInput: ()=>Ni,
- TGATools: ()=>J_,
- Tags: ()=>ye,
- TargetCamera: ()=>da,
- TargetedAnimation: ()=>Wn,
- TextFileAssetTask: ()=>qb,
- Texture: ()=>io,
- TextureAspect: ()=>yu,
- TextureAssetTask: ()=>$b,
- TextureBlock: ()=>Vm,
- TextureDimension: ()=>mu,
- TextureFormat: ()=>bu,
- TextureOptimization: ()=>lT,
- TexturePacker: ()=>_m,
- TexturePackerFrame: ()=>fm,
- TextureSampleType: ()=>Cu,
- TextureSampler: ()=>Nt,
- TextureTools: ()=>Nc,
- TextureUsage: ()=>gu,
- TextureViewDimension: ()=>vu,
- ThinEngine: ()=>Ht,
- ThinMaterialHelper: ()=>Pr,
- ThinRenderTargetTexture: ()=>Tm,
- ThinTexture: ()=>qr,
- TiledBoxBuilder: ()=>gv,
- TiledPlaneBuilder: ()=>fv,
- TimerState: ()=>Nf,
- TmpColors: ()=>L,
- TmpVectors: ()=>I,
- ToGammaSpace: ()=>p,
- ToHalfFloat: ()=>Oc,
- ToLinearSpace: ()=>f,
- TonemapPostProcess: ()=>Tb,
- TonemappingOperator: ()=>bb,
- Tools: ()=>gi,
- TorusBuilder: ()=>Zs,
- TorusKnotBuilder: ()=>bv,
- TouchCamera: ()=>fa,
- TrailMesh: ()=>hv,
- Trajectory: ()=>wT,
- TrajectoryClassifier: ()=>kT,
- TranscodeAsync: ()=>lm,
- TransformBlock: ()=>Hp,
- TransformNode: ()=>yr,
- TrigonometryBlock: ()=>Rf,
- TrigonometryBlockOperations: ()=>Af,
- TubeBuilder: ()=>Dv,
- TwirlBlock: ()=>Lm,
- UniformBuffer: ()=>Fi,
- UniversalCamera: ()=>Na,
- UnregisterAllMaterialPlugins: ()=>xs,
- UnregisterMaterialPlugin: ()=>As,
- UploadContent: ()=>Z_,
- UploadEnvLevelsAsync: ()=>Hc,
- UploadEnvSpherical: ()=>Yc,
- UploadLevelsAsync: ()=>jc,
- UtilityLayerRenderer: ()=>El,
- VRCameraMetrics: ()=>ts,
- VRDeviceOrientationArcRotateCamera: ()=>cs,
- VRDeviceOrientationFreeCamera: ()=>us,
- VRDeviceOrientationGamepadCamera: ()=>hs,
- VRDistortionCorrectionPostProcess: ()=>is,
- VRExperienceHelper: ()=>hl,
- VRMultiviewToSingleviewPostProcess: ()=>ss,
- ValidatedNativeDataStream: ()=>Ku,
- ValueCondition: ()=>X,
- Vector2: ()=>A,
- Vector3: ()=>x,
- Vector4: ()=>R,
- VectorMergerBlock: ()=>sf,
- VectorSplitterBlock: ()=>Jm,
- VertexAnimationBaker: ()=>so,
- VertexBuffer: ()=>Bi,
- VertexData: ()=>$n,
- VertexFormat: ()=>Uu,
- VertexOutputBlock: ()=>jp,
- VideoDome: ()=>Xf,
- VideoRecorder: ()=>ST,
- VideoTexture: ()=>Hf,
- ViewDirectionBlock: ()=>rg,
- Viewport: ()=>xr,
- VirtualJoystick: ()=>ua,
- VirtualJoysticksCamera: ()=>es,
- ViveController: ()=>ud,
- VolumetricLightScatteringPostProcess: ()=>Eb,
- VoronoiNoiseBlock: ()=>Wg,
- WaveBlock: ()=>yg,
- WaveBlockKind: ()=>gg,
- WebGL2ParticleSystem: ()=>oy,
- WebGL2ShaderProcessor: ()=>wt,
- WebGLDataBuffer: ()=>Ut,
- WebGLHardwareTexture: ()=>kt,
- WebGLPipelineContext: ()=>Vt,
- WebGPUCacheBindGroups: ()=>Nh,
- WebGPUCacheRenderPipeline: ()=>Ah,
- WebGPUCacheRenderPipelineTree: ()=>Rh,
- WebGPUCacheSampler: ()=>Th,
- WebGPUDataBuffer: ()=>_h,
- WebGPUDrawContext: ()=>Oh,
- WebGPUEngine: ()=>Qh,
- WebGPUTintWASM: ()=>Yh,
- WebRequest: ()=>Ye,
- WebVRController: ()=>_s,
- WebVRFreeCamera: ()=>fs,
- WebXRAbstractFeature: ()=>wp,
- WebXRAbstractMotionController: ()=>xp,
- WebXRAnchorSystem: ()=>$T,
- WebXRBackgroundRemover: ()=>iE,
- WebXRCamera: ()=>Ep,
- WebXRCompositionLayerWrapper: ()=>AE,
- WebXRControllerComponent: ()=>Ap,
- WebXRControllerMovement: ()=>mE,
- WebXRControllerPhysics: ()=>rE,
- WebXRControllerPointerSelection: ()=>Bp,
- WebXRDefaultExperience: ()=>Gf,
- WebXRDefaultExperienceOptions: ()=>kf,
- WebXRDomOverlay: ()=>_E,
- WebXREnterExitUI: ()=>wf,
- WebXREnterExitUIButton: ()=>Lf,
- WebXREnterExitUIOptions: ()=>Ff,
- WebXRExperienceHelper: ()=>Sp,
- WebXREyeTracking: ()=>vE,
- WebXRFeatureName: ()=>Io,
- WebXRFeaturePointSystem: ()=>sE,
- WebXRFeaturesManager: ()=>Oo,
- WebXRGenericHandController: ()=>OE,
- WebXRGenericTriggerMotionController: ()=>Rp,
- WebXRHTCViveMotionController: ()=>BE,
- WebXRHand: ()=>uE,
- WebXRHandTracking: ()=>hE,
- WebXRHitTest: ()=>oE,
- WebXRHitTestLegacy: ()=>ZT,
- WebXRImageTracking: ()=>fE,
- WebXRInput: ()=>Fp,
- WebXRInputSource: ()=>Lp,
- WebXRLayers: ()=>IE,
- WebXRLightEstimation: ()=>gE,
- WebXRManagedOutputCanvas: ()=>Gs,
- WebXRManagedOutputCanvasOptions: ()=>ks,
- WebXRMeshDetector: ()=>pE,
- WebXRMicrosoftMixedRealityController: ()=>NE,
- WebXRMotionControllerManager: ()=>Ip,
- WebXRMotionControllerTeleportation: ()=>Vf,
- WebXRNearControllerMode: ()=>Pf,
- WebXRNearInteraction: ()=>Df,
- WebXROculusTouchMotionController: ()=>FE,
- WebXRPlaneDetector: ()=>tE,
- WebXRProfiledMotionController: ()=>Pp,
- WebXRProjectionLayerWrapper: ()=>RE,
- WebXRSessionManager: ()=>Xs,
- WebXRState: ()=>Ns,
- WebXRTrackingState: ()=>Ls,
- WebXRWalkingLocomotion: ()=>SE,
- WeightedSound: ()=>Kr,
- WindowsMotionController: ()=>dd,
- WorkerPool: ()=>gp,
- WorleyNoise3DBlock: ()=>Sg,
- XRWindowsMotionController: ()=>pd,
- Xbox360Button: ()=>Sa,
- Xbox360Dpad: ()=>Aa,
- Xbox360Pad: ()=>Ma,
- XboxInput: ()=>Di,
- _BabylonLoaderRegistered: ()=>D_,
- _BasisTextureLoader: ()=>dm,
- _CreationDataStorage: ()=>Lr,
- _DDSTextureLoader: ()=>fp,
- _ENVTextureLoader: ()=>_p,
- _HDRTextureLoader: ()=>em,
- _IAnimationState: ()=>Ke,
- _InstancesBatch: ()=>wr,
- _KTXTextureLoader: ()=>Tp,
- _MeshCollisionData: ()=>br,
- _OcclusionDataStorage: ()=>fc,
- _PrimaryIsoTriangle: ()=>Vv,
- _TGATextureLoader: ()=>$_,
- _TimeToken: ()=>pc,
- _UpdateRGBDAsync: ()=>Kc,
- _forceSceneHelpersToBundle: ()=>zf,
- _forceTransformFeedbackToBundle: ()=>_c,
- _injectLTSFileTools: ()=>ci,
- allocateAndCopyTypedBuffer: ()=>gr,
- className: ()=>vi,
- createDetailMapPlugin: ()=>$g,
- createPBRAnisotropicPlugin: ()=>Kg,
- createPBRBRDFPlugin: ()=>Qg,
- createPBRClearCoatPlugin: ()=>qg,
- createPBRSheenPlugin: ()=>Zg,
- createPBRSubSurfacePlugin: ()=>Jg,
- createYieldingScheduler: ()=>Yn,
- editableInPropertyPage: ()=>Yp,
- expandToProperty: ()=>Re,
- extractMinAndMax: ()=>ur,
- extractMinAndMaxIndexed: ()=>cr,
- inlineScheduler: ()=>jn,
- makeAsyncFunction: ()=>Jn,
- makeSyncFunction: ()=>Zn,
- nativeOverride: ()=>ze,
- normalizeEnvInfo: ()=>kc,
- runCoroutine: ()=>Kn,
- runCoroutineAsync: ()=>qn,
- runCoroutineSync: ()=>Qn,
- serialize: ()=>Ce,
- serializeAsCameraReference: ()=>Ve,
- serializeAsColor3: ()=>Me,
- serializeAsColor4: ()=>Fe,
- serializeAsColorCurves: ()=>Le,
- serializeAsFresnelParameters: ()=>Ie,
- serializeAsImageProcessingConfiguration: ()=>we,
- serializeAsMatrix: ()=>Ue,
- serializeAsMeshReference: ()=>Ne,
- serializeAsQuaternion: ()=>Be,
- serializeAsTexture: ()=>Pe,
- serializeAsVector2: ()=>Oe,
- serializeAsVector3: ()=>De,
- setAndStartTimer: ()=>Bf,
- setStereoscopicAnaglyphRigMode: ()=>Ga,
- setStereoscopicRigMode: ()=>Ka,
- setVRRigMode: ()=>ls,
- setWebVRRigMode: ()=>ps
- });
- var o = function() {
- function e() {
- 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 e.AddParser = function(e, t) {
- this._BabylonFileParsers[e] = t
- }
- ,
- e.GetParser = function(e) {
- return this._BabylonFileParsers[e] ? this._BabylonFileParsers[e] : null
- }
- ,
- e.AddIndividualParser = function(e, t) {
- this._IndividualBabylonFileParsers[e] = t
- }
- ,
- e.GetIndividualParser = function(e) {
- return this._IndividualBabylonFileParsers[e] ? this._IndividualBabylonFileParsers[e] : null
- }
- ,
- e.Parse = function(e, t, i, n) {
- for (var r in this._BabylonFileParsers)
- Object.prototype.hasOwnProperty.call(this._BabylonFileParsers, r) && this._BabylonFileParsers[r](e, t, i, n)
- }
- ,
- Object.defineProperty(e.prototype, "environmentTexture", {
- get: function() {
- return this._environmentTexture
- },
- set: function(e) {
- this._environmentTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getNodes = function() {
- var e = new Array;
- return e = (e = (e = (e = e.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),
- this.skeletons.forEach((function(t) {
- return e = e.concat(t.bones)
- }
- )),
- e
- }
- ,
- e._BabylonFileParsers = {},
- e._IndividualBabylonFileParsers = {},
- e
- }()
- , a = function() {
- function e() {}
- return 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.ALPHA_ONEONE_ONEONE = 11,
- e.ALPHA_ALPHATOCOLOR = 12,
- e.ALPHA_REVERSEONEMINUS = 13,
- e.ALPHA_SRC_DSTONEMINUSSRCALPHA = 14,
- e.ALPHA_ONEONE_ONEZERO = 15,
- e.ALPHA_EXCLUSION = 16,
- e.ALPHA_LAYER_ACCUMULATE = 17,
- e.ALPHA_EQUATION_ADD = 0,
- e.ALPHA_EQUATION_SUBSTRACT = 1,
- e.ALPHA_EQUATION_REVERSE_SUBTRACT = 2,
- e.ALPHA_EQUATION_MAX = 3,
- e.ALPHA_EQUATION_MIN = 4,
- e.ALPHA_EQUATION_DARKEN = 5,
- 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.ZERO = 0,
- 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.TEXTURE_CREATIONFLAG_STORAGE = 1,
- 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.TEXTUREFORMAT_BGRA = 12,
- e.TEXTUREFORMAT_DEPTH24_STENCIL8 = 13,
- e.TEXTUREFORMAT_DEPTH32_FLOAT = 14,
- e.TEXTUREFORMAT_DEPTH16 = 15,
- e.TEXTUREFORMAT_DEPTH24 = 16,
- e.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM = 36492,
- e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 36495,
- e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 36494,
- e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5 = 33779,
- e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3 = 33778,
- e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1 = 33777,
- e.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1 = 33776,
- e.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4 = 37808,
- e.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL = 36196,
- 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.TEXTURETYPE_UNDEFINED = 16,
- e.TEXTURE_NEAREST_SAMPLINGMODE = 1,
- e.TEXTURE_NEAREST_NEAREST = 1,
- e.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
- e.TEXTURE_LINEAR_LINEAR = 2,
- e.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
- 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_MIPLINEAR = 8,
- e.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
- e.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
- e.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
- 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.TEXTURE_FILTERING_QUALITY_OFFLINE = 4096,
- e.TEXTURE_FILTERING_QUALITY_HIGH = 64,
- e.TEXTURE_FILTERING_QUALITY_MEDIUM = 16,
- e.TEXTURE_FILTERING_QUALITY_LOW = 8,
- e.SCALEMODE_FLOOR = 1,
- e.SCALEMODE_NEAREST = 2,
- e.SCALEMODE_CEILING = 3,
- e.MATERIAL_TextureDirtyFlag = 1,
- e.MATERIAL_LightDirtyFlag = 2,
- e.MATERIAL_FresnelDirtyFlag = 4,
- e.MATERIAL_AttributesDirtyFlag = 8,
- e.MATERIAL_MiscDirtyFlag = 16,
- e.MATERIAL_PrePassDirtyFlag = 32,
- e.MATERIAL_AllDirtyFlag = 63,
- e.MATERIAL_TriangleFillMode = 0,
- e.MATERIAL_WireFrameFillMode = 1,
- e.MATERIAL_PointFillMode = 2,
- e.MATERIAL_PointListDrawMode = 3,
- e.MATERIAL_LineListDrawMode = 4,
- e.MATERIAL_LineLoopDrawMode = 5,
- e.MATERIAL_LineStripDrawMode = 6,
- e.MATERIAL_TriangleStripDrawMode = 7,
- e.MATERIAL_TriangleFanDrawMode = 8,
- e.MATERIAL_ClockWiseSideOrientation = 0,
- e.MATERIAL_CounterClockWiseSideOrientation = 1,
- e.ACTION_NothingTrigger = 0,
- e.ACTION_OnPickTrigger = 1,
- e.ACTION_OnLeftPickTrigger = 2,
- e.ACTION_OnRightPickTrigger = 3,
- e.ACTION_OnCenterPickTrigger = 4,
- e.ACTION_OnPickDownTrigger = 5,
- e.ACTION_OnDoublePickTrigger = 6,
- e.ACTION_OnPickUpTrigger = 7,
- e.ACTION_OnPickOutTrigger = 16,
- e.ACTION_OnLongPressTrigger = 8,
- e.ACTION_OnPointerOverTrigger = 9,
- e.ACTION_OnPointerOutTrigger = 10,
- e.ACTION_OnEveryFrameTrigger = 11,
- e.ACTION_OnIntersectionEnterTrigger = 12,
- e.ACTION_OnIntersectionExitTrigger = 13,
- e.ACTION_OnKeyDownTrigger = 14,
- e.ACTION_OnKeyUpTrigger = 15,
- e.PARTICLES_BILLBOARDMODE_Y = 2,
- e.PARTICLES_BILLBOARDMODE_ALL = 7,
- e.PARTICLES_BILLBOARDMODE_STRETCHED = 8,
- e.MESHES_CULLINGSTRATEGY_STANDARD = 0,
- e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
- e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
- e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
- e.SCENELOADER_NO_LOGGING = 0,
- e.SCENELOADER_MINIMAL_LOGGING = 1,
- e.SCENELOADER_SUMMARY_LOGGING = 2,
- e.SCENELOADER_DETAILED_LOGGING = 3,
- e.PREPASS_IRRADIANCE_TEXTURE_TYPE = 0,
- e.PREPASS_POSITION_TEXTURE_TYPE = 1,
- e.PREPASS_VELOCITY_TEXTURE_TYPE = 2,
- e.PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3,
- e.PREPASS_COLOR_TEXTURE_TYPE = 4,
- e.PREPASS_DEPTH_TEXTURE_TYPE = 5,
- e.PREPASS_NORMAL_TEXTURE_TYPE = 6,
- e.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE = 7,
- e.BUFFER_CREATIONFLAG_READ = 1,
- e.BUFFER_CREATIONFLAG_WRITE = 2,
- e.BUFFER_CREATIONFLAG_READWRITE = 3,
- e.BUFFER_CREATIONFLAG_UNIFORM = 4,
- e.BUFFER_CREATIONFLAG_VERTEX = 8,
- e.BUFFER_CREATIONFLAG_INDEX = 16,
- e.BUFFER_CREATIONFLAG_STORAGE = 32,
- e.RENDERPASS_MAIN = 0,
- e.INPUT_ALT_KEY = 18,
- e.INPUT_CTRL_KEY = 17,
- e.INPUT_META_KEY1 = 91,
- e.INPUT_META_KEY2 = 92,
- e.INPUT_META_KEY3 = 93,
- e.INPUT_SHIFT_KEY = 16,
- e.SNAPSHOTRENDERING_STANDARD = 0,
- e.SNAPSHOTRENDERING_FAST = 1,
- 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.MAX_SUPPORTED_UV_SETS = 6,
- e.GL_ALPHA_EQUATION_ADD = 32774,
- e.GL_ALPHA_EQUATION_MIN = 32775,
- e.GL_ALPHA_EQUATION_MAX = 32776,
- e.GL_ALPHA_EQUATION_SUBTRACT = 32778,
- e.GL_ALPHA_EQUATION_REVERSE_SUBTRACT = 32779,
- e.GL_ALPHA_FUNCTION_SRC = 768,
- e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR = 769,
- e.GL_ALPHA_FUNCTION_SRC_ALPHA = 770,
- e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA = 771,
- e.GL_ALPHA_FUNCTION_DST_ALPHA = 772,
- e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA = 773,
- e.GL_ALPHA_FUNCTION_DST_COLOR = 774,
- e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR = 775,
- e.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED = 776,
- e.GL_ALPHA_FUNCTION_CONSTANT_COLOR = 32769,
- e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR = 32770,
- e.GL_ALPHA_FUNCTION_CONSTANT_ALPHA = 32771,
- e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA = 32772,
- e
- }()
- , s = function() {
- function e() {
- this.hoverCursor = "",
- this.actions = new Array,
- this.isRecursive = !1
- }
- return Object.defineProperty(e, "HasTriggers", {
- get: function() {
- for (var t in e.Triggers)
- if (Object.prototype.hasOwnProperty.call(e.Triggers, t))
- return !0;
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "HasPickTriggers", {
- get: function() {
- for (var t in e.Triggers)
- if (Object.prototype.hasOwnProperty.call(e.Triggers, t)) {
- var i = parseInt(t);
- if (i >= a.ACTION_OnPickTrigger && i <= a.ACTION_OnPickUpTrigger)
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.HasSpecificTrigger = function(t) {
- for (var i in e.Triggers)
- if (Object.prototype.hasOwnProperty.call(e.Triggers, i) && parseInt(i) === t)
- return !0;
- return !1
- }
- ,
- e.Triggers = {},
- e
- }()
- , l = function() {
- function e(e, t, i, n) {
- void 0 === t && (t = !1),
- this.initialize(e, t, i, n)
- }
- return e.prototype.initialize = function(e, t, i, n) {
- return void 0 === t && (t = !1),
- this.mask = e,
- this.skipNextObservers = t,
- this.target = i,
- this.currentTarget = n,
- this
- }
- ,
- e
- }()
- , c = function(e, t, i) {
- void 0 === i && (i = null),
- this.callback = e,
- this.mask = t,
- this.scope = i,
- this._willBeUnregistered = !1,
- this.unregisterOnNextCall = !1
- }
- , u = function() {
- function e() {}
- return e.prototype.dispose = function() {
- if (this._observers && this._observables)
- for (var e = 0; e < this._observers.length; e++)
- this._observables[e].remove(this._observers[e]);
- this._observers = null,
- this._observables = null
- }
- ,
- e.Watch = function(t, i, n, r) {
- void 0 === n && (n = -1),
- void 0 === r && (r = null);
- var o = new e;
- o._observers = new Array,
- o._observables = t;
- for (var a = 0, s = t; a < s.length; a++) {
- var l = s[a].add(i, n, !1, r);
- l && o._observers.push(l)
- }
- return o
- }
- ,
- e
- }()
- , h = function() {
- function e(e) {
- this._observers = new Array,
- this._eventState = new l(0),
- e && (this._onObserverAdded = e)
- }
- return e.FromPromise = function(t, i) {
- var n = new e;
- return t.then((function(e) {
- n.notifyObservers(e)
- }
- )).catch((function(e) {
- if (!i)
- throw e;
- i.notifyObservers(e)
- }
- )),
- n
- }
- ,
- Object.defineProperty(e.prototype, "observers", {
- get: function() {
- return this._observers
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.add = function(e, t, i, n, r) {
- if (void 0 === t && (t = -1),
- void 0 === i && (i = !1),
- void 0 === n && (n = null),
- void 0 === r && (r = !1),
- !e)
- return null;
- var o = new c(e,t,n);
- return o.unregisterOnNextCall = r,
- i ? this._observers.unshift(o) : this._observers.push(o),
- this._onObserverAdded && this._onObserverAdded(o),
- o
- }
- ,
- e.prototype.addOnce = function(e) {
- return this.add(e, void 0, void 0, void 0, !0)
- }
- ,
- e.prototype.remove = function(e) {
- return !!e && -1 !== this._observers.indexOf(e) && (this._deferUnregister(e),
- !0)
- }
- ,
- e.prototype.removeCallback = function(e, t) {
- for (var i = 0; i < this._observers.length; i++) {
- var n = this._observers[i];
- if (!(n._willBeUnregistered || n.callback !== e || t && t !== n.scope))
- return this._deferUnregister(n),
- !0
- }
- return !1
- }
- ,
- e.prototype._deferUnregister = function(e) {
- var t = this;
- e.unregisterOnNextCall = !1,
- e._willBeUnregistered = !0,
- setTimeout((function() {
- t._remove(e)
- }
- ), 0)
- }
- ,
- e.prototype._remove = function(e) {
- if (!e)
- return !1;
- var t = this._observers.indexOf(e);
- return -1 !== t && (this._observers.splice(t, 1),
- !0)
- }
- ,
- e.prototype.makeObserverTopPriority = function(e) {
- this._remove(e),
- this._observers.unshift(e)
- }
- ,
- e.prototype.makeObserverBottomPriority = function(e) {
- this._remove(e),
- this._observers.push(e)
- }
- ,
- e.prototype.notifyObservers = function(e, t, i, n, r) {
- if (void 0 === t && (t = -1),
- !this._observers.length)
- return !0;
- var o = this._eventState;
- o.mask = t,
- o.target = i,
- o.currentTarget = n,
- o.skipNextObservers = !1,
- o.lastReturnValue = e,
- o.userInfo = r;
- for (var a = 0, s = this._observers; a < s.length; a++) {
- var l = s[a];
- if (!l._willBeUnregistered && (l.mask & t && (l.scope ? o.lastReturnValue = l.callback.apply(l.scope, [e, o]) : o.lastReturnValue = l.callback(e, o),
- l.unregisterOnNextCall && this._deferUnregister(l)),
- o.skipNextObservers))
- return !1
- }
- return !0
- }
- ,
- e.prototype.notifyObserversWithPromise = function(e, t, i, n, r) {
- var o = this;
- void 0 === t && (t = -1);
- var a = Promise.resolve(e);
- if (!this._observers.length)
- return a;
- var s = this._eventState;
- return s.mask = t,
- s.target = i,
- s.currentTarget = n,
- s.skipNextObservers = !1,
- s.userInfo = r,
- this._observers.forEach((function(i) {
- s.skipNextObservers || i._willBeUnregistered || i.mask & t && (a = i.scope ? a.then((function(t) {
- return s.lastReturnValue = t,
- i.callback.apply(i.scope, [e, s])
- }
- )) : a.then((function(t) {
- return s.lastReturnValue = t,
- i.callback(e, s)
- }
- )),
- i.unregisterOnNextCall && o._deferUnregister(i))
- }
- )),
- a.then((function() {
- return e
- }
- ))
- }
- ,
- e.prototype.notifyObserver = function(e, t, i) {
- if (void 0 === i && (i = -1),
- !e._willBeUnregistered) {
- var n = this._eventState;
- n.mask = i,
- n.skipNextObservers = !1,
- e.callback(t, n),
- e.unregisterOnNextCall && this._deferUnregister(e)
- }
- }
- ,
- e.prototype.hasObservers = function() {
- return this._observers.length > 0
- }
- ,
- e.prototype.clear = function() {
- this._observers = new Array,
- this._onObserverAdded = null
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return t._observers = this._observers.slice(0),
- t
- }
- ,
- e.prototype.hasSpecificMask = function(e) {
- void 0 === e && (e = -1);
- for (var t = 0, i = this._observers; t < i.length; t++) {
- var n = i[t];
- if (n.mask & e || n.mask === e)
- return !0
- }
- return !1
- }
- ,
- e
- }()
- , d = function() {
- function e() {}
- return e.WithinEpsilon = function(e, t, i) {
- return void 0 === i && (i = 1401298e-51),
- Math.abs(e - t) <= i
- }
- ,
- e.ToHex = function(e) {
- var t = e.toString(16);
- return e <= 15 ? ("0" + t).toUpperCase() : t.toUpperCase()
- }
- ,
- e.Sign = function(e) {
- return 0 == (e = +e) || isNaN(e) ? e : e > 0 ? 1 : -1
- }
- ,
- e.Clamp = function(e, t, i) {
- return void 0 === t && (t = 0),
- void 0 === i && (i = 1),
- Math.min(i, Math.max(t, e))
- }
- ,
- e.Log2 = function(e) {
- return Math.log(e) * Math.LOG2E
- }
- ,
- e.ILog2 = function(e) {
- if (Math.log2)
- return Math.floor(Math.log2(e));
- if (e < 0)
- return NaN;
- if (0 === e)
- return -1 / 0;
- var t = 0;
- if (e < 1) {
- for (; e < 1; )
- t++,
- e *= 2;
- t = -t
- } else if (e > 1)
- for (; e > 1; )
- t++,
- e = Math.floor(e / 2);
- return t
- }
- ,
- e.Repeat = function(e, t) {
- return e - Math.floor(e / t) * t
- }
- ,
- e.Normalize = function(e, t, i) {
- return (e - t) / (i - t)
- }
- ,
- e.Denormalize = function(e, t, i) {
- return e * (i - t) + t
- }
- ,
- e.DeltaAngle = function(t, i) {
- var n = e.Repeat(i - t, 360);
- return n > 180 && (n -= 360),
- n
- }
- ,
- e.PingPong = function(t, i) {
- var n = e.Repeat(t, 2 * i);
- return i - Math.abs(n - i)
- }
- ,
- e.SmoothStep = function(t, i, n) {
- var r = e.Clamp(n);
- return i * (r = -2 * r * r * r + 3 * r * r) + t * (1 - r)
- }
- ,
- e.MoveTowards = function(t, i, n) {
- return Math.abs(i - t) <= n ? i : t + e.Sign(i - t) * n
- }
- ,
- e.MoveTowardsAngle = function(t, i, n) {
- var r = e.DeltaAngle(t, i)
- , o = 0;
- return -n < r && r < n ? o = i : (i = t + r,
- o = e.MoveTowards(t, i, n)),
- o
- }
- ,
- e.Lerp = function(e, t, i) {
- return e + (t - e) * i
- }
- ,
- e.LerpAngle = function(t, i, n) {
- var r = e.Repeat(i - t, 360);
- return r > 180 && (r -= 360),
- t + r * e.Clamp(n)
- }
- ,
- e.InverseLerp = function(t, i, n) {
- return t != i ? e.Clamp((n - t) / (i - t)) : 0
- }
- ,
- e.Hermite = function(e, t, i, n, r) {
- var o = r * r
- , a = r * o;
- return e * (2 * a - 3 * o + 1) + i * (-2 * a + 3 * o) + t * (a - 2 * o + r) + n * (a - o)
- }
- ,
- e.Hermite1stDerivative = function(e, t, i, n, r) {
- var o = r * r;
- return 6 * (o - r) * e + (3 * o - 4 * r + 1) * t + 6 * (-o + r) * i + (3 * o - 2 * r) * n
- }
- ,
- e.RandomRange = function(e, t) {
- return e === t ? e : Math.random() * (t - e) + e
- }
- ,
- e.RangeToPercent = function(e, t, i) {
- return (e - t) / (i - t)
- }
- ,
- e.PercentToRange = function(e, t, i) {
- return (i - t) * e + t
- }
- ,
- e.NormalizeRadians = function(t) {
- return t - e.TwoPi * Math.floor((t + Math.PI) / e.TwoPi)
- }
- ,
- e.HCF = function(t, i) {
- var n = t % i;
- return 0 === n ? i : e.HCF(i, n)
- }
- ,
- e.TwoPi = 2 * Math.PI,
- e
- }()
- , p = 1 / 2.2
- , f = 2.2
- , _ = (1 + Math.sqrt(5)) / 2
- , m = .001
- , g = function() {
- function e() {}
- return e.BuildArray = function(e, t) {
- for (var i = [], n = 0; n < e; ++n)
- i.push(t());
- return i
- }
- ,
- e.BuildTuple = function(t, i) {
- return e.BuildArray(t, i)
- }
- ,
- e
- }()
- , v = {};
- function y(e, t) {
- v[e] = t
- }
- function b(e) {
- return v[e]
- }
- var T = function() {
- function e() {}
- return e.SetMatrixPrecision = function(t) {
- if (e.MatrixTrackPrecisionChange = !1,
- t && !e.MatrixUse64Bits && e.MatrixTrackedMatrices)
- for (var i = 0; i < e.MatrixTrackedMatrices.length; ++i) {
- var n = e.MatrixTrackedMatrices[i]
- , r = n._m;
- n._m = new Array(16);
- for (var o = 0; o < 16; ++o)
- n._m[o] = r[o]
- }
- e.MatrixUse64Bits = t,
- e.MatrixCurrentType = e.MatrixUse64Bits ? Array : Float32Array,
- e.MatrixTrackedMatrices = null
- }
- ,
- e.MatrixUse64Bits = !1,
- e.MatrixTrackPrecisionChange = !0,
- e.MatrixCurrentType = Float32Array,
- e.MatrixTrackedMatrices = [],
- e
- }()
- , E = function() {
- function e() {}
- return Object.defineProperty(e, "LastCreatedEngine", {
- get: function() {
- return 0 === this.Instances.length ? null : this.Instances[this.Instances.length - 1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LastCreatedScene", {
- get: function() {
- return this._LastCreatedScene
- },
- enumerable: !1,
- configurable: !0
- }),
- e.Instances = new Array,
- e._LastCreatedScene = null,
- e.UseFallbackTexture = !0,
- e.FallbackTexture = "",
- e
- }()
- , S = function(e) {
- return parseInt(e.toString().replace(/\W/g, ""))
- }
- , A = function() {
- function e(e, t) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- this.x = e,
- this.y = t
- }
- return e.prototype.toString = function() {
- return "{X: ".concat(this.x, " Y: ").concat(this.y, "}")
- }
- ,
- e.prototype.getClassName = function() {
- return "Vector2"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = S(this.x);
- return 397 * e ^ S(this.y)
- }
- ,
- e.prototype.toArray = function(e, t) {
- return void 0 === t && (t = 0),
- e[t] = this.x,
- e[t + 1] = this.y,
- this
- }
- ,
- e.prototype.fromArray = function(t, i) {
- return void 0 === i && (i = 0),
- e.FromArrayToRef(t, i, this),
- this
- }
- ,
- e.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- e.prototype.copyFrom = function(e) {
- return this.x = e.x,
- this.y = e.y,
- this
- }
- ,
- e.prototype.copyFromFloats = function(e, t) {
- return this.x = e,
- this.y = t,
- this
- }
- ,
- e.prototype.set = function(e, t) {
- return this.copyFromFloats(e, t)
- }
- ,
- e.prototype.add = function(t) {
- return new e(this.x + t.x,this.y + t.y)
- }
- ,
- e.prototype.addToRef = function(e, t) {
- return t.x = this.x + e.x,
- t.y = this.y + e.y,
- this
- }
- ,
- e.prototype.addInPlace = function(e) {
- return this.x += e.x,
- this.y += e.y,
- this
- }
- ,
- e.prototype.addVector3 = function(t) {
- return new e(this.x + t.x,this.y + t.y)
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this.x - t.x,this.y - t.y)
- }
- ,
- e.prototype.subtractToRef = function(e, t) {
- return t.x = this.x - e.x,
- t.y = this.y - e.y,
- this
- }
- ,
- e.prototype.subtractInPlace = function(e) {
- return this.x -= e.x,
- this.y -= e.y,
- this
- }
- ,
- e.prototype.multiplyInPlace = function(e) {
- return this.x *= e.x,
- this.y *= e.y,
- this
- }
- ,
- e.prototype.multiply = function(t) {
- return new e(this.x * t.x,this.y * t.y)
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- return t.x = this.x * e.x,
- t.y = this.y * e.y,
- this
- }
- ,
- e.prototype.multiplyByFloats = function(t, i) {
- return new e(this.x * t,this.y * i)
- }
- ,
- e.prototype.divide = function(t) {
- return new e(this.x / t.x,this.y / t.y)
- }
- ,
- e.prototype.divideToRef = function(e, t) {
- return t.x = this.x / e.x,
- t.y = this.y / e.y,
- this
- }
- ,
- e.prototype.divideInPlace = function(e) {
- return this.divideToRef(e, this)
- }
- ,
- e.prototype.negate = function() {
- return new e(-this.x,-this.y)
- }
- ,
- e.prototype.negateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this
- }
- ,
- e.prototype.negateToRef = function(e) {
- return e.copyFromFloats(-1 * this.x, -1 * this.y)
- }
- ,
- e.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this
- }
- ,
- e.prototype.scale = function(t) {
- var i = new e(0,0);
- return this.scaleToRef(t, i),
- i
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- return t.x = this.x * e,
- t.y = this.y * e,
- this
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- return t.x += this.x * e,
- t.y += this.y * e,
- this
- }
- ,
- e.prototype.equals = function(e) {
- return e && this.x === e.x && this.y === e.y
- }
- ,
- e.prototype.equalsWithEpsilon = function(e, t) {
- return void 0 === t && (t = m),
- e && d.WithinEpsilon(this.x, e.x, t) && d.WithinEpsilon(this.y, e.y, t)
- }
- ,
- e.prototype.floor = function() {
- return new e(Math.floor(this.x),Math.floor(this.y))
- }
- ,
- e.prototype.fract = function() {
- return new e(this.x - Math.floor(this.x),this.y - Math.floor(this.y))
- }
- ,
- e.prototype.rotateToRef = function(e, t) {
- var i = Math.cos(e)
- , n = Math.sin(e);
- return t.x = i * this.x - n * this.y,
- t.y = n * this.x + i * this.y,
- this
- }
- ,
- e.prototype.length = function() {
- return Math.sqrt(this.x * this.x + this.y * this.y)
- }
- ,
- e.prototype.lengthSquared = function() {
- return this.x * this.x + this.y * this.y
- }
- ,
- e.prototype.normalize = function() {
- return e.NormalizeToRef(this, this),
- this
- }
- ,
- e.prototype.clone = function() {
- return new e(this.x,this.y)
- }
- ,
- e.Zero = function() {
- return new e(0,0)
- }
- ,
- e.One = function() {
- return new e(1,1)
- }
- ,
- e.FromArray = function(t, i) {
- return void 0 === i && (i = 0),
- new e(t[i],t[i + 1])
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- i.x = e[t],
- i.y = e[t + 1]
- }
- ,
- e.CatmullRom = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a;
- return new e(.5 * (2 * i.x + (-t.x + n.x) * o + (2 * t.x - 5 * i.x + 4 * n.x - r.x) * a + (-t.x + 3 * i.x - 3 * n.x + r.x) * s),.5 * (2 * i.y + (-t.y + n.y) * o + (2 * t.y - 5 * i.y + 4 * n.y - r.y) * a + (-t.y + 3 * i.y - 3 * n.y + r.y) * s))
- }
- ,
- e.Clamp = function(t, i, n) {
- var r = t.x;
- r = (r = r > n.x ? n.x : r) < i.x ? i.x : r;
- var o = t.y;
- return new e(r,o = (o = o > n.y ? n.y : o) < i.y ? i.y : o)
- }
- ,
- e.Hermite = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a
- , l = 2 * s - 3 * a + 1
- , c = -2 * s + 3 * a
- , u = s - 2 * a + o
- , h = s - a;
- return new e(t.x * l + n.x * c + i.x * u + r.x * h,t.y * l + n.y * c + i.y * u + r.y * h)
- }
- ,
- e.Hermite1stDerivative = function(t, i, n, r, o) {
- var a = e.Zero();
- return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
- a
- }
- ,
- e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
- var a = r * r;
- o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
- o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y
- }
- ,
- e.Lerp = function(t, i, n) {
- return new e(t.x + (i.x - t.x) * n,t.y + (i.y - t.y) * n)
- }
- ,
- e.Dot = function(e, t) {
- return e.x * t.x + e.y * t.y
- }
- ,
- e.Normalize = function(t) {
- var i = e.Zero();
- return this.NormalizeToRef(t, i),
- i
- }
- ,
- e.NormalizeToRef = function(e, t) {
- var i = e.length();
- 0 !== i && (t.x = e.x / i,
- t.y = e.y / i)
- }
- ,
- e.Minimize = function(t, i) {
- return new e(t.x < i.x ? t.x : i.x,t.y < i.y ? t.y : i.y)
- }
- ,
- e.Maximize = function(t, i) {
- return new e(t.x > i.x ? t.x : i.x,t.y > i.y ? t.y : i.y)
- }
- ,
- e.Transform = function(t, i) {
- var n = e.Zero();
- return e.TransformToRef(t, i, n),
- n
- }
- ,
- e.TransformToRef = function(e, t, i) {
- var n = t.m
- , r = e.x * n[0] + e.y * n[4] + n[12]
- , o = e.x * n[1] + e.y * n[5] + n[13];
- i.x = r,
- i.y = o
- }
- ,
- e.PointInTriangle = function(e, t, i, n) {
- var r = .5 * (-i.y * n.x + t.y * (-i.x + n.x) + t.x * (i.y - n.y) + i.x * n.y)
- , o = r < 0 ? -1 : 1
- , a = (t.y * n.x - t.x * n.y + (n.y - t.y) * e.x + (t.x - n.x) * e.y) * o
- , s = (t.x * i.y - t.y * i.x + (t.y - i.y) * e.x + (i.x - t.x) * e.y) * o;
- return a > 0 && s > 0 && a + s < 2 * r * o
- }
- ,
- e.Distance = function(t, i) {
- return Math.sqrt(e.DistanceSquared(t, i))
- }
- ,
- e.DistanceSquared = function(e, t) {
- var i = e.x - t.x
- , n = e.y - t.y;
- return i * i + n * n
- }
- ,
- e.Center = function(t, i) {
- return e.CenterToRef(t, i, e.Zero())
- }
- ,
- e.CenterToRef = function(e, t, i) {
- return i.copyFromFloats((e.x + t.x) / 2, (e.y + t.y) / 2)
- }
- ,
- e.DistanceOfPointFromSegment = function(t, i, n) {
- var r = e.DistanceSquared(i, n);
- if (0 === r)
- return e.Distance(t, i);
- var o = n.subtract(i)
- , a = Math.max(0, Math.min(1, e.Dot(t.subtract(i), o) / r))
- , s = i.add(o.multiplyByFloats(a, a));
- return e.Distance(t, s)
- }
- ,
- e
- }()
- , x = function() {
- function e(e, t, i) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- this._isDirty = !0,
- this._x = e,
- this._y = t,
- this._z = i
- }
- return Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._x
- },
- set: function(e) {
- this._x = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._y
- },
- set: function(e) {
- this._y = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "z", {
- get: function() {
- return this._z
- },
- set: function(e) {
- this._z = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.toString = function() {
- return "{X: ".concat(this._x, " Y: ").concat(this._y, " Z: ").concat(this._z, "}")
- }
- ,
- e.prototype.getClassName = function() {
- return "Vector3"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = S(this._x);
- return 397 * (e = 397 * e ^ S(this._y)) ^ S(this._z)
- }
- ,
- e.prototype.asArray = function() {
- var e = [];
- return this.toArray(e, 0),
- e
- }
- ,
- e.prototype.toArray = function(e, t) {
- return void 0 === t && (t = 0),
- e[t] = this._x,
- e[t + 1] = this._y,
- e[t + 2] = this._z,
- this
- }
- ,
- e.prototype.fromArray = function(t, i) {
- return void 0 === i && (i = 0),
- e.FromArrayToRef(t, i, this),
- this
- }
- ,
- e.prototype.toQuaternion = function() {
- return C.RotationYawPitchRoll(this._y, this._x, this._z)
- }
- ,
- e.prototype.addInPlace = function(e) {
- return this.addInPlaceFromFloats(e._x, e._y, e._z)
- }
- ,
- e.prototype.addInPlaceFromFloats = function(e, t, i) {
- return this.x += e,
- this.y += t,
- this.z += i,
- this
- }
- ,
- e.prototype.add = function(t) {
- return new e(this._x + t._x,this._y + t._y,this._z + t._z)
- }
- ,
- e.prototype.addToRef = function(e, t) {
- return t.copyFromFloats(this._x + e._x, this._y + e._y, this._z + e._z)
- }
- ,
- e.prototype.subtractInPlace = function(e) {
- return this.x -= e._x,
- this.y -= e._y,
- this.z -= e._z,
- this
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this._x - t._x,this._y - t._y,this._z - t._z)
- }
- ,
- e.prototype.subtractToRef = function(e, t) {
- return this.subtractFromFloatsToRef(e._x, e._y, e._z, t)
- }
- ,
- e.prototype.subtractFromFloats = function(t, i, n) {
- return new e(this._x - t,this._y - i,this._z - n)
- }
- ,
- e.prototype.subtractFromFloatsToRef = function(e, t, i, n) {
- return n.copyFromFloats(this._x - e, this._y - t, this._z - i)
- }
- ,
- e.prototype.negate = function() {
- return new e(-this._x,-this._y,-this._z)
- }
- ,
- e.prototype.negateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this.z *= -1,
- this
- }
- ,
- e.prototype.negateToRef = function(e) {
- return e.copyFromFloats(-1 * this._x, -1 * this._y, -1 * this._z)
- }
- ,
- e.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this.z *= e,
- this
- }
- ,
- e.prototype.scale = function(t) {
- return new e(this._x * t,this._y * t,this._z * t)
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- return t.copyFromFloats(this._x * e, this._y * e, this._z * e)
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- return t.addInPlaceFromFloats(this._x * e, this._y * e, this._z * e)
- }
- ,
- e.prototype.projectOnPlane = function(t, i) {
- var n = e.Zero();
- return this.projectOnPlaneToRef(t, i, n),
- n
- }
- ,
- e.prototype.projectOnPlaneToRef = function(t, i, n) {
- var r = t.normal
- , o = t.d
- , a = M.Vector3[0];
- this.subtractToRef(i, a),
- a.normalize();
- var s = e.Dot(a, r)
- , l = -(e.Dot(i, r) + o) / s
- , c = a.scaleInPlace(l);
- i.addToRef(c, n)
- }
- ,
- e.prototype.equals = function(e) {
- return e && this._x === e._x && this._y === e._y && this._z === e._z
- }
- ,
- e.prototype.equalsWithEpsilon = function(e, t) {
- return void 0 === t && (t = m),
- e && d.WithinEpsilon(this._x, e._x, t) && d.WithinEpsilon(this._y, e._y, t) && d.WithinEpsilon(this._z, e._z, t)
- }
- ,
- e.prototype.equalsToFloats = function(e, t, i) {
- return this._x === e && this._y === t && this._z === i
- }
- ,
- e.prototype.multiplyInPlace = function(e) {
- return this.x *= e._x,
- this.y *= e._y,
- this.z *= e._z,
- this
- }
- ,
- e.prototype.multiply = function(e) {
- return this.multiplyByFloats(e._x, e._y, e._z)
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- return t.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z)
- }
- ,
- e.prototype.multiplyByFloats = function(t, i, n) {
- return new e(this._x * t,this._y * i,this._z * n)
- }
- ,
- e.prototype.divide = function(t) {
- return new e(this._x / t._x,this._y / t._y,this._z / t._z)
- }
- ,
- e.prototype.divideToRef = function(e, t) {
- return t.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z)
- }
- ,
- e.prototype.divideInPlace = function(e) {
- return this.divideToRef(e, this)
- }
- ,
- e.prototype.minimizeInPlace = function(e) {
- return this.minimizeInPlaceFromFloats(e._x, e._y, e._z)
- }
- ,
- e.prototype.maximizeInPlace = function(e) {
- return this.maximizeInPlaceFromFloats(e._x, e._y, e._z)
- }
- ,
- e.prototype.minimizeInPlaceFromFloats = function(e, t, i) {
- return e < this._x && (this.x = e),
- t < this._y && (this.y = t),
- i < this._z && (this.z = i),
- this
- }
- ,
- e.prototype.maximizeInPlaceFromFloats = function(e, t, i) {
- return e > this._x && (this.x = e),
- t > this._y && (this.y = t),
- i > this._z && (this.z = i),
- this
- }
- ,
- e.prototype.isNonUniformWithinEpsilon = function(e) {
- var t = Math.abs(this._x)
- , i = Math.abs(this._y);
- if (!d.WithinEpsilon(t, i, e))
- return !0;
- var n = Math.abs(this._z);
- return !d.WithinEpsilon(t, n, e) || !d.WithinEpsilon(i, n, e)
- }
- ,
- Object.defineProperty(e.prototype, "isNonUniform", {
- get: function() {
- var e = Math.abs(this._x);
- return e !== Math.abs(this._y) || e !== Math.abs(this._z)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.floor = function() {
- return new e(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))
- }
- ,
- e.prototype.fract = function() {
- return new e(this._x - Math.floor(this._x),this._y - Math.floor(this._y),this._z - Math.floor(this._z))
- }
- ,
- e.prototype.length = function() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z)
- }
- ,
- e.prototype.lengthSquared = function() {
- return this._x * this._x + this._y * this._y + this._z * this._z
- }
- ,
- e.prototype.normalize = function() {
- return this.normalizeFromLength(this.length())
- }
- ,
- e.prototype.reorderInPlace = function(e) {
- var t = this;
- return "xyz" === (e = e.toLowerCase()) || (M.Vector3[0].copyFrom(this),
- ["x", "y", "z"].forEach((function(i, n) {
- t[i] = M.Vector3[0][e[n]]
- }
- ))),
- this
- }
- ,
- e.prototype.rotateByQuaternionToRef = function(t, i) {
- return t.toRotationMatrix(M.Matrix[0]),
- e.TransformCoordinatesToRef(this, M.Matrix[0], i),
- i
- }
- ,
- e.prototype.rotateByQuaternionAroundPointToRef = function(e, t, i) {
- return this.subtractToRef(t, M.Vector3[0]),
- M.Vector3[0].rotateByQuaternionToRef(e, M.Vector3[0]),
- t.addToRef(M.Vector3[0], i),
- i
- }
- ,
- e.prototype.cross = function(t) {
- return e.Cross(this, t)
- }
- ,
- e.prototype.normalizeFromLength = function(e) {
- return 0 === e || 1 === e ? this : this.scaleInPlace(1 / e)
- }
- ,
- e.prototype.normalizeToNew = function() {
- var t = new e(0,0,0);
- return this.normalizeToRef(t),
- t
- }
- ,
- e.prototype.normalizeToRef = function(e) {
- var t = this.length();
- return 0 === t || 1 === t ? e.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / t, e)
- }
- ,
- e.prototype.clone = function() {
- return new e(this._x,this._y,this._z)
- }
- ,
- e.prototype.copyFrom = function(e) {
- return this.copyFromFloats(e._x, e._y, e._z)
- }
- ,
- e.prototype.copyFromFloats = function(e, t, i) {
- return this.x = e,
- this.y = t,
- this.z = i,
- this
- }
- ,
- e.prototype.set = function(e, t, i) {
- return this.copyFromFloats(e, t, i)
- }
- ,
- e.prototype.setAll = function(e) {
- return this.x = this.y = this.z = e,
- this
- }
- ,
- e.GetClipFactor = function(t, i, n, r) {
- var o = e.Dot(t, n) - r;
- return o / (o - (e.Dot(i, n) - r))
- }
- ,
- e.GetAngleBetweenVectors = function(t, i, n) {
- var r = t.normalizeToRef(M.Vector3[1])
- , o = i.normalizeToRef(M.Vector3[2])
- , a = e.Dot(r, o)
- , s = Math.acos(a)
- , l = M.Vector3[3];
- return e.CrossToRef(r, o, l),
- e.Dot(l, n) > 0 ? isNaN(s) ? 0 : s : isNaN(s) ? -Math.PI : -Math.acos(a)
- }
- ,
- e.GetAngleBetweenVectorsOnPlane = function(t, i, n) {
- M.Vector3[0].copyFrom(t);
- var r = M.Vector3[0];
- M.Vector3[1].copyFrom(i);
- var o = M.Vector3[1];
- M.Vector3[2].copyFrom(n);
- var a = M.Vector3[2]
- , s = M.Vector3[3]
- , l = M.Vector3[4];
- r.normalize(),
- o.normalize(),
- a.normalize(),
- e.CrossToRef(a, r, s),
- e.CrossToRef(s, a, l);
- var c = Math.atan2(e.Dot(o, s), e.Dot(o, l));
- return d.NormalizeRadians(c)
- }
- ,
- e.SlerpToRef = function(t, i, n, r) {
- n = d.Clamp(n, 0, 1);
- var o = M.Vector3[0]
- , a = M.Vector3[1];
- o.copyFrom(t);
- var s = o.length();
- o.normalizeFromLength(s),
- a.copyFrom(i);
- var l = a.length();
- a.normalizeFromLength(l);
- var c, u, h = e.Dot(o, a);
- if (h < 1 - m) {
- var p = Math.acos(h)
- , f = 1 / Math.sin(p);
- c = Math.sin((1 - n) * p) * f,
- u = Math.sin(n * p) * f
- } else
- c = 1 - n,
- u = n;
- o.scaleInPlace(c),
- a.scaleInPlace(u),
- r.copyFrom(o).addInPlace(a),
- r.scaleInPlace(d.Lerp(s, l, n))
- }
- ,
- e.SmoothToRef = function(t, i, n, r, o) {
- e.SlerpToRef(t, i, 0 === r ? 1 : n / r, o)
- }
- ,
- e.FromArray = function(t, i) {
- return void 0 === i && (i = 0),
- new e(t[i],t[i + 1],t[i + 2])
- }
- ,
- e.FromFloatArray = function(t, i) {
- return e.FromArray(t, i)
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- i.x = e[t],
- i.y = e[t + 1],
- i.z = e[t + 2]
- }
- ,
- e.FromFloatArrayToRef = function(t, i, n) {
- return e.FromArrayToRef(t, i, n)
- }
- ,
- e.FromFloatsToRef = function(e, t, i, n) {
- n.copyFromFloats(e, t, i)
- }
- ,
- e.Zero = function() {
- return new e(0,0,0)
- }
- ,
- e.One = function() {
- return new e(1,1,1)
- }
- ,
- e.Up = function() {
- return new e(0,1,0)
- }
- ,
- Object.defineProperty(e, "UpReadOnly", {
- get: function() {
- return e._UpReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "RightReadOnly", {
- get: function() {
- return e._RightReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LeftReadOnly", {
- get: function() {
- return e._LeftReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LeftHandedForwardReadOnly", {
- get: function() {
- return e._LeftHandedForwardReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "RightHandedForwardReadOnly", {
- get: function() {
- return e._RightHandedForwardReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ZeroReadOnly", {
- get: function() {
- return e._ZeroReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- e.Down = function() {
- return new e(0,-1,0)
- }
- ,
- e.Forward = function(t) {
- return void 0 === t && (t = !1),
- new e(0,0,t ? -1 : 1)
- }
- ,
- e.Backward = function(t) {
- return void 0 === t && (t = !1),
- new e(0,0,t ? 1 : -1)
- }
- ,
- e.Right = function() {
- return new e(1,0,0)
- }
- ,
- e.Left = function() {
- return new e(-1,0,0)
- }
- ,
- e.TransformCoordinates = function(t, i) {
- var n = e.Zero();
- return e.TransformCoordinatesToRef(t, i, n),
- n
- }
- ,
- e.TransformCoordinatesToRef = function(t, i, n) {
- e.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, i, n)
- }
- ,
- e.TransformCoordinatesFromFloatsToRef = function(e, t, i, n, r) {
- var o = n.m
- , a = e * o[0] + t * o[4] + i * o[8] + o[12]
- , s = e * o[1] + t * o[5] + i * o[9] + o[13]
- , l = e * o[2] + t * o[6] + i * o[10] + o[14]
- , c = 1 / (e * o[3] + t * o[7] + i * o[11] + o[15]);
- r.x = a * c,
- r.y = s * c,
- r.z = l * c
- }
- ,
- e.TransformNormal = function(t, i) {
- var n = e.Zero();
- return e.TransformNormalToRef(t, i, n),
- n
- }
- ,
- e.TransformNormalToRef = function(e, t, i) {
- this.TransformNormalFromFloatsToRef(e._x, e._y, e._z, t, i)
- }
- ,
- e.TransformNormalFromFloatsToRef = function(e, t, i, n, r) {
- var o = n.m;
- r.x = e * o[0] + t * o[4] + i * o[8],
- r.y = e * o[1] + t * o[5] + i * o[9],
- r.z = e * o[2] + t * o[6] + i * o[10]
- }
- ,
- e.CatmullRom = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a;
- return new e(.5 * (2 * i._x + (-t._x + n._x) * o + (2 * t._x - 5 * i._x + 4 * n._x - r._x) * a + (-t._x + 3 * i._x - 3 * n._x + r._x) * s),.5 * (2 * i._y + (-t._y + n._y) * o + (2 * t._y - 5 * i._y + 4 * n._y - r._y) * a + (-t._y + 3 * i._y - 3 * n._y + r._y) * s),.5 * (2 * i._z + (-t._z + n._z) * o + (2 * t._z - 5 * i._z + 4 * n._z - r._z) * a + (-t._z + 3 * i._z - 3 * n._z + r._z) * s))
- }
- ,
- e.Clamp = function(t, i, n) {
- var r = new e;
- return e.ClampToRef(t, i, n, r),
- r
- }
- ,
- e.ClampToRef = function(e, t, i, n) {
- var r = e._x;
- r = (r = r > i._x ? i._x : r) < t._x ? t._x : r;
- var o = e._y;
- o = (o = o > i._y ? i._y : o) < t._y ? t._y : o;
- var a = e._z;
- a = (a = a > i._z ? i._z : a) < t._z ? t._z : a,
- n.copyFromFloats(r, o, a)
- }
- ,
- e.CheckExtends = function(e, t, i) {
- t.minimizeInPlace(e),
- i.maximizeInPlace(e)
- }
- ,
- e.Hermite = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a
- , l = 2 * s - 3 * a + 1
- , c = -2 * s + 3 * a
- , u = s - 2 * a + o
- , h = s - a;
- return new e(t._x * l + n._x * c + i._x * u + r._x * h,t._y * l + n._y * c + i._y * u + r._y * h,t._z * l + n._z * c + i._z * u + r._z * h)
- }
- ,
- e.Hermite1stDerivative = function(t, i, n, r, o) {
- var a = e.Zero();
- return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
- a
- }
- ,
- e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
- var a = r * r;
- o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
- o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y,
- o.z = 6 * (a - r) * e.z + (3 * a - 4 * r + 1) * t.z + 6 * (-a + r) * i.z + (3 * a - 2 * r) * n.z
- }
- ,
- e.Lerp = function(t, i, n) {
- var r = new e(0,0,0);
- return e.LerpToRef(t, i, n, r),
- r
- }
- ,
- e.LerpToRef = function(e, t, i, n) {
- n.x = e._x + (t._x - e._x) * i,
- n.y = e._y + (t._y - e._y) * i,
- n.z = e._z + (t._z - e._z) * i
- }
- ,
- e.Dot = function(e, t) {
- return e._x * t._x + e._y * t._y + e._z * t._z
- }
- ,
- e.Cross = function(t, i) {
- var n = e.Zero();
- return e.CrossToRef(t, i, n),
- n
- }
- ,
- e.CrossToRef = function(e, t, i) {
- var n = e._y * t._z - e._z * t._y
- , r = e._z * t._x - e._x * t._z
- , o = e._x * t._y - e._y * t._x;
- i.copyFromFloats(n, r, o)
- }
- ,
- e.Normalize = function(t) {
- var i = e.Zero();
- return e.NormalizeToRef(t, i),
- i
- }
- ,
- e.NormalizeToRef = function(e, t) {
- e.normalizeToRef(t)
- }
- ,
- e.Project = function(t, i, n, r) {
- var o = new e;
- return e.ProjectToRef(t, i, n, r, o),
- o
- }
- ,
- e.ProjectToRef = function(t, i, n, r, o) {
- var a = r.width
- , s = r.height
- , l = r.x
- , c = r.y
- , u = M.Matrix[1];
- P.FromValuesToRef(a / 2, 0, 0, 0, 0, -s / 2, 0, 0, 0, 0, .5, 0, l + a / 2, s / 2 + c, .5, 1, u);
- var h = M.Matrix[0];
- return i.multiplyToRef(n, h),
- h.multiplyToRef(u, h),
- e.TransformCoordinatesToRef(t, h, o),
- o
- }
- ,
- e._UnprojectFromInvertedMatrixToRef = function(t, i, n) {
- e.TransformCoordinatesToRef(t, i, n);
- var r = i.m
- , o = t._x * r[3] + t._y * r[7] + t._z * r[11] + r[15];
- d.WithinEpsilon(o, 1) && n.scaleInPlace(1 / o)
- }
- ,
- e.UnprojectFromTransform = function(e, t, i, n, r) {
- return this.Unproject(e, t, i, n, r, P.IdentityReadOnly)
- }
- ,
- e.Unproject = function(t, i, n, r, o, a) {
- var s = e.Zero();
- return e.UnprojectToRef(t, i, n, r, o, a, s),
- s
- }
- ,
- e.UnprojectToRef = function(t, i, n, r, o, a, s) {
- e.UnprojectFloatsToRef(t._x, t._y, t._z, i, n, r, o, a, s)
- }
- ,
- e.UnprojectFloatsToRef = function(t, i, n, r, o, a, s, l, c) {
- var u, h = M.Matrix[0];
- a.multiplyToRef(s, h),
- h.multiplyToRef(l, h),
- h.invert();
- var d = M.Vector3[0];
- d.x = t / r * 2 - 1,
- d.y = -(i / o * 2 - 1),
- (null === (u = E.LastCreatedEngine) || void 0 === u ? void 0 : u.isNDCHalfZRange) ? d.z = n : d.z = 2 * n - 1,
- e._UnprojectFromInvertedMatrixToRef(d, h, c)
- }
- ,
- e.Minimize = function(e, t) {
- var i = e.clone();
- return i.minimizeInPlace(t),
- i
- }
- ,
- e.Maximize = function(e, t) {
- var i = e.clone();
- return i.maximizeInPlace(t),
- i
- }
- ,
- e.Distance = function(t, i) {
- return Math.sqrt(e.DistanceSquared(t, i))
- }
- ,
- e.DistanceSquared = function(e, t) {
- var i = e._x - t._x
- , n = e._y - t._y
- , r = e._z - t._z;
- return i * i + n * n + r * r
- }
- ,
- e.ProjectOnTriangleToRef = function(t, i, n, r, o) {
- var a = M.Vector3[0]
- , s = M.Vector3[1]
- , l = M.Vector3[2]
- , c = M.Vector3[3]
- , u = M.Vector3[4];
- n.subtractToRef(i, a),
- r.subtractToRef(i, s),
- r.subtractToRef(n, l);
- var h = a.length()
- , p = s.length()
- , f = l.length();
- if (h < m || p < m || f < m)
- return o.copyFrom(i),
- e.Distance(t, i);
- t.subtractToRef(i, u),
- e.CrossToRef(a, s, c);
- var _ = c.length();
- if (_ < m)
- return o.copyFrom(i),
- e.Distance(t, i);
- c.normalizeFromLength(_);
- var g = u.length();
- if (g < m)
- return o.copyFrom(i),
- 0;
- u.normalizeFromLength(g);
- var v = e.Dot(c, u)
- , y = M.Vector3[5]
- , b = M.Vector3[6];
- y.copyFrom(c).scaleInPlace(-g * v),
- b.copyFrom(t).addInPlace(y);
- var T = M.Vector3[4]
- , E = M.Vector3[5]
- , S = M.Vector3[7]
- , A = M.Vector3[8];
- T.copyFrom(a).scaleInPlace(1 / h),
- A.copyFrom(s).scaleInPlace(1 / p),
- T.addInPlace(A).scaleInPlace(-1),
- E.copyFrom(a).scaleInPlace(-1 / h),
- A.copyFrom(l).scaleInPlace(1 / f),
- E.addInPlace(A).scaleInPlace(-1),
- S.copyFrom(l).scaleInPlace(-1 / f),
- A.copyFrom(s).scaleInPlace(-1 / p),
- S.addInPlace(A).scaleInPlace(-1);
- var x = M.Vector3[9];
- x.copyFrom(b).subtractInPlace(i),
- e.CrossToRef(T, x, A);
- var R = e.Dot(A, c);
- x.copyFrom(b).subtractInPlace(n),
- e.CrossToRef(E, x, A);
- var C = e.Dot(A, c);
- x.copyFrom(b).subtractInPlace(r),
- e.CrossToRef(S, x, A);
- var P, I, O = e.Dot(A, c), D = M.Vector3[10];
- R > 0 && C < 0 ? (D.copyFrom(a),
- P = i,
- I = n) : C > 0 && O < 0 ? (D.copyFrom(l),
- P = n,
- I = r) : (D.copyFrom(s).scaleInPlace(-1),
- P = r,
- I = i);
- var N = M.Vector3[9]
- , L = M.Vector3[4];
- if (P.subtractToRef(b, A),
- I.subtractToRef(b, N),
- e.CrossToRef(A, N, L),
- !(e.Dot(L, c) < 0))
- return o.copyFrom(b),
- Math.abs(g * v);
- var F = M.Vector3[5];
- e.CrossToRef(D, L, F),
- F.normalize();
- var w = M.Vector3[9];
- w.copyFrom(P).subtractInPlace(b);
- var B = w.length();
- if (B < m)
- return o.copyFrom(P),
- e.Distance(t, P);
- w.normalizeFromLength(B);
- var U = e.Dot(F, w)
- , V = M.Vector3[7];
- V.copyFrom(b).addInPlace(F.scaleInPlace(B * U)),
- A.copyFrom(V).subtractInPlace(P),
- g = D.length(),
- D.normalizeFromLength(g);
- var k = e.Dot(A, D) / Math.max(g, m);
- return k = d.Clamp(k, 0, 1),
- V.copyFrom(P).addInPlace(D.scaleInPlace(k * g)),
- o.copyFrom(V),
- e.Distance(t, V)
- }
- ,
- e.Center = function(t, i) {
- return e.CenterToRef(t, i, e.Zero())
- }
- ,
- e.CenterToRef = function(e, t, i) {
- return i.copyFromFloats((e._x + t._x) / 2, (e._y + t._y) / 2, (e._z + t._z) / 2)
- }
- ,
- e.RotationFromAxis = function(t, i, n) {
- var r = e.Zero();
- return e.RotationFromAxisToRef(t, i, n, r),
- r
- }
- ,
- e.RotationFromAxisToRef = function(e, t, i, n) {
- var r = M.Quaternion[0];
- C.RotationQuaternionFromAxisToRef(e, t, i, r),
- r.toEulerAnglesToRef(n)
- }
- ,
- e._UpReadOnly = e.Up(),
- e._LeftHandedForwardReadOnly = e.Forward(!1),
- e._RightHandedForwardReadOnly = e.Forward(!0),
- e._RightReadOnly = e.Right(),
- e._LeftReadOnly = e.Left(),
- e._ZeroReadOnly = e.Zero(),
- e
- }()
- , R = function() {
- function e(e, t, i, n) {
- this.x = e,
- this.y = t,
- this.z = i,
- this.w = n
- }
- return e.prototype.toString = function() {
- return "{X: ".concat(this.x, " Y: ").concat(this.y, " Z: ").concat(this.z, " W: ").concat(this.w, "}")
- }
- ,
- e.prototype.getClassName = function() {
- return "Vector4"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = S(this.x);
- return 397 * (e = 397 * (e = 397 * e ^ S(this.y)) ^ S(this.z)) ^ S(this.w)
- }
- ,
- e.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- e.prototype.toArray = function(e, t) {
- return void 0 === t && (t = 0),
- e[t] = this.x,
- e[t + 1] = this.y,
- e[t + 2] = this.z,
- e[t + 3] = this.w,
- this
- }
- ,
- e.prototype.fromArray = function(t, i) {
- return void 0 === i && (i = 0),
- e.FromArrayToRef(t, i, this),
- this
- }
- ,
- e.prototype.addInPlace = function(e) {
- return this.x += e.x,
- this.y += e.y,
- this.z += e.z,
- this.w += e.w,
- this
- }
- ,
- e.prototype.add = function(t) {
- return new e(this.x + t.x,this.y + t.y,this.z + t.z,this.w + t.w)
- }
- ,
- e.prototype.addToRef = function(e, t) {
- return t.x = this.x + e.x,
- t.y = this.y + e.y,
- t.z = this.z + e.z,
- t.w = this.w + e.w,
- this
- }
- ,
- e.prototype.subtractInPlace = function(e) {
- return this.x -= e.x,
- this.y -= e.y,
- this.z -= e.z,
- this.w -= e.w,
- this
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this.x - t.x,this.y - t.y,this.z - t.z,this.w - t.w)
- }
- ,
- e.prototype.subtractToRef = function(e, t) {
- return t.x = this.x - e.x,
- t.y = this.y - e.y,
- t.z = this.z - e.z,
- t.w = this.w - e.w,
- this
- }
- ,
- e.prototype.subtractFromFloats = function(t, i, n, r) {
- return new e(this.x - t,this.y - i,this.z - n,this.w - r)
- }
- ,
- e.prototype.subtractFromFloatsToRef = function(e, t, i, n, r) {
- return r.x = this.x - e,
- r.y = this.y - t,
- r.z = this.z - i,
- r.w = this.w - n,
- this
- }
- ,
- e.prototype.negate = function() {
- return new e(-this.x,-this.y,-this.z,-this.w)
- }
- ,
- e.prototype.negateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this.z *= -1,
- this.w *= -1,
- this
- }
- ,
- e.prototype.negateToRef = function(e) {
- return e.copyFromFloats(-1 * this.x, -1 * this.y, -1 * this.z, -1 * this.w)
- }
- ,
- e.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this.z *= e,
- this.w *= e,
- this
- }
- ,
- e.prototype.scale = function(t) {
- return new e(this.x * t,this.y * t,this.z * t,this.w * t)
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- return t.x = this.x * e,
- t.y = this.y * e,
- t.z = this.z * e,
- t.w = this.w * e,
- this
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- return t.x += this.x * e,
- t.y += this.y * e,
- t.z += this.z * e,
- t.w += this.w * e,
- this
- }
- ,
- e.prototype.equals = function(e) {
- return e && this.x === e.x && this.y === e.y && this.z === e.z && this.w === e.w
- }
- ,
- e.prototype.equalsWithEpsilon = function(e, t) {
- return void 0 === t && (t = m),
- e && d.WithinEpsilon(this.x, e.x, t) && d.WithinEpsilon(this.y, e.y, t) && d.WithinEpsilon(this.z, e.z, t) && d.WithinEpsilon(this.w, e.w, t)
- }
- ,
- e.prototype.equalsToFloats = function(e, t, i, n) {
- return this.x === e && this.y === t && this.z === i && this.w === n
- }
- ,
- e.prototype.multiplyInPlace = function(e) {
- return this.x *= e.x,
- this.y *= e.y,
- this.z *= e.z,
- this.w *= e.w,
- this
- }
- ,
- e.prototype.multiply = function(t) {
- return new e(this.x * t.x,this.y * t.y,this.z * t.z,this.w * t.w)
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- return t.x = this.x * e.x,
- t.y = this.y * e.y,
- t.z = this.z * e.z,
- t.w = this.w * e.w,
- this
- }
- ,
- e.prototype.multiplyByFloats = function(t, i, n, r) {
- return new e(this.x * t,this.y * i,this.z * n,this.w * r)
- }
- ,
- e.prototype.divide = function(t) {
- return new e(this.x / t.x,this.y / t.y,this.z / t.z,this.w / t.w)
- }
- ,
- e.prototype.divideToRef = function(e, t) {
- return t.x = this.x / e.x,
- t.y = this.y / e.y,
- t.z = this.z / e.z,
- t.w = this.w / e.w,
- this
- }
- ,
- e.prototype.divideInPlace = function(e) {
- return this.divideToRef(e, this)
- }
- ,
- e.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
- }
- ,
- e.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
- }
- ,
- e.prototype.floor = function() {
- return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))
- }
- ,
- e.prototype.fract = function() {
- return new e(this.x - Math.floor(this.x),this.y - Math.floor(this.y),this.z - Math.floor(this.z),this.w - Math.floor(this.w))
- }
- ,
- e.prototype.length = function() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
- }
- ,
- e.prototype.lengthSquared = function() {
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
- }
- ,
- e.prototype.normalize = function() {
- var e = this.length();
- return 0 === e ? this : this.scaleInPlace(1 / e)
- }
- ,
- e.prototype.toVector3 = function() {
- return new x(this.x,this.y,this.z)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.x,this.y,this.z,this.w)
- }
- ,
- e.prototype.copyFrom = function(e) {
- return this.x = e.x,
- this.y = e.y,
- this.z = e.z,
- this.w = e.w,
- this
- }
- ,
- e.prototype.copyFromFloats = function(e, t, i, n) {
- return this.x = e,
- this.y = t,
- this.z = i,
- this.w = n,
- this
- }
- ,
- e.prototype.set = function(e, t, i, n) {
- return this.copyFromFloats(e, t, i, n)
- }
- ,
- e.prototype.setAll = function(e) {
- return this.x = this.y = this.z = this.w = e,
- this
- }
- ,
- e.FromArray = function(t, i) {
- return i || (i = 0),
- new e(t[i],t[i + 1],t[i + 2],t[i + 3])
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- i.x = e[t],
- i.y = e[t + 1],
- i.z = e[t + 2],
- i.w = e[t + 3]
- }
- ,
- e.FromFloatArrayToRef = function(t, i, n) {
- e.FromArrayToRef(t, i, n)
- }
- ,
- e.FromFloatsToRef = function(e, t, i, n, r) {
- r.x = e,
- r.y = t,
- r.z = i,
- r.w = n
- }
- ,
- e.Zero = function() {
- return new e(0,0,0,0)
- }
- ,
- e.One = function() {
- return new e(1,1,1,1)
- }
- ,
- e.Normalize = function(t) {
- var i = e.Zero();
- return e.NormalizeToRef(t, i),
- i
- }
- ,
- e.NormalizeToRef = function(e, t) {
- t.copyFrom(e),
- t.normalize()
- }
- ,
- e.Minimize = function(e, t) {
- var i = e.clone();
- return i.minimizeInPlace(t),
- i
- }
- ,
- e.Maximize = function(e, t) {
- var i = e.clone();
- return i.maximizeInPlace(t),
- i
- }
- ,
- e.Distance = function(t, i) {
- return Math.sqrt(e.DistanceSquared(t, i))
- }
- ,
- e.DistanceSquared = function(e, t) {
- var i = e.x - t.x
- , n = e.y - t.y
- , r = e.z - t.z
- , o = e.w - t.w;
- return i * i + n * n + r * r + o * o
- }
- ,
- e.Center = function(t, i) {
- return e.CenterToRef(t, i, e.Zero())
- }
- ,
- e.CenterToRef = function(e, t, i) {
- return i.copyFromFloats((e.x + t.x) / 2, (e.y + t.y) / 2, (e.z + t.z) / 2, (e.w + t.w) / 2)
- }
- ,
- e.TransformCoordinates = function(t, i) {
- var n = e.Zero();
- return e.TransformCoordinatesToRef(t, i, n),
- n
- }
- ,
- e.TransformCoordinatesToRef = function(t, i, n) {
- e.TransformCoordinatesFromFloatsToRef(t._x, t._y, t._z, i, n)
- }
- ,
- e.TransformCoordinatesFromFloatsToRef = function(e, t, i, n, r) {
- var o = n.m
- , a = e * o[0] + t * o[4] + i * o[8] + o[12]
- , s = e * o[1] + t * o[5] + i * o[9] + o[13]
- , l = e * o[2] + t * o[6] + i * o[10] + o[14]
- , c = e * o[3] + t * o[7] + i * o[11] + o[15];
- r.x = a,
- r.y = s,
- r.z = l,
- r.w = c
- }
- ,
- e.TransformNormal = function(t, i) {
- var n = e.Zero();
- return e.TransformNormalToRef(t, i, n),
- n
- }
- ,
- e.TransformNormalToRef = function(e, t, i) {
- var n = t.m
- , r = e.x * n[0] + e.y * n[4] + e.z * n[8]
- , o = e.x * n[1] + e.y * n[5] + e.z * n[9]
- , a = e.x * n[2] + e.y * n[6] + e.z * n[10];
- i.x = r,
- i.y = o,
- i.z = a,
- i.w = e.w
- }
- ,
- e.TransformNormalFromFloatsToRef = function(e, t, i, n, r, o) {
- var a = r.m;
- o.x = e * a[0] + t * a[4] + i * a[8],
- o.y = e * a[1] + t * a[5] + i * a[9],
- o.z = e * a[2] + t * a[6] + i * a[10],
- o.w = n
- }
- ,
- e.FromVector3 = function(t, i) {
- return void 0 === i && (i = 0),
- new e(t._x,t._y,t._z,i)
- }
- ,
- e
- }()
- , C = function() {
- function e(e, t, i, n) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- void 0 === n && (n = 1),
- this._isDirty = !0,
- this._x = e,
- this._y = t,
- this._z = i,
- this._w = n
- }
- return Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._x
- },
- set: function(e) {
- this._x = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._y
- },
- set: function(e) {
- this._y = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "z", {
- get: function() {
- return this._z
- },
- set: function(e) {
- this._z = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "w", {
- get: function() {
- return this._w
- },
- set: function(e) {
- this._w = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.toString = function() {
- return "{X: ".concat(this._x, " Y: ").concat(this._y, " Z: ").concat(this._z, " W: ").concat(this._w, "}")
- }
- ,
- e.prototype.getClassName = function() {
- return "Quaternion"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = S(this._x);
- return 397 * (e = 397 * (e = 397 * e ^ S(this._y)) ^ S(this._z)) ^ S(this._w)
- }
- ,
- e.prototype.asArray = function() {
- return [this._x, this._y, this._z, this._w]
- }
- ,
- e.prototype.equals = function(e) {
- return e && this._x === e._x && this._y === e._y && this._z === e._z && this._w === e._w
- }
- ,
- e.prototype.equalsWithEpsilon = function(e, t) {
- return void 0 === t && (t = m),
- e && d.WithinEpsilon(this._x, e._x, t) && d.WithinEpsilon(this._y, e._y, t) && d.WithinEpsilon(this._z, e._z, t) && d.WithinEpsilon(this._w, e._w, t)
- }
- ,
- e.prototype.clone = function() {
- return new e(this._x,this._y,this._z,this._w)
- }
- ,
- e.prototype.copyFrom = function(e) {
- return this.x = e._x,
- this.y = e._y,
- this.z = e._z,
- this.w = e._w,
- this
- }
- ,
- e.prototype.copyFromFloats = function(e, t, i, n) {
- return this.x = e,
- this.y = t,
- this.z = i,
- this.w = n,
- this
- }
- ,
- e.prototype.set = function(e, t, i, n) {
- return this.copyFromFloats(e, t, i, n)
- }
- ,
- e.prototype.add = function(t) {
- return new e(this._x + t._x,this._y + t._y,this._z + t._z,this._w + t._w)
- }
- ,
- e.prototype.addInPlace = function(e) {
- return this._x += e._x,
- this._y += e._y,
- this._z += e._z,
- this._w += e._w,
- this
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this._x - t._x,this._y - t._y,this._z - t._z,this._w - t._w)
- }
- ,
- e.prototype.scale = function(t) {
- return new e(this._x * t,this._y * t,this._z * t,this._w * t)
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- return t.x = this._x * e,
- t.y = this._y * e,
- t.z = this._z * e,
- t.w = this._w * e,
- this
- }
- ,
- e.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this.z *= e,
- this.w *= e,
- this
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- return t.x += this._x * e,
- t.y += this._y * e,
- t.z += this._z * e,
- t.w += this._w * e,
- this
- }
- ,
- e.prototype.multiply = function(t) {
- var i = new e(0,0,0,1);
- return this.multiplyToRef(t, i),
- i
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- var i = this._x * e._w + this._y * e._z - this._z * e._y + this._w * e._x
- , n = -this._x * e._z + this._y * e._w + this._z * e._x + this._w * e._y
- , r = this._x * e._y - this._y * e._x + this._z * e._w + this._w * e._z
- , o = -this._x * e._x - this._y * e._y - this._z * e._z + this._w * e._w;
- return t.copyFromFloats(i, n, r, o),
- this
- }
- ,
- e.prototype.multiplyInPlace = function(e) {
- return this.multiplyToRef(e, this),
- this
- }
- ,
- e.prototype.conjugateToRef = function(e) {
- return e.copyFromFloats(-this._x, -this._y, -this._z, this._w),
- this
- }
- ,
- e.prototype.conjugateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this.z *= -1,
- this
- }
- ,
- e.prototype.conjugate = function() {
- return new e(-this._x,-this._y,-this._z,this._w)
- }
- ,
- e.prototype.length = function() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w)
- }
- ,
- e.prototype.normalize = function() {
- var e = this.length();
- if (0 === e)
- return this;
- var t = 1 / e;
- return this.x *= t,
- this.y *= t,
- this.z *= t,
- this.w *= t,
- this
- }
- ,
- e.prototype.toEulerAngles = function() {
- var e = x.Zero();
- return this.toEulerAnglesToRef(e),
- e
- }
- ,
- e.prototype.toEulerAnglesToRef = function(e) {
- var t = this._z
- , i = this._x
- , n = this._y
- , r = this._w
- , o = r * r
- , a = t * t
- , s = i * i
- , l = n * n
- , c = n * t - i * r
- , u = .4999999;
- return c < -u ? (e.y = 2 * Math.atan2(n, r),
- e.x = Math.PI / 2,
- e.z = 0) : c > u ? (e.y = 2 * Math.atan2(n, r),
- e.x = -Math.PI / 2,
- e.z = 0) : (e.z = Math.atan2(2 * (i * n + t * r), -a - s + l + o),
- e.x = Math.asin(-2 * (t * n - i * r)),
- e.y = Math.atan2(2 * (t * i + n * r), a - s - l + o)),
- this
- }
- ,
- e.prototype.toRotationMatrix = function(e) {
- return P.FromQuaternionToRef(this, e),
- this
- }
- ,
- e.prototype.fromRotationMatrix = function(t) {
- return e.FromRotationMatrixToRef(t, this),
- this
- }
- ,
- e.FromRotationMatrix = function(t) {
- var i = new e;
- return e.FromRotationMatrixToRef(t, i),
- i
- }
- ,
- e.FromRotationMatrixToRef = function(e, t) {
- var i, n = e.m, r = n[0], o = n[4], a = n[8], s = n[1], l = n[5], c = n[9], u = n[2], h = n[6], d = n[10], p = r + l + d;
- p > 0 ? (i = .5 / Math.sqrt(p + 1),
- t.w = .25 / i,
- t.x = (h - c) * i,
- t.y = (a - u) * i,
- t.z = (s - o) * i) : r > l && r > d ? (i = 2 * Math.sqrt(1 + r - l - d),
- t.w = (h - c) / i,
- t.x = .25 * i,
- t.y = (o + s) / i,
- t.z = (a + u) / i) : l > d ? (i = 2 * Math.sqrt(1 + l - r - d),
- t.w = (a - u) / i,
- t.x = (o + s) / i,
- t.y = .25 * i,
- t.z = (c + h) / i) : (i = 2 * Math.sqrt(1 + d - r - l),
- t.w = (s - o) / i,
- t.x = (a + u) / i,
- t.y = (c + h) / i,
- t.z = .25 * i)
- }
- ,
- e.Dot = function(e, t) {
- return e._x * t._x + e._y * t._y + e._z * t._z + e._w * t._w
- }
- ,
- e.AreClose = function(t, i) {
- return e.Dot(t, i) >= 0
- }
- ,
- e.SmoothToRef = function(t, i, n, r, o) {
- var a = 0 === r ? 1 : n / r;
- a = d.Clamp(a, 0, 1),
- e.SlerpToRef(t, i, a, o)
- }
- ,
- e.Zero = function() {
- return new e(0,0,0,0)
- }
- ,
- e.Inverse = function(t) {
- return new e(-t._x,-t._y,-t._z,t._w)
- }
- ,
- e.InverseToRef = function(e, t) {
- return t.set(-e._x, -e._y, -e._z, e._w),
- t
- }
- ,
- e.Identity = function() {
- return new e(0,0,0,1)
- }
- ,
- e.IsIdentity = function(e) {
- return e && 0 === e._x && 0 === e._y && 0 === e._z && 1 === e._w
- }
- ,
- e.RotationAxis = function(t, i) {
- return e.RotationAxisToRef(t, i, new e)
- }
- ,
- e.RotationAxisToRef = function(e, t, i) {
- var n = Math.sin(t / 2);
- return e.normalize(),
- i.w = Math.cos(t / 2),
- i.x = e._x * n,
- i.y = e._y * n,
- i.z = e._z * n,
- i
- }
- ,
- e.FromArray = function(t, i) {
- return i || (i = 0),
- new e(t[i],t[i + 1],t[i + 2],t[i + 3])
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- i.x = e[t],
- i.y = e[t + 1],
- i.z = e[t + 2],
- i.w = e[t + 3]
- }
- ,
- e.FromEulerAngles = function(t, i, n) {
- var r = new e;
- return e.RotationYawPitchRollToRef(i, t, n, r),
- r
- }
- ,
- e.FromEulerAnglesToRef = function(t, i, n, r) {
- return e.RotationYawPitchRollToRef(i, t, n, r),
- r
- }
- ,
- e.FromEulerVector = function(t) {
- var i = new e;
- return e.RotationYawPitchRollToRef(t._y, t._x, t._z, i),
- i
- }
- ,
- e.FromEulerVectorToRef = function(t, i) {
- return e.RotationYawPitchRollToRef(t._y, t._x, t._z, i),
- i
- }
- ,
- e.FromUnitVectorsToRef = function(e, t, i) {
- var n = x.Dot(e, t) + 1;
- return n < m ? Math.abs(e.x) > Math.abs(e.z) ? i.set(-e.y, e.x, 0, 0) : i.set(0, -e.z, e.y, 0) : (x.CrossToRef(e, t, I.Vector3[0]),
- i.set(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[0].z, n)),
- i.normalize()
- }
- ,
- e.RotationYawPitchRoll = function(t, i, n) {
- var r = new e;
- return e.RotationYawPitchRollToRef(t, i, n, r),
- r
- }
- ,
- e.RotationYawPitchRollToRef = function(e, t, i, n) {
- var r = .5 * i
- , o = .5 * t
- , a = .5 * e
- , s = Math.sin(r)
- , l = Math.cos(r)
- , c = Math.sin(o)
- , u = Math.cos(o)
- , h = Math.sin(a)
- , d = Math.cos(a);
- n.x = d * c * l + h * u * s,
- n.y = h * u * l - d * c * s,
- n.z = d * u * s - h * c * l,
- n.w = d * u * l + h * c * s
- }
- ,
- e.RotationAlphaBetaGamma = function(t, i, n) {
- var r = new e;
- return e.RotationAlphaBetaGammaToRef(t, i, n, r),
- r
- }
- ,
- e.RotationAlphaBetaGammaToRef = function(e, t, i, n) {
- var r = .5 * (i + e)
- , o = .5 * (i - e)
- , a = .5 * t;
- n.x = Math.cos(o) * Math.sin(a),
- n.y = Math.sin(o) * Math.sin(a),
- n.z = Math.sin(r) * Math.cos(a),
- n.w = Math.cos(r) * Math.cos(a)
- }
- ,
- e.RotationQuaternionFromAxis = function(t, i, n) {
- var r = new e(0,0,0,0);
- return e.RotationQuaternionFromAxisToRef(t, i, n, r),
- r
- }
- ,
- e.RotationQuaternionFromAxisToRef = function(t, i, n, r) {
- var o = M.Matrix[0];
- P.FromXYZAxesToRef(t.normalize(), i.normalize(), n.normalize(), o),
- e.FromRotationMatrixToRef(o, r)
- }
- ,
- e.FromLookDirectionLH = function(t, i) {
- var n = new e;
- return e.FromLookDirectionLHToRef(t, i, n),
- n
- }
- ,
- e.FromLookDirectionLHToRef = function(t, i, n) {
- var r = M.Matrix[0];
- P.LookDirectionLHToRef(t, i, r),
- e.FromRotationMatrixToRef(r, n)
- }
- ,
- e.FromLookDirectionRH = function(t, i) {
- var n = new e;
- return e.FromLookDirectionRHToRef(t, i, n),
- n
- }
- ,
- e.FromLookDirectionRHToRef = function(t, i, n) {
- var r = M.Matrix[0];
- return P.LookDirectionRHToRef(t, i, r),
- e.FromRotationMatrixToRef(r, n)
- }
- ,
- e.Slerp = function(t, i, n) {
- var r = e.Identity();
- return e.SlerpToRef(t, i, n, r),
- r
- }
- ,
- e.SlerpToRef = function(e, t, i, n) {
- var r, o, a = e._x * t._x + e._y * t._y + e._z * t._z + e._w * t._w, s = !1;
- if (a < 0 && (s = !0,
- a = -a),
- a > .999999)
- o = 1 - i,
- r = s ? -i : i;
- else {
- var l = Math.acos(a)
- , c = 1 / Math.sin(l);
- o = Math.sin((1 - i) * l) * c,
- r = s ? -Math.sin(i * l) * c : Math.sin(i * l) * c
- }
- n.x = o * e._x + r * t._x,
- n.y = o * e._y + r * t._y,
- n.z = o * e._z + r * t._z,
- n.w = o * e._w + r * t._w
- }
- ,
- e.Hermite = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a
- , l = 2 * s - 3 * a + 1
- , c = -2 * s + 3 * a
- , u = s - 2 * a + o
- , h = s - a;
- return new e(t._x * l + n._x * c + i._x * u + r._x * h,t._y * l + n._y * c + i._y * u + r._y * h,t._z * l + n._z * c + i._z * u + r._z * h,t._w * l + n._w * c + i._w * u + r._w * h)
- }
- ,
- e.Hermite1stDerivative = function(t, i, n, r, o) {
- var a = e.Zero();
- return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
- a
- }
- ,
- e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
- var a = r * r;
- o.x = 6 * (a - r) * e.x + (3 * a - 4 * r + 1) * t.x + 6 * (-a + r) * i.x + (3 * a - 2 * r) * n.x,
- o.y = 6 * (a - r) * e.y + (3 * a - 4 * r + 1) * t.y + 6 * (-a + r) * i.y + (3 * a - 2 * r) * n.y,
- o.z = 6 * (a - r) * e.z + (3 * a - 4 * r + 1) * t.z + 6 * (-a + r) * i.z + (3 * a - 2 * r) * n.z,
- o.w = 6 * (a - r) * e.w + (3 * a - 4 * r + 1) * t.w + 6 * (-a + r) * i.w + (3 * a - 2 * r) * n.w
- }
- ,
- e
- }()
- , P = function() {
- function e() {
- this._isIdentity = !1,
- this._isIdentityDirty = !0,
- this._isIdentity3x2 = !0,
- this._isIdentity3x2Dirty = !0,
- this.updateFlag = -1,
- T.MatrixTrackPrecisionChange && T.MatrixTrackedMatrices.push(this),
- this._m = new T.MatrixCurrentType(16),
- this.markAsUpdated()
- }
- return Object.defineProperty(e, "Use64Bits", {
- get: function() {
- return T.MatrixUse64Bits
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "m", {
- get: function() {
- return this._m
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.markAsUpdated = function() {
- this.updateFlag = e._UpdateFlagSeed++,
- this._isIdentity = !1,
- this._isIdentity3x2 = !1,
- this._isIdentityDirty = !0,
- this._isIdentity3x2Dirty = !0
- }
- ,
- e.prototype._updateIdentityStatus = function(e, t, i, n) {
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- void 0 === n && (n = !0),
- this._isIdentity = e,
- this._isIdentity3x2 = e || i,
- this._isIdentityDirty = !this._isIdentity && t,
- this._isIdentity3x2Dirty = !this._isIdentity3x2 && n
- }
- ,
- e.prototype.isIdentity = function() {
- if (this._isIdentityDirty) {
- this._isIdentityDirty = !1;
- var e = this._m;
- this._isIdentity = 1 === e[0] && 0 === e[1] && 0 === e[2] && 0 === e[3] && 0 === e[4] && 1 === e[5] && 0 === e[6] && 0 === e[7] && 0 === e[8] && 0 === e[9] && 1 === e[10] && 0 === e[11] && 0 === e[12] && 0 === e[13] && 0 === e[14] && 1 === e[15]
- }
- return this._isIdentity
- }
- ,
- e.prototype.isIdentityAs3x2 = function() {
- return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1,
- 1 !== this._m[0] || 1 !== this._m[5] || 1 !== this._m[15] || 0 !== 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] ? this._isIdentity3x2 = !1 : this._isIdentity3x2 = !0),
- this._isIdentity3x2
- }
- ,
- e.prototype.determinant = function() {
- if (!0 === this._isIdentity)
- return 1;
- var e = this._m
- , t = e[0]
- , i = e[1]
- , n = e[2]
- , r = e[3]
- , o = e[4]
- , a = e[5]
- , s = e[6]
- , l = e[7]
- , c = e[8]
- , u = e[9]
- , h = e[10]
- , d = e[11]
- , p = e[12]
- , f = e[13]
- , _ = e[14]
- , m = e[15]
- , g = h * m - _ * d
- , v = u * m - f * d
- , y = u * _ - f * h
- , b = c * m - p * d
- , T = c * _ - h * p
- , E = c * f - p * u;
- return t * +(a * g - s * v + l * y) + i * -(o * g - s * b + l * T) + n * +(o * v - a * b + l * E) + r * -(o * y - a * T + s * E)
- }
- ,
- e.prototype.toArray = function() {
- return this._m
- }
- ,
- e.prototype.asArray = function() {
- return this._m
- }
- ,
- e.prototype.invert = function() {
- return this.invertToRef(this),
- this
- }
- ,
- e.prototype.reset = function() {
- return e.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this),
- this._updateIdentityStatus(!1),
- this
- }
- ,
- e.prototype.add = function(t) {
- var i = new e;
- return this.addToRef(t, i),
- i
- }
- ,
- e.prototype.addToRef = function(e, t) {
- for (var i = this._m, n = t._m, r = e.m, o = 0; o < 16; o++)
- n[o] = i[o] + r[o];
- return t.markAsUpdated(),
- this
- }
- ,
- e.prototype.addToSelf = function(e) {
- for (var t = this._m, i = e.m, n = 0; n < 16; n++)
- t[n] += i[n];
- return this.markAsUpdated(),
- this
- }
- ,
- e.prototype.invertToRef = function(t) {
- if (!0 === this._isIdentity)
- return e.IdentityToRef(t),
- this;
- var i = this._m
- , n = i[0]
- , r = i[1]
- , o = i[2]
- , a = i[3]
- , s = i[4]
- , l = i[5]
- , c = i[6]
- , u = i[7]
- , h = i[8]
- , d = i[9]
- , p = i[10]
- , f = i[11]
- , _ = i[12]
- , m = i[13]
- , g = i[14]
- , v = i[15]
- , y = p * v - g * f
- , b = d * v - m * f
- , T = d * g - m * p
- , E = h * v - _ * f
- , S = h * g - p * _
- , A = h * m - _ * d
- , x = +(l * y - c * b + u * T)
- , R = -(s * y - c * E + u * S)
- , C = +(s * b - l * E + u * A)
- , P = -(s * T - l * S + c * A)
- , M = n * x + r * R + o * C + a * P;
- if (0 === M)
- return t.copyFrom(this),
- this;
- var I = 1 / M
- , O = c * v - g * u
- , D = l * v - m * u
- , N = l * g - m * c
- , L = s * v - _ * u
- , F = s * g - _ * c
- , w = s * m - _ * l
- , B = c * f - p * u
- , U = l * f - d * u
- , V = l * p - d * c
- , k = s * f - h * u
- , G = s * p - h * c
- , z = s * d - h * l
- , W = -(r * y - o * b + a * T)
- , H = +(n * y - o * E + a * S)
- , X = -(n * b - r * E + a * A)
- , j = +(n * T - r * S + o * A)
- , Y = +(r * O - o * D + a * N)
- , K = -(n * O - o * L + a * F)
- , Q = +(n * D - r * L + a * w)
- , q = -(n * N - r * F + o * w)
- , Z = -(r * B - o * U + a * V)
- , J = +(n * B - o * k + a * G)
- , $ = -(n * U - r * k + a * z)
- , ee = +(n * V - r * G + o * z);
- return e.FromValuesToRef(x * I, W * I, Y * I, Z * I, R * I, H * I, K * I, J * I, C * I, X * I, Q * I, $ * I, P * I, j * I, q * I, ee * I, t),
- this
- }
- ,
- e.prototype.addAtIndex = function(e, t) {
- return this._m[e] += t,
- this.markAsUpdated(),
- this
- }
- ,
- e.prototype.multiplyAtIndex = function(e, t) {
- return this._m[e] *= t,
- this.markAsUpdated(),
- this
- }
- ,
- e.prototype.setTranslationFromFloats = function(e, t, i) {
- return this._m[12] = e,
- this._m[13] = t,
- this._m[14] = i,
- this.markAsUpdated(),
- this
- }
- ,
- e.prototype.addTranslationFromFloats = function(e, t, i) {
- return this._m[12] += e,
- this._m[13] += t,
- this._m[14] += i,
- this.markAsUpdated(),
- this
- }
- ,
- e.prototype.setTranslation = function(e) {
- return this.setTranslationFromFloats(e._x, e._y, e._z)
- }
- ,
- e.prototype.getTranslation = function() {
- return new x(this._m[12],this._m[13],this._m[14])
- }
- ,
- e.prototype.getTranslationToRef = function(e) {
- return e.x = this._m[12],
- e.y = this._m[13],
- e.z = this._m[14],
- this
- }
- ,
- e.prototype.removeRotationAndScaling = function() {
- var t = this.m;
- return e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t[12], t[13], t[14], t[15], this),
- this._updateIdentityStatus(0 === t[12] && 0 === t[13] && 0 === t[14] && 1 === t[15]),
- this
- }
- ,
- e.prototype.multiply = function(t) {
- var i = new e;
- return this.multiplyToRef(t, i),
- i
- }
- ,
- e.prototype.copyFrom = function(e) {
- e.copyToArray(this._m);
- var t = e;
- return this.updateFlag = t.updateFlag,
- this._updateIdentityStatus(t._isIdentity, t._isIdentityDirty, t._isIdentity3x2, t._isIdentity3x2Dirty),
- this
- }
- ,
- e.prototype.copyToArray = function(e, t) {
- void 0 === t && (t = 0);
- var i = this._m;
- return e[t] = i[0],
- e[t + 1] = i[1],
- e[t + 2] = i[2],
- e[t + 3] = i[3],
- e[t + 4] = i[4],
- e[t + 5] = i[5],
- e[t + 6] = i[6],
- e[t + 7] = i[7],
- e[t + 8] = i[8],
- e[t + 9] = i[9],
- e[t + 10] = i[10],
- e[t + 11] = i[11],
- e[t + 12] = i[12],
- e[t + 13] = i[13],
- e[t + 14] = i[14],
- e[t + 15] = i[15],
- this
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- return this._isIdentity ? (t.copyFrom(e),
- this) : e._isIdentity ? (t.copyFrom(this),
- this) : (this.multiplyToArray(e, t._m, 0),
- t.markAsUpdated(),
- this)
- }
- ,
- e.prototype.multiplyToArray = function(e, t, i) {
- var n = this._m
- , r = e.m
- , o = n[0]
- , a = n[1]
- , s = n[2]
- , l = n[3]
- , c = n[4]
- , u = n[5]
- , h = n[6]
- , d = n[7]
- , p = n[8]
- , f = n[9]
- , _ = n[10]
- , m = n[11]
- , g = n[12]
- , v = n[13]
- , y = n[14]
- , b = n[15]
- , T = r[0]
- , E = r[1]
- , S = r[2]
- , A = r[3]
- , x = r[4]
- , R = r[5]
- , C = r[6]
- , P = r[7]
- , M = r[8]
- , I = r[9]
- , O = r[10]
- , D = r[11]
- , N = r[12]
- , L = r[13]
- , F = r[14]
- , w = r[15];
- return t[i] = o * T + a * x + s * M + l * N,
- t[i + 1] = o * E + a * R + s * I + l * L,
- t[i + 2] = o * S + a * C + s * O + l * F,
- t[i + 3] = o * A + a * P + s * D + l * w,
- t[i + 4] = c * T + u * x + h * M + d * N,
- t[i + 5] = c * E + u * R + h * I + d * L,
- t[i + 6] = c * S + u * C + h * O + d * F,
- t[i + 7] = c * A + u * P + h * D + d * w,
- t[i + 8] = p * T + f * x + _ * M + m * N,
- t[i + 9] = p * E + f * R + _ * I + m * L,
- t[i + 10] = p * S + f * C + _ * O + m * F,
- t[i + 11] = p * A + f * P + _ * D + m * w,
- t[i + 12] = g * T + v * x + y * M + b * N,
- t[i + 13] = g * E + v * R + y * I + b * L,
- t[i + 14] = g * S + v * C + y * O + b * F,
- t[i + 15] = g * A + v * P + y * D + b * w,
- this
- }
- ,
- e.prototype.equals = function(e) {
- var t = e;
- if (!t)
- return !1;
- if ((this._isIdentity || t._isIdentity) && !this._isIdentityDirty && !t._isIdentityDirty)
- return this._isIdentity && t._isIdentity;
- var i = this.m
- , n = t.m;
- return i[0] === n[0] && i[1] === n[1] && i[2] === n[2] && i[3] === n[3] && i[4] === n[4] && i[5] === n[5] && i[6] === n[6] && i[7] === n[7] && i[8] === n[8] && i[9] === n[9] && i[10] === n[10] && i[11] === n[11] && i[12] === n[12] && i[13] === n[13] && i[14] === n[14] && i[15] === n[15]
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return t.copyFrom(this),
- t
- }
- ,
- e.prototype.getClassName = function() {
- return "Matrix"
- }
- ,
- e.prototype.getHashCode = function() {
- for (var e = S(this._m[0]), t = 1; t < 16; t++)
- e = 397 * e ^ S(this._m[t]);
- return e
- }
- ,
- e.prototype.decomposeToTransformNode = function(e) {
- return e.rotationQuaternion = e.rotationQuaternion || new C,
- this.decompose(e.scaling, e.rotationQuaternion, e.position)
- }
- ,
- e.prototype.decompose = function(t, i, n, r) {
- if (this._isIdentity)
- return n && n.setAll(0),
- t && t.setAll(1),
- i && i.copyFromFloats(0, 0, 0, 1),
- !0;
- var o = this._m;
- if (n && n.copyFromFloats(o[12], o[13], o[14]),
- (t = t || M.Vector3[0]).x = Math.sqrt(o[0] * o[0] + o[1] * o[1] + o[2] * o[2]),
- t.y = Math.sqrt(o[4] * o[4] + o[5] * o[5] + o[6] * o[6]),
- t.z = Math.sqrt(o[8] * o[8] + o[9] * o[9] + o[10] * o[10]),
- r) {
- var a = r.scaling.x < 0 ? -1 : 1
- , s = r.scaling.y < 0 ? -1 : 1
- , l = r.scaling.z < 0 ? -1 : 1;
- t.x *= a,
- t.y *= s,
- t.z *= l
- } else
- this.determinant() <= 0 && (t.y *= -1);
- if (0 === t._x || 0 === t._y || 0 === t._z)
- return i && i.copyFromFloats(0, 0, 0, 1),
- !1;
- if (i) {
- var c = 1 / t._x
- , u = 1 / t._y
- , h = 1 / t._z;
- e.FromValuesToRef(o[0] * c, o[1] * c, o[2] * c, 0, o[4] * u, o[5] * u, o[6] * u, 0, o[8] * h, o[9] * h, o[10] * h, 0, 0, 0, 0, 1, M.Matrix[0]),
- C.FromRotationMatrixToRef(M.Matrix[0], i)
- }
- return !0
- }
- ,
- e.prototype.getRow = function(e) {
- if (e < 0 || e > 3)
- return null;
- var t = 4 * e;
- return new R(this._m[t + 0],this._m[t + 1],this._m[t + 2],this._m[t + 3])
- }
- ,
- e.prototype.setRow = function(e, t) {
- return this.setRowFromFloats(e, t.x, t.y, t.z, t.w)
- }
- ,
- e.prototype.transpose = function() {
- return e.Transpose(this)
- }
- ,
- e.prototype.transposeToRef = function(t) {
- return e.TransposeToRef(this, t),
- this
- }
- ,
- e.prototype.setRowFromFloats = function(e, t, i, n, r) {
- if (e < 0 || e > 3)
- return this;
- var o = 4 * e;
- return this._m[o + 0] = t,
- this._m[o + 1] = i,
- this._m[o + 2] = n,
- this._m[o + 3] = r,
- this.markAsUpdated(),
- this
- }
- ,
- e.prototype.scale = function(t) {
- var i = new e;
- return this.scaleToRef(t, i),
- i
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- for (var i = 0; i < 16; i++)
- t._m[i] = this._m[i] * e;
- return t.markAsUpdated(),
- this
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- for (var i = 0; i < 16; i++)
- t._m[i] += this._m[i] * e;
- return t.markAsUpdated(),
- this
- }
- ,
- e.prototype.toNormalMatrix = function(t) {
- var i = M.Matrix[0];
- this.invertToRef(i),
- i.transposeToRef(t);
- var n = t._m;
- e.FromValuesToRef(n[0], n[1], n[2], 0, n[4], n[5], n[6], 0, n[8], n[9], n[10], 0, 0, 0, 0, 1, t)
- }
- ,
- e.prototype.getRotationMatrix = function() {
- var t = new e;
- return this.getRotationMatrixToRef(t),
- t
- }
- ,
- e.prototype.getRotationMatrixToRef = function(t) {
- var i = M.Vector3[0];
- if (!this.decompose(i))
- return e.IdentityToRef(t),
- this;
- var n = this._m
- , r = 1 / i._x
- , o = 1 / i._y
- , a = 1 / i._z;
- return e.FromValuesToRef(n[0] * r, n[1] * r, n[2] * r, 0, n[4] * o, n[5] * o, n[6] * o, 0, n[8] * a, n[9] * a, n[10] * a, 0, 0, 0, 0, 1, t),
- this
- }
- ,
- e.prototype.toggleModelMatrixHandInPlace = function() {
- var e = this._m;
- e[2] *= -1,
- e[6] *= -1,
- e[8] *= -1,
- e[9] *= -1,
- e[14] *= -1,
- this.markAsUpdated()
- }
- ,
- e.prototype.toggleProjectionMatrixHandInPlace = function() {
- var e = this._m;
- e[8] *= -1,
- e[9] *= -1,
- e[10] *= -1,
- e[11] *= -1,
- this.markAsUpdated()
- }
- ,
- e.FromArray = function(t, i) {
- void 0 === i && (i = 0);
- var n = new e;
- return e.FromArrayToRef(t, i, n),
- n
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- for (var n = 0; n < 16; n++)
- i._m[n] = e[n + t];
- i.markAsUpdated()
- }
- ,
- e.FromFloat32ArrayToRefScaled = function(e, t, i, n) {
- for (var r = 0; r < 16; r++)
- n._m[r] = e[r + t] * i;
- n.markAsUpdated()
- }
- ,
- Object.defineProperty(e, "IdentityReadOnly", {
- get: function() {
- return e._IdentityReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- e.FromValuesToRef = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m) {
- var g = m._m;
- g[0] = e,
- g[1] = t,
- g[2] = i,
- g[3] = n,
- g[4] = r,
- g[5] = o,
- g[6] = a,
- g[7] = s,
- g[8] = l,
- g[9] = c,
- g[10] = u,
- g[11] = h,
- g[12] = d,
- g[13] = p,
- g[14] = f,
- g[15] = _,
- m.markAsUpdated()
- }
- ,
- e.FromValues = function(t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m) {
- var g = new e
- , v = g._m;
- return v[0] = t,
- v[1] = i,
- v[2] = n,
- v[3] = r,
- v[4] = o,
- v[5] = a,
- v[6] = s,
- v[7] = l,
- v[8] = c,
- v[9] = u,
- v[10] = h,
- v[11] = d,
- v[12] = p,
- v[13] = f,
- v[14] = _,
- v[15] = m,
- g.markAsUpdated(),
- g
- }
- ,
- e.Compose = function(t, i, n) {
- var r = new e;
- return e.ComposeToRef(t, i, n, r),
- r
- }
- ,
- e.ComposeToRef = function(e, t, i, n) {
- var r = n._m
- , o = t._x
- , a = t._y
- , s = t._z
- , l = t._w
- , c = o + o
- , u = a + a
- , h = s + s
- , d = o * c
- , p = o * u
- , f = o * h
- , _ = a * u
- , m = a * h
- , g = s * h
- , v = l * c
- , y = l * u
- , b = l * h
- , T = e._x
- , E = e._y
- , S = e._z;
- r[0] = (1 - (_ + g)) * T,
- r[1] = (p + b) * T,
- r[2] = (f - y) * T,
- r[3] = 0,
- r[4] = (p - b) * E,
- r[5] = (1 - (d + g)) * E,
- r[6] = (m + v) * E,
- r[7] = 0,
- r[8] = (f + y) * S,
- r[9] = (m - v) * S,
- r[10] = (1 - (d + _)) * S,
- r[11] = 0,
- r[12] = i._x,
- r[13] = i._y,
- r[14] = i._z,
- r[15] = 1,
- n.markAsUpdated()
- }
- ,
- e.Identity = function() {
- var t = e.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
- return t._updateIdentityStatus(!0),
- t
- }
- ,
- e.IdentityToRef = function(t) {
- e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, t),
- t._updateIdentityStatus(!0)
- }
- ,
- e.Zero = function() {
- var t = e.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- return t._updateIdentityStatus(!1),
- t
- }
- ,
- e.RotationX = function(t) {
- var i = new e;
- return e.RotationXToRef(t, i),
- i
- }
- ,
- e.Invert = function(t) {
- var i = new e;
- return t.invertToRef(i),
- i
- }
- ,
- e.RotationXToRef = function(t, i) {
- var n = Math.sin(t)
- , r = Math.cos(t);
- e.FromValuesToRef(1, 0, 0, 0, 0, r, n, 0, 0, -n, r, 0, 0, 0, 0, 1, i),
- i._updateIdentityStatus(1 === r && 0 === n)
- }
- ,
- e.RotationY = function(t) {
- var i = new e;
- return e.RotationYToRef(t, i),
- i
- }
- ,
- e.RotationYToRef = function(t, i) {
- var n = Math.sin(t)
- , r = Math.cos(t);
- e.FromValuesToRef(r, 0, -n, 0, 0, 1, 0, 0, n, 0, r, 0, 0, 0, 0, 1, i),
- i._updateIdentityStatus(1 === r && 0 === n)
- }
- ,
- e.RotationZ = function(t) {
- var i = new e;
- return e.RotationZToRef(t, i),
- i
- }
- ,
- e.RotationZToRef = function(t, i) {
- var n = Math.sin(t)
- , r = Math.cos(t);
- e.FromValuesToRef(r, n, 0, 0, -n, r, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, i),
- i._updateIdentityStatus(1 === r && 0 === n)
- }
- ,
- e.RotationAxis = function(t, i) {
- var n = new e;
- return e.RotationAxisToRef(t, i, n),
- n
- }
- ,
- e.RotationAxisToRef = function(e, t, i) {
- var n = Math.sin(-t)
- , r = Math.cos(-t)
- , o = 1 - r;
- e.normalize();
- var a = i._m;
- a[0] = e._x * e._x * o + r,
- a[1] = e._x * e._y * o - e._z * n,
- a[2] = e._x * e._z * o + e._y * n,
- a[3] = 0,
- a[4] = e._y * e._x * o + e._z * n,
- a[5] = e._y * e._y * o + r,
- a[6] = e._y * e._z * o - e._x * n,
- a[7] = 0,
- a[8] = e._z * e._x * o - e._y * n,
- a[9] = e._z * e._y * o + e._x * n,
- a[10] = e._z * e._z * o + r,
- a[11] = 0,
- a[12] = 0,
- a[13] = 0,
- a[14] = 0,
- a[15] = 1,
- i.markAsUpdated()
- }
- ,
- e.RotationAlignToRef = function(e, t, i) {
- var n = x.Dot(t, e)
- , r = i._m;
- if (n < -1 + m)
- r[0] = -1,
- r[1] = 0,
- r[2] = 0,
- r[3] = 0,
- r[4] = 0,
- r[5] = -1,
- r[6] = 0,
- r[7] = 0,
- r[8] = 0,
- r[9] = 0,
- r[10] = 1,
- r[11] = 0;
- else {
- var o = x.Cross(t, e)
- , a = 1 / (1 + n);
- r[0] = o._x * o._x * a + n,
- r[1] = o._y * o._x * a - o._z,
- r[2] = o._z * o._x * a + o._y,
- r[3] = 0,
- r[4] = o._x * o._y * a + o._z,
- r[5] = o._y * o._y * a + n,
- r[6] = o._z * o._y * a - o._x,
- r[7] = 0,
- r[8] = o._x * o._z * a - o._y,
- r[9] = o._y * o._z * a + o._x,
- r[10] = o._z * o._z * a + n,
- r[11] = 0
- }
- r[12] = 0,
- r[13] = 0,
- r[14] = 0,
- r[15] = 1,
- i.markAsUpdated()
- }
- ,
- e.RotationYawPitchRoll = function(t, i, n) {
- var r = new e;
- return e.RotationYawPitchRollToRef(t, i, n, r),
- r
- }
- ,
- e.RotationYawPitchRollToRef = function(e, t, i, n) {
- C.RotationYawPitchRollToRef(e, t, i, M.Quaternion[0]),
- M.Quaternion[0].toRotationMatrix(n)
- }
- ,
- e.Scaling = function(t, i, n) {
- var r = new e;
- return e.ScalingToRef(t, i, n, r),
- r
- }
- ,
- e.ScalingToRef = function(t, i, n, r) {
- e.FromValuesToRef(t, 0, 0, 0, 0, i, 0, 0, 0, 0, n, 0, 0, 0, 0, 1, r),
- r._updateIdentityStatus(1 === t && 1 === i && 1 === n)
- }
- ,
- e.Translation = function(t, i, n) {
- var r = new e;
- return e.TranslationToRef(t, i, n, r),
- r
- }
- ,
- e.TranslationToRef = function(t, i, n, r) {
- e.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, i, n, 1, r),
- r._updateIdentityStatus(0 === t && 0 === i && 0 === n)
- }
- ,
- e.Lerp = function(t, i, n) {
- var r = new e;
- return e.LerpToRef(t, i, n, r),
- r
- }
- ,
- e.LerpToRef = function(e, t, i, n) {
- for (var r = n._m, o = e.m, a = t.m, s = 0; s < 16; s++)
- r[s] = o[s] * (1 - i) + a[s] * i;
- n.markAsUpdated()
- }
- ,
- e.DecomposeLerp = function(t, i, n) {
- var r = new e;
- return e.DecomposeLerpToRef(t, i, n, r),
- r
- }
- ,
- e.DecomposeLerpToRef = function(t, i, n, r) {
- var o = M.Vector3[0]
- , a = M.Quaternion[0]
- , s = M.Vector3[1];
- t.decompose(o, a, s);
- var l = M.Vector3[2]
- , c = M.Quaternion[1]
- , u = M.Vector3[3];
- i.decompose(l, c, u);
- var h = M.Vector3[4];
- x.LerpToRef(o, l, n, h);
- var d = M.Quaternion[2];
- C.SlerpToRef(a, c, n, d);
- var p = M.Vector3[5];
- x.LerpToRef(s, u, n, p),
- e.ComposeToRef(h, d, p, r)
- }
- ,
- e.LookAtLH = function(t, i, n) {
- var r = new e;
- return e.LookAtLHToRef(t, i, n, r),
- r
- }
- ,
- e.LookAtLHToRef = function(t, i, n, r) {
- var o = M.Vector3[0]
- , a = M.Vector3[1]
- , s = M.Vector3[2];
- i.subtractToRef(t, s),
- s.normalize(),
- x.CrossToRef(n, s, o);
- var l = o.lengthSquared();
- 0 === l ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
- x.CrossToRef(s, o, a),
- a.normalize();
- var c = -x.Dot(o, t)
- , u = -x.Dot(a, t)
- , h = -x.Dot(s, t);
- e.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, c, u, h, 1, r)
- }
- ,
- e.LookAtRH = function(t, i, n) {
- var r = new e;
- return e.LookAtRHToRef(t, i, n, r),
- r
- }
- ,
- e.LookAtRHToRef = function(t, i, n, r) {
- var o = M.Vector3[0]
- , a = M.Vector3[1]
- , s = M.Vector3[2];
- t.subtractToRef(i, s),
- s.normalize(),
- x.CrossToRef(n, s, o);
- var l = o.lengthSquared();
- 0 === l ? o.x = 1 : o.normalizeFromLength(Math.sqrt(l)),
- x.CrossToRef(s, o, a),
- a.normalize();
- var c = -x.Dot(o, t)
- , u = -x.Dot(a, t)
- , h = -x.Dot(s, t);
- e.FromValuesToRef(o._x, a._x, s._x, 0, o._y, a._y, s._y, 0, o._z, a._z, s._z, 0, c, u, h, 1, r)
- }
- ,
- e.LookDirectionLH = function(t, i) {
- var n = new e;
- return e.LookDirectionLHToRef(t, i, n),
- n
- }
- ,
- e.LookDirectionLHToRef = function(t, i, n) {
- var r = M.Vector3[0];
- r.copyFrom(t),
- r.scaleInPlace(-1);
- var o = M.Vector3[1];
- x.CrossToRef(i, r, o),
- e.FromValuesToRef(o._x, o._y, o._z, 0, i._x, i._y, i._z, 0, r._x, r._y, r._z, 0, 0, 0, 0, 1, n)
- }
- ,
- e.LookDirectionRH = function(t, i) {
- var n = new e;
- return e.LookDirectionRHToRef(t, i, n),
- n
- }
- ,
- e.LookDirectionRHToRef = function(t, i, n) {
- var r = M.Vector3[2];
- x.CrossToRef(i, t, r),
- e.FromValuesToRef(r._x, r._y, r._z, 0, i._x, i._y, i._z, 0, t._x, t._y, t._z, 0, 0, 0, 0, 1, n)
- }
- ,
- e.OrthoLH = function(t, i, n, r, o) {
- var a = new e;
- return e.OrthoLHToRef(t, i, n, r, a, o),
- a
- }
- ,
- e.OrthoLHToRef = function(t, i, n, r, o, a) {
- var s = 2 / t
- , l = 2 / i
- , c = 2 / (r - n)
- , u = -(r + n) / (r - n);
- e.FromValuesToRef(s, 0, 0, 0, 0, l, 0, 0, 0, 0, c, 0, 0, 0, u, 1, o),
- a && o.multiplyToRef(O, o),
- o._updateIdentityStatus(1 === s && 1 === l && 1 === c && 0 === u)
- }
- ,
- e.OrthoOffCenterLH = function(t, i, n, r, o, a, s) {
- var l = new e;
- return e.OrthoOffCenterLHToRef(t, i, n, r, o, a, l, s),
- l
- }
- ,
- e.OrthoOffCenterLHToRef = function(t, i, n, r, o, a, s, l) {
- var c = 2 / (i - t)
- , u = 2 / (r - n)
- , h = 2 / (a - o)
- , d = -(a + o) / (a - o)
- , p = (t + i) / (t - i)
- , f = (r + n) / (n - r);
- e.FromValuesToRef(c, 0, 0, 0, 0, u, 0, 0, 0, 0, h, 0, p, f, d, 1, s),
- l && s.multiplyToRef(O, s),
- s.markAsUpdated()
- }
- ,
- e.OrthoOffCenterRH = function(t, i, n, r, o, a, s) {
- var l = new e;
- return e.OrthoOffCenterRHToRef(t, i, n, r, o, a, l, s),
- l
- }
- ,
- e.OrthoOffCenterRHToRef = function(t, i, n, r, o, a, s, l) {
- e.OrthoOffCenterLHToRef(t, i, n, r, o, a, s, l),
- s._m[10] *= -1
- }
- ,
- e.PerspectiveLH = function(t, i, n, r, o, a) {
- void 0 === a && (a = 0);
- var s = new e
- , l = 2 * n / t
- , c = 2 * n / i
- , u = (r + n) / (r - n)
- , h = -2 * r * n / (r - n)
- , d = Math.tan(a);
- return e.FromValuesToRef(l, 0, 0, 0, 0, c, 0, d, 0, 0, u, 1, 0, 0, h, 0, s),
- o && s.multiplyToRef(O, s),
- s._updateIdentityStatus(!1),
- s
- }
- ,
- e.PerspectiveFovLH = function(t, i, n, r, o, a, s) {
- void 0 === a && (a = 0),
- void 0 === s && (s = !1);
- var l = new e;
- return e.PerspectiveFovLHToRef(t, i, n, r, l, !0, o, a, s),
- l
- }
- ,
- e.PerspectiveFovLHToRef = function(t, i, n, r, o, a, s, l, c) {
- void 0 === a && (a = !0),
- void 0 === l && (l = 0),
- void 0 === c && (c = !1);
- var u = n
- , h = r
- , d = 1 / Math.tan(.5 * t)
- , p = a ? d / i : d
- , f = a ? d : d * i
- , _ = c && 0 === u ? -1 : 0 !== h ? (h + u) / (h - u) : 1
- , m = c && 0 === u ? 2 * h : 0 !== h ? -2 * h * u / (h - u) : -2 * u
- , g = Math.tan(l);
- e.FromValuesToRef(p, 0, 0, 0, 0, f, 0, g, 0, 0, _, 1, 0, 0, m, 0, o),
- s && o.multiplyToRef(O, o),
- o._updateIdentityStatus(!1)
- }
- ,
- e.PerspectiveFovReverseLHToRef = function(t, i, n, r, o, a, s, l) {
- void 0 === a && (a = !0),
- void 0 === l && (l = 0);
- var c = 1 / Math.tan(.5 * t)
- , u = a ? c / i : c
- , h = a ? c : c * i
- , d = Math.tan(l);
- e.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -n, 1, 0, 0, 1, 0, o),
- s && o.multiplyToRef(O, o),
- o._updateIdentityStatus(!1)
- }
- ,
- e.PerspectiveFovRH = function(t, i, n, r, o, a, s) {
- void 0 === a && (a = 0),
- void 0 === s && (s = !1);
- var l = new e;
- return e.PerspectiveFovRHToRef(t, i, n, r, l, !0, o, a, s),
- l
- }
- ,
- e.PerspectiveFovRHToRef = function(t, i, n, r, o, a, s, l, c) {
- void 0 === a && (a = !0),
- void 0 === l && (l = 0),
- void 0 === c && (c = !1);
- var u = n
- , h = r
- , d = 1 / Math.tan(.5 * t)
- , p = a ? d / i : d
- , f = a ? d : d * i
- , _ = c && 0 === u ? 1 : 0 !== h ? -(h + u) / (h - u) : -1
- , m = c && 0 === u ? 2 * h : 0 !== h ? -2 * h * u / (h - u) : -2 * u
- , g = Math.tan(l);
- e.FromValuesToRef(p, 0, 0, 0, 0, f, 0, g, 0, 0, _, -1, 0, 0, m, 0, o),
- s && o.multiplyToRef(O, o),
- o._updateIdentityStatus(!1)
- }
- ,
- e.PerspectiveFovReverseRHToRef = function(t, i, n, r, o, a, s, l) {
- void 0 === a && (a = !0),
- void 0 === l && (l = 0);
- var c = 1 / Math.tan(.5 * t)
- , u = a ? c / i : c
- , h = a ? c : c * i
- , d = Math.tan(l);
- e.FromValuesToRef(u, 0, 0, 0, 0, h, 0, d, 0, 0, -n, -1, 0, 0, -1, 0, o),
- s && o.multiplyToRef(O, o),
- o._updateIdentityStatus(!1)
- }
- ,
- e.PerspectiveFovWebVRToRef = function(e, t, i, n, r, o, a) {
- void 0 === r && (r = !1),
- void 0 === a && (a = 0);
- var s = r ? -1 : 1
- , l = Math.tan(e.upDegrees * Math.PI / 180)
- , c = Math.tan(e.downDegrees * Math.PI / 180)
- , u = Math.tan(e.leftDegrees * Math.PI / 180)
- , h = Math.tan(e.rightDegrees * Math.PI / 180)
- , d = 2 / (u + h)
- , p = 2 / (l + c)
- , f = Math.tan(a)
- , _ = n._m;
- _[0] = d,
- _[1] = _[2] = _[3] = _[4] = 0,
- _[5] = p,
- _[6] = 0,
- _[7] = f,
- _[8] = (u - h) * d * .5,
- _[9] = -(l - c) * p * .5,
- _[10] = -i / (t - i),
- _[11] = 1 * s,
- _[12] = _[13] = _[15] = 0,
- _[14] = -2 * i * t / (i - t),
- o && n.multiplyToRef(O, n),
- n.markAsUpdated()
- }
- ,
- e.GetFinalMatrix = function(t, i, n, r, o, a) {
- var s = t.width
- , l = t.height
- , c = t.x
- , u = t.y
- , h = e.FromValues(s / 2, 0, 0, 0, 0, -l / 2, 0, 0, 0, 0, a - o, 0, c + s / 2, l / 2 + u, o, 1)
- , d = M.Matrix[0];
- return i.multiplyToRef(n, d),
- d.multiplyToRef(r, d),
- d.multiply(h)
- }
- ,
- e.GetAsMatrix2x2 = function(e) {
- var t = e.m
- , i = [t[0], t[1], t[4], t[5]];
- return T.MatrixUse64Bits ? i : new Float32Array(i)
- }
- ,
- e.GetAsMatrix3x3 = function(e) {
- var t = e.m
- , i = [t[0], t[1], t[2], t[4], t[5], t[6], t[8], t[9], t[10]];
- return T.MatrixUse64Bits ? i : new Float32Array(i)
- }
- ,
- e.Transpose = function(t) {
- var i = new e;
- return e.TransposeToRef(t, i),
- i
- }
- ,
- e.TransposeToRef = function(e, t) {
- var i = t._m
- , n = e.m;
- i[0] = n[0],
- i[1] = n[4],
- i[2] = n[8],
- i[3] = n[12],
- i[4] = n[1],
- i[5] = n[5],
- i[6] = n[9],
- i[7] = n[13],
- i[8] = n[2],
- i[9] = n[6],
- i[10] = n[10],
- i[11] = n[14],
- i[12] = n[3],
- i[13] = n[7],
- i[14] = n[11],
- i[15] = n[15],
- t.markAsUpdated(),
- t._updateIdentityStatus(e._isIdentity, e._isIdentityDirty)
- }
- ,
- e.Reflection = function(t) {
- var i = new e;
- return e.ReflectionToRef(t, i),
- i
- }
- ,
- e.ReflectionToRef = function(t, i) {
- t.normalize();
- var n = t.normal.x
- , r = t.normal.y
- , o = t.normal.z
- , a = -2 * n
- , s = -2 * r
- , l = -2 * o;
- e.FromValuesToRef(a * n + 1, s * n, l * n, 0, a * r, s * r + 1, l * r, 0, a * o, s * o, l * o + 1, 0, a * t.d, s * t.d, l * t.d, 1, i)
- }
- ,
- e.FromXYZAxesToRef = function(t, i, n, r) {
- e.FromValuesToRef(t._x, t._y, t._z, 0, i._x, i._y, i._z, 0, n._x, n._y, n._z, 0, 0, 0, 0, 1, r)
- }
- ,
- e.FromQuaternionToRef = function(e, t) {
- var i = e._x * e._x
- , n = e._y * e._y
- , r = e._z * e._z
- , o = e._x * e._y
- , a = e._z * e._w
- , s = e._z * e._x
- , l = e._y * e._w
- , c = e._y * e._z
- , u = e._x * e._w;
- t._m[0] = 1 - 2 * (n + r),
- t._m[1] = 2 * (o + a),
- t._m[2] = 2 * (s - l),
- t._m[3] = 0,
- t._m[4] = 2 * (o - a),
- t._m[5] = 1 - 2 * (r + i),
- t._m[6] = 2 * (c + u),
- t._m[7] = 0,
- t._m[8] = 2 * (s + l),
- t._m[9] = 2 * (c - u),
- t._m[10] = 1 - 2 * (n + i),
- t._m[11] = 0,
- t._m[12] = 0,
- t._m[13] = 0,
- t._m[14] = 0,
- t._m[15] = 1,
- t.markAsUpdated()
- }
- ,
- e._UpdateFlagSeed = 0,
- e._IdentityReadOnly = e.Identity(),
- e
- }()
- , M = function() {
- function e() {}
- return e.Vector3 = g.BuildTuple(11, x.Zero),
- e.Matrix = g.BuildTuple(2, P.Identity),
- e.Quaternion = g.BuildTuple(3, C.Zero),
- e
- }()
- , I = function() {
- function e() {}
- return e.Vector2 = g.BuildTuple(3, A.Zero),
- e.Vector3 = g.BuildTuple(13, x.Zero),
- e.Vector4 = g.BuildTuple(3, R.Zero),
- e.Quaternion = g.BuildTuple(2, C.Zero),
- e.Matrix = g.BuildTuple(8, P.Identity),
- e
- }();
- y("BABYLON.Vector2", A),
- y("BABYLON.Vector3", x),
- y("BABYLON.Vector4", R),
- y("BABYLON.Matrix", P);
- var O = P.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, 0, 0, 0, .5, 1)
- , D = function() {
- function e(e, t, i) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- this.r = e,
- this.g = t,
- this.b = i
- }
- return e.prototype.toString = function() {
- return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}"
- }
- ,
- e.prototype.getClassName = function() {
- return "Color3"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = 255 * this.r | 0;
- return 397 * (e = 397 * e ^ (255 * this.g | 0)) ^ (255 * this.b | 0)
- }
- ,
- e.prototype.toArray = function(e, t) {
- return void 0 === t && (t = 0),
- e[t] = this.r,
- e[t + 1] = this.g,
- e[t + 2] = this.b,
- this
- }
- ,
- e.prototype.fromArray = function(t, i) {
- return void 0 === i && (i = 0),
- e.FromArrayToRef(t, i, this),
- this
- }
- ,
- e.prototype.toColor4 = function(e) {
- return void 0 === e && (e = 1),
- new N(this.r,this.g,this.b,e)
- }
- ,
- e.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- e.prototype.toLuminance = function() {
- return .3 * this.r + .59 * this.g + .11 * this.b
- }
- ,
- e.prototype.multiply = function(t) {
- return new e(this.r * t.r,this.g * t.g,this.b * t.b)
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- return t.r = this.r * e.r,
- t.g = this.g * e.g,
- t.b = this.b * e.b,
- this
- }
- ,
- e.prototype.equals = function(e) {
- return e && this.r === e.r && this.g === e.g && this.b === e.b
- }
- ,
- e.prototype.equalsFloats = function(e, t, i) {
- return this.r === e && this.g === t && this.b === i
- }
- ,
- e.prototype.scale = function(t) {
- return new e(this.r * t,this.g * t,this.b * t)
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- return t.r = this.r * e,
- t.g = this.g * e,
- t.b = this.b * e,
- this
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- return t.r += this.r * e,
- t.g += this.g * e,
- t.b += this.b * e,
- this
- }
- ,
- e.prototype.clampToRef = function(e, t, i) {
- return void 0 === e && (e = 0),
- void 0 === t && (t = 1),
- i.r = d.Clamp(this.r, e, t),
- i.g = d.Clamp(this.g, e, t),
- i.b = d.Clamp(this.b, e, t),
- this
- }
- ,
- e.prototype.add = function(t) {
- return new e(this.r + t.r,this.g + t.g,this.b + t.b)
- }
- ,
- e.prototype.addToRef = function(e, t) {
- return t.r = this.r + e.r,
- t.g = this.g + e.g,
- t.b = this.b + e.b,
- this
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this.r - t.r,this.g - t.g,this.b - t.b)
- }
- ,
- e.prototype.subtractToRef = function(e, t) {
- return t.r = this.r - e.r,
- t.g = this.g - e.g,
- t.b = this.b - e.b,
- this
- }
- ,
- e.prototype.clone = function() {
- return new e(this.r,this.g,this.b)
- }
- ,
- e.prototype.copyFrom = function(e) {
- return this.r = e.r,
- this.g = e.g,
- this.b = e.b,
- this
- }
- ,
- e.prototype.copyFromFloats = function(e, t, i) {
- return this.r = e,
- this.g = t,
- this.b = i,
- this
- }
- ,
- e.prototype.set = function(e, t, i) {
- return this.copyFromFloats(e, t, i)
- }
- ,
- e.prototype.toHexString = function() {
- var e = Math.round(255 * this.r)
- , t = Math.round(255 * this.g)
- , i = Math.round(255 * this.b);
- return "#" + d.ToHex(e) + d.ToHex(t) + d.ToHex(i)
- }
- ,
- e.prototype.toLinearSpace = function() {
- var t = new e;
- return this.toLinearSpaceToRef(t),
- t
- }
- ,
- e.prototype.toHSV = function() {
- var t = new e;
- return this.toHSVToRef(t),
- t
- }
- ,
- e.prototype.toHSVToRef = function(e) {
- var t = this.r
- , i = this.g
- , n = this.b
- , r = Math.max(t, i, n)
- , o = Math.min(t, i, n)
- , a = 0
- , s = 0
- , l = r
- , c = r - o;
- 0 !== r && (s = c / r),
- r != o && (r == t ? (a = (i - n) / c,
- i < n && (a += 6)) : r == i ? a = (n - t) / c + 2 : r == n && (a = (t - i) / c + 4),
- a *= 60),
- e.r = a,
- e.g = s,
- e.b = l
- }
- ,
- e.prototype.toLinearSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, f),
- e.g = Math.pow(this.g, f),
- e.b = Math.pow(this.b, f),
- this
- }
- ,
- e.prototype.toGammaSpace = function() {
- var t = new e;
- return this.toGammaSpaceToRef(t),
- t
- }
- ,
- e.prototype.toGammaSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, p),
- e.g = Math.pow(this.g, p),
- e.b = Math.pow(this.b, p),
- this
- }
- ,
- e.HSVtoRGBToRef = function(e, t, i, n) {
- var r = i * t
- , o = e / 60
- , a = r * (1 - Math.abs(o % 2 - 1))
- , s = 0
- , l = 0
- , c = 0;
- o >= 0 && o <= 1 ? (s = r,
- l = a) : o >= 1 && o <= 2 ? (s = a,
- l = r) : o >= 2 && o <= 3 ? (l = r,
- c = a) : o >= 3 && o <= 4 ? (l = a,
- c = r) : o >= 4 && o <= 5 ? (s = a,
- c = r) : o >= 5 && o <= 6 && (s = r,
- c = a);
- var u = i - r;
- n.set(s + u, l + u, c + u)
- }
- ,
- e.FromHexString = function(t) {
- if ("#" !== t.substring(0, 1) || 7 !== t.length)
- return new e(0,0,0);
- var i = parseInt(t.substring(1, 3), 16)
- , n = parseInt(t.substring(3, 5), 16)
- , r = parseInt(t.substring(5, 7), 16);
- return e.FromInts(i, n, r)
- }
- ,
- e.FromArray = function(t, i) {
- return void 0 === i && (i = 0),
- new e(t[i],t[i + 1],t[i + 2])
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- void 0 === t && (t = 0),
- i.r = e[t],
- i.g = e[t + 1],
- i.b = e[t + 2]
- }
- ,
- e.FromInts = function(t, i, n) {
- return new e(t / 255,i / 255,n / 255)
- }
- ,
- e.Lerp = function(t, i, n) {
- var r = new e(0,0,0);
- return e.LerpToRef(t, i, n, r),
- r
- }
- ,
- e.LerpToRef = function(e, t, i, n) {
- n.r = e.r + (t.r - e.r) * i,
- n.g = e.g + (t.g - e.g) * i,
- n.b = e.b + (t.b - e.b) * i
- }
- ,
- e.Hermite = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a
- , l = 2 * s - 3 * a + 1
- , c = -2 * s + 3 * a
- , u = s - 2 * a + o
- , h = s - a;
- return new e(t.r * l + n.r * c + i.r * u + r.r * h,t.g * l + n.g * c + i.g * u + r.g * h,t.b * l + n.b * c + i.b * u + r.b * h)
- }
- ,
- e.Hermite1stDerivative = function(t, i, n, r, o) {
- var a = e.Black();
- return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
- a
- }
- ,
- e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
- var a = r * r;
- o.r = 6 * (a - r) * e.r + (3 * a - 4 * r + 1) * t.r + 6 * (-a + r) * i.r + (3 * a - 2 * r) * n.r,
- o.g = 6 * (a - r) * e.g + (3 * a - 4 * r + 1) * t.g + 6 * (-a + r) * i.g + (3 * a - 2 * r) * n.g,
- o.b = 6 * (a - r) * e.b + (3 * a - 4 * r + 1) * t.b + 6 * (-a + r) * i.b + (3 * a - 2 * r) * n.b
- }
- ,
- e.Red = function() {
- return new e(1,0,0)
- }
- ,
- e.Green = function() {
- return new e(0,1,0)
- }
- ,
- e.Blue = function() {
- return new e(0,0,1)
- }
- ,
- e.Black = function() {
- return new e(0,0,0)
- }
- ,
- Object.defineProperty(e, "BlackReadOnly", {
- get: function() {
- return e._BlackReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- e.White = function() {
- return new e(1,1,1)
- }
- ,
- e.Purple = function() {
- return new e(.5,0,.5)
- }
- ,
- e.Magenta = function() {
- return new e(1,0,1)
- }
- ,
- e.Yellow = function() {
- return new e(1,1,0)
- }
- ,
- e.Gray = function() {
- return new e(.5,.5,.5)
- }
- ,
- e.Teal = function() {
- return new e(0,1,1)
- }
- ,
- e.Random = function() {
- return new e(Math.random(),Math.random(),Math.random())
- }
- ,
- e._BlackReadOnly = e.Black(),
- e
- }()
- , N = function() {
- function e(e, t, i, n) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- void 0 === n && (n = 1),
- this.r = e,
- this.g = t,
- this.b = i,
- this.a = n
- }
- return e.prototype.addInPlace = function(e) {
- return this.r += e.r,
- this.g += e.g,
- this.b += e.b,
- this.a += e.a,
- this
- }
- ,
- e.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- e.prototype.toArray = function(e, t) {
- return void 0 === t && (t = 0),
- e[t] = this.r,
- e[t + 1] = this.g,
- e[t + 2] = this.b,
- e[t + 3] = this.a,
- this
- }
- ,
- e.prototype.fromArray = function(t, i) {
- return void 0 === i && (i = 0),
- e.FromArrayToRef(t, i, this),
- this
- }
- ,
- e.prototype.equals = function(e) {
- return e && this.r === e.r && this.g === e.g && this.b === e.b && this.a === e.a
- }
- ,
- e.prototype.add = function(t) {
- return new e(this.r + t.r,this.g + t.g,this.b + t.b,this.a + t.a)
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this.r - t.r,this.g - t.g,this.b - t.b,this.a - t.a)
- }
- ,
- e.prototype.subtractToRef = function(e, t) {
- return t.r = this.r - e.r,
- t.g = this.g - e.g,
- t.b = this.b - e.b,
- t.a = this.a - e.a,
- this
- }
- ,
- e.prototype.scale = function(t) {
- return new e(this.r * t,this.g * t,this.b * t,this.a * t)
- }
- ,
- e.prototype.scaleToRef = function(e, t) {
- return t.r = this.r * e,
- t.g = this.g * e,
- t.b = this.b * e,
- t.a = this.a * e,
- this
- }
- ,
- e.prototype.scaleAndAddToRef = function(e, t) {
- return t.r += this.r * e,
- t.g += this.g * e,
- t.b += this.b * e,
- t.a += this.a * e,
- this
- }
- ,
- e.prototype.clampToRef = function(e, t, i) {
- return void 0 === e && (e = 0),
- void 0 === t && (t = 1),
- i.r = d.Clamp(this.r, e, t),
- i.g = d.Clamp(this.g, e, t),
- i.b = d.Clamp(this.b, e, t),
- i.a = d.Clamp(this.a, e, t),
- this
- }
- ,
- e.prototype.multiply = function(t) {
- return new e(this.r * t.r,this.g * t.g,this.b * t.b,this.a * t.a)
- }
- ,
- e.prototype.multiplyToRef = function(e, t) {
- return t.r = this.r * e.r,
- t.g = this.g * e.g,
- t.b = this.b * e.b,
- t.a = this.a * e.a,
- t
- }
- ,
- e.prototype.toString = function() {
- return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}"
- }
- ,
- e.prototype.getClassName = function() {
- return "Color4"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = 255 * this.r | 0;
- return 397 * (e = 397 * (e = 397 * e ^ (255 * this.g | 0)) ^ (255 * this.b | 0)) ^ (255 * this.a | 0)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.r,this.g,this.b,this.a)
- }
- ,
- e.prototype.copyFrom = function(e) {
- return this.r = e.r,
- this.g = e.g,
- this.b = e.b,
- this.a = e.a,
- this
- }
- ,
- e.prototype.copyFromFloats = function(e, t, i, n) {
- return this.r = e,
- this.g = t,
- this.b = i,
- this.a = n,
- this
- }
- ,
- e.prototype.set = function(e, t, i, n) {
- return this.copyFromFloats(e, t, i, n)
- }
- ,
- e.prototype.toHexString = function(e) {
- void 0 === e && (e = !1);
- var t = Math.round(255 * this.r)
- , i = Math.round(255 * this.g)
- , n = Math.round(255 * this.b);
- if (e)
- return "#" + d.ToHex(t) + d.ToHex(i) + d.ToHex(n);
- var r = Math.round(255 * this.a);
- return "#" + d.ToHex(t) + d.ToHex(i) + d.ToHex(n) + d.ToHex(r)
- }
- ,
- e.prototype.toLinearSpace = function() {
- var t = new e;
- return this.toLinearSpaceToRef(t),
- t
- }
- ,
- e.prototype.toLinearSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, f),
- e.g = Math.pow(this.g, f),
- e.b = Math.pow(this.b, f),
- e.a = this.a,
- this
- }
- ,
- e.prototype.toGammaSpace = function() {
- var t = new e;
- return this.toGammaSpaceToRef(t),
- t
- }
- ,
- e.prototype.toGammaSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, p),
- e.g = Math.pow(this.g, p),
- e.b = Math.pow(this.b, p),
- e.a = this.a,
- this
- }
- ,
- e.FromHexString = function(t) {
- if ("#" !== t.substring(0, 1) || 9 !== t.length && 7 !== t.length)
- return new e(0,0,0,0);
- var i = parseInt(t.substring(1, 3), 16)
- , n = parseInt(t.substring(3, 5), 16)
- , r = parseInt(t.substring(5, 7), 16)
- , o = 9 === t.length ? parseInt(t.substring(7, 9), 16) : 255;
- return e.FromInts(i, n, r, o)
- }
- ,
- e.Lerp = function(t, i, n) {
- var r = new e(0,0,0,0);
- return e.LerpToRef(t, i, n, r),
- r
- }
- ,
- e.LerpToRef = function(e, t, i, n) {
- n.r = e.r + (t.r - e.r) * i,
- n.g = e.g + (t.g - e.g) * i,
- n.b = e.b + (t.b - e.b) * i,
- n.a = e.a + (t.a - e.a) * i
- }
- ,
- e.Hermite = function(t, i, n, r, o) {
- var a = o * o
- , s = o * a
- , l = 2 * s - 3 * a + 1
- , c = -2 * s + 3 * a
- , u = s - 2 * a + o
- , h = s - a;
- return new e(t.r * l + n.r * c + i.r * u + r.r * h,t.g * l + n.g * c + i.g * u + r.g * h,t.b * l + n.b * c + i.b * u + r.b * h,t.a * l + n.a * c + i.a * u + r.a * h)
- }
- ,
- e.Hermite1stDerivative = function(t, i, n, r, o) {
- var a = new e;
- return this.Hermite1stDerivativeToRef(t, i, n, r, o, a),
- a
- }
- ,
- e.Hermite1stDerivativeToRef = function(e, t, i, n, r, o) {
- var a = r * r;
- o.r = 6 * (a - r) * e.r + (3 * a - 4 * r + 1) * t.r + 6 * (-a + r) * i.r + (3 * a - 2 * r) * n.r,
- o.g = 6 * (a - r) * e.g + (3 * a - 4 * r + 1) * t.g + 6 * (-a + r) * i.g + (3 * a - 2 * r) * n.g,
- o.b = 6 * (a - r) * e.b + (3 * a - 4 * r + 1) * t.b + 6 * (-a + r) * i.b + (3 * a - 2 * r) * n.b,
- o.a = 6 * (a - r) * e.a + (3 * a - 4 * r + 1) * t.a + 6 * (-a + r) * i.a + (3 * a - 2 * r) * n.a
- }
- ,
- e.FromColor3 = function(t, i) {
- return void 0 === i && (i = 1),
- new e(t.r,t.g,t.b,i)
- }
- ,
- e.FromArray = function(t, i) {
- return void 0 === i && (i = 0),
- new e(t[i],t[i + 1],t[i + 2],t[i + 3])
- }
- ,
- e.FromArrayToRef = function(e, t, i) {
- void 0 === t && (t = 0),
- i.r = e[t],
- i.g = e[t + 1],
- i.b = e[t + 2],
- i.a = e[t + 3]
- }
- ,
- e.FromInts = function(t, i, n, r) {
- return new e(t / 255,i / 255,n / 255,r / 255)
- }
- ,
- e.CheckColors4 = function(e, t) {
- if (e.length === 3 * t) {
- for (var i = [], n = 0; n < e.length; n += 3) {
- var r = n / 3 * 4;
- i[r] = e[n],
- i[r + 1] = e[n + 1],
- i[r + 2] = e[n + 2],
- i[r + 3] = 1
- }
- return i
- }
- return e
- }
- ,
- e
- }()
- , L = function() {
- function e() {}
- return e.Color3 = g.BuildArray(3, D.Black),
- e.Color4 = g.BuildArray(3, (function() {
- return new N(0,0,0,0)
- }
- )),
- e
- }();
- y("BABYLON.Color3", D),
- y("BABYLON.Color4", N);
- var F = function() {
- function e(e, t) {
- this.triggerOptions = e,
- this.onBeforeExecuteObservable = new h,
- e.parameter ? (this.trigger = e.trigger,
- this._triggerParameter = e.parameter) : e.trigger ? this.trigger = e.trigger : this.trigger = e,
- this._nextActiveAction = this,
- this._condition = t
- }
- return e.prototype._prepare = function() {}
- ,
- e.prototype.getTriggerParameter = function() {
- return this._triggerParameter
- }
- ,
- e.prototype.setTriggerParameter = function(e) {
- this._triggerParameter = e
- }
- ,
- e.prototype._evaluateConditionForCurrentFrame = function() {
- var e = this._condition;
- if (!e)
- return !0;
- var t = this._actionManager.getScene().getRenderId();
- return e._evaluationId !== t && (e._evaluationId = t,
- e._currentResult = e.isValid()),
- e._currentResult
- }
- ,
- e.prototype._executeCurrent = function(e) {
- this._evaluateConditionForCurrentFrame() && (this.onBeforeExecuteObservable.notifyObservers(this),
- this._nextActiveAction.execute(e),
- this.skipToNextActiveAction())
- }
- ,
- e.prototype.execute = function(e) {}
- ,
- e.prototype.skipToNextActiveAction = function() {
- this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager),
- this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this
- }
- ,
- e.prototype.then = function(e) {
- return this._child = e,
- e._actionManager = this._actionManager,
- e._prepare(),
- e
- }
- ,
- e.prototype._getProperty = function(e) {
- return this._actionManager._getProperty(e)
- }
- ,
- e.prototype._getEffectiveTarget = function(e, t) {
- return this._actionManager._getEffectiveTarget(e, t)
- }
- ,
- e.prototype.serialize = function(e) {}
- ,
- e.prototype._serialize = function(e, t) {
- var i = {
- type: 1,
- children: [],
- name: e.name,
- properties: e.properties || []
- };
- if (this._child && this._child.serialize(i),
- this._condition) {
- var n = this._condition.serialize();
- return n.children.push(i),
- t && t.children.push(n),
- n
- }
- return t && t.children.push(i),
- i
- }
- ,
- e._SerializeValueAsString = function(e) {
- return "number" == typeof e ? e.toString() : "boolean" == typeof e ? e ? "true" : "false" : e instanceof A ? e.x + ", " + e.y : e instanceof x ? e.x + ", " + e.y + ", " + e.z : e instanceof D ? e.r + ", " + e.g + ", " + e.b : e instanceof N ? e.r + ", " + e.g + ", " + e.b + ", " + e.a : e
- }
- ,
- e._GetTargetProperty = function(e) {
- return {
- name: "target",
- targetType: e._isMesh ? "MeshProperties" : e._isLight ? "LightProperties" : e._isCamera ? "CameraProperties" : "SceneProperties",
- value: e._isScene ? "Scene" : e.name
- }
- }
- ,
- e
- }();
- y("BABYLON.Action", F);
- var w = function() {
- function e(e, t, i, n, r, o) {
- this.source = e,
- this.pointerX = t,
- this.pointerY = i,
- this.meshUnderPointer = n,
- this.sourceEvent = r,
- this.additionalData = o
- }
- return e.CreateNew = function(t, i, n) {
- var r = t.getScene();
- return new e(t,r.pointerX,r.pointerY,r.meshUnderPointer || t,i,n)
- }
- ,
- e.CreateNewFromSprite = function(t, i, n, r) {
- return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,n,r)
- }
- ,
- e.CreateNewFromScene = function(t, i) {
- return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)
- }
- ,
- e.CreateNewFromPrimitive = function(t, i, n, r) {
- return new e(t,i.x,i.y,null,n,r)
- }
- ,
- e
- }()
- , B = function(e, t) {
- return B = Object.setPrototypeOf || {
- __proto__: []
- }instanceof Array && function(e, t) {
- e.__proto__ = t
- }
- || function(e, t) {
- for (var i in t)
- Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i])
- }
- ,
- B(e, t)
- };
- function U(e, t) {
- if ("function" != typeof t && null !== t)
- throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
- function i() {
- this.constructor = e
- }
- B(e, t),
- e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype,
- new i)
- }
- var V = function() {
- return V = Object.assign || function(e) {
- for (var t, i = 1, n = arguments.length; i < n; i++)
- for (var r in t = arguments[i])
- Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
- return e
- }
- ,
- V.apply(this, arguments)
- };
- function k(e, t, i, n) {
- var r, o = arguments.length, a = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, i) : n;
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate)
- a = Reflect.decorate(e, t, i, n);
- else
- for (var s = e.length - 1; s >= 0; s--)
- (r = e[s]) && (a = (o < 3 ? r(a) : o > 3 ? r(t, i, a) : r(t, i)) || a);
- return o > 3 && a && Object.defineProperty(t, i, a),
- a
- }
- function G(e, t, i, n) {
- return new (i || (i = Promise))((function(r, o) {
- function a(e) {
- try {
- l(n.next(e))
- } catch (e) {
- o(e)
- }
- }
- function s(e) {
- try {
- l(n.throw(e))
- } catch (e) {
- o(e)
- }
- }
- function l(e) {
- var t;
- e.done ? r(e.value) : (t = e.value,
- t instanceof i ? t : new i((function(e) {
- e(t)
- }
- ))).then(a, s)
- }
- l((n = n.apply(e, t || [])).next())
- }
- ))
- }
- function z(e, t) {
- var i, n, r, o, a = {
- label: 0,
- sent: function() {
- if (1 & r[0])
- throw r[1];
- return r[1]
- },
- trys: [],
- ops: []
- };
- return o = {
- next: s(0),
- throw: s(1),
- return: s(2)
- },
- "function" == typeof Symbol && (o[Symbol.iterator] = function() {
- return this
- }
- ),
- o;
- function s(o) {
- return function(s) {
- return function(o) {
- if (i)
- throw new TypeError("Generator is already executing.");
- for (; a; )
- try {
- if (i = 1,
- n && (r = 2 & o[0] ? n.return : o[0] ? n.throw || ((r = n.return) && r.call(n),
- 0) : n.next) && !(r = r.call(n, o[1])).done)
- return r;
- switch (n = 0,
- r && (o = [2 & o[0], r.value]),
- o[0]) {
- case 0:
- case 1:
- r = o;
- break;
- case 4:
- return a.label++,
- {
- value: o[1],
- done: !1
- };
- case 5:
- a.label++,
- n = o[1],
- o = [0];
- continue;
- case 7:
- o = a.ops.pop(),
- a.trys.pop();
- continue;
- default:
- if (!((r = (r = a.trys).length > 0 && r[r.length - 1]) || 6 !== o[0] && 2 !== o[0])) {
- a = 0;
- continue
- }
- if (3 === o[0] && (!r || o[1] > r[0] && o[1] < r[3])) {
- a.label = o[1];
- break
- }
- if (6 === o[0] && a.label < r[1]) {
- a.label = r[1],
- r = o;
- break
- }
- if (r && a.label < r[2]) {
- a.label = r[2],
- a.ops.push(o);
- break
- }
- r[2] && a.ops.pop(),
- a.trys.pop();
- continue
- }
- o = t.call(e, a)
- } catch (e) {
- o = [6, e],
- n = 0
- } finally {
- i = r = 0
- }
- if (5 & o[0])
- throw o[1];
- return {
- value: o[0] ? o[1] : void 0,
- done: !0
- }
- }([o, s])
- }
- }
- }
- function W(e, t, i) {
- if (i || 2 === arguments.length)
- for (var n, r = 0, o = t.length; r < o; r++)
- !n && r in t || (n || (n = Array.prototype.slice.call(t, 0, r)),
- n[r] = t[r]);
- return e.concat(n || Array.prototype.slice.call(t))
- }
- Object.create,
- Object.create;
- var H = function() {
- function e(e) {
- this._actionManager = e
- }
- return e.prototype.isValid = function() {
- return !0
- }
- ,
- e.prototype._getProperty = function(e) {
- return this._actionManager._getProperty(e)
- }
- ,
- e.prototype._getEffectiveTarget = function(e, t) {
- return this._actionManager._getEffectiveTarget(e, t)
- }
- ,
- e.prototype.serialize = function() {}
- ,
- e.prototype._serialize = function(e) {
- return {
- type: 2,
- children: [],
- name: e.name,
- properties: e.properties
- }
- }
- ,
- e
- }()
- , X = function(e) {
- function t(i, n, r, o, a) {
- void 0 === a && (a = t.IsEqual);
- var s = e.call(this, i) || this;
- return s.propertyPath = r,
- s.value = o,
- s.operator = a,
- s._target = n,
- s._effectiveTarget = s._getEffectiveTarget(n, s.propertyPath),
- s._property = s._getProperty(s.propertyPath),
- s
- }
- return U(t, e),
- Object.defineProperty(t, "IsEqual", {
- get: function() {
- return t._IsEqual
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "IsDifferent", {
- get: function() {
- return t._IsDifferent
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "IsGreater", {
- get: function() {
- return t._IsGreater
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "IsLesser", {
- get: function() {
- return t._IsLesser
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.isValid = function() {
- switch (this.operator) {
- case t.IsGreater:
- return this._effectiveTarget[this._property] > this.value;
- case t.IsLesser:
- return this._effectiveTarget[this._property] < this.value;
- case t.IsEqual:
- case t.IsDifferent:
- var e;
- return e = this.value.equals ? this.value.equals(this._effectiveTarget[this._property]) : this.value === this._effectiveTarget[this._property],
- this.operator === t.IsEqual ? e : !e
- }
- return !1
- }
- ,
- t.prototype.serialize = function() {
- return this._serialize({
- name: "ValueCondition",
- properties: [F._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: F._SerializeValueAsString(this.value)
- }, {
- name: "operator",
- value: t.GetOperatorName(this.operator)
- }]
- })
- }
- ,
- t.GetOperatorName = function(e) {
- switch (e) {
- case t._IsEqual:
- return "IsEqual";
- case t._IsDifferent:
- return "IsDifferent";
- case t._IsGreater:
- return "IsGreater";
- case t._IsLesser:
- return "IsLesser";
- default:
- return ""
- }
- }
- ,
- t._IsEqual = 0,
- t._IsDifferent = 1,
- t._IsGreater = 2,
- t._IsLesser = 3,
- t
- }(H)
- , j = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.predicate = i,
- n
- }
- return U(t, e),
- t.prototype.isValid = function() {
- return this.predicate()
- }
- ,
- t
- }(H)
- , Y = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t) || this;
- return r.value = n,
- r._target = i,
- r
- }
- return U(t, e),
- t.prototype.isValid = function() {
- return this._target.state === this.value
- }
- ,
- t.prototype.serialize = function() {
- return this._serialize({
- name: "StateCondition",
- properties: [F._GetTargetProperty(this._target), {
- name: "value",
- value: this.value
- }]
- })
- }
- ,
- t
- }(H);
- y("BABYLON.ValueCondition", X),
- y("BABYLON.PredicateCondition", j),
- y("BABYLON.StateCondition", Y);
- var K = function() {
- function e() {}
- return e._CheckLimit = function(t, i) {
- var n = e._LogLimitOutputs[t];
- return n ? n.current++ : (n = {
- limit: i,
- current: 1
- },
- e._LogLimitOutputs[t] = n),
- n.current <= n.limit
- }
- ,
- e._GenerateLimitMessage = function(t, i) {
- var n = e._LogLimitOutputs[t];
- if (n && e.MessageLimitReached && n.current === n.limit)
- switch (i) {
- case 0:
- e.Log(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "log"));
- break;
- case 1:
- e.Warn(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "warning"));
- break;
- case 2:
- e.Error(e.MessageLimitReached.replace(/%LIMIT%/g, "" + n.limit).replace(/%TYPE%/g, "error"))
- }
- }
- ,
- e._AddLogEntry = function(t) {
- e._LogCache = t + e._LogCache,
- e.OnNewCacheEntry && e.OnNewCacheEntry(t)
- }
- ,
- e._FormatMessage = function(e) {
- var t = function(e) {
- return e < 10 ? "0" + e : "" + e
- }
- , i = new Date;
- return "[" + t(i.getHours()) + ":" + t(i.getMinutes()) + ":" + t(i.getSeconds()) + "]: " + e
- }
- ,
- e._LogDisabled = function(e, t) {}
- ,
- e._LogEnabled = function(t, i) {
- if (void 0 === i || e._CheckLimit(t, i)) {
- var n = e._FormatMessage(t);
- console.log("BJS - " + n);
- var r = "<div style='color:white'>" + n + "</div><br>";
- e._AddLogEntry(r),
- e._GenerateLimitMessage(t, 0)
- }
- }
- ,
- e._WarnDisabled = function(e, t) {}
- ,
- e._WarnEnabled = function(t, i) {
- if (void 0 === i || e._CheckLimit(t, i)) {
- var n = e._FormatMessage(t);
- console.warn("BJS - " + n);
- var r = "<div style='color:orange'>" + t + "</div><br>";
- e._AddLogEntry(r),
- e._GenerateLimitMessage(t, 1)
- }
- }
- ,
- e._ErrorDisabled = function(e, t) {}
- ,
- e._ErrorEnabled = function(t, i) {
- if (void 0 === i || e._CheckLimit(t, i)) {
- var n = e._FormatMessage(t);
- e.errorsCount++,
- console.error("BJS - " + n);
- var r = "<div style='color:red'>" + n + "</div><br>";
- e._AddLogEntry(r),
- e._GenerateLimitMessage(t, 2)
- }
- }
- ,
- Object.defineProperty(e, "LogCache", {
- get: function() {
- return e._LogCache
- },
- enumerable: !1,
- configurable: !0
- }),
- e.ClearLogCache = function() {
- e._LogCache = "",
- e._LogLimitOutputs = {},
- e.errorsCount = 0
- }
- ,
- Object.defineProperty(e, "LogLevels", {
- set: function(t) {
- (t & e.MessageLogLevel) === e.MessageLogLevel ? e.Log = e._LogEnabled : e.Log = e._LogDisabled,
- (t & e.WarningLogLevel) === e.WarningLogLevel ? e.Warn = e._WarnEnabled : e.Warn = e._WarnDisabled,
- (t & e.ErrorLogLevel) === e.ErrorLogLevel ? e.Error = e._ErrorEnabled : e.Error = e._ErrorDisabled
- },
- enumerable: !1,
- configurable: !0
- }),
- e.NoneLogLevel = 0,
- e.MessageLogLevel = 1,
- e.WarningLogLevel = 2,
- e.ErrorLogLevel = 4,
- e.AllLogLevel = 7,
- e.MessageLimitReached = "Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",
- e._LogCache = "",
- e._LogLimitOutputs = {},
- e.errorsCount = 0,
- e.Log = e._LogEnabled,
- e.Warn = e._WarnEnabled,
- e.Error = e._ErrorEnabled,
- e
- }()
- , Q = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, r) || this;
- return o.propertyPath = n,
- o._target = o._effectiveTarget = i,
- o
- }
- return U(t, e),
- t.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath)
- }
- ,
- t.prototype.execute = function() {
- this._effectiveTarget[this._property] = !this._effectiveTarget[this._property]
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "SwitchBooleanAction",
- properties: [F._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }]
- }, t)
- }
- ,
- t
- }(F)
- , q = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, r) || this;
- return o.value = n,
- o._target = i,
- o
- }
- return U(t, e),
- t.prototype.execute = function() {
- this._target.state = this.value
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "SetStateAction",
- properties: [F._GetTargetProperty(this._target), {
- name: "value",
- value: this.value
- }]
- }, t)
- }
- ,
- t
- }(F)
- , Z = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, o) || this;
- return a.propertyPath = n,
- a.value = r,
- a._target = a._effectiveTarget = i,
- a
- }
- return U(t, e),
- t.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath)
- }
- ,
- t.prototype.execute = function() {
- this._effectiveTarget[this._property] = this.value,
- this._target.markAsDirty && this._target.markAsDirty(this._property)
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "SetValueAction",
- properties: [F._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: F._SerializeValueAsString(this.value)
- }]
- }, t)
- }
- ,
- t
- }(F)
- , J = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, o) || this;
- return a.propertyPath = n,
- a.value = r,
- a._target = a._effectiveTarget = i,
- a
- }
- return U(t, e),
- t.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath),
- "number" != typeof this._effectiveTarget[this._property] && K.Warn("Warning: IncrementValueAction can only be used with number values")
- }
- ,
- t.prototype.execute = function() {
- this._effectiveTarget[this._property] += this.value,
- this._target.markAsDirty && this._target.markAsDirty(this._property)
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "IncrementValueAction",
- properties: [F._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: F._SerializeValueAsString(this.value)
- }]
- }, t)
- }
- ,
- t
- }(F)
- , $ = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, a) || this;
- return s.from = n,
- s.to = r,
- s.loop = o,
- s._target = i,
- s
- }
- return U(t, e),
- t.prototype._prepare = function() {}
- ,
- t.prototype.execute = function() {
- this._actionManager.getScene().beginAnimation(this._target, this.from, this.to, this.loop)
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "PlayAnimationAction",
- properties: [F._GetTargetProperty(this._target), {
- name: "from",
- value: String(this.from)
- }, {
- name: "to",
- value: String(this.to)
- }, {
- name: "loop",
- value: F._SerializeValueAsString(this.loop) || !1
- }]
- }, t)
- }
- ,
- t
- }(F)
- , ee = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r._target = i,
- r
- }
- return U(t, e),
- t.prototype._prepare = function() {}
- ,
- t.prototype.execute = function() {
- this._actionManager.getScene().stopAnimation(this._target)
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "StopAnimationAction",
- properties: [F._GetTargetProperty(this._target)]
- }, t)
- }
- ,
- t
- }(F)
- , te = function(e) {
- function t(t, i) {
- return void 0 === t && (t = a.ACTION_NothingTrigger),
- e.call(this, t, i) || this
- }
- return U(t, e),
- t.prototype.execute = function() {}
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "DoNothingAction",
- properties: []
- }, t)
- }
- ,
- t
- }(F)
- , ie = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = !0);
- var o = e.call(this, t, n) || this;
- return o.children = i,
- o.enableChildrenConditions = r,
- o
- }
- return U(t, e),
- t.prototype._prepare = function() {
- for (var e = 0; e < this.children.length; e++)
- this.children[e]._actionManager = this._actionManager,
- this.children[e]._prepare()
- }
- ,
- t.prototype.execute = function(e) {
- for (var t = 0, i = this.children; t < i.length; t++) {
- var n = i[t];
- this.enableChildrenConditions && !n._evaluateConditionForCurrentFrame() || n.execute(e)
- }
- }
- ,
- t.prototype.serialize = function(t) {
- for (var i = e.prototype._serialize.call(this, {
- name: "CombineAction",
- properties: [],
- combine: []
- }, t), n = 0; n < this.children.length; n++)
- i.combine.push(this.children[n].serialize(null));
- return i
- }
- ,
- t
- }(F)
- , ne = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r.func = i,
- r
- }
- return U(t, e),
- t.prototype.execute = function(e) {
- this.func(e)
- }
- ,
- t
- }(F)
- , re = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, r) || this;
- return o._target = i,
- o._parent = n,
- o
- }
- return U(t, e),
- t.prototype._prepare = function() {}
- ,
- t.prototype.execute = function() {
- if (this._target.parent !== this._parent) {
- var e = this._parent.getWorldMatrix().clone();
- e.invert(),
- this._target.position = x.TransformCoordinates(this._target.position, e),
- this._target.parent = this._parent
- }
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "SetParentAction",
- properties: [F._GetTargetProperty(this._target), F._GetTargetProperty(this._parent)]
- }, t)
- }
- ,
- t
- }(F);
- y("BABYLON.SetParentAction", re),
- y("BABYLON.ExecuteCodeAction", ne),
- y("BABYLON.DoNothingAction", te),
- y("BABYLON.StopAnimationAction", ee),
- y("BABYLON.PlayAnimationAction", $),
- y("BABYLON.IncrementValueAction", J),
- y("BABYLON.SetValueAction", Z),
- y("BABYLON.SetStateAction", q),
- y("BABYLON.SetParentAction", re);
- var oe = function(e, t) {
- return -1 !== e.indexOf(t, e.length - t.length)
- }
- , ae = function(e, t) {
- return !!e && 0 === e.indexOf(t)
- }
- , se = function(e) {
- if ("undefined" != typeof TextDecoder)
- return (new TextDecoder).decode(e);
- for (var t = "", i = 0; i < e.byteLength; i++)
- t += String.fromCharCode(e[i]);
- return t
- }
- , le = function(e) {
- for (var t, i, n, r, o, a, s, l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", c = "", u = 0, h = ArrayBuffer.isView(e) ? new Uint8Array(e.buffer,e.byteOffset,e.byteLength) : new Uint8Array(e); u < h.length; )
- r = (t = h[u++]) >> 2,
- o = (3 & t) << 4 | (i = u < h.length ? h[u++] : Number.NaN) >> 4,
- a = (15 & i) << 2 | (n = u < h.length ? h[u++] : Number.NaN) >> 6,
- s = 63 & n,
- isNaN(i) ? a = s = 64 : isNaN(n) && (s = 64),
- c += l.charAt(r) + l.charAt(o) + l.charAt(a) + l.charAt(s);
- return c
- }
- , ce = function(e) {
- return atob(e)
- }
- , ue = function(e) {
- for (var t = ce(e), i = t.length, n = new Uint8Array(new ArrayBuffer(i)), r = 0; r < i; r++)
- n[r] = t.charCodeAt(r);
- return n.buffer
- }
- , he = function(e, t) {
- for (var i = String(e); i.length < t; )
- i = "0" + i;
- return i
- }
- , de = {
- EndsWith: oe,
- StartsWith: ae,
- Decode: se,
- EncodeArrayBufferToBase64: le,
- DecodeBase64ToString: ce,
- DecodeBase64ToBinary: ue,
- PadNumber: he
- }
- , pe = function(e, t) {
- return e ? e.getClassName && "Mesh" === e.getClassName() ? null : e.getClassName && "SubMesh" === e.getClassName() ? e.clone(t) : e.clone ? e.clone() : null : null
- }
- , fe = function() {
- function e() {}
- return e.DeepCopy = function(e, t, i, n) {
- for (var r = function(e) {
- var t = [];
- do {
- Object.getOwnPropertyNames(e).forEach((function(e) {
- -1 === t.indexOf(e) && t.push(e)
- }
- ))
- } while (e = Object.getPrototypeOf(e));
- return t
- }(e), o = 0, a = r; o < a.length; o++) {
- var s = a[o];
- if (("_" !== s[0] || n && -1 !== n.indexOf(s)) && !(oe(s, "Observable") || i && -1 !== i.indexOf(s))) {
- var l = e[s]
- , c = typeof l;
- if ("function" !== c)
- try {
- if ("object" === c)
- if (l instanceof Array) {
- if (t[s] = [],
- l.length > 0)
- if ("object" == typeof l[0])
- for (var u = 0; u < l.length; u++) {
- var h = pe(l[u], t);
- -1 === t[s].indexOf(h) && t[s].push(h)
- }
- else
- t[s] = l.slice(0)
- } else
- t[s] = pe(l, t);
- else
- t[s] = l
- } catch (e) {
- K.Warn(e.message)
- }
- }
- }
- }
- ,
- e
- }()
- , _e = function(e) {
- function t(t) {
- var i = e.call(this) || this;
- return (t = t || E.LastCreatedScene) ? (i._scene = t,
- t.actionManagers.push(i),
- i) : i
- }
- return U(t, e),
- t.prototype.dispose = function() {
- for (var e = this._scene.actionManagers.indexOf(this), i = 0; i < this.actions.length; i++) {
- var n = this.actions[i];
- t.Triggers[n.trigger]--,
- 0 === t.Triggers[n.trigger] && delete t.Triggers[n.trigger]
- }
- e > -1 && this._scene.actionManagers.splice(e, 1)
- }
- ,
- t.prototype.getScene = function() {
- return this._scene
- }
- ,
- t.prototype.hasSpecificTriggers = function(e) {
- for (var t = 0; t < this.actions.length; t++) {
- var i = this.actions[t];
- if (e.indexOf(i.trigger) > -1)
- return !0
- }
- return !1
- }
- ,
- t.prototype.hasSpecificTriggers2 = function(e, t) {
- for (var i = 0; i < this.actions.length; i++) {
- var n = this.actions[i];
- if (e == n.trigger || t == n.trigger)
- return !0
- }
- return !1
- }
- ,
- t.prototype.hasSpecificTrigger = function(e, t) {
- for (var i = 0; i < this.actions.length; i++) {
- var n = this.actions[i];
- if (n.trigger === e) {
- if (!t)
- return !0;
- if (t(n.getTriggerParameter()))
- return !0
- }
- }
- return !1
- }
- ,
- Object.defineProperty(t.prototype, "hasPointerTriggers", {
- get: function() {
- for (var e = 0; e < this.actions.length; e++) {
- var i = this.actions[e];
- if (i.trigger >= t.OnPickTrigger && i.trigger <= t.OnPointerOutTrigger)
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasPickTriggers", {
- get: function() {
- for (var e = 0; e < this.actions.length; e++) {
- var i = this.actions[e];
- if (i.trigger >= t.OnPickTrigger && i.trigger <= t.OnPickUpTrigger)
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.registerAction = function(e) {
- return e.trigger === t.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (K.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),
- null) : (this.actions.push(e),
- t.Triggers[e.trigger] ? t.Triggers[e.trigger]++ : t.Triggers[e.trigger] = 1,
- e._actionManager = this,
- e._prepare(),
- e)
- }
- ,
- t.prototype.unregisterAction = function(e) {
- var i = this.actions.indexOf(e);
- return -1 !== i && (this.actions.splice(i, 1),
- t.Triggers[e.trigger] -= 1,
- 0 === t.Triggers[e.trigger] && delete t.Triggers[e.trigger],
- e._actionManager = null,
- !0)
- }
- ,
- t.prototype.processTrigger = function(e, i) {
- for (var n = 0; n < this.actions.length; n++) {
- var r = this.actions[n];
- if (r.trigger === e) {
- if (i && (e === t.OnKeyUpTrigger || e === t.OnKeyDownTrigger)) {
- var o = r.getTriggerParameter();
- if (o && o !== i.sourceEvent.keyCode) {
- if (!o.toLowerCase)
- continue;
- var a = o.toLowerCase();
- if (a !== i.sourceEvent.key) {
- var s = i.sourceEvent.charCode ? i.sourceEvent.charCode : i.sourceEvent.keyCode;
- if (String.fromCharCode(s).toLowerCase() !== a)
- continue
- }
- }
- }
- r._executeCurrent(i)
- }
- }
- }
- ,
- t.prototype._getEffectiveTarget = function(e, t) {
- for (var i = t.split("."), n = 0; n < i.length - 1; n++)
- e = e[i[n]];
- return e
- }
- ,
- t.prototype._getProperty = function(e) {
- var t = e.split(".");
- return t[t.length - 1]
- }
- ,
- t.prototype.serialize = function(e) {
- for (var i = {
- children: new Array,
- name: e,
- type: 3,
- properties: new Array
- }, n = 0; n < this.actions.length; n++) {
- var r = {
- type: 0,
- children: new Array,
- name: t.GetTriggerName(this.actions[n].trigger),
- properties: new Array
- }
- , o = this.actions[n].triggerOptions;
- if (o && "number" != typeof o)
- if (o.parameter instanceof Node)
- r.properties.push(F._GetTargetProperty(o.parameter));
- else {
- var a = {};
- fe.DeepCopy(o.parameter, a, ["mesh"]),
- o.parameter && o.parameter.mesh && (a._meshId = o.parameter.mesh.id),
- r.properties.push({
- name: "parameter",
- targetType: null,
- value: a
- })
- }
- this.actions[n].serialize(r),
- i.children.push(r)
- }
- return i
- }
- ,
- t.Parse = function(e, i, n) {
- var r = new t(n);
- null === i ? n.actionManager = r : i.actionManager = r;
- for (var o = function(e, t, i, n) {
- if (null === n) {
- var r = parseFloat(t);
- return "true" === t || "false" === t ? "true" === t : isNaN(r) ? t : r
- }
- for (var o = n.split("."), a = t.split(","), s = 0; s < o.length; s++)
- i = i[o[s]];
- if ("boolean" == typeof i)
- return "true" === a[0];
- if ("string" == typeof i)
- return a[0];
- var l = new Array;
- for (s = 0; s < a.length; s++)
- l.push(parseFloat(a[s]));
- return i instanceof x ? x.FromArray(l) : i instanceof R ? R.FromArray(l) : i instanceof D ? D.FromArray(l) : i instanceof N ? N.FromArray(l) : parseFloat(a[0])
- }, a = function(e, i, s, l, c) {
- if (void 0 === c && (c = null),
- !e.detached) {
- var u = new Array
- , h = null
- , d = null
- , p = e.combine && e.combine.length > 0;
- if (2 === e.type ? u.push(r) : u.push(i),
- p) {
- for (var f = new Array, _ = 0; _ < e.combine.length; _++)
- a(e.combine[_], t.NothingTrigger, s, l, f);
- u.push(f)
- } else
- for (var m = 0; m < e.properties.length; m++) {
- var g = e.properties[m].value
- , v = e.properties[m].name
- , y = e.properties[m].targetType;
- "target" === v ? g = h = null !== y && "SceneProperties" === y ? n : n.getNodeByName(g) : "parent" === v ? g = n.getNodeByName(g) : "sound" === v ? n.getSoundByName && (g = n.getSoundByName(g)) : "propertyPath" !== v ? g = 2 === e.type && "operator" === v ? X[g] : o(0, g, h, "value" === v ? d : null) : d = g,
- u.push(g)
- }
- if (null === c ? u.push(s) : u.push(null),
- "InterpolateValueAction" === e.name) {
- var T = u[u.length - 2];
- u[u.length - 1] = T,
- u[u.length - 2] = s
- }
- var E = function(e, t) {
- var i = b("BABYLON." + e);
- if (i) {
- var n = Object.create(i.prototype);
- return n.constructor.apply(n, t),
- n
- }
- }(e.name, u);
- if (E instanceof H && null !== s) {
- var S = new te(i,s);
- l ? l.then(S) : r.registerAction(S),
- l = S
- }
- for (null === c ? E instanceof H ? (s = E,
- E = l) : (s = null,
- l ? l.then(E) : r.registerAction(E)) : c.push(E),
- m = 0; m < e.children.length; m++)
- a(e.children[m], i, s, E, null)
- }
- }, s = 0; s < e.children.length; s++) {
- var l = void 0
- , c = e.children[s];
- if (c.properties.length > 0) {
- var u = c.properties[0].value
- , h = null === c.properties[0].targetType ? u : n.getMeshByName(u);
- h._meshId && (h.mesh = n.getMeshById(h._meshId)),
- l = {
- trigger: t[c.name],
- parameter: h
- }
- } else
- l = t[c.name];
- for (var d = 0; d < c.children.length; d++)
- c.detached || a(c.children[d], l, null, null)
- }
- }
- ,
- t.GetTriggerName = function(e) {
- switch (e) {
- 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 ""
- }
- }
- ,
- t.NothingTrigger = a.ACTION_NothingTrigger,
- t.OnPickTrigger = a.ACTION_OnPickTrigger,
- t.OnLeftPickTrigger = a.ACTION_OnLeftPickTrigger,
- t.OnRightPickTrigger = a.ACTION_OnRightPickTrigger,
- t.OnCenterPickTrigger = a.ACTION_OnCenterPickTrigger,
- t.OnPickDownTrigger = a.ACTION_OnPickDownTrigger,
- t.OnDoublePickTrigger = a.ACTION_OnDoublePickTrigger,
- t.OnPickUpTrigger = a.ACTION_OnPickUpTrigger,
- t.OnPickOutTrigger = a.ACTION_OnPickOutTrigger,
- t.OnLongPressTrigger = a.ACTION_OnLongPressTrigger,
- t.OnPointerOverTrigger = a.ACTION_OnPointerOverTrigger,
- t.OnPointerOutTrigger = a.ACTION_OnPointerOutTrigger,
- t.OnEveryFrameTrigger = a.ACTION_OnEveryFrameTrigger,
- t.OnIntersectionEnterTrigger = a.ACTION_OnIntersectionEnterTrigger,
- t.OnIntersectionExitTrigger = a.ACTION_OnIntersectionExitTrigger,
- t.OnKeyDownTrigger = a.ACTION_OnKeyDownTrigger,
- t.OnKeyUpTrigger = 15,
- t
- }(s)
- , me = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r._sound = i,
- r
- }
- return U(t, e),
- t.prototype._prepare = function() {}
- ,
- t.prototype.execute = function() {
- void 0 !== this._sound && this._sound.play()
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "PlaySoundAction",
- properties: [{
- name: "sound",
- value: this._sound.name
- }]
- }, t)
- }
- ,
- t
- }(F)
- , ge = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r._sound = i,
- r
- }
- return U(t, e),
- t.prototype._prepare = function() {}
- ,
- t.prototype.execute = function() {
- void 0 !== this._sound && this._sound.stop()
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "StopSoundAction",
- properties: [{
- name: "sound",
- value: this._sound.name
- }]
- }, t)
- }
- ,
- t
- }(F);
- y("BABYLON.PlaySoundAction", me),
- y("BABYLON.StopSoundAction", ge);
- var ve = function() {
- function e() {}
- return e.Eval = function(t, i) {
- return "true" === (t = t.match(/\([^()]*\)/g) ? t.replace(/\([^()]*\)/g, (function(t) {
- return t = t.slice(1, t.length - 1),
- e._HandleParenthesisContent(t, i)
- }
- )) : e._HandleParenthesisContent(t, i)) || "false" !== t && e.Eval(t, i)
- }
- ,
- e._HandleParenthesisContent = function(t, i) {
- var n;
- i = i || function(e) {
- return "true" === e
- }
- ;
- var r = t.split("||");
- for (var o in r)
- if (Object.prototype.hasOwnProperty.call(r, o)) {
- var a = e._SimplifyNegation(r[o].trim())
- , s = a.split("&&");
- if (s.length > 1)
- for (var l = 0; l < s.length; ++l) {
- var c = e._SimplifyNegation(s[l].trim());
- if (!(n = "true" !== c && "false" !== c ? "!" === c[0] ? !i(c.substring(1)) : i(c) : "true" === c)) {
- a = "false";
- break
- }
- }
- if (n || "true" === a) {
- n = !0;
- break
- }
- n = "true" !== a && "false" !== a ? "!" === a[0] ? !i(a.substring(1)) : i(a) : "true" === a
- }
- return n ? "true" : "false"
- }
- ,
- e._SimplifyNegation = function(e) {
- return "!true" === (e = (e = e.replace(/^[\s!]+/, (function(e) {
- return (e = e.replace(/[\s]/g, (function() {
- return ""
- }
- ))).length % 2 ? "!" : ""
- }
- ))).trim()) ? e = "false" : "!false" === e && (e = "true"),
- e
- }
- ,
- e
- }()
- , ye = function() {
- function e() {}
- return e.EnableFor = function(t) {
- t._tags = t._tags || {},
- t.hasTags = function() {
- return e.HasTags(t)
- }
- ,
- t.addTags = function(i) {
- return e.AddTagsTo(t, i)
- }
- ,
- t.removeTags = function(i) {
- return e.RemoveTagsFrom(t, i)
- }
- ,
- t.matchesTagsQuery = function(i) {
- return e.MatchesQuery(t, i)
- }
- }
- ,
- e.DisableFor = function(e) {
- delete e._tags,
- delete e.hasTags,
- delete e.addTags,
- delete e.removeTags,
- delete e.matchesTagsQuery
- }
- ,
- e.HasTags = function(e) {
- if (!e._tags)
- return !1;
- var t = e._tags;
- for (var i in t)
- if (Object.prototype.hasOwnProperty.call(t, i))
- return !0;
- return !1
- }
- ,
- e.GetTags = function(e, t) {
- if (void 0 === t && (t = !0),
- !e._tags)
- return null;
- if (t) {
- var i = [];
- for (var n in e._tags)
- Object.prototype.hasOwnProperty.call(e._tags, n) && !0 === e._tags[n] && i.push(n);
- return i.join(" ")
- }
- return e._tags
- }
- ,
- e.AddTagsTo = function(t, i) {
- i && "string" == typeof i && i.split(" ").forEach((function(i) {
- e._AddTagTo(t, i)
- }
- ))
- }
- ,
- e._AddTagTo = function(t, i) {
- "" !== (i = i.trim()) && "true" !== i && "false" !== i && (i.match(/[\s]/) || i.match(/^([!]|([|]|[&]){2})/) || (e.EnableFor(t),
- t._tags[i] = !0))
- }
- ,
- e.RemoveTagsFrom = function(t, i) {
- if (e.HasTags(t)) {
- var n = i.split(" ");
- for (var r in n)
- e._RemoveTagFrom(t, n[r])
- }
- }
- ,
- e._RemoveTagFrom = function(e, t) {
- delete e._tags[t]
- }
- ,
- e.MatchesQuery = function(t, i) {
- return void 0 === i || ("" === i ? e.HasTags(t) : ve.Eval(i, (function(i) {
- return e.HasTags(t) && t._tags[i]
- }
- )))
- }
- ,
- e
- }();
- function be(e) {
- return "".concat(e, " needs to be imported before as it contains a side-effect required by your code.")
- }
- var Te = {}
- , Ee = {}
- , Se = function(e, t, i) {
- var n = e();
- ye && ye.AddTagsTo(n, t.tags);
- var r = Ae(n);
- for (var o in r) {
- var a = r[o]
- , s = t[o]
- , l = a.type;
- if (null != s && ("uniqueId" !== o || Ge.AllowLoadingUniqueId))
- switch (l) {
- case 0:
- case 6:
- case 11:
- n[o] = s;
- break;
- case 1:
- n[o] = i || s.isRenderTarget ? s : s.clone();
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 7:
- case 10:
- case 12:
- n[o] = i ? s : s.clone()
- }
- }
- return n
- };
- function Ae(e) {
- var t = e.getClassName();
- if (Ee[t])
- return Ee[t];
- Ee[t] = {};
- for (var i = Ee[t], n = e, r = t; r; ) {
- var o = Te[r];
- for (var a in o)
- i[a] = o[a];
- var s = void 0
- , l = !1;
- do {
- if (!(s = Object.getPrototypeOf(n)).getClassName) {
- l = !0;
- break
- }
- if (s.getClassName() !== r)
- break;
- n = s
- } while (s);
- if (l)
- break;
- r = s.getClassName(),
- n = s
- }
- return i
- }
- function xe(e, t) {
- return function(i, n) {
- var r = function(e) {
- var t = e.getClassName();
- return Te[t] || (Te[t] = {}),
- Te[t]
- }(i);
- r[n] || (r[n] = {
- type: e,
- sourceName: t
- })
- }
- }
- function Re(e, t) {
- return void 0 === t && (t = null),
- function(e, t) {
- return void 0 === t && (t = null),
- function(i, n) {
- var r = t || "_" + n;
- Object.defineProperty(i, n, {
- get: function() {
- return this[r]
- },
- set: function(t) {
- "function" == typeof this.equals && this.equals(t) || this[r] !== t && (this[r] = t,
- i[e].apply(this))
- },
- enumerable: !0,
- configurable: !0
- })
- }
- }(e, t)
- }
- function Ce(e) {
- return xe(0, e)
- }
- function Pe(e) {
- return xe(1, e)
- }
- function Me(e) {
- return xe(2, e)
- }
- function Ie(e) {
- return xe(3, e)
- }
- function Oe(e) {
- return xe(4, e)
- }
- function De(e) {
- return xe(5, e)
- }
- function Ne(e) {
- return xe(6, e)
- }
- function Le(e) {
- return xe(7, e)
- }
- function Fe(e) {
- return xe(8, e)
- }
- function we(e) {
- return xe(9, e)
- }
- function Be(e) {
- return xe(10, e)
- }
- function Ue(e) {
- return xe(12, e)
- }
- function Ve(e) {
- return xe(11, e)
- }
- var ke, Ge = function() {
- function e() {}
- return e.AppendSerializedAnimations = function(e, t) {
- if (e.animations) {
- t.animations = [];
- for (var i = 0; i < e.animations.length; i++) {
- var n = e.animations[i];
- t.animations.push(n.serialize())
- }
- }
- }
- ,
- e.Serialize = function(t, i) {
- i || (i = {}),
- ye && (i.tags = ye.GetTags(t));
- var n = Ae(t);
- for (var r in n) {
- var o = n[r]
- , a = o.sourceName || r
- , s = o.type
- , l = t[r];
- if (null != l && ("uniqueId" !== r || e.AllowLoadingUniqueId))
- switch (s) {
- case 0:
- i[a] = l;
- break;
- case 1:
- case 3:
- case 7:
- case 9:
- i[a] = l.serialize();
- break;
- case 2:
- case 4:
- case 5:
- case 8:
- case 10:
- case 12:
- i[a] = l.asArray();
- break;
- case 6:
- case 11:
- i[a] = l.id
- }
- }
- return i
- }
- ,
- e.Parse = function(t, i, n, r) {
- void 0 === r && (r = null);
- var o = t();
- r || (r = ""),
- ye && ye.AddTagsTo(o, i.tags);
- var a = Ae(o);
- for (var s in a) {
- var l = a[s]
- , c = i[l.sourceName || s]
- , u = l.type;
- if (null != c && ("uniqueId" !== s || e.AllowLoadingUniqueId)) {
- var h = o;
- switch (u) {
- case 0:
- h[s] = c;
- break;
- case 1:
- n && (h[s] = e._TextureParser(c, n, r));
- break;
- case 2:
- h[s] = D.FromArray(c);
- break;
- case 3:
- h[s] = e._FresnelParametersParser(c);
- break;
- case 4:
- h[s] = A.FromArray(c);
- break;
- case 5:
- h[s] = x.FromArray(c);
- break;
- case 6:
- n && (h[s] = n.getLastMeshById(c));
- break;
- case 7:
- h[s] = e._ColorCurvesParser(c);
- break;
- case 8:
- h[s] = N.FromArray(c);
- break;
- case 9:
- h[s] = e._ImageProcessingConfigurationParser(c);
- break;
- case 10:
- h[s] = C.FromArray(c);
- break;
- case 11:
- n && (h[s] = n.getCameraById(c));
- break;
- case 12:
- h[s] = P.FromArray(c)
- }
- }
- }
- return o
- }
- ,
- e.Clone = function(e, t) {
- return Se(e, t, !1)
- }
- ,
- e.Instanciate = function(e, t) {
- return Se(e, t, !0)
- }
- ,
- e.AllowLoadingUniqueId = !1,
- e._ImageProcessingConfigurationParser = function(e) {
- throw be("ImageProcessingConfiguration")
- }
- ,
- e._FresnelParametersParser = function(e) {
- throw be("FresnelParameters")
- }
- ,
- e._ColorCurvesParser = function(e) {
- throw be("ColorCurves")
- }
- ,
- e._TextureParser = function(e, t, i) {
- throw be("Texture")
- }
- ,
- e
- }();
- function ze(e, t, i, n) {
- var r = i.value;
- i.value = function() {
- for (var i = [], o = 0; o < arguments.length; o++)
- i[o] = arguments[o];
- var a = r;
- if ("undefined" != typeof _native && _native[t]) {
- var s = _native[t];
- a = n ? function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- return n.apply(void 0, e) ? s.apply(void 0, e) : r.apply(void 0, e)
- }
- : s
- }
- return e[t] = a,
- a.apply(void 0, i)
- }
- }
- ze.filter = function(e) {
- return function(t, i, n) {
- return ze(t, i, n, e)
- }
- }
- ,
- function(e) {
- e[e.NONE = 0] = "NONE",
- e[e.STEP = 1] = "STEP"
- }(ke || (ke = {}));
- var We = function() {
- function e(e, t, i) {
- this.name = e,
- this.from = t,
- this.to = i
- }
- return e.prototype.clone = function() {
- return new e(this.name,this.from,this.to)
- }
- ,
- e
- }()
- , He = function() {
- this._doNotSerialize = !1,
- this._isDisposed = !1,
- this._sceneRootNodesIndex = -1,
- this._isEnabled = !0,
- this._isParentEnabled = !0,
- this._isReady = !0,
- this._onEnabledStateChangedObservable = new h,
- this._onClonedObservable = new h
- }
- , Xe = function() {
- function e(e, t) {
- void 0 === t && (t = null),
- this._isDirty = !1,
- this._nodeDataStorage = new He,
- 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 = P.Identity(),
- this._worldMatrixDeterminant = 0,
- this._worldMatrixDeterminantIsDirty = !0,
- this._animationPropertiesOverride = null,
- this._isNode = !0,
- this.onDisposeObservable = new h,
- this._onDisposeObserver = null,
- this._behaviors = new Array,
- this.name = e,
- this.id = e,
- this._scene = t || E.LastCreatedScene,
- this.uniqueId = this._scene.getUniqueId(),
- this._initCache()
- }
- return e.AddNodeConstructor = function(e, t) {
- this._NodeConstructors[e] = t
- }
- ,
- e.Construct = function(e, t, i, n) {
- var r = this._NodeConstructors[e];
- return r ? r(t, i, n) : null
- }
- ,
- Object.defineProperty(e.prototype, "doNotSerialize", {
- get: function() {
- return !!this._nodeDataStorage._doNotSerialize || !!this._parentNode && this._parentNode.doNotSerialize
- },
- set: function(e) {
- this._nodeDataStorage._doNotSerialize = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isDisposed = function() {
- return this._nodeDataStorage._isDisposed
- }
- ,
- Object.defineProperty(e.prototype, "parent", {
- get: function() {
- return this._parentNode
- },
- set: function(e) {
- if (this._parentNode !== e) {
- var t = this._parentNode;
- if (this._parentNode && void 0 !== this._parentNode._children && null !== this._parentNode._children) {
- var i = this._parentNode._children.indexOf(this);
- -1 !== i && this._parentNode._children.splice(i, 1),
- e || this._nodeDataStorage._isDisposed || this._addToSceneRootNodes()
- }
- this._parentNode = e,
- this._parentNode && (void 0 !== this._parentNode._children && null !== this._parentNode._children || (this._parentNode._children = new Array),
- this._parentNode._children.push(this),
- t || this._removeFromSceneRootNodes()),
- this._syncParentEnabledState()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._addToSceneRootNodes = function() {
- -1 === this._nodeDataStorage._sceneRootNodesIndex && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length,
- this._scene.rootNodes.push(this))
- }
- ,
- e.prototype._removeFromSceneRootNodes = function() {
- if (-1 !== this._nodeDataStorage._sceneRootNodesIndex) {
- var e = this._scene.rootNodes
- , t = e.length - 1;
- e[this._nodeDataStorage._sceneRootNodesIndex] = e[t],
- e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex,
- this._scene.rootNodes.pop(),
- this._nodeDataStorage._sceneRootNodesIndex = -1
- }
- }
- ,
- Object.defineProperty(e.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
- },
- set: function(e) {
- this._animationPropertiesOverride = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "Node"
- }
- ,
- Object.defineProperty(e.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onEnabledStateChangedObservable", {
- get: function() {
- return this._nodeDataStorage._onEnabledStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onClonedObservable", {
- get: function() {
- return this._nodeDataStorage._onClonedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype.getEngine = function() {
- return this._scene.getEngine()
- }
- ,
- e.prototype.addBehavior = function(e, t) {
- var i = this;
- return void 0 === t && (t = !1),
- -1 !== this._behaviors.indexOf(e) || (e.init(),
- this._scene.isLoading && !t ? this._scene.onDataLoadedObservable.addOnce((function() {
- e.attach(i)
- }
- )) : e.attach(this),
- this._behaviors.push(e)),
- this
- }
- ,
- e.prototype.removeBehavior = function(e) {
- var t = this._behaviors.indexOf(e);
- return -1 === t || (this._behaviors[t].detach(),
- this._behaviors.splice(t, 1)),
- this
- }
- ,
- Object.defineProperty(e.prototype, "behaviors", {
- get: function() {
- return this._behaviors
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getBehaviorByName = function(e) {
- for (var t = 0, i = this._behaviors; t < i.length; t++) {
- var n = i[t];
- if (n.name === e)
- return n
- }
- return null
- }
- ,
- e.prototype.getWorldMatrix = function() {
- return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(),
- this._worldMatrix
- }
- ,
- e.prototype._getWorldMatrixDeterminant = function() {
- return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1,
- this._worldMatrixDeterminant = this._worldMatrix.determinant()),
- this._worldMatrixDeterminant
- }
- ,
- Object.defineProperty(e.prototype, "worldMatrixFromCache", {
- get: function() {
- return this._worldMatrix
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._initCache = function() {
- this._cache = {},
- this._cache.parent = void 0
- }
- ,
- e.prototype.updateCache = function(e) {
- !e && this.isSynchronized() || (this._cache.parent = this.parent,
- this._updateCache())
- }
- ,
- e.prototype._getActionManagerForTrigger = function(e, t) {
- return void 0 === t && (t = !0),
- this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
- }
- ,
- e.prototype._updateCache = function(e) {}
- ,
- e.prototype._isSynchronized = function() {
- return !0
- }
- ,
- e.prototype._markSyncedWithParent = function() {
- this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId)
- }
- ,
- e.prototype.isSynchronizedWithParent = function() {
- return !this._parentNode || !this._parentNode._isDirty && this._parentUpdateId === this._parentNode._childUpdateId && this._parentNode.isSynchronized()
- }
- ,
- e.prototype.isSynchronized = function() {
- return this._cache.parent != this._parentNode ? (this._cache.parent = this._parentNode,
- !1) : !(this._parentNode && !this.isSynchronizedWithParent()) && this._isSynchronized()
- }
- ,
- e.prototype.isReady = function(e) {
- return void 0 === e && (e = !1),
- this._nodeDataStorage._isReady
- }
- ,
- e.prototype.markAsDirty = function(e) {
- return this._currentRenderId = Number.MAX_VALUE,
- this._isDirty = !0,
- this
- }
- ,
- e.prototype.isEnabled = function(e) {
- return void 0 === e && (e = !0),
- !1 === e ? this._nodeDataStorage._isEnabled : !!this._nodeDataStorage._isEnabled && this._nodeDataStorage._isParentEnabled
- }
- ,
- e.prototype._syncParentEnabledState = function() {
- this._nodeDataStorage._isParentEnabled = !this._parentNode || this._parentNode.isEnabled(),
- this._children && this._children.forEach((function(e) {
- e._syncParentEnabledState()
- }
- ))
- }
- ,
- e.prototype.setEnabled = function(e) {
- this._nodeDataStorage._isEnabled !== e && (this._nodeDataStorage._isEnabled = e,
- this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e),
- this._syncParentEnabledState())
- }
- ,
- e.prototype.isDescendantOf = function(e) {
- return !!this.parent && (this.parent === e || this.parent.isDescendantOf(e))
- }
- ,
- e.prototype._getDescendants = function(e, t, i) {
- if (void 0 === t && (t = !1),
- this._children)
- for (var n = 0; n < this._children.length; n++) {
- var r = this._children[n];
- i && !i(r) || e.push(r),
- t || r._getDescendants(e, !1, i)
- }
- }
- ,
- e.prototype.getDescendants = function(e, t) {
- var i = new Array;
- return this._getDescendants(i, e, t),
- i
- }
- ,
- e.prototype.getChildMeshes = function(e, t) {
- var i = [];
- return this._getDescendants(i, e, (function(e) {
- return (!t || t(e)) && void 0 !== e.cullingStrategy
- }
- )),
- i
- }
- ,
- e.prototype.getChildren = function(e, t) {
- return void 0 === t && (t = !0),
- this.getDescendants(t, e)
- }
- ,
- e.prototype._setReady = function(e) {
- e !== this._nodeDataStorage._isReady && (e ? (this.onReady && this.onReady(this),
- this._nodeDataStorage._isReady = !0) : this._nodeDataStorage._isReady = !1)
- }
- ,
- e.prototype.getAnimationByName = function(e) {
- for (var t = 0; t < this.animations.length; t++) {
- var i = this.animations[t];
- if (i.name === e)
- return i
- }
- return null
- }
- ,
- e.prototype.createAnimationRange = function(t, i, n) {
- if (!this._ranges[t]) {
- this._ranges[t] = e._AnimationRangeFactory(t, i, n);
- for (var r = 0, o = this.animations.length; r < o; r++)
- this.animations[r] && this.animations[r].createRange(t, i, n)
- }
- }
- ,
- e.prototype.deleteAnimationRange = function(e, t) {
- void 0 === t && (t = !0);
- for (var i = 0, n = this.animations.length; i < n; i++)
- this.animations[i] && this.animations[i].deleteRange(e, t);
- this._ranges[e] = null
- }
- ,
- e.prototype.getAnimationRange = function(e) {
- return this._ranges[e] || null
- }
- ,
- e.prototype.getAnimationRanges = function() {
- var e, t = [];
- for (e in this._ranges)
- t.push(this._ranges[e]);
- return t
- }
- ,
- e.prototype.beginAnimation = function(e, t, i, n) {
- var r = this.getAnimationRange(e);
- return r ? this._scene.beginAnimation(this, r.from, r.to, t, i, n) : null
- }
- ,
- e.prototype.serializeAnimationRanges = function() {
- var e = [];
- for (var t in this._ranges) {
- var i = this._ranges[t];
- if (i) {
- var n = {};
- n.name = t,
- n.from = i.from,
- n.to = i.to,
- e.push(n)
- }
- }
- return e
- }
- ,
- e.prototype.computeWorldMatrix = function(e) {
- return this._worldMatrix || (this._worldMatrix = P.Identity()),
- this._worldMatrix
- }
- ,
- e.prototype.dispose = function(e, t) {
- if (void 0 === t && (t = !1),
- this._nodeDataStorage._isDisposed = !0,
- !e)
- for (var i = 0, n = this.getDescendants(!0); i < n.length; i++)
- n[i].dispose(e, t);
- this.parent ? this.parent = null : this._removeFromSceneRootNodes(),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onEnabledStateChangedObservable.clear(),
- this.onClonedObservable.clear();
- for (var r = 0, o = this._behaviors; r < o.length; r++)
- o[r].detach();
- this._behaviors = [],
- this.metadata = null
- }
- ,
- e.ParseAnimationRanges = function(e, t, i) {
- if (t.ranges)
- for (var n = 0; n < t.ranges.length; n++) {
- var r = t.ranges[n];
- e.createAnimationRange(r.name, r.from, r.to)
- }
- }
- ,
- e.prototype.getHierarchyBoundingVectors = function(e, t) {
- var i, n;
- void 0 === e && (e = !0),
- void 0 === t && (t = null),
- this.getScene().incrementRenderId(),
- this.computeWorldMatrix(!0);
- var r = this;
- if (r.getBoundingInfo && r.subMeshes) {
- var o = r.getBoundingInfo();
- i = o.boundingBox.minimumWorld.clone(),
- n = o.boundingBox.maximumWorld.clone()
- } else
- i = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- n = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- if (e)
- for (var a = 0, s = this.getDescendants(!1); a < s.length; a++) {
- var l = s[a];
- if (l.computeWorldMatrix(!0),
- (!t || t(l)) && l.getBoundingInfo && 0 !== l.getTotalVertices()) {
- var c = l.getBoundingInfo().boundingBox
- , u = c.minimumWorld
- , h = c.maximumWorld;
- x.CheckExtends(u, i, n),
- x.CheckExtends(h, i, n)
- }
- }
- return {
- min: i,
- max: n
- }
- }
- ,
- e._AnimationRangeFactory = function(e, t, i) {
- throw be("AnimationRange")
- }
- ,
- e._NodeConstructors = {},
- k([Ce()], e.prototype, "name", void 0),
- k([Ce()], e.prototype, "id", void 0),
- k([Ce()], e.prototype, "uniqueId", void 0),
- k([Ce()], e.prototype, "state", void 0),
- k([Ce()], e.prototype, "metadata", void 0),
- e
- }()
- , je = function() {
- function e(e, t) {
- this.width = e,
- this.height = t
- }
- return e.prototype.toString = function() {
- return "{W: ".concat(this.width, ", H: ").concat(this.height, "}")
- }
- ,
- e.prototype.getClassName = function() {
- return "Size"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = 0 | this.width;
- return 397 * e ^ (0 | this.height)
- }
- ,
- e.prototype.copyFrom = function(e) {
- this.width = e.width,
- this.height = e.height
- }
- ,
- e.prototype.copyFromFloats = function(e, t) {
- return this.width = e,
- this.height = t,
- this
- }
- ,
- e.prototype.set = function(e, t) {
- return this.copyFromFloats(e, t)
- }
- ,
- e.prototype.multiplyByFloats = function(t, i) {
- return new e(this.width * t,this.height * i)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.width,this.height)
- }
- ,
- e.prototype.equals = function(e) {
- return !!e && this.width === e.width && this.height === e.height
- }
- ,
- Object.defineProperty(e.prototype, "surface", {
- get: function() {
- return this.width * this.height
- },
- enumerable: !1,
- configurable: !0
- }),
- e.Zero = function() {
- return new e(0,0)
- }
- ,
- e.prototype.add = function(t) {
- return new e(this.width + t.width,this.height + t.height)
- }
- ,
- e.prototype.subtract = function(t) {
- return new e(this.width - t.width,this.height - t.height)
- }
- ,
- e.Lerp = function(t, i, n) {
- return new e(t.width + (i.width - t.width) * n,t.height + (i.height - t.height) * n)
- }
- ,
- e
- }()
- , Ye = function() {
- function e() {
- this._xhr = "undefined" != typeof _native && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest
- }
- return e.prototype._injectCustomRequestHeaders = function() {
- for (var t in e.CustomRequestHeaders) {
- var i = e.CustomRequestHeaders[t];
- i && this._xhr.setRequestHeader(t, i)
- }
- }
- ,
- Object.defineProperty(e.prototype, "onprogress", {
- get: function() {
- return this._xhr.onprogress
- },
- set: function(e) {
- this._xhr.onprogress = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "readyState", {
- get: function() {
- return this._xhr.readyState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "status", {
- get: function() {
- return this._xhr.status
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "statusText", {
- get: function() {
- return this._xhr.statusText
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "response", {
- get: function() {
- return this._xhr.response
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "responseURL", {
- get: function() {
- return this._xhr.responseURL
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "responseText", {
- get: function() {
- return this._xhr.responseText
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "responseType", {
- get: function() {
- return this._xhr.responseType
- },
- set: function(e) {
- this._xhr.responseType = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "timeout", {
- get: function() {
- return this._xhr.timeout
- },
- set: function(e) {
- this._xhr.timeout = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addEventListener = function(e, t, i) {
- this._xhr.addEventListener(e, t, i)
- }
- ,
- e.prototype.removeEventListener = function(e, t, i) {
- this._xhr.removeEventListener(e, t, i)
- }
- ,
- e.prototype.abort = function() {
- this._xhr.abort()
- }
- ,
- e.prototype.send = function(t) {
- e.CustomRequestHeaders && this._injectCustomRequestHeaders(),
- this._xhr.send(t)
- }
- ,
- e.prototype.open = function(t, i) {
- for (var n = 0, r = e.CustomRequestModifiers; n < r.length; n++)
- (0,
- r[n])(this._xhr, i);
- return i = (i = i.replace("file:http:", "http:")).replace("file:https:", "https:"),
- this._xhr.open(t, i, !0)
- }
- ,
- e.prototype.setRequestHeader = function(e, t) {
- this._xhr.setRequestHeader(e, t)
- }
- ,
- e.prototype.getResponseHeader = function(e) {
- return this._xhr.getResponseHeader(e)
- }
- ,
- e.CustomRequestHeaders = {},
- e.CustomRequestModifiers = new Array,
- e
- }()
- , Ke = function() {}
- , Qe = function() {
- function e(t, i, n, r, o, a) {
- this.name = t,
- this.targetProperty = i,
- this.framePerSecond = n,
- this.dataType = r,
- this.loopMode = o,
- this.enableBlending = a,
- this._easingFunction = null,
- this._runtimeAnimations = new Array,
- this._events = new Array,
- this.blendingSpeed = .01,
- this._ranges = {},
- this.targetPropertyPath = i.split("."),
- this.dataType = r,
- this.loopMode = void 0 === o ? e.ANIMATIONLOOPMODE_CYCLE : o,
- this.uniqueId = e._UniqueIdGenerator++
- }
- return e._PrepareAnimation = function(t, i, n, r, o, a, s, l) {
- var c = void 0;
- if (!isNaN(parseFloat(o)) && isFinite(o) ? c = e.ANIMATIONTYPE_FLOAT : o instanceof C ? c = e.ANIMATIONTYPE_QUATERNION : o instanceof x ? c = e.ANIMATIONTYPE_VECTOR3 : o instanceof A ? c = e.ANIMATIONTYPE_VECTOR2 : o instanceof D ? c = e.ANIMATIONTYPE_COLOR3 : o instanceof N ? c = e.ANIMATIONTYPE_COLOR4 : o instanceof je && (c = e.ANIMATIONTYPE_SIZE),
- null == c)
- return null;
- var u = new e(t,i,n,c,s)
- , h = [{
- frame: 0,
- value: o
- }, {
- frame: r,
- value: a
- }];
- return u.setKeys(h),
- void 0 !== l && u.setEasingFunction(l),
- u
- }
- ,
- e.CreateAnimation = function(t, i, n, r) {
- var o = new e(t + "Animation",t,n,i,e.ANIMATIONLOOPMODE_CONSTANT);
- return o.setEasingFunction(r),
- o
- }
- ,
- e.CreateAndStartAnimation = function(t, i, n, r, o, a, s, l, c, u, h) {
- var d = e._PrepareAnimation(t, n, r, o, a, s, l, c);
- return d ? (i.getScene && (h = i.getScene()),
- h ? h.beginDirectAnimation(i, [d], 0, o, 1 === d.loopMode, 1, u) : null) : null
- }
- ,
- e.CreateAndStartHierarchyAnimation = function(t, i, n, r, o, a, s, l, c, u, h) {
- var d = e._PrepareAnimation(t, r, o, a, s, l, c, u);
- return d ? i.getScene().beginDirectHierarchyAnimation(i, n, [d], 0, a, 1 === d.loopMode, 1, h) : null
- }
- ,
- e.CreateMergeAndStartAnimation = function(t, i, n, r, o, a, s, l, c, u) {
- var h = e._PrepareAnimation(t, n, r, o, a, s, l, c);
- return h ? (i.animations.push(h),
- i.getScene().beginAnimation(i, 0, o, 1 === h.loopMode, 1, u)) : null
- }
- ,
- e.MakeAnimationAdditive = function(t, i, n, r, o) {
- void 0 === i && (i = 0),
- void 0 === r && (r = !1);
- var a = t;
- if (r && ((a = t.clone()).name = o || a.name),
- !a._keys.length)
- return a;
- i = i >= 0 ? i : 0;
- var s = 0
- , l = a._keys[0]
- , c = a._keys.length - 1
- , u = a._keys[c]
- , h = {
- referenceValue: l.value,
- referencePosition: I.Vector3[0],
- referenceQuaternion: I.Quaternion[0],
- referenceScaling: I.Vector3[1],
- keyPosition: I.Vector3[2],
- keyQuaternion: I.Quaternion[1],
- keyScaling: I.Vector3[3]
- }
- , d = !1
- , p = l.frame
- , f = u.frame;
- if (n) {
- var _ = a.getRange(n);
- _ && (p = _.from,
- f = _.to)
- }
- var m = l.frame === p
- , g = u.frame === f;
- if (1 === a._keys.length) {
- var v = a._getKeyValue(a._keys[0]);
- h.referenceValue = v.clone ? v.clone() : v,
- d = !0
- } else
- i <= l.frame ? (v = a._getKeyValue(l.value),
- h.referenceValue = v.clone ? v.clone() : v,
- d = !0) : i >= u.frame && (v = a._getKeyValue(u.value),
- h.referenceValue = v.clone ? v.clone() : v,
- d = !0);
- for (var y = 0; !d || !m || !g && y < a._keys.length - 1; ) {
- var b = a._keys[y]
- , T = a._keys[y + 1];
- if (!d && i >= b.frame && i <= T.frame) {
- if (v = void 0,
- i === b.frame)
- v = a._getKeyValue(b.value);
- else if (i === T.frame)
- v = a._getKeyValue(T.value);
- else {
- var E = {
- key: y,
- repeatCount: 0,
- loopMode: this.ANIMATIONLOOPMODE_CONSTANT
- };
- v = a._interpolate(i, E)
- }
- h.referenceValue = v.clone ? v.clone() : v,
- d = !0
- }
- if (!m && p >= b.frame && p <= T.frame) {
- if (p === b.frame)
- s = y;
- else if (p === T.frame)
- s = y + 1;
- else {
- E = {
- key: y,
- repeatCount: 0,
- loopMode: this.ANIMATIONLOOPMODE_CONSTANT
- };
- var S = {
- frame: p,
- value: (v = a._interpolate(p, E)).clone ? v.clone() : v
- };
- a._keys.splice(y + 1, 0, S),
- s = y + 1
- }
- m = !0
- }
- !g && f >= b.frame && f <= T.frame && (f === b.frame ? c = y : (f === T.frame || (E = {
- key: y,
- repeatCount: 0,
- loopMode: this.ANIMATIONLOOPMODE_CONSTANT
- },
- S = {
- frame: f,
- value: (v = a._interpolate(f, E)).clone ? v.clone() : v
- },
- a._keys.splice(y + 1, 0, S)),
- c = y + 1),
- g = !0),
- y++
- }
- for (a.dataType === e.ANIMATIONTYPE_QUATERNION ? h.referenceValue.normalize().conjugateInPlace() : a.dataType === e.ANIMATIONTYPE_MATRIX && (h.referenceValue.decompose(h.referenceScaling, h.referenceQuaternion, h.referencePosition),
- h.referenceQuaternion.normalize().conjugateInPlace()),
- y = s; y <= c; y++)
- if (S = a._keys[y],
- !y || a.dataType === e.ANIMATIONTYPE_FLOAT || S.value !== l.value)
- switch (a.dataType) {
- case e.ANIMATIONTYPE_MATRIX:
- S.value.decompose(h.keyScaling, h.keyQuaternion, h.keyPosition),
- h.keyPosition.subtractInPlace(h.referencePosition),
- h.keyScaling.divideInPlace(h.referenceScaling),
- h.referenceQuaternion.multiplyToRef(h.keyQuaternion, h.keyQuaternion),
- P.ComposeToRef(h.keyScaling, h.keyQuaternion, h.keyPosition, S.value);
- break;
- case e.ANIMATIONTYPE_QUATERNION:
- h.referenceValue.multiplyToRef(S.value, S.value);
- break;
- case e.ANIMATIONTYPE_VECTOR2:
- case e.ANIMATIONTYPE_VECTOR3:
- case e.ANIMATIONTYPE_COLOR3:
- case e.ANIMATIONTYPE_COLOR4:
- S.value.subtractToRef(h.referenceValue, S.value);
- break;
- case e.ANIMATIONTYPE_SIZE:
- S.value.width -= h.referenceValue.width,
- S.value.height -= h.referenceValue.height;
- break;
- default:
- S.value -= h.referenceValue
- }
- return a
- }
- ,
- e.TransitionTo = function(e, t, i, n, r, o, a, s) {
- if (void 0 === s && (s = null),
- a <= 0)
- return i[e] = t,
- s && s(),
- null;
- var l = r * (a / 1e3);
- o.setKeys([{
- frame: 0,
- value: i[e].clone ? i[e].clone() : i[e]
- }, {
- frame: l,
- value: t
- }]),
- i.animations || (i.animations = []),
- i.animations.push(o);
- var c = n.beginAnimation(i, 0, l, !1);
- return c.onAnimationEnd = s,
- c
- }
- ,
- Object.defineProperty(e.prototype, "runtimeAnimations", {
- get: function() {
- return this._runtimeAnimations
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasRunningRuntimeAnimations", {
- get: function() {
- for (var e = 0, t = this._runtimeAnimations; e < t.length; e++)
- if (!t[e].isStopped())
- return !0;
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.toString = function(e) {
- var t = "Name: " + this.name + ", property: " + this.targetProperty;
- if (t += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType],
- t += ", nKeys: " + (this._keys ? this._keys.length : "none"),
- t += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
- e) {
- t += ", Ranges: {";
- var i = !0;
- for (var n in this._ranges)
- i && (t += ", ",
- i = !1),
- t += n;
- t += "}"
- }
- return t
- }
- ,
- e.prototype.addEvent = function(e) {
- this._events.push(e),
- this._events.sort((function(e, t) {
- return e.frame - t.frame
- }
- ))
- }
- ,
- e.prototype.removeEvents = function(e) {
- for (var t = 0; t < this._events.length; t++)
- this._events[t].frame === e && (this._events.splice(t, 1),
- t--)
- }
- ,
- e.prototype.getEvents = function() {
- return this._events
- }
- ,
- e.prototype.createRange = function(e, t, i) {
- this._ranges[e] || (this._ranges[e] = new We(e,t,i))
- }
- ,
- e.prototype.deleteRange = function(e, t) {
- void 0 === t && (t = !0);
- var i = this._ranges[e];
- if (i) {
- if (t)
- for (var n = i.from, r = i.to, o = this._keys.length - 1; o >= 0; o--)
- this._keys[o].frame >= n && this._keys[o].frame <= r && this._keys.splice(o, 1);
- this._ranges[e] = null
- }
- }
- ,
- e.prototype.getRange = function(e) {
- return this._ranges[e]
- }
- ,
- e.prototype.getKeys = function() {
- return this._keys
- }
- ,
- e.prototype.getHighestFrame = function() {
- for (var e = 0, t = 0, i = this._keys.length; t < i; t++)
- e < this._keys[t].frame && (e = this._keys[t].frame);
- return e
- }
- ,
- e.prototype.getEasingFunction = function() {
- return this._easingFunction
- }
- ,
- e.prototype.setEasingFunction = function(e) {
- this._easingFunction = e
- }
- ,
- e.prototype.floatInterpolateFunction = function(e, t, i) {
- return d.Lerp(e, t, i)
- }
- ,
- e.prototype.floatInterpolateFunctionWithTangents = function(e, t, i, n, r) {
- return d.Hermite(e, t, i, n, r)
- }
- ,
- e.prototype.quaternionInterpolateFunction = function(e, t, i) {
- return C.Slerp(e, t, i)
- }
- ,
- e.prototype.quaternionInterpolateFunctionWithTangents = function(e, t, i, n, r) {
- return C.Hermite(e, t, i, n, r).normalize()
- }
- ,
- e.prototype.vector3InterpolateFunction = function(e, t, i) {
- return x.Lerp(e, t, i)
- }
- ,
- e.prototype.vector3InterpolateFunctionWithTangents = function(e, t, i, n, r) {
- return x.Hermite(e, t, i, n, r)
- }
- ,
- e.prototype.vector2InterpolateFunction = function(e, t, i) {
- return A.Lerp(e, t, i)
- }
- ,
- e.prototype.vector2InterpolateFunctionWithTangents = function(e, t, i, n, r) {
- return A.Hermite(e, t, i, n, r)
- }
- ,
- e.prototype.sizeInterpolateFunction = function(e, t, i) {
- return je.Lerp(e, t, i)
- }
- ,
- e.prototype.color3InterpolateFunction = function(e, t, i) {
- return D.Lerp(e, t, i)
- }
- ,
- e.prototype.color3InterpolateFunctionWithTangents = function(e, t, i, n, r) {
- return D.Hermite(e, t, i, n, r)
- }
- ,
- e.prototype.color4InterpolateFunction = function(e, t, i) {
- return N.Lerp(e, t, i)
- }
- ,
- e.prototype.color4InterpolateFunctionWithTangents = function(e, t, i, n, r) {
- return N.Hermite(e, t, i, n, r)
- }
- ,
- e.prototype._getKeyValue = function(e) {
- return "function" == typeof e ? e() : e
- }
- ,
- e.prototype.evaluate = function(t) {
- return this._interpolate(t, {
- key: 0,
- repeatCount: 0,
- loopMode: e.ANIMATIONLOOPMODE_CONSTANT
- })
- }
- ,
- e.prototype._interpolate = function(t, i) {
- if (i.loopMode === e.ANIMATIONLOOPMODE_CONSTANT && i.repeatCount > 0)
- return i.highLimitValue.clone ? i.highLimitValue.clone() : i.highLimitValue;
- var n = this._keys;
- if (1 === n.length)
- return this._getKeyValue(n[0].value);
- var r = i.key;
- if (n[r].frame >= t)
- for (; r - 1 >= 0 && n[r].frame >= t; )
- r--;
- for (var o = r; o < n.length - 1; o++) {
- var a = n[o + 1];
- if (a.frame >= t) {
- i.key = o;
- var s = n[o]
- , l = this._getKeyValue(s.value)
- , c = this._getKeyValue(a.value);
- if (s.interpolation === ke.STEP)
- return a.frame > t ? l : c;
- var u = void 0 !== s.outTangent && void 0 !== a.inTangent
- , h = a.frame - s.frame
- , d = (t - s.frame) / h
- , p = this.getEasingFunction();
- switch (null !== p && (d = p.ease(d)),
- this.dataType) {
- case e.ANIMATIONTYPE_FLOAT:
- var f = u ? this.floatInterpolateFunctionWithTangents(l, s.outTangent * h, c, a.inTangent * h, d) : this.floatInterpolateFunction(l, c, d);
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return f;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return i.offsetValue * i.repeatCount + f
- }
- break;
- case e.ANIMATIONTYPE_QUATERNION:
- var _ = u ? this.quaternionInterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.quaternionInterpolateFunction(l, c, d);
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return _;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return _.addInPlace(i.offsetValue.scale(i.repeatCount))
- }
- return _;
- case e.ANIMATIONTYPE_VECTOR3:
- var m = u ? this.vector3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.vector3InterpolateFunction(l, c, d);
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return m;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return m.add(i.offsetValue.scale(i.repeatCount))
- }
- break;
- case e.ANIMATIONTYPE_VECTOR2:
- var g = u ? this.vector2InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.vector2InterpolateFunction(l, c, d);
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return g;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return g.add(i.offsetValue.scale(i.repeatCount))
- }
- break;
- case e.ANIMATIONTYPE_SIZE:
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return this.sizeInterpolateFunction(l, c, d);
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return this.sizeInterpolateFunction(l, c, d).add(i.offsetValue.scale(i.repeatCount))
- }
- break;
- case e.ANIMATIONTYPE_COLOR3:
- var v = u ? this.color3InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.color3InterpolateFunction(l, c, d);
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return v;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return v.add(i.offsetValue.scale(i.repeatCount))
- }
- break;
- case e.ANIMATIONTYPE_COLOR4:
- var y = u ? this.color4InterpolateFunctionWithTangents(l, s.outTangent.scale(h), c, a.inTangent.scale(h), d) : this.color4InterpolateFunction(l, c, d);
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return y;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return y.add(i.offsetValue.scale(i.repeatCount))
- }
- break;
- case e.ANIMATIONTYPE_MATRIX:
- switch (i.loopMode) {
- case e.ANIMATIONLOOPMODE_CYCLE:
- case e.ANIMATIONLOOPMODE_CONSTANT:
- return e.AllowMatricesInterpolation ? this.matrixInterpolateFunction(l, c, d, i.workValue) : l;
- case e.ANIMATIONLOOPMODE_RELATIVE:
- return l
- }
- }
- break
- }
- }
- return this._getKeyValue(n[n.length - 1].value)
- }
- ,
- e.prototype.matrixInterpolateFunction = function(t, i, n, r) {
- return e.AllowMatrixDecomposeForInterpolation ? r ? (P.DecomposeLerpToRef(t, i, n, r),
- r) : P.DecomposeLerp(t, i, n) : r ? (P.LerpToRef(t, i, n, r),
- r) : P.Lerp(t, i, n)
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);
- if (t.enableBlending = this.enableBlending,
- t.blendingSpeed = this.blendingSpeed,
- this._keys && t.setKeys(this._keys),
- this._ranges)
- for (var i in t._ranges = {},
- this._ranges) {
- var n = this._ranges[i];
- n && (t._ranges[i] = n.clone())
- }
- return t
- }
- ,
- e.prototype.setKeys = function(e) {
- this._keys = e.slice(0)
- }
- ,
- e.prototype.serialize = function() {
- var t = {};
- t.name = this.name,
- t.property = this.targetProperty,
- t.framePerSecond = this.framePerSecond,
- t.dataType = this.dataType,
- t.loopBehavior = this.loopMode,
- t.enableBlending = this.enableBlending,
- t.blendingSpeed = this.blendingSpeed;
- var i = this.dataType;
- t.keys = [];
- for (var n = this.getKeys(), r = 0; r < n.length; r++) {
- var o = n[r]
- , a = {};
- switch (a.frame = o.frame,
- i) {
- case e.ANIMATIONTYPE_FLOAT:
- a.values = [o.value],
- void 0 !== o.inTangent && a.values.push(o.inTangent),
- void 0 !== o.outTangent && (void 0 === o.inTangent && a.values.push(void 0),
- a.values.push(o.outTangent)),
- void 0 !== o.interpolation && (void 0 === o.inTangent && a.values.push(void 0),
- void 0 === o.outTangent && a.values.push(void 0),
- a.values.push(o.interpolation));
- break;
- case e.ANIMATIONTYPE_QUATERNION:
- case e.ANIMATIONTYPE_MATRIX:
- case e.ANIMATIONTYPE_VECTOR3:
- case e.ANIMATIONTYPE_COLOR3:
- case e.ANIMATIONTYPE_COLOR4:
- a.values = o.value.asArray(),
- null != o.inTangent && a.values.push(o.inTangent.asArray()),
- null != o.outTangent && (void 0 === o.inTangent && a.values.push(void 0),
- a.values.push(o.outTangent.asArray())),
- void 0 !== o.interpolation && (void 0 === o.inTangent && a.values.push(void 0),
- void 0 === o.outTangent && a.values.push(void 0),
- a.values.push(o.interpolation))
- }
- t.keys.push(a)
- }
- for (var s in t.ranges = [],
- this._ranges) {
- var l = this._ranges[s];
- if (l) {
- var c = {};
- c.name = s,
- c.from = l.from,
- c.to = l.to,
- t.ranges.push(c)
- }
- }
- return t
- }
- ,
- e._UniversalLerp = function(e, t, i) {
- var n = e.constructor;
- return n.Lerp ? n.Lerp(e, t, i) : n.Slerp ? n.Slerp(e, t, i) : e.toFixed ? e * (1 - i) + i * t : t
- }
- ,
- e.Parse = function(t) {
- var i, n, r = new e(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior), o = t.dataType, a = [];
- for (t.enableBlending && (r.enableBlending = t.enableBlending),
- t.blendingSpeed && (r.blendingSpeed = t.blendingSpeed),
- n = 0; n < t.keys.length; n++) {
- var s = t.keys[n]
- , l = void 0
- , c = void 0
- , u = void 0;
- switch (o) {
- case e.ANIMATIONTYPE_FLOAT:
- i = s.values[0],
- s.values.length >= 2 && (l = s.values[1]),
- s.values.length >= 3 && (c = s.values[2]),
- s.values.length >= 4 && (u = s.values[3]);
- break;
- case e.ANIMATIONTYPE_QUATERNION:
- if (i = C.FromArray(s.values),
- s.values.length >= 8) {
- var h = C.FromArray(s.values.slice(4, 8));
- h.equals(C.Zero()) || (l = h)
- }
- if (s.values.length >= 12) {
- var d = C.FromArray(s.values.slice(8, 12));
- d.equals(C.Zero()) || (c = d)
- }
- s.values.length >= 13 && (u = s.values[12]);
- break;
- case e.ANIMATIONTYPE_MATRIX:
- i = P.FromArray(s.values),
- s.values.length >= 17 && (u = s.values[16]);
- break;
- case e.ANIMATIONTYPE_COLOR3:
- i = D.FromArray(s.values),
- s.values[3] && (l = D.FromArray(s.values[3])),
- s.values[4] && (c = D.FromArray(s.values[4])),
- s.values[5] && (u = s.values[5]);
- break;
- case e.ANIMATIONTYPE_COLOR4:
- i = N.FromArray(s.values),
- s.values[4] && (l = N.FromArray(s.values[4])),
- s.values[5] && (c = N.FromArray(s.values[5])),
- s.values[6] && (u = N.FromArray(s.values[6]));
- break;
- case e.ANIMATIONTYPE_VECTOR3:
- default:
- i = x.FromArray(s.values),
- s.values[3] && (l = x.FromArray(s.values[3])),
- s.values[4] && (c = x.FromArray(s.values[4])),
- s.values[5] && (u = s.values[5])
- }
- var p = {};
- p.frame = s.frame,
- p.value = i,
- null != l && (p.inTangent = l),
- null != c && (p.outTangent = c),
- null != u && (p.interpolation = u),
- a.push(p)
- }
- if (r.setKeys(a),
- t.ranges)
- for (n = 0; n < t.ranges.length; n++)
- i = t.ranges[n],
- r.createRange(i.name, i.from, i.to);
- return r
- }
- ,
- e.AppendSerializedAnimations = function(e, t) {
- Ge.AppendSerializedAnimations(e, t)
- }
- ,
- e.ParseFromFileAsync = function(e, t) {
- var i = this;
- return new Promise((function(n, r) {
- var o = new Ye;
- o.addEventListener("readystatechange", (function() {
- if (4 == o.readyState)
- if (200 == o.status) {
- var t = JSON.parse(o.responseText);
- if (t.animations && (t = t.animations),
- t.length) {
- for (var a = new Array, s = 0, l = t; s < l.length; s++) {
- var c = l[s];
- a.push(i.Parse(c))
- }
- n(a)
- } else
- a = i.Parse(t),
- e && (a.name = e),
- n(a)
- } else
- r("Unable to load the animation")
- }
- )),
- o.open("GET", t),
- o.send()
- }
- ))
- }
- ,
- e.CreateFromSnippetAsync = function(e) {
- var t = this;
- return new Promise((function(i, n) {
- var r = new Ye;
- r.addEventListener("readystatechange", (function() {
- if (4 == r.readyState)
- if (200 == r.status) {
- var o = JSON.parse(JSON.parse(r.responseText).jsonPayload);
- if (o.animations) {
- for (var a = JSON.parse(o.animations), s = new Array, l = 0, c = a.animations; l < c.length; l++) {
- var u = c[l];
- (h = t.Parse(u)).snippetId = e,
- s.push(h)
- }
- i(s)
- } else {
- var h;
- a = JSON.parse(o.animation),
- (h = t.Parse(a)).snippetId = e,
- i(h)
- }
- } else
- n("Unable to load the snippet " + e)
- }
- )),
- r.open("GET", t.SnippetUrl + "/" + e.replace(/#/g, "/")),
- r.send()
- }
- ))
- }
- ,
- e._UniqueIdGenerator = 0,
- e.AllowMatricesInterpolation = !1,
- e.AllowMatrixDecomposeForInterpolation = !0,
- e.SnippetUrl = "https://snippet.babylonjs.com",
- e.ANIMATIONTYPE_FLOAT = 0,
- e.ANIMATIONTYPE_VECTOR3 = 1,
- e.ANIMATIONTYPE_QUATERNION = 2,
- e.ANIMATIONTYPE_MATRIX = 3,
- e.ANIMATIONTYPE_COLOR3 = 4,
- e.ANIMATIONTYPE_COLOR4 = 7,
- e.ANIMATIONTYPE_VECTOR2 = 5,
- e.ANIMATIONTYPE_SIZE = 6,
- e.ANIMATIONLOOPMODE_RELATIVE = 0,
- e.ANIMATIONLOOPMODE_CYCLE = 1,
- e.ANIMATIONLOOPMODE_CONSTANT = 2,
- e
- }();
- y("BABYLON.Animation", Qe),
- Xe._AnimationRangeFactory = function(e, t, i) {
- return new We(e,t,i)
- }
- ;
- var qe = function(e) {
- function t(t, i, n, r, o, a, s, l) {
- void 0 === o && (o = 1e3);
- var c = e.call(this, t, a) || this;
- return c.duration = 1e3,
- c.onInterpolationDoneObservable = new h,
- c.propertyPath = n,
- c.value = r,
- c.duration = o,
- c.stopOtherAnimations = s,
- c.onInterpolationDone = l,
- c._target = c._effectiveTarget = i,
- c
- }
- return U(t, e),
- t.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath)
- }
- ,
- t.prototype.execute = function() {
- var e, t = this, i = this._actionManager.getScene(), n = [{
- frame: 0,
- value: this._effectiveTarget[this._property]
- }, {
- frame: 100,
- value: this.value
- }];
- if ("number" == typeof this.value)
- e = Qe.ANIMATIONTYPE_FLOAT;
- else if (this.value instanceof D)
- e = Qe.ANIMATIONTYPE_COLOR3;
- else if (this.value instanceof x)
- e = Qe.ANIMATIONTYPE_VECTOR3;
- else if (this.value instanceof P)
- e = Qe.ANIMATIONTYPE_MATRIX;
- else {
- if (!(this.value instanceof C))
- return void K.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
- e = Qe.ANIMATIONTYPE_QUATERNION
- }
- var r = new Qe("InterpolateValueAction",this._property,1e3 / this.duration * 100,e,Qe.ANIMATIONLOOPMODE_CONSTANT);
- r.setKeys(n),
- this.stopOtherAnimations && i.stopAnimation(this._effectiveTarget),
- i.beginDirectAnimation(this._effectiveTarget, [r], 0, 100, !1, 1, (function() {
- t.onInterpolationDoneObservable.notifyObservers(t),
- t.onInterpolationDone && t.onInterpolationDone()
- }
- ))
- }
- ,
- t.prototype.serialize = function(t) {
- return e.prototype._serialize.call(this, {
- name: "InterpolateValueAction",
- properties: [F._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: F._SerializeValueAsString(this.value)
- }, {
- name: "duration",
- value: F._SerializeValueAsString(this.duration)
- }, {
- name: "stopOtherAnimations",
- value: F._SerializeValueAsString(this.stopOtherAnimations) || !1
- }]
- }, t)
- }
- ,
- t
- }(F);
- y("BABYLON.InterpolateValueAction", qe);
- var Ze = Object.freeze(new C(0,0,0,0))
- , Je = Object.freeze(x.Zero())
- , $e = Object.freeze(A.Zero())
- , et = Object.freeze(je.Zero())
- , tt = Object.freeze(D.Black())
- , it = function() {
- function e(e, t, i, n) {
- var r = 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 = t,
- this._target = e,
- this._scene = i,
- this._host = n,
- this._activeTargets = [],
- t._runtimeAnimations.push(this),
- this._animationState = {
- key: 0,
- repeatCount: 0,
- loopMode: this._getCorrectLoopMode()
- },
- this._animation.dataType === Qe.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = P.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,
- 0 !== this._minFrame) {
- var o = {
- frame: 0,
- value: this._minValue
- };
- this._keys.splice(0, 0, o)
- }
- if (this._target instanceof Array) {
- for (var a = 0, s = 0, l = this._target; s < l.length; s++) {
- var c = l[s];
- this._preparePath(c, a),
- this._getOriginalValues(a),
- a++
- }
- this._targetIsArray = !0
- } else
- this._preparePath(this._target),
- this._getOriginalValues(),
- this._targetIsArray = !1,
- this._directTarget = this._activeTargets[0];
- var u = t.getEvents();
- u && u.length > 0 && u.forEach((function(e) {
- r._events.push(e._clone())
- }
- )),
- this._enableBlending = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.enableBlending : this._animation.enableBlending
- }
- return Object.defineProperty(e.prototype, "currentFrame", {
- get: function() {
- return this._currentFrame
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "weight", {
- get: function() {
- return this._weight
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentValue", {
- get: function() {
- return this._currentValue
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "targetPath", {
- get: function() {
- return this._targetPath
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "target", {
- get: function() {
- return this._currentActiveTarget
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isAdditive", {
- get: function() {
- return this._host && this._host.isAdditive
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._preparePath = function(e, t) {
- void 0 === t && (t = 0);
- var i = this._animation.targetPropertyPath;
- if (i.length > 1) {
- for (var n = e[i[0]], r = 1; r < i.length - 1; r++)
- n = n[i[r]];
- this._targetPath = i[i.length - 1],
- this._activeTargets[t] = n
- } else
- this._targetPath = i[0],
- this._activeTargets[t] = e
- }
- ,
- Object.defineProperty(e.prototype, "animation", {
- get: function() {
- return this._animation
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reset = function(e) {
- if (void 0 === e && (e = !1),
- e)
- if (this._target instanceof Array)
- for (var t = 0, i = 0, n = this._target; i < n.length; i++) {
- var r = n[i];
- void 0 !== this._originalValue[t] && this._setValue(r, this._activeTargets[t], this._originalValue[t], -1, t),
- t++
- }
- else
- void 0 !== this._originalValue[0] && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
- for (this._offsetsCache = {},
- this._highLimitsCache = {},
- this._currentFrame = 0,
- this._blendingFactor = 0,
- t = 0; t < this._events.length; t++)
- this._events[t].isDone = !1
- }
- ,
- e.prototype.isStopped = function() {
- return this._stopped
- }
- ,
- e.prototype.dispose = function() {
- var e = this._animation.runtimeAnimations.indexOf(this);
- e > -1 && this._animation.runtimeAnimations.splice(e, 1)
- }
- ,
- e.prototype.setValue = function(e, t) {
- if (this._targetIsArray)
- for (var i = 0; i < this._target.length; i++) {
- var n = this._target[i];
- this._setValue(n, this._activeTargets[i], e, t, i)
- }
- else
- this._setValue(this._target, this._directTarget, e, t, 0)
- }
- ,
- e.prototype._getOriginalValues = function(e) {
- var t;
- void 0 === e && (e = 0);
- var i = this._activeTargets[e];
- (t = i.getRestPose && "_matrix" === this._targetPath ? i.getRestPose() : i[this._targetPath]) && t.clone ? this._originalValue[e] = t.clone() : this._originalValue[e] = t
- }
- ,
- e.prototype._setValue = function(e, t, i, n, r) {
- if (this._currentActiveTarget = t,
- this._weight = n,
- this._enableBlending && this._blendingFactor <= 1) {
- if (!this._originalBlendValue) {
- var o = t[this._targetPath];
- o.clone ? this._originalBlendValue = o.clone() : this._originalBlendValue = o
- }
- this._originalBlendValue.m ? Qe.AllowMatrixDecomposeForInterpolation ? this._currentValue ? P.DecomposeLerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = P.DecomposeLerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue ? P.LerpToRef(this._originalBlendValue, i, this._blendingFactor, this._currentValue) : this._currentValue = P.Lerp(this._originalBlendValue, i, this._blendingFactor) : this._currentValue = Qe._UniversalLerp(this._originalBlendValue, i, this._blendingFactor);
- var a = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
- this._blendingFactor += a
- } else
- this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(i) : this._currentValue = i : (null == i ? void 0 : i.clone) ? this._currentValue = i.clone() : this._currentValue = i;
- -1 !== n ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[r]) : t[this._targetPath] = this._currentValue,
- e.markAsDirty && e.markAsDirty(this._animation.targetProperty)
- }
- ,
- e.prototype._getCorrectLoopMode = function() {
- return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode
- }
- ,
- e.prototype.goToFrame = function(e) {
- var t = this._animation.getKeys();
- e < t[0].frame ? e = t[0].frame : e > t[t.length - 1].frame && (e = t[t.length - 1].frame);
- var i = this._events;
- if (i.length)
- for (var n = 0; n < i.length; n++)
- i[n].onlyOnce || (i[n].isDone = i[n].frame < e);
- this._currentFrame = e;
- var r = this._animation._interpolate(e, this._animationState);
- this.setValue(r, -1)
- }
- ,
- e.prototype._prepareForSpeedRatioChange = function(e) {
- var t = this._previousDelay * (this._animation.framePerSecond * e) / 1e3;
- this._ratioOffset = this._previousRatio - t
- }
- ,
- e.prototype.animate = function(e, t, i, n, r, o) {
- void 0 === o && (o = -1);
- var a = this._animation
- , s = a.targetPropertyPath;
- if (!s || s.length < 1)
- return this._stopped = !0,
- !1;
- var l = !0;
- (t < this._minFrame || t > this._maxFrame) && (t = this._minFrame),
- (i < this._minFrame || i > this._maxFrame) && (i = this._maxFrame);
- var c, u, h = i - t, d = e * (a.framePerSecond * r) / 1e3 + this._ratioOffset, p = 0;
- if (this._previousDelay = e,
- this._previousRatio = d,
- !n && i >= t && d >= h)
- l = !1,
- p = a._getKeyValue(this._maxValue);
- else if (!n && t >= i && d <= h)
- l = !1,
- p = a._getKeyValue(this._minValue);
- else if (this._animationState.loopMode !== Qe.ANIMATIONLOOPMODE_CYCLE) {
- var f = i.toString() + t.toString();
- if (!this._offsetsCache[f]) {
- this._animationState.repeatCount = 0,
- this._animationState.loopMode = Qe.ANIMATIONLOOPMODE_CYCLE;
- var _ = a._interpolate(t, this._animationState)
- , m = a._interpolate(i, this._animationState);
- switch (this._animationState.loopMode = this._getCorrectLoopMode(),
- a.dataType) {
- case Qe.ANIMATIONTYPE_FLOAT:
- this._offsetsCache[f] = m - _;
- break;
- case Qe.ANIMATIONTYPE_QUATERNION:
- case Qe.ANIMATIONTYPE_VECTOR3:
- case Qe.ANIMATIONTYPE_VECTOR2:
- case Qe.ANIMATIONTYPE_SIZE:
- case Qe.ANIMATIONTYPE_COLOR3:
- this._offsetsCache[f] = m.subtract(_)
- }
- this._highLimitsCache[f] = m
- }
- p = this._highLimitsCache[f],
- c = this._offsetsCache[f]
- }
- if (void 0 === c)
- switch (a.dataType) {
- case Qe.ANIMATIONTYPE_FLOAT:
- c = 0;
- break;
- case Qe.ANIMATIONTYPE_QUATERNION:
- c = Ze;
- break;
- case Qe.ANIMATIONTYPE_VECTOR3:
- c = Je;
- break;
- case Qe.ANIMATIONTYPE_VECTOR2:
- c = $e;
- break;
- case Qe.ANIMATIONTYPE_SIZE:
- c = et;
- break;
- case Qe.ANIMATIONTYPE_COLOR3:
- c = tt
- }
- if (this._host && this._host.syncRoot) {
- var g = this._host.syncRoot;
- u = t + (i - t) * ((g.masterFrame - g.fromFrame) / (g.toFrame - g.fromFrame))
- } else
- u = d > 0 && t > i || d < 0 && t < i ? l && 0 !== h ? i + d % h : t : l && 0 !== h ? t + d % h : i;
- var v = this._events;
- if ((r > 0 && this.currentFrame > u || r < 0 && this.currentFrame < u) && (this._onLoop(),
- v.length))
- for (var y = 0; y < v.length; y++)
- v[y].onlyOnce || (v[y].isDone = !1);
- this._currentFrame = u,
- this._animationState.repeatCount = 0 === h ? 0 : d / h >> 0,
- this._animationState.highLimitValue = p,
- this._animationState.offsetValue = c;
- var b = a._interpolate(u, this._animationState);
- if (this.setValue(b, o),
- v.length)
- for (y = 0; y < v.length; y++)
- if (h > 0 && u >= v[y].frame && v[y].frame >= t || h < 0 && u <= v[y].frame && v[y].frame <= t) {
- var T = v[y];
- T.isDone || (T.onlyOnce && (v.splice(y, 1),
- y--),
- T.isDone = !0,
- T.action(u))
- }
- return l || (this._stopped = !0),
- l
- }
- ,
- e
- }();
- function nt() {
- return "undefined" != typeof window
- }
- function rt() {
- return "undefined" != typeof navigator
- }
- function ot() {
- return "undefined" != typeof document
- }
- function at(e) {
- for (var t = "", i = e.firstChild; i; )
- 3 === i.nodeType && (t += i.textContent),
- i = i.nextSibling;
- return t
- }
- var st, lt = {
- IsWindowObjectExist: nt,
- IsNavigatorAvailable: rt,
- IsDocumentAvailable: ot,
- GetDOMTextContent: at
- }, ct = function() {
- function e() {}
- return Object.defineProperty(e, "Now", {
- get: function() {
- return lt.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now()
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(), ut = function() {
- function e() {}
- return e.FilesToLoad = {},
- e
- }(), ht = function() {
- function e() {}
- return e.ExponentialBackoff = function(e, t) {
- return void 0 === e && (e = 3),
- void 0 === t && (t = 500),
- function(i, n, r) {
- return 0 !== n.status || r >= e || -1 !== i.indexOf("file:") ? -1 : Math.pow(2, r) * t
- }
- }
- ,
- e
- }(), dt = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t._setPrototypeOf = Object.setPrototypeOf || function(e, t) {
- return e.__proto__ = t,
- e
- }
- ,
- t
- }(Error), pt = {
- MeshInvalidPositionsError: 0,
- UnsupportedTextureError: 1e3,
- GLTFLoaderUnexpectedMagicError: 2e3,
- SceneLoaderError: 3e3,
- LoadFileError: 4e3,
- RequestFileError: 4001,
- ReadFileError: 4002
- }, ft = function(e) {
- function t(i, n, r) {
- var o = e.call(this, i) || this;
- return o.errorCode = n,
- o.innerError = r,
- o.name = "RuntimeError",
- dt._setPrototypeOf(o, t.prototype),
- o
- }
- return U(t, e),
- t
- }(dt), _t = function() {
- function e() {
- this.children = []
- }
- return e.prototype.isValid = function(e) {
- return !0
- }
- ,
- e.prototype.process = function(e, t) {
- var i = "";
- if (this.line) {
- var n = this.line
- , r = t.processor;
- r && (r.lineProcessor && (n = r.lineProcessor(n, t.isFragment, t.processingContext)),
- r.attributeProcessor && ae(this.line, "attribute") ? n = r.attributeProcessor(this.line, e, t.processingContext) : r.varyingProcessor && ae(this.line, "varying") ? n = r.varyingProcessor(this.line, t.isFragment, e, t.processingContext) : r.uniformProcessor && r.uniformRegexp && r.uniformRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (n = r.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : r.uniformBufferProcessor && r.uniformBufferRegexp && r.uniformBufferRegexp.test(this.line) ? t.lookForClosingBracketForUniformBuffer || (n = r.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
- t.lookForClosingBracketForUniformBuffer = !0) : r.textureProcessor && r.textureRegexp && r.textureRegexp.test(this.line) ? n = r.textureProcessor(this.line, t.isFragment, e, t.processingContext) : (r.uniformProcessor || r.uniformBufferProcessor) && ae(this.line, "uniform") && !t.lookForClosingBracketForUniformBuffer && (/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line) ? r.uniformProcessor && (n = r.uniformProcessor(this.line, t.isFragment, e, t.processingContext)) : r.uniformBufferProcessor && (n = r.uniformBufferProcessor(this.line, t.isFragment, t.processingContext),
- t.lookForClosingBracketForUniformBuffer = !0)),
- t.lookForClosingBracketForUniformBuffer && -1 !== this.line.indexOf("}") && (t.lookForClosingBracketForUniformBuffer = !1,
- r.endOfUniformBufferProcessor && (n = r.endOfUniformBufferProcessor(this.line, t.isFragment, t.processingContext)))),
- i += n + "\r\n"
- }
- return this.children.forEach((function(n) {
- i += n.process(e, t)
- }
- )),
- this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"),
- i
- }
- ,
- e
- }(), mt = function() {
- function e() {}
- return Object.defineProperty(e.prototype, "currentLine", {
- get: function() {
- return this._lines[this.lineIndex]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "canRead", {
- get: function() {
- return this.lineIndex < this._lines.length - 1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lines", {
- set: function(e) {
- this._lines = [];
- for (var t = 0, i = e; t < i.length; t++) {
- var n = i[t];
- if ("#" !== n[0])
- for (var r = n.split(";"), o = 0; o < r.length; o++) {
- var a = r[o];
- (a = a.trim()) && this._lines.push(a + (o !== r.length - 1 ? ";" : ""))
- }
- else
- this._lines.push(n)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(), gt = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.process = function(e, t) {
- for (var i = 0; i < this.children.length; i++) {
- var n = this.children[i];
- if (n.isValid(e))
- return n.process(e, t)
- }
- return ""
- }
- ,
- t
- }(_t), vt = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.isValid = function(e) {
- return this.testExpression.isTrue(e)
- }
- ,
- t
- }(_t), yt = function() {
- function e() {}
- return e.prototype.isTrue = function(e) {
- return !0
- }
- ,
- e.postfixToInfix = function(t) {
- for (var i = [], n = 0, r = t; n < r.length; n++) {
- var o = r[n];
- if (void 0 === e._OperatorPriority[o])
- i.push(o);
- else {
- var a = i[i.length - 1]
- , s = i[i.length - 2];
- i.length -= 2,
- i.push("(".concat(s).concat(o).concat(a, ")"))
- }
- }
- return i[i.length - 1]
- }
- ,
- e.infixToPostfix = function(t) {
- for (var i = [], n = -1, r = function() {
- "" !== (c = c.trim()) && (i.push(c),
- c = "")
- }, o = function(t) {
- n < e._Stack.length - 1 && (e._Stack[++n] = t)
- }, a = function() {
- return e._Stack[n]
- }, s = function() {
- return -1 === n ? "!!INVALID EXPRESSION!!" : e._Stack[n--]
- }, l = 0, c = ""; l < t.length; ) {
- var u = t.charAt(l)
- , h = l < t.length - 1 ? t.substr(l, 2) : "";
- if ("(" === u)
- c = "",
- o(u);
- else if (")" === u) {
- for (r(); -1 !== n && "(" !== a(); )
- i.push(s());
- s()
- } else if (e._OperatorPriority[h] > 1) {
- for (r(); -1 !== n && e._OperatorPriority[a()] >= e._OperatorPriority[h]; )
- i.push(s());
- o(h),
- l++
- } else
- c += u;
- l++
- }
- for (r(); -1 !== n; )
- "(" === a() ? s() : i.push(s());
- return i
- }
- ,
- e._OperatorPriority = {
- ")": 0,
- "(": 1,
- "||": 2,
- "&&": 3
- },
- e._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
- e
- }(), bt = function(e) {
- function t(t, i) {
- void 0 === i && (i = !1);
- var n = e.call(this) || this;
- return n.define = t,
- n.not = i,
- n
- }
- return U(t, e),
- t.prototype.isTrue = function(e) {
- var t = void 0 !== e[this.define];
- return this.not && (t = !t),
- t
- }
- ,
- t
- }(yt), Tt = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.isTrue = function(e) {
- return this.leftOperand.isTrue(e) || this.rightOperand.isTrue(e)
- }
- ,
- t
- }(yt), Et = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.isTrue = function(e) {
- return this.leftOperand.isTrue(e) && this.rightOperand.isTrue(e)
- }
- ,
- t
- }(yt), St = function(e) {
- function t(t, i, n) {
- var r = e.call(this) || this;
- return r.define = t,
- r.operand = i,
- r.testValue = n,
- r
- }
- return U(t, e),
- t.prototype.isTrue = function(e) {
- var t = e[this.define];
- void 0 === t && (t = this.define);
- var i = !1
- , n = parseInt(t)
- , r = parseInt(this.testValue);
- switch (this.operand) {
- case ">":
- i = n > r;
- break;
- case "<":
- i = n < r;
- break;
- case "<=":
- i = n <= r;
- break;
- case ">=":
- i = n >= r;
- break;
- case "==":
- i = n === r
- }
- return i
- }
- ,
- t
- }(yt);
- !function(e) {
- e[e.GLSL = 0] = "GLSL",
- e[e.WGSL = 1] = "WGSL"
- }(st || (st = {}));
- var At, xt = /defined\s*?\((.+?)\)/g, Rt = /defined\s*?\[(.+?)\]/g, Ct = function() {
- function e() {}
- return e.Initialize = function(e) {
- e.processor && e.processor.initializeShaders && e.processor.initializeShaders(e.processingContext)
- }
- ,
- e.Process = function(e, t, i, n) {
- var r, o = this;
- (null === (r = t.processor) || void 0 === r ? void 0 : r.preProcessShaderCode) && (e = t.processor.preProcessShaderCode(e, t.isFragment)),
- this._ProcessIncludes(e, t, (function(e) {
- t.processCodeAfterIncludes && (e = t.processCodeAfterIncludes(t.isFragment ? "fragment" : "vertex", e));
- var r = o._ProcessShaderConversion(e, t, n);
- i(r)
- }
- ))
- }
- ,
- e.PreProcess = function(e, t, i, n) {
- var r, o = this;
- (null === (r = t.processor) || void 0 === r ? void 0 : r.preProcessShaderCode) && (e = t.processor.preProcessShaderCode(e, t.isFragment)),
- this._ProcessIncludes(e, t, (function(e) {
- t.processCodeAfterIncludes && (e = t.processCodeAfterIncludes(t.isFragment ? "fragment" : "vertex", e));
- var r = o._ApplyPreProcessing(e, t, n);
- i(r)
- }
- ))
- }
- ,
- e.Finalize = function(e, t, i) {
- return i.processor && i.processor.finalizeShaders ? i.processor.finalizeShaders(e, t, i.processingContext) : {
- vertexCode: e,
- fragmentCode: t
- }
- }
- ,
- e._ProcessPrecision = function(e, t) {
- var i;
- if (null === (i = t.processor) || void 0 === i ? void 0 : i.noPrecision)
- return e;
- var n = t.shouldUseHighPrecisionShader;
- return -1 === e.indexOf("precision highp float") ? e = n ? "precision highp float;\n" + e : "precision mediump float;\n" + e : n || (e = e.replace("precision highp float", "precision mediump float")),
- e
- }
- ,
- e._ExtractOperation = function(e) {
- var t = /defined\((.+)\)/.exec(e);
- if (t && t.length)
- return new bt(t[1].trim(),"!" === e[0]);
- for (var i = "", n = 0, r = 0, o = ["==", ">=", "<=", "<", ">"]; r < o.length && (i = o[r],
- !((n = e.indexOf(i)) > -1)); r++)
- ;
- if (-1 === n)
- return new bt(e);
- var a = e.substring(0, n).trim()
- , s = e.substring(n + i.length).trim();
- return new St(a,i,s)
- }
- ,
- e._BuildSubExpression = function(e) {
- e = e.replace(xt, "defined[$1]");
- for (var t = [], i = 0, n = yt.infixToPostfix(e); i < n.length; i++) {
- var r = n[i];
- if ("||" !== r && "&&" !== r)
- t.push(r);
- else if (t.length >= 2) {
- var o = t[t.length - 1]
- , a = t[t.length - 2];
- t.length -= 2;
- var s = "&&" == r ? new Et : new Tt;
- "string" == typeof o && (o = o.replace(Rt, "defined($1)")),
- "string" == typeof a && (a = a.replace(Rt, "defined($1)")),
- s.leftOperand = "string" == typeof a ? this._ExtractOperation(a) : a,
- s.rightOperand = "string" == typeof o ? this._ExtractOperation(o) : o,
- t.push(s)
- }
- }
- var l = t[t.length - 1];
- return "string" == typeof l && (l = l.replace(Rt, "defined($1)")),
- "string" == typeof l ? this._ExtractOperation(l) : l
- }
- ,
- e._BuildExpression = function(e, t) {
- var i = new vt
- , n = e.substring(0, t)
- , r = e.substring(t);
- return r = r.substring(0, (r.indexOf("//") + 1 || r.length + 1) - 1).trim(),
- i.testExpression = "#ifdef" === n ? new bt(r) : "#ifndef" === n ? new bt(r,!0) : this._BuildSubExpression(r),
- i
- }
- ,
- e._MoveCursorWithinIf = function(e, t, i) {
- for (var n = e.currentLine; this._MoveCursor(e, i); ) {
- var r = (n = e.currentLine).substring(0, 5).toLowerCase();
- if ("#else" === r) {
- var o = new _t;
- return t.children.push(o),
- void this._MoveCursor(e, o)
- }
- if ("#elif" === r) {
- var a = this._BuildExpression(n, 5);
- t.children.push(a),
- i = a
- }
- }
- }
- ,
- e._MoveCursor = function(e, t) {
- for (; e.canRead; ) {
- e.lineIndex++;
- var i = e.currentLine
- , n = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);
- if (n && n.length)
- switch (n[0]) {
- case "#ifdef":
- var r = new gt;
- t.children.push(r);
- var o = this._BuildExpression(i, 6);
- r.children.push(o),
- this._MoveCursorWithinIf(e, r, o);
- break;
- case "#else":
- case "#elif":
- return !0;
- case "#endif":
- return !1;
- case "#ifndef":
- r = new gt,
- t.children.push(r),
- o = this._BuildExpression(i, 7),
- r.children.push(o),
- this._MoveCursorWithinIf(e, r, o);
- break;
- case "#if":
- r = new gt,
- o = this._BuildExpression(i, 3),
- t.children.push(r),
- r.children.push(o),
- this._MoveCursorWithinIf(e, r, o)
- }
- else {
- var a = new _t;
- if (a.line = i,
- t.children.push(a),
- "#" === i[0] && "d" === i[1]) {
- var s = i.replace(";", "").split(" ");
- a.additionalDefineKey = s[1],
- 3 === s.length && (a.additionalDefineValue = s[2])
- }
- }
- }
- return !1
- }
- ,
- e._EvaluatePreProcessors = function(e, t, i) {
- var n = new _t
- , r = new mt;
- return r.lineIndex = -1,
- r.lines = e.split("\n"),
- this._MoveCursor(r, n),
- n.process(t, i)
- }
- ,
- e._PreparePreProcessors = function(e, t) {
- for (var i, n = {}, r = 0, o = e.defines; r < o.length; r++) {
- var a = o[r].replace("#define", "").replace(";", "").trim().split(" ");
- n[a[0]] = a.length > 1 ? a[1] : ""
- }
- return (null === (i = e.processor) || void 0 === i ? void 0 : i.shaderLanguage) === st.GLSL && (n.GL_ES = "true"),
- n.__VERSION__ = e.version,
- n[e.platformName] = "true",
- t._getGlobalDefines(n),
- n
- }
- ,
- e._ProcessShaderConversion = function(e, t, i) {
- var n = this._ProcessPrecision(e, t);
- if (!t.processor)
- return n;
- if (t.processor.shaderLanguage === st.GLSL && -1 !== n.indexOf("#version 3"))
- return n.replace("#version 300 es", "");
- var r = t.defines
- , o = this._PreparePreProcessors(t, i);
- return t.processor.preProcessor && (n = t.processor.preProcessor(n, r, t.isFragment, t.processingContext)),
- n = this._EvaluatePreProcessors(n, o, t),
- t.processor.postProcessor && (n = t.processor.postProcessor(n, r, t.isFragment, t.processingContext, i)),
- i._features.needShaderCodeInlining && (n = i.inlineShaderCode(n)),
- n
- }
- ,
- e._ApplyPreProcessing = function(e, t, i) {
- var n, r, o = e, a = t.defines, s = this._PreparePreProcessors(t, i);
- return (null === (n = t.processor) || void 0 === n ? void 0 : n.preProcessor) && (o = t.processor.preProcessor(o, a, t.isFragment, t.processingContext)),
- o = this._EvaluatePreProcessors(o, s, t),
- (null === (r = t.processor) || void 0 === r ? void 0 : r.postProcessor) && (o = t.processor.postProcessor(o, a, t.isFragment, t.processingContext, i)),
- i._features.needShaderCodeInlining && (o = i.inlineShaderCode(o)),
- o
- }
- ,
- e._ProcessIncludes = function(t, i, n) {
- for (var r = this, o = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, a = o.exec(t), s = new String(t), l = !1, c = function() {
- var c = a[1];
- if (-1 !== c.indexOf("__decl__") && (c = c.replace(/__decl__/, ""),
- i.supportsUniformBuffers && (c = (c = c.replace(/Vertex/, "Ubo")).replace(/Fragment/, "Ubo")),
- c += "Declaration"),
- !i.includesShadersStore[c]) {
- var u = i.shadersRepository + "ShadersInclude/" + c + ".fx";
- return e._FileToolsLoadFile(u, (function(e) {
- i.includesShadersStore[c] = e,
- r._ProcessIncludes(s, i, n)
- }
- )),
- {
- value: void 0
- }
- }
- var h = i.includesShadersStore[c];
- if (a[2])
- for (var d = a[3].split(","), p = 0; p < d.length; p += 2) {
- var f = new RegExp(d[p],"g")
- , _ = d[p + 1];
- h = h.replace(f, _)
- }
- if (a[4]) {
- var m = a[5];
- if (-1 !== m.indexOf("..")) {
- var g = m.split("..")
- , v = parseInt(g[0])
- , y = parseInt(g[1])
- , b = h.slice(0);
- h = "",
- isNaN(y) && (y = i.indexParameters[g[1]]);
- for (var T = v; T < y; T++)
- i.supportsUniformBuffers || (b = b.replace(/light\{X\}.(\w*)/g, (function(e, t) {
- return t + "{X}"
- }
- ))),
- h += b.replace(/\{X\}/g, T.toString()) + "\n"
- } else
- i.supportsUniformBuffers || (h = h.replace(/light\{X\}.(\w*)/g, (function(e, t) {
- return t + "{X}"
- }
- ))),
- h = h.replace(/\{X\}/g, m)
- }
- s = s.replace(a[0], h),
- l = l || h.indexOf("#include<") >= 0 || h.indexOf("#include <") >= 0,
- a = o.exec(t)
- }; null != a; ) {
- var u = c();
- if ("object" == typeof u)
- return u.value
- }
- l ? this._ProcessIncludes(s.toString(), i, n) : n(s)
- }
- ,
- e._FileToolsLoadFile = function(e, t, i, n, r, o) {
- throw be("FileTools")
- }
- ,
- e
- }(), Pt = function() {
- function e() {}
- return e.GetShadersRepository = function(t) {
- return void 0 === t && (t = st.GLSL),
- t === st.GLSL ? e.ShadersRepository : e.ShadersRepositoryWGSL
- }
- ,
- e.GetShadersStore = function(t) {
- return void 0 === t && (t = st.GLSL),
- t === st.GLSL ? e.ShadersStore : e.ShadersStoreWGSL
- }
- ,
- e.GetIncludesShadersStore = function(t) {
- return void 0 === t && (t = st.GLSL),
- t === st.GLSL ? e.IncludesShadersStore : e.IncludesShadersStoreWGSL
- }
- ,
- e.ShadersRepository = "src/Shaders/",
- e.ShadersStore = {},
- e.IncludesShadersStore = {},
- e.ShadersRepositoryWGSL = "src/ShadersWGSL/",
- e.ShadersStoreWGSL = {},
- e.IncludesShadersStoreWGSL = {},
- e
- }(), Mt = function() {
- function e(t, i, n, r, o, a, s, l, c, u, d, p) {
- void 0 === r && (r = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === d && (d = ""),
- void 0 === p && (p = st.GLSL);
- var f, _, m, g = this;
- this.name = null,
- this.defines = "",
- this.onCompiled = null,
- this.onError = null,
- this.onBind = null,
- this.uniqueId = 0,
- this.onCompileObservable = new h,
- this.onErrorObservable = new h,
- 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 = t,
- this._key = d;
- var v, y, b = void 0, T = null;
- if (i.attributes) {
- var E = i;
- if (this._engine = n,
- this._attributesNames = E.attributes,
- this._uniformsNames = E.uniformsNames.concat(E.samplers),
- this._samplerList = E.samplers.slice(),
- this.defines = E.defines,
- this.onError = E.onError,
- this.onCompiled = E.onCompiled,
- this._fallbacks = E.fallbacks,
- this._indexParameters = E.indexParameters,
- this._transformFeedbackVaryings = E.transformFeedbackVaryings || null,
- this._multiTarget = !!E.multiTarget,
- this._shaderLanguage = null !== (f = E.shaderLanguage) && void 0 !== f ? f : st.GLSL,
- E.uniformBuffersNames) {
- this._uniformBuffersNamesList = E.uniformBuffersNames.slice();
- for (var S = 0; S < E.uniformBuffersNames.length; S++)
- this._uniformBuffersNames[E.uniformBuffersNames[S]] = S
- }
- T = null !== (_ = E.processFinalCode) && void 0 !== _ ? _ : null,
- b = null !== (m = E.processCodeAfterIncludes) && void 0 !== m ? m : void 0
- } else
- this._engine = o,
- this.defines = null == a ? "" : a,
- this._uniformsNames = n.concat(r),
- this._samplerList = r ? r.slice() : [],
- this._attributesNames = i,
- this._uniformBuffersNamesList = [],
- this._shaderLanguage = p,
- this.onError = c,
- this.onCompiled = l,
- this._indexParameters = u,
- this._fallbacks = s;
- this._attributeLocationByName = {},
- this.uniqueId = e._UniqueIdSeed++;
- var A = nt() ? this._engine.getHostDocument() : null;
- t.vertexSource ? v = "source:" + t.vertexSource : t.vertexElement ? (v = A ? A.getElementById(t.vertexElement) : null) || (v = t.vertexElement) : v = t.vertex || t,
- t.fragmentSource ? y = "source:" + t.fragmentSource : t.fragmentElement ? (y = A ? A.getElementById(t.fragmentElement) : null) || (y = t.fragmentElement) : y = t.fragment || t,
- this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
- var x = {
- defines: this.defines.split("\n"),
- indexParameters: this._indexParameters,
- isFragment: !1,
- shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,
- processor: this._engine._getShaderProcessor(this._shaderLanguage),
- supportsUniformBuffers: this._engine.supportsUniformBuffers,
- shadersRepository: Pt.GetShadersRepository(this._shaderLanguage),
- includesShadersStore: Pt.GetIncludesShadersStore(this._shaderLanguage),
- version: (100 * this._engine.version).toString(),
- platformName: this._engine.shaderPlatformName,
- processingContext: this._processingContext,
- isNDCHalfZRange: this._engine.isNDCHalfZRange,
- useReverseDepthBuffer: this._engine.useReverseDepthBuffer,
- processCodeAfterIncludes: b
- }
- , R = [void 0, void 0]
- , C = function() {
- if (R[0] && R[1]) {
- x.isFragment = !0;
- var e = R[0]
- , i = R[1];
- Ct.Process(i, x, (function(i) {
- T && (i = T("fragment", i));
- var n = Ct.Finalize(e, i, x);
- g._useFinalCode(n.vertexCode, n.fragmentCode, t)
- }
- ), g._engine)
- }
- };
- this._loadShader(v, "Vertex", "", (function(e) {
- Ct.Initialize(x),
- Ct.Process(e, x, (function(t) {
- g._rawVertexSourceCode = e,
- T && (t = T("vertex", t)),
- R[0] = t,
- C()
- }
- ), g._engine)
- }
- )),
- this._loadShader(y, "Fragment", "Pixel", (function(e) {
- g._rawFragmentSourceCode = e,
- R[1] = e,
- C()
- }
- ))
- }
- return Object.defineProperty(e, "ShadersRepository", {
- get: function() {
- return Pt.ShadersRepository
- },
- set: function(e) {
- Pt.ShadersRepository = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBindObservable", {
- get: function() {
- return this._onBindObservable || (this._onBindObservable = new h),
- this._onBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._useFinalCode = function(e, t, i) {
- if (i) {
- var n = i.vertexElement || i.vertex || i.spectorName || i
- , r = i.fragmentElement || i.fragment || i.spectorName || i;
- this._vertexSourceCode = (this._shaderLanguage === st.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + n + "\n" + e,
- this._fragmentSourceCode = (this._shaderLanguage === st.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + r + "\n" + t
- } else
- this._vertexSourceCode = e,
- this._fragmentSourceCode = t;
- this._prepareEffect()
- }
- ,
- Object.defineProperty(e.prototype, "key", {
- get: function() {
- return this._key
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function() {
- try {
- return this._isReadyInternal()
- } catch (e) {
- return !1
- }
- }
- ,
- e.prototype._isReadyInternal = function() {
- return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady
- }
- ,
- e.prototype.getEngine = function() {
- return this._engine
- }
- ,
- e.prototype.getPipelineContext = function() {
- return this._pipelineContext
- }
- ,
- e.prototype.getAttributesNames = function() {
- return this._attributesNames
- }
- ,
- e.prototype.getAttributeLocation = function(e) {
- return this._attributes[e]
- }
- ,
- e.prototype.getAttributeLocationByName = function(e) {
- return this._attributeLocationByName[e]
- }
- ,
- e.prototype.getAttributesCount = function() {
- return this._attributes.length
- }
- ,
- e.prototype.getUniformIndex = function(e) {
- return this._uniformsNames.indexOf(e)
- }
- ,
- e.prototype.getUniform = function(e) {
- return this._uniforms[e]
- }
- ,
- e.prototype.getSamplers = function() {
- return this._samplerList
- }
- ,
- e.prototype.getUniformNames = function() {
- return this._uniformsNames
- }
- ,
- e.prototype.getUniformBuffersNames = function() {
- return this._uniformBuffersNamesList
- }
- ,
- e.prototype.getIndexParameters = function() {
- return this._indexParameters
- }
- ,
- e.prototype.getCompilationError = function() {
- return this._compilationError
- }
- ,
- e.prototype.allFallbacksProcessed = function() {
- return this._allFallbacksProcessed
- }
- ,
- e.prototype.executeWhenCompiled = function(e) {
- var t = this;
- this.isReady() ? e(this) : (this.onCompileObservable.add((function(t) {
- e(t)
- }
- )),
- this._pipelineContext && !this._pipelineContext.isAsync || setTimeout((function() {
- t._checkIsReady(null)
- }
- ), 16))
- }
- ,
- e.prototype._checkIsReady = function(e) {
- var t = this;
- try {
- if (this._isReadyInternal())
- return
- } catch (t) {
- return void this._processCompilationErrors(t, e)
- }
- setTimeout((function() {
- t._checkIsReady(e)
- }
- ), 16)
- }
- ,
- e.prototype._loadShader = function(e, t, i, n) {
- if ("undefined" != typeof HTMLElement && e instanceof HTMLElement)
- n(at(e));
- else if ("source:" !== e.substr(0, 7))
- if ("base64:" !== e.substr(0, 7)) {
- var r, o = Pt.GetShadersStore(this._shaderLanguage);
- o[e + t + "Shader"] ? n(o[e + t + "Shader"]) : i && o[e + i + "Shader"] ? n(o[e + i + "Shader"]) : (r = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : Pt.GetShadersRepository(this._shaderLanguage) + e,
- this._engine._loadFile(r + "." + t.toLowerCase() + ".fx", n))
- } else
- n(window.atob(e.substr(7)));
- else
- n(e.substr(7))
- }
- ,
- Object.defineProperty(e.prototype, "vertexSourceCode", {
- get: function() {
- var e, t;
- return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._vertexSourceCodeOverride : null !== (t = null === (e = this._pipelineContext) || void 0 === e ? void 0 : e._getVertexShaderCode()) && void 0 !== t ? t : this._vertexSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fragmentSourceCode", {
- get: function() {
- var e, t;
- return this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? this._fragmentSourceCodeOverride : null !== (t = null === (e = this._pipelineContext) || void 0 === e ? void 0 : e._getFragmentShaderCode()) && void 0 !== t ? t : this._fragmentSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rawVertexSourceCode", {
- get: function() {
- return this._rawVertexSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rawFragmentSourceCode", {
- get: function() {
- return this._rawFragmentSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._rebuildProgram = function(e, t, i, n) {
- var r = this;
- this._isReady = !1,
- this._vertexSourceCodeOverride = e,
- this._fragmentSourceCodeOverride = t,
- this.onError = function(e, t) {
- n && n(t)
- }
- ,
- this.onCompiled = function() {
- var e = r.getEngine().scenes;
- if (e)
- for (var t = 0; t < e.length; t++)
- e[t].markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag);
- r._pipelineContext._handlesSpectorRebuildCallback(i)
- }
- ,
- this._fallbacks = null,
- this._prepareEffect()
- }
- ,
- e.prototype._prepareEffect = function() {
- var e = this
- , t = this._attributesNames
- , i = this.defines
- , n = this._pipelineContext;
- this._isReady = !1;
- try {
- var r = this._engine;
- this._pipelineContext = r.createPipelineContext(this._processingContext),
- this._pipelineContext._name = this._key;
- var o = this._rebuildProgram.bind(this);
- this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride ? r._preparePipelineContext(this._pipelineContext, this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, !0, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, null, this._transformFeedbackVaryings, this._key) : r._preparePipelineContext(this._pipelineContext, this._vertexSourceCode, this._fragmentSourceCode, !1, this._rawVertexSourceCode, this._rawFragmentSourceCode, o, i, this._transformFeedbackVaryings, this._key),
- r._executeWhenRenderingStateIsCompiled(this._pipelineContext, (function() {
- if (e._attributes = [],
- e._pipelineContext._fillEffectInformation(e, e._uniformBuffersNames, e._uniformsNames, e._uniforms, e._samplerList, e._samplers, t, e._attributes),
- t)
- for (var i = 0; i < t.length; i++) {
- var o = t[i];
- e._attributeLocationByName[o] = e._attributes[i]
- }
- r.bindSamplers(e),
- e._compilationError = "",
- e._isReady = !0,
- e.onCompiled && e.onCompiled(e),
- e.onCompileObservable.notifyObservers(e),
- e.onCompileObservable.clear(),
- e._fallbacks && e._fallbacks.unBindMesh(),
- n && e.getEngine()._deletePipelineContext(n)
- }
- )),
- this._pipelineContext.isAsync && this._checkIsReady(n)
- } catch (e) {
- this._processCompilationErrors(e, n)
- }
- }
- ,
- e.prototype._getShaderCodeAndErrorLine = function(e, t, i) {
- var n = i ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/
- , r = null;
- if (t && e) {
- var o = t.match(n);
- if (o && 2 === o.length) {
- var a = parseInt(o[1])
- , s = e.split("\n", -1);
- s.length >= a && (r = "Offending line [".concat(a, "] in ").concat(i ? "fragment" : "vertex", " code: ").concat(s[a - 1]))
- }
- }
- return [e, r]
- }
- ,
- e.prototype._processCompilationErrors = function(t, i) {
- var n, r, o, a, s;
- void 0 === i && (i = null),
- this._compilationError = t.message;
- var l = this._attributesNames
- , c = this._fallbacks;
- if (K.Error("Unable to compile effect:"),
- K.Error("Uniforms: " + this._uniformsNames.map((function(e) {
- return " " + e
- }
- ))),
- K.Error("Attributes: " + l.map((function(e) {
- return " " + e
- }
- ))),
- K.Error("Defines:\r\n" + this.defines),
- e.LogShaderCodeOnCompilationError) {
- var u = null
- , h = null
- , d = null;
- (null === (o = this._pipelineContext) || void 0 === o ? void 0 : o._getVertexShaderCode()) && (d = (n = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1))[0],
- u = n[1],
- d && (K.Error("Vertex code:"),
- K.Error(d))),
- (null === (a = this._pipelineContext) || void 0 === a ? void 0 : a._getFragmentShaderCode()) && (d = (r = this._getShaderCodeAndErrorLine(null === (s = this._pipelineContext) || void 0 === s ? void 0 : s._getFragmentShaderCode(), this._compilationError, !0))[0],
- h = r[1],
- d && (K.Error("Fragment code:"),
- K.Error(d))),
- u && K.Error(u),
- h && K.Error(h)
- }
- K.Error("Error: " + this._compilationError),
- i && (this._pipelineContext = i,
- this._isReady = !0,
- this.onError && this.onError(this, this._compilationError),
- this.onErrorObservable.notifyObservers(this)),
- c ? (this._pipelineContext = null,
- c.hasMoreFallbacks ? (this._allFallbacksProcessed = !1,
- K.Error("Trying next fallback."),
- this.defines = c.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(e.prototype, "isSupported", {
- get: function() {
- return "" === this._compilationError
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._bindTexture = function(e, t) {
- this._engine._bindTexture(this._samplers[e], t, e)
- }
- ,
- e.prototype.setTexture = function(e, t) {
- this._engine.setTexture(this._samplers[e], this._uniforms[e], t, e)
- }
- ,
- e.prototype.setDepthStencilTexture = function(e, t) {
- this._engine.setDepthStencilTexture(this._samplers[e], this._uniforms[e], t, e)
- }
- ,
- e.prototype.setTextureArray = function(e, t) {
- var i = e + "Ex";
- if (-1 === this._samplerList.indexOf(i + "0")) {
- for (var n = this._samplerList.indexOf(e), r = 1; r < t.length; r++) {
- var o = i + (r - 1).toString();
- this._samplerList.splice(n + r, 0, o)
- }
- for (var a = 0, s = 0, l = this._samplerList; s < l.length; s++) {
- var c = l[s];
- this._samplers[c] = a,
- a += 1
- }
- }
- this._engine.setTextureArray(this._samplers[e], this._uniforms[e], t, e)
- }
- ,
- e.prototype.setTextureFromPostProcess = function(e, t) {
- this._engine.setTextureFromPostProcess(this._samplers[e], t, e)
- }
- ,
- e.prototype.setTextureFromPostProcessOutput = function(e, t) {
- this._engine.setTextureFromPostProcessOutput(this._samplers[e], t, e)
- }
- ,
- e.prototype.bindUniformBuffer = function(t, i) {
- var n = this._uniformBuffersNames[i];
- void 0 === n || e._BaseCache[n] === t && this._engine._features.useUBOBindingCache || (e._BaseCache[n] = t,
- this._engine.bindUniformBufferBase(t, n, i))
- }
- ,
- e.prototype.bindUniformBlock = function(e, t) {
- this._engine.bindUniformBlock(this._pipelineContext, e, t)
- }
- ,
- e.prototype.setInt = function(e, t) {
- return this._pipelineContext.setInt(e, t),
- this
- }
- ,
- e.prototype.setInt2 = function(e, t, i) {
- return this._pipelineContext.setInt2(e, t, i),
- this
- }
- ,
- e.prototype.setInt3 = function(e, t, i, n) {
- return this._pipelineContext.setInt3(e, t, i, n),
- this
- }
- ,
- e.prototype.setInt4 = function(e, t, i, n, r) {
- return this._pipelineContext.setInt4(e, t, i, n, r),
- this
- }
- ,
- e.prototype.setIntArray = function(e, t) {
- return this._pipelineContext.setIntArray(e, t),
- this
- }
- ,
- e.prototype.setIntArray2 = function(e, t) {
- return this._pipelineContext.setIntArray2(e, t),
- this
- }
- ,
- e.prototype.setIntArray3 = function(e, t) {
- return this._pipelineContext.setIntArray3(e, t),
- this
- }
- ,
- e.prototype.setIntArray4 = function(e, t) {
- return this._pipelineContext.setIntArray4(e, t),
- this
- }
- ,
- e.prototype.setFloatArray = function(e, t) {
- return this._pipelineContext.setArray(e, t),
- this
- }
- ,
- e.prototype.setFloatArray2 = function(e, t) {
- return this._pipelineContext.setArray2(e, t),
- this
- }
- ,
- e.prototype.setFloatArray3 = function(e, t) {
- return this._pipelineContext.setArray3(e, t),
- this
- }
- ,
- e.prototype.setFloatArray4 = function(e, t) {
- return this._pipelineContext.setArray4(e, t),
- this
- }
- ,
- e.prototype.setArray = function(e, t) {
- return this._pipelineContext.setArray(e, t),
- this
- }
- ,
- e.prototype.setArray2 = function(e, t) {
- return this._pipelineContext.setArray2(e, t),
- this
- }
- ,
- e.prototype.setArray3 = function(e, t) {
- return this._pipelineContext.setArray3(e, t),
- this
- }
- ,
- e.prototype.setArray4 = function(e, t) {
- return this._pipelineContext.setArray4(e, t),
- this
- }
- ,
- e.prototype.setMatrices = function(e, t) {
- return this._pipelineContext.setMatrices(e, t),
- this
- }
- ,
- e.prototype.setMatrix = function(e, t) {
- return this._pipelineContext.setMatrix(e, t),
- this
- }
- ,
- e.prototype.setMatrix3x3 = function(e, t) {
- return this._pipelineContext.setMatrix3x3(e, t),
- this
- }
- ,
- e.prototype.setMatrix2x2 = function(e, t) {
- return this._pipelineContext.setMatrix2x2(e, t),
- this
- }
- ,
- e.prototype.setFloat = function(e, t) {
- return this._pipelineContext.setFloat(e, t),
- this
- }
- ,
- e.prototype.setBool = function(e, t) {
- return this._pipelineContext.setInt(e, t ? 1 : 0),
- this
- }
- ,
- e.prototype.setVector2 = function(e, t) {
- return this._pipelineContext.setVector2(e, t),
- this
- }
- ,
- e.prototype.setFloat2 = function(e, t, i) {
- return this._pipelineContext.setFloat2(e, t, i),
- this
- }
- ,
- e.prototype.setVector3 = function(e, t) {
- return this._pipelineContext.setVector3(e, t),
- this
- }
- ,
- e.prototype.setFloat3 = function(e, t, i, n) {
- return this._pipelineContext.setFloat3(e, t, i, n),
- this
- }
- ,
- e.prototype.setVector4 = function(e, t) {
- return this._pipelineContext.setVector4(e, t),
- this
- }
- ,
- e.prototype.setFloat4 = function(e, t, i, n, r) {
- return this._pipelineContext.setFloat4(e, t, i, n, r),
- this
- }
- ,
- e.prototype.setColor3 = function(e, t) {
- return this._pipelineContext.setColor3(e, t),
- this
- }
- ,
- e.prototype.setColor4 = function(e, t, i) {
- return this._pipelineContext.setColor4(e, t, i),
- this
- }
- ,
- e.prototype.setDirectColor4 = function(e, t) {
- return this._pipelineContext.setDirectColor4(e, t),
- this
- }
- ,
- e.prototype.dispose = function() {
- this._pipelineContext && this._pipelineContext.dispose(),
- this._engine._releaseEffect(this)
- }
- ,
- e.RegisterShader = function(e, t, i, n) {
- void 0 === n && (n = st.GLSL),
- t && (Pt.GetShadersStore(n)["".concat(e, "PixelShader")] = t),
- i && (Pt.GetShadersStore(n)["".concat(e, "VertexShader")] = i)
- }
- ,
- e.ResetCache = function() {
- e._BaseCache = {}
- }
- ,
- e.LogShaderCodeOnCompilationError = !0,
- e._UniqueIdSeed = 0,
- e._BaseCache = {},
- e.ShadersStore = Pt.ShadersStore,
- e.IncludesShadersStore = Pt.IncludesShadersStore,
- e
- }(), It = function() {
- function e(e) {
- void 0 === e && (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(e.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(e.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(e.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(e.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(e.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(e.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(e.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(e.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(e.prototype, "frontFace", {
- get: function() {
- return this._frontFace
- },
- set: function(e) {
- this._frontFace !== e && (this._frontFace = e,
- this._isFrontFaceDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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
- }
- ,
- e.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))
- }
- ,
- e
- }(), Ot = function() {
- function e() {
- this.reset()
- }
- return e.prototype.reset = function() {
- this.enabled = !1,
- this.mask = 255,
- this.func = e.ALWAYS,
- this.funcRef = 1,
- this.funcMask = 255,
- this.opStencilFail = e.KEEP,
- this.opDepthFail = e.KEEP,
- this.opStencilDepthPass = e.REPLACE
- }
- ,
- Object.defineProperty(e.prototype, "stencilFunc", {
- get: function() {
- return this.func
- },
- set: function(e) {
- this.func = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilFuncRef", {
- get: function() {
- return this.funcRef
- },
- set: function(e) {
- this.funcRef = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilFuncMask", {
- get: function() {
- return this.funcMask
- },
- set: function(e) {
- this.funcMask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilOpStencilFail", {
- get: function() {
- return this.opStencilFail
- },
- set: function(e) {
- this.opStencilFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilOpDepthFail", {
- get: function() {
- return this.opDepthFail
- },
- set: function(e) {
- this.opDepthFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilOpStencilDepthPass", {
- get: function() {
- return this.opStencilDepthPass
- },
- set: function(e) {
- this.opStencilDepthPass = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilMask", {
- get: function() {
- return this.mask
- },
- set: function(e) {
- this.mask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilTest", {
- get: function() {
- return this.enabled
- },
- set: function(e) {
- this.enabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.ALWAYS = a.ALWAYS,
- e.KEEP = a.KEEP,
- e.REPLACE = a.REPLACE,
- e
- }(), Dt = function() {
- function e() {
- 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(e.prototype, "isDirty", {
- get: function() {
- return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alphaBlend", {
- get: function() {
- return this._alphaBlend
- },
- set: function(e) {
- this._alphaBlend !== e && (this._alphaBlend = e,
- this._isAlphaBlendDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setAlphaBlendConstants = function(e, t, i, n) {
- this._blendConstants[0] === e && this._blendConstants[1] === t && this._blendConstants[2] === i && this._blendConstants[3] === n || (this._blendConstants[0] = e,
- this._blendConstants[1] = t,
- this._blendConstants[2] = i,
- this._blendConstants[3] = n,
- this._isBlendConstantsDirty = !0)
- }
- ,
- e.prototype.setAlphaBlendFunctionParameters = function(e, t, i, n) {
- this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === t && this._blendFunctionParameters[2] === i && this._blendFunctionParameters[3] === n || (this._blendFunctionParameters[0] = e,
- this._blendFunctionParameters[1] = t,
- this._blendFunctionParameters[2] = i,
- this._blendFunctionParameters[3] = n,
- this._isBlendFunctionParametersDirty = !0)
- }
- ,
- e.prototype.setAlphaEquationParameters = function(e, t) {
- this._blendEquationParameters[0] === e && this._blendEquationParameters[1] === t || (this._blendEquationParameters[0] = e,
- this._blendEquationParameters[1] = t,
- this._isBlendEquationParametersDirty = !0)
- }
- ,
- e.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
- }
- ,
- e.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))
- }
- ,
- e
- }(), Nt = function() {
- function e() {
- this.samplingMode = -1,
- this._useMipMaps = !0,
- this._cachedWrapU = null,
- this._cachedWrapV = null,
- this._cachedWrapR = null,
- this._cachedAnisotropicFilteringLevel = null,
- this._comparisonFunction = 0
- }
- return Object.defineProperty(e.prototype, "wrapU", {
- get: function() {
- return this._cachedWrapU
- },
- set: function(e) {
- this._cachedWrapU = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wrapV", {
- get: function() {
- return this._cachedWrapV
- },
- set: function(e) {
- this._cachedWrapV = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wrapR", {
- get: function() {
- return this._cachedWrapR
- },
- set: function(e) {
- this._cachedWrapR = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "anisotropicFilteringLevel", {
- get: function() {
- return this._cachedAnisotropicFilteringLevel
- },
- set: function(e) {
- this._cachedAnisotropicFilteringLevel = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "comparisonFunction", {
- get: function() {
- return this._comparisonFunction
- },
- set: function(e) {
- this._comparisonFunction = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useMipMaps", {
- get: function() {
- return this._useMipMaps
- },
- set: function(e) {
- this._useMipMaps = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setParameters = function(e, t, i, n, r, o) {
- return void 0 === e && (e = a.TEXTURE_WRAP_ADDRESSMODE),
- void 0 === t && (t = a.TEXTURE_WRAP_ADDRESSMODE),
- void 0 === i && (i = a.TEXTURE_WRAP_ADDRESSMODE),
- void 0 === n && (n = 1),
- void 0 === r && (r = a.TEXTURE_BILINEAR_SAMPLINGMODE),
- void 0 === o && (o = 0),
- this._cachedWrapU = e,
- this._cachedWrapV = t,
- this._cachedWrapR = i,
- this._cachedAnisotropicFilteringLevel = n,
- this.samplingMode = r,
- this._comparisonFunction = o,
- this
- }
- ,
- e.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
- }
- ,
- e
- }();
- !function(e) {
- e[e.Unknown = 0] = "Unknown",
- e[e.Url = 1] = "Url",
- e[e.Temp = 2] = "Temp",
- e[e.Raw = 3] = "Raw",
- e[e.Dynamic = 4] = "Dynamic",
- e[e.RenderTarget = 5] = "RenderTarget",
- e[e.MultiRenderTarget = 6] = "MultiRenderTarget",
- e[e.Cube = 7] = "Cube",
- e[e.CubeRaw = 8] = "CubeRaw",
- e[e.CubePrefiltered = 9] = "CubePrefiltered",
- e[e.Raw3D = 10] = "Raw3D",
- e[e.Raw2DArray = 11] = "Raw2DArray",
- e[e.DepthStencil = 12] = "DepthStencil",
- e[e.CubeRawRGBD = 13] = "CubeRawRGBD",
- e[e.Depth = 14] = "Depth"
- }(At || (At = {}));
- var Lt = function(e) {
- function t(i, n, r) {
- void 0 === r && (r = !1);
- var o = e.call(this) || this;
- return o.isReady = !1,
- o.isCube = !1,
- o.is3D = !1,
- o.is2DArray = !1,
- o.isMultiview = !1,
- o.url = "",
- o.generateMipMaps = !1,
- o.samples = 0,
- o.type = -1,
- o.format = -1,
- o.onLoadedObservable = new h,
- o.onErrorObservable = new h,
- o.onRebuildCallback = null,
- o.width = 0,
- o.height = 0,
- o.depth = 0,
- o.baseWidth = 0,
- o.baseHeight = 0,
- o.baseDepth = 0,
- o.invertY = !1,
- o._invertVScale = !1,
- o._associatedChannel = -1,
- o._source = At.Unknown,
- o._buffer = null,
- o._bufferView = null,
- o._bufferViewArray = null,
- o._bufferViewArrayArray = null,
- o._size = 0,
- o._extension = "",
- o._files = null,
- o._workingCanvas = null,
- o._workingContext = null,
- o._cachedCoordinatesMode = null,
- o._isDisabled = !1,
- o._compression = null,
- o._sphericalPolynomial = null,
- o._sphericalPolynomialPromise = null,
- o._sphericalPolynomialComputed = !1,
- o._lodGenerationScale = 0,
- o._lodGenerationOffset = 0,
- o._useSRGBBuffer = !1,
- o._lodTextureHigh = null,
- o._lodTextureMid = null,
- o._lodTextureLow = null,
- o._isRGBD = !1,
- o._linearSpecularLOD = !1,
- o._irradianceTexture = null,
- o._hardwareTexture = null,
- o._maxLodLevel = null,
- o._references = 1,
- o._gammaSpace = null,
- o._engine = i,
- o._source = n,
- o._uniqueId = t._Counter++,
- r || (o._hardwareTexture = i._createHardwareTexture()),
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "useMipMaps", {
- get: function() {
- return this.generateMipMaps
- },
- set: function(e) {
- this.generateMipMaps = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getEngine = function() {
- return this._engine
- }
- ,
- Object.defineProperty(t.prototype, "source", {
- get: function() {
- return this._source
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.incrementReferences = function() {
- this._references++
- }
- ,
- t.prototype.updateSize = function(e, t, i) {
- void 0 === i && (i = 1),
- this._engine.updateTextureDimensions(this, e, t, i),
- this.width = e,
- this.height = t,
- this.depth = i,
- this.baseWidth = e,
- this.baseHeight = t,
- this.baseDepth = i,
- this._size = e * t * i
- }
- ,
- t.prototype._rebuild = function() {
- var e, t = this;
- if (this.isReady = !1,
- this._cachedCoordinatesMode = null,
- this._cachedWrapU = null,
- this._cachedWrapV = null,
- this._cachedWrapR = null,
- this._cachedAnisotropicFilteringLevel = null,
- this.onRebuildCallback) {
- var i = this.onRebuildCallback(this)
- , n = function(e) {
- e._swapAndDie(t, !1),
- t.isReady = i.isReady
- };
- i.isAsync ? i.proxy.then(n) : n(i.proxy)
- } else {
- var r;
- switch (this.source) {
- case At.Temp:
- break;
- case At.Url:
- return void (r = this._engine.createTexture(null !== (e = this._originalUrl) && void 0 !== e ? e : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, (function() {
- r._swapAndDie(t, !1),
- t.isReady = !0
- }
- ), null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer));
- case At.Raw:
- (r = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case At.Raw3D:
- (r = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case At.Raw2DArray:
- (r = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type))._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case At.Dynamic:
- (r = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode))._swapAndDie(this, !1),
- this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
- break;
- case At.Cube:
- return void (r = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, (function() {
- r._swapAndDie(t, !1),
- t.isReady = !0
- }
- ), null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer));
- case At.CubeRaw:
- (r = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression))._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case At.CubeRawRGBD:
- return;
- case At.CubePrefiltered:
- return void ((r = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, (function(e) {
- e && e._swapAndDie(t, !1),
- t.isReady = !0
- }
- ), null, this.format, this._extension))._sphericalPolynomial = this._sphericalPolynomial)
- }
- }
- }
- ,
- t.prototype._swapAndDie = function(e, t) {
- var i;
- void 0 === t && (t = !0),
- null === (i = this._hardwareTexture) || void 0 === i || i.setUsage(e._source, this.generateMipMaps, this.isCube, this.width, this.height),
- e._hardwareTexture = this._hardwareTexture,
- t && (e._isRGBD = this._isRGBD),
- this._lodTextureHigh && (e._lodTextureHigh && e._lodTextureHigh.dispose(),
- e._lodTextureHigh = this._lodTextureHigh),
- this._lodTextureMid && (e._lodTextureMid && e._lodTextureMid.dispose(),
- e._lodTextureMid = this._lodTextureMid),
- this._lodTextureLow && (e._lodTextureLow && e._lodTextureLow.dispose(),
- e._lodTextureLow = this._lodTextureLow),
- this._irradianceTexture && (e._irradianceTexture && e._irradianceTexture.dispose(),
- e._irradianceTexture = this._irradianceTexture);
- var n = this._engine.getLoadedTexturesCache()
- , r = n.indexOf(this);
- -1 !== r && n.splice(r, 1),
- -1 === (r = n.indexOf(e)) && n.push(e)
- }
- ,
- t.prototype.dispose = function() {
- this._references--,
- this.onLoadedObservable.clear(),
- this.onErrorObservable.clear(),
- 0 === this._references && (this._engine._releaseTexture(this),
- this._hardwareTexture = null)
- }
- ,
- t._Counter = 0,
- t
- }(Nt)
- , Ft = function() {
- function e() {
- this.shaderLanguage = st.GLSL
- }
- return e.prototype.postProcessor = function(e, t, i, n, r) {
- return r.getCaps().drawBuffersExtension || (e = e.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g, "")),
- e
- }
- ,
- e
- }()
- , wt = function() {
- function e() {
- this.shaderLanguage = st.GLSL
- }
- return e.prototype.attributeProcessor = function(e) {
- return e.replace("attribute", "in")
- }
- ,
- e.prototype.varyingProcessor = function(e, t) {
- return e.replace("varying", t ? "in" : "out")
- }
- ,
- e.prototype.postProcessor = function(e, t, i) {
- var n = -1 !== e.search(/#extension.+GL_EXT_draw_buffers.+require/);
- if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("),
- i)
- e = (e = (e = (e = (e = (e = (e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/void\s+?main\s*\(/g, (n ? "" : "out vec4 glFragColor;\n") + "void main(");
- else if (-1 !== t.indexOf("#define MULTIVIEW"))
- return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + e;
- return e
- }
- ,
- e
- }()
- , Bt = function() {
- function e() {
- this.references = 0,
- this.capacity = 0,
- this.is32Bits = !1,
- this.uniqueId = e._Counter++
- }
- return Object.defineProperty(e.prototype, "underlyingResource", {
- get: function() {
- return null
- },
- enumerable: !1,
- configurable: !0
- }),
- e._Counter = 0,
- e
- }()
- , Ut = function(e) {
- function t(t) {
- var i = e.call(this) || this;
- return i._buffer = t,
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "underlyingResource", {
- get: function() {
- return this._buffer
- },
- enumerable: !1,
- configurable: !0
- }),
- t
- }(Bt)
- , Vt = function() {
- function e() {
- this._valueCache = {},
- this.vertexCompilationError = null,
- this.fragmentCompilationError = null,
- this.programLinkError = null,
- this.programValidationError = null
- }
- return Object.defineProperty(e.prototype, "isAsync", {
- get: function() {
- return this.isParallelCompiled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isReady", {
- get: function() {
- return !!this.program && (!this.isParallelCompiled || this.engine._isRenderingStateCompiled(this))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._handlesSpectorRebuildCallback = function(e) {
- e && this.program && e(this.program)
- }
- ,
- e.prototype._fillEffectInformation = function(e, t, i, n, r, o, a, s) {
- var l, c = this.engine;
- if (c.supportsUniformBuffers)
- for (var u in t)
- e.bindUniformBlock(u, t[u]);
- for (this.engine.getUniforms(this, i).forEach((function(e, t) {
- n[i[t]] = e
- }
- )),
- this._uniforms = n,
- l = 0; l < r.length; l++)
- null == e.getUniform(r[l]) && (r.splice(l, 1),
- l--);
- r.forEach((function(e, t) {
- o[e] = t
- }
- ));
- for (var h = 0, d = c.getAttributes(this, a); h < d.length; h++) {
- var p = d[h];
- s.push(p)
- }
- }
- ,
- e.prototype.dispose = function() {
- this._uniforms = {}
- }
- ,
- e.prototype._cacheMatrix = function(e, t) {
- var i = this._valueCache[e]
- , n = t.updateFlag;
- return (void 0 === i || i !== n) && (this._valueCache[e] = n,
- !0)
- }
- ,
- e.prototype._cacheFloat2 = function(e, t, i) {
- var n = this._valueCache[e];
- if (!n || 2 !== n.length)
- return n = [t, i],
- this._valueCache[e] = n,
- !0;
- var r = !1;
- return n[0] !== t && (n[0] = t,
- r = !0),
- n[1] !== i && (n[1] = i,
- r = !0),
- r
- }
- ,
- e.prototype._cacheFloat3 = function(e, t, i, n) {
- var r = this._valueCache[e];
- if (!r || 3 !== r.length)
- return r = [t, i, n],
- this._valueCache[e] = r,
- !0;
- var o = !1;
- return r[0] !== t && (r[0] = t,
- o = !0),
- r[1] !== i && (r[1] = i,
- o = !0),
- r[2] !== n && (r[2] = n,
- o = !0),
- o
- }
- ,
- e.prototype._cacheFloat4 = function(e, t, i, n, r) {
- var o = this._valueCache[e];
- if (!o || 4 !== o.length)
- return o = [t, i, n, r],
- this._valueCache[e] = o,
- !0;
- var a = !1;
- return o[0] !== t && (o[0] = t,
- a = !0),
- o[1] !== i && (o[1] = i,
- a = !0),
- o[2] !== n && (o[2] = n,
- a = !0),
- o[3] !== r && (o[3] = r,
- a = !0),
- a
- }
- ,
- e.prototype.setInt = function(e, t) {
- var i = this._valueCache[e];
- void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t)
- }
- ,
- e.prototype.setInt2 = function(e, t, i) {
- this._cacheFloat2(e, t, i) && (this.engine.setInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setInt3 = function(e, t, i, n) {
- this._cacheFloat3(e, t, i, n) && (this.engine.setInt3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setInt4 = function(e, t, i, n, r) {
- this._cacheFloat4(e, t, i, n, r) && (this.engine.setInt4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setIntArray = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray(this._uniforms[e], t)
- }
- ,
- e.prototype.setIntArray2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray2(this._uniforms[e], t)
- }
- ,
- e.prototype.setIntArray3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray3(this._uniforms[e], t)
- }
- ,
- e.prototype.setIntArray4 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray4(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray2(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray3(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray4 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray4(this._uniforms[e], t)
- }
- ,
- e.prototype.setMatrices = function(e, t) {
- t && (this._valueCache[e] = null,
- this.engine.setMatrices(this._uniforms[e], t))
- }
- ,
- e.prototype.setMatrix = function(e, t) {
- this._cacheMatrix(e, t) && (this.engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setMatrix3x3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setMatrix3x3(this._uniforms[e], t)
- }
- ,
- e.prototype.setMatrix2x2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setMatrix2x2(this._uniforms[e], t)
- }
- ,
- e.prototype.setFloat = function(e, t) {
- var i = this._valueCache[e];
- void 0 !== i && i === t || this.engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t)
- }
- ,
- e.prototype.setVector2 = function(e, t) {
- this._cacheFloat2(e, t.x, t.y) && (this.engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setFloat2 = function(e, t, i) {
- this._cacheFloat2(e, t, i) && (this.engine.setFloat2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setVector3 = function(e, t) {
- this._cacheFloat3(e, t.x, t.y, t.z) && (this.engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setFloat3 = function(e, t, i, n) {
- this._cacheFloat3(e, t, i, n) && (this.engine.setFloat3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setVector4 = function(e, t) {
- this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setFloat4 = function(e, t, i, n, r) {
- this._cacheFloat4(e, t, i, n, r) && (this.engine.setFloat4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setColor3 = function(e, t) {
- this._cacheFloat3(e, t.r, t.g, t.b) && (this.engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setColor4 = function(e, t, i) {
- this._cacheFloat4(e, t.r, t.g, t.b, i) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, i) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setDirectColor4 = function(e, t) {
- this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null))
- }
- ,
- e.prototype._getVertexShaderCode = function() {
- return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null
- }
- ,
- e.prototype._getFragmentShaderCode = function() {
- return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null
- }
- ,
- e
- }()
- , kt = function() {
- function e(e, t) {
- if (void 0 === e && (e = null),
- this._MSAARenderBuffer = null,
- this._context = t,
- !e && !(e = t.createTexture()))
- throw new Error("Unable to create webGL texture");
- this.set(e)
- }
- return Object.defineProperty(e.prototype, "underlyingResource", {
- get: function() {
- return this._webGLTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setUsage = function() {}
- ,
- e.prototype.set = function(e) {
- this._webGLTexture = e
- }
- ,
- e.prototype.reset = function() {
- this._webGLTexture = null,
- this._MSAARenderBuffer = null
- }
- ,
- e.prototype.release = function() {
- this._MSAARenderBuffer && (this._context.deleteRenderbuffer(this._MSAARenderBuffer),
- this._MSAARenderBuffer = null),
- this._webGLTexture && this._context.deleteTexture(this._webGLTexture),
- this.reset()
- }
- ,
- e
- }()
- , Gt = function() {
- function e(e, t) {
- void 0 === t && (t = !0),
- this.effect = null,
- this.defines = null,
- this.drawContext = e.createDrawContext(),
- t && (this.materialContext = e.createMaterialContext())
- }
- return e.IsWrapper = function(e) {
- return void 0 === e.getPipelineContext
- }
- ,
- e.GetEffect = function(e) {
- return void 0 === e.getPipelineContext ? e.effect : e
- }
- ,
- e.prototype.setEffect = function(e, t, i) {
- var n;
- void 0 === i && (i = !0),
- this.effect = e,
- void 0 !== t && (this.defines = t),
- i && (null === (n = this.drawContext) || void 0 === n || n.reset())
- }
- ,
- e.prototype.dispose = function() {
- var e;
- null === (e = this.drawContext) || void 0 === e || e.dispose()
- }
- ,
- e
- }()
- , zt = function() {
- function e(e) {
- void 0 === e && (e = !0),
- this._isStencilTestDirty = !1,
- this._isStencilMaskDirty = !1,
- this._isStencilFuncDirty = !1,
- this._isStencilOpDirty = !1,
- this.useStencilGlobalOnly = !1,
- e && this.reset()
- }
- return Object.defineProperty(e.prototype, "isDirty", {
- get: function() {
- return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.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(e.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(e.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(e.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(e.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(e.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(e.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled !== e && (this._enabled = e,
- this._isStencilTestDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reset = function() {
- var e;
- this.stencilMaterial = void 0,
- null === (e = this.stencilGlobal) || void 0 === e || e.reset(),
- this._isStencilTestDirty = !0,
- this._isStencilMaskDirty = !0,
- this._isStencilFuncDirty = !0,
- this._isStencilOpDirty = !0
- }
- ,
- e.prototype.apply = function(e) {
- var t;
- if (e) {
- var i = !this.useStencilGlobalOnly && !!(null === (t = this.stencilMaterial) || void 0 === t ? void 0 : t.enabled);
- this.enabled = i ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
- this.func = i ? this.stencilMaterial.func : this.stencilGlobal.func,
- this.funcRef = i ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
- this.funcMask = i ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
- this.opStencilFail = i ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
- this.opDepthFail = i ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
- this.opStencilDepthPass = i ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
- this.mask = i ? 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))
- }
- }
- ,
- e
- }()
- , Wt = function() {}
- , Ht = function() {
- function e(t, i, n, r) {
- var o = this;
- this._name = "WebGL",
- 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 h,
- 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 h,
- this.onContextRestoredObservable = new h,
- this._contextWasLost = !1,
- this._doNotHandleContextLost = !1,
- this.disableVertexArrayObjects = !1,
- this._colorWrite = !0,
- this._colorWriteChanged = !0,
- this._depthCullingState = new It,
- this._stencilStateComposer = new zt,
- this._stencilState = new Ot,
- this._alphaState = new Dt,
- this._alphaMode = a.ALPHA_ADD,
- this._alphaEquation = a.ALPHA_DISABLE,
- 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._adaptToDeviceRatio = !1,
- this._transformTextureUrl = null,
- this.hostInformation = {
- isMobile: !1
- },
- this.premultipliedAlpha = !0,
- this.onBeforeTextureInitObservable = new h,
- this._isWebGPU = !1,
- this._snapshotRenderingMode = a.SNAPSHOTRENDERING_STANDARD,
- this._viewportCached = {
- x: 0,
- y: 0,
- z: 0,
- w: 0
- },
- this._unpackFlipYCached = null,
- this.enableUnpackFlipYCached = !0,
- this._boundUniforms = {};
- var s = null;
- if (n = n || {},
- this._creationOptions = n,
- this._adaptToDeviceRatio = null != r && r,
- this._stencilStateComposer.stencilGlobal = this._stencilState,
- T.SetMatrixPrecision(!!n.useHighPrecisionMatrix),
- t) {
- if (r = r || n.adaptToDeviceRatio || !1,
- t.getContext) {
- if (s = t,
- this._renderingCanvas = s,
- void 0 !== i && (n.antialias = i),
- void 0 === n.deterministicLockstep && (n.deterministicLockstep = !1),
- void 0 === n.lockstepMaxSteps && (n.lockstepMaxSteps = 4),
- void 0 === n.timeStep && (n.timeStep = 1 / 60),
- void 0 === n.preserveDrawingBuffer && (n.preserveDrawingBuffer = !1),
- void 0 === n.audioEngine && (n.audioEngine = !0),
- void 0 !== n.audioEngineOptions && void 0 !== n.audioEngineOptions.audioContext && (this._audioContext = n.audioEngineOptions.audioContext),
- void 0 !== n.audioEngineOptions && void 0 !== n.audioEngineOptions.audioDestination && (this._audioDestination = n.audioEngineOptions.audioDestination),
- void 0 === n.stencil && (n.stencil = !0),
- !1 === n.premultipliedAlpha && (this.premultipliedAlpha = !1),
- void 0 === n.xrCompatible && (n.xrCompatible = !0),
- this._doNotHandleContextLost = !!n.doNotHandleContextLost,
- navigator && navigator.userAgent) {
- this._checkForMobile = function() {
- var e = navigator.userAgent;
- o.hostInformation.isMobile = -1 !== e.indexOf("Mobile") || -1 !== e.indexOf("Mac") && ot() && "ontouchend"in document
- }
- ,
- this._checkForMobile(),
- nt() && window.addEventListener("resize", this._checkForMobile);
- for (var l = navigator.userAgent, c = 0, u = e.ExceptionList; c < u.length; c++) {
- var d = u[c]
- , p = d.key
- , f = d.targets;
- if (new RegExp(p).test(l)) {
- if (d.capture && d.captureConstraint) {
- var _ = d.capture
- , m = d.captureConstraint
- , g = new RegExp(_).exec(l);
- if (g && g.length > 0 && parseInt(g[g.length - 1]) >= m)
- continue
- }
- for (var v = 0, y = f; v < y.length; v++)
- switch (y[v]) {
- case "uniformBuffer":
- this.disableUniformBuffers = !0;
- break;
- case "vao":
- this.disableVertexArrayObjects = !0
- }
- }
- }
- }
- if (this._doNotHandleContextLost || (this._onContextLost = function(e) {
- e.preventDefault(),
- o._contextWasLost = !0,
- K.Warn("WebGL context lost."),
- o.onContextLostObservable.notifyObservers(o)
- }
- ,
- this._onContextRestored = function() {
- o._restoreEngineAfterContextLost(o._initGLContext.bind(o))
- }
- ,
- s.addEventListener("webglcontextlost", this._onContextLost, !1),
- s.addEventListener("webglcontextrestored", this._onContextRestored, !1),
- n.powerPreference = "high-performance"),
- this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
- this._badDesktopOS && (n.xrCompatible = !1),
- !n.disableWebGL2Support)
- try {
- this._gl = s.getContext("webgl2", n) || s.getContext("experimental-webgl2", n),
- this._gl && (this._webGLVersion = 2,
- this._shaderPlatformName = "WEBGL2",
- this._gl.deleteQuery || (this._webGLVersion = 1,
- this._shaderPlatformName = "WEBGL1"))
- } catch (e) {}
- if (!this._gl) {
- if (!s)
- throw new Error("The provided canvas is null or undefined.");
- try {
- this._gl = s.getContext("webgl", n) || s.getContext("experimental-webgl", n)
- } catch (e) {
- throw new Error("WebGL not supported")
- }
- }
- if (!this._gl)
- throw new Error("WebGL not supported")
- } else {
- this._gl = t,
- this._renderingCanvas = this._gl.canvas,
- this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2,
- this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1";
- var b = this._gl.getContextAttributes();
- b && (n.stencil = b.stencil)
- }
- this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
- void 0 !== n.useHighPrecisionFloats && (this._highPrecisionShadersAllowed = n.useHighPrecisionFloats);
- var E = nt() && window.devicePixelRatio || 1
- , S = n.limitDeviceRatio || E;
- this._hardwareScalingLevel = r ? 1 / Math.min(S, E) : 1,
- this.resize(),
- this._isStencilEnable = !!n.stencil,
- this._initGLContext(),
- this._initFeatures();
- for (var A = 0; A < this._caps.maxVertexAttribs; A++)
- this._currentBufferPointers[A] = new Wt;
- this._shaderProcessor = this.webGLVersion > 1 ? new wt : new Ft,
- this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
- var x = "Babylon.js v".concat(e.Version);
- console.log(x + " - ".concat(this.description)),
- this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", x)
- }
- }
- return Object.defineProperty(e, "NpmPackage", {
- get: function() {
- return "babylonjs@5.0.0-rc.4"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "Version", {
- get: function() {
- return "5.0.0-rc.4"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.prototype, "name", {
- get: function() {
- return this._name
- },
- set: function(e) {
- this._name = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "version", {
- get: function() {
- return this._webGLVersion
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ShadersRepository", {
- get: function() {
- return Mt.ShadersRepository
- },
- set: function(e) {
- Mt.ShadersRepository = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getShaderProcessor = function(e) {
- return this._shaderProcessor
- }
- ,
- Object.defineProperty(e.prototype, "useReverseDepthBuffer", {
- get: function() {
- return this._useReverseDepthBuffer
- },
- set: function(e) {
- e !== this._useReverseDepthBuffer && (this._useReverseDepthBuffer = e,
- this._depthCullingState.depthFunc = e ? a.GEQUAL : a.LEQUAL)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "frameId", {
- get: function() {
- return this._frameId
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportsUniformBuffers", {
- get: function() {
- return this.webGLVersion > 1 && !this.disableUniformBuffers
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getCreationOptions = function() {
- return this._creationOptions
- }
- ,
- Object.defineProperty(e.prototype, "_shouldUseHighPrecisionShader", {
- get: function() {
- return !(!this._caps.highPrecisionShaderSupported || !this._highPrecisionShadersAllowed)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "needPOTTextures", {
- get: function() {
- return this._webGLVersion < 2 || this.forcePOTTextures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "activeRenderLoops", {
- get: function() {
- return this._activeRenderLoops
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "doNotHandleContextLost", {
- get: function() {
- return this._doNotHandleContextLost
- },
- set: function(e) {
- this._doNotHandleContextLost = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_supportsHardwareTextureRescaling", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "framebufferDimensionsObject", {
- set: function(e) {
- this._framebufferDimensionsObject = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentViewport", {
- get: function() {
- return this._cachedViewport
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "emptyTexture", {
- get: function() {
- return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)),
- this._emptyTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "emptyTexture3D", {
- get: function() {
- return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)),
- this._emptyTexture3D
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "emptyTexture2DArray", {
- get: function() {
- return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)),
- this._emptyTexture2DArray
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "emptyCubeTexture", {
- get: function() {
- if (!this._emptyCubeTexture) {
- var e = new Uint8Array(4)
- , t = [e, e, e, e, e, e];
- this._emptyCubeTexture = this.createRawCubeTexture(t, 1, a.TEXTUREFORMAT_RGBA, a.TEXTURETYPE_UNSIGNED_INT, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
- }
- return this._emptyCubeTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isWebGPU", {
- get: function() {
- return this._isWebGPU
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shaderPlatformName", {
- get: function() {
- return this._shaderPlatformName
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "snapshotRendering", {
- get: function() {
- return !1
- },
- set: function(e) {},
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "snapshotRenderingMode", {
- get: function() {
- return this._snapshotRenderingMode
- },
- set: function(e) {
- this._snapshotRenderingMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.snapshotRenderingReset = function() {
- this.snapshotRendering = !1
- }
- ,
- e._CreateCanvas = function(e, t) {
- if ("undefined" == typeof document)
- return new OffscreenCanvas(e,t);
- var i = document.createElement("canvas");
- return i.width = e,
- i.height = t,
- i
- }
- ,
- e.prototype.createCanvas = function(t, i) {
- return e._CreateCanvas(t, i)
- }
- ,
- e.prototype.createCanvasImage = function() {
- return document.createElement("img")
- }
- ,
- e.prototype._restoreEngineAfterContextLost = function(e) {
- var t = this;
- setTimeout((function() {
- return G(t, void 0, void 0, (function() {
- var t, i, n, r, o;
- return z(this, (function(a) {
- switch (a.label) {
- case 0:
- return this._dummyFramebuffer = null,
- t = this._depthCullingState.depthTest,
- i = this._depthCullingState.depthFunc,
- n = this._depthCullingState.depthMask,
- r = this._stencilState.stencilTest,
- [4, e()];
- case 1:
- return a.sent(),
- this._rebuildEffects(),
- null === (o = this._rebuildComputeEffects) || void 0 === o || o.call(this),
- this._rebuildInternalTextures(),
- this._rebuildRenderTargetWrappers(),
- this._rebuildBuffers(),
- this.wipeCaches(!0),
- this._depthCullingState.depthTest = t,
- this._depthCullingState.depthFunc = i,
- this._depthCullingState.depthMask = n,
- this._stencilState.stencilTest = r,
- K.Warn(this.name + " context successfully restored."),
- this.onContextRestoredObservable.notifyObservers(this),
- this._contextWasLost = !1,
- [2]
- }
- }
- ))
- }
- ))
- }
- ), 0)
- }
- ,
- e.prototype._sharedInit = function(e, t, i) {
- this._renderingCanvas = e
- }
- ,
- e.prototype._getShaderProcessingContext = function(e) {
- return null
- }
- ,
- e.prototype._rebuildInternalTextures = function() {
- for (var e = 0, t = this._internalTexturesCache.slice(); e < t.length; e++)
- t[e]._rebuild()
- }
- ,
- e.prototype._rebuildRenderTargetWrappers = function() {
- for (var e = 0, t = this._renderTargetWrapperCache.slice(); e < t.length; e++)
- t[e]._rebuild()
- }
- ,
- e.prototype._rebuildEffects = function() {
- for (var e in this._compiledEffects) {
- var t = this._compiledEffects[e];
- t._pipelineContext = null,
- t._wasPreviouslyReady = !1,
- t._prepareEffect()
- }
- Mt.ResetCache()
- }
- ,
- e.prototype.areAllEffectsReady = function() {
- for (var e in this._compiledEffects)
- if (!this._compiledEffects[e].isReady())
- return !1;
- return !0
- }
- ,
- e.prototype._rebuildBuffers = function() {
- for (var e = 0, t = this._uniformBuffers; e < t.length; e++)
- t[e]._rebuild();
- for (var i = 0, n = this._storageBuffers; i < n.length; i++)
- n[i]._rebuild()
- }
- ,
- e.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 || null !== this._gl.getExtension("OES_standard_derivatives"),
- 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 || null !== this._gl.getExtension("OES_element_index_uint"),
- fragmentDepthSupported: this._webGLVersion > 1 || null !== this._gl.getExtension("EXT_frag_depth"),
- 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,
- supportTransformFeedbacks: this._webGLVersion > 1,
- textureMaxLevel: this._webGLVersion > 1
- },
- this._glVersion = this._gl.getParameter(this._gl.VERSION);
- var e = this._gl.getExtension("WEBGL_debug_renderer_info");
- if (null != e && (this._glRenderer = this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),
- this._glVendor = this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),
- this._glVendor || (this._glVendor = this._gl.getParameter(this._gl.VENDOR) || "Unknown vendor"),
- this._glRenderer || (this._glRenderer = this._gl.getParameter(this._gl.RENDERER) || "Unknown renderer"),
- 36193 !== this._gl.HALF_FLOAT_OES && (this._gl.HALF_FLOAT_OES = 36193),
- 34842 !== this._gl.RGBA16F && (this._gl.RGBA16F = 34842),
- 34836 !== this._gl.RGBA32F && (this._gl.RGBA32F = 34836),
- 35056 !== this._gl.DEPTH24_STENCIL8 && (this._gl.DEPTH24_STENCIL8 = 35056),
- this._caps.timerQuery && (1 === this._webGLVersion && (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 && 5131 !== this._gl.HALF_FLOAT_OES && (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 t = this._gl.getExtension("WEBGL_draw_buffers");
- if (null !== t) {
- this._caps.drawBuffersExtension = !0,
- this._gl.drawBuffers = t.drawBuffersWEBGL.bind(t),
- this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
- for (var i = 0; i < 16; i++)
- this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = t["COLOR_ATTACHMENT" + i + "_WEBGL"]
- }
- }
- if (this._webGLVersion > 1)
- this._caps.depthTextureExtension = !0;
- else {
- var n = this._gl.getExtension("WEBGL_depth_texture");
- null != n && (this._caps.depthTextureExtension = !0,
- this._gl.UNSIGNED_INT_24_8 = n.UNSIGNED_INT_24_8_WEBGL)
- }
- if (this.disableVertexArrayObjects)
- this._caps.vertexArrayObject = !1;
- else if (this._webGLVersion > 1)
- this._caps.vertexArrayObject = !0;
- else {
- var r = this._gl.getExtension("OES_vertex_array_object");
- null != r && (this._caps.vertexArrayObject = !0,
- this._gl.createVertexArray = r.createVertexArrayOES.bind(r),
- this._gl.bindVertexArray = r.bindVertexArrayOES.bind(r),
- this._gl.deleteVertexArray = r.deleteVertexArrayOES.bind(r))
- }
- if (this._webGLVersion > 1)
- this._caps.instancedArrays = !0;
- else {
- var o = this._gl.getExtension("ANGLE_instanced_arrays");
- null != o ? (this._caps.instancedArrays = !0,
- this._gl.drawArraysInstanced = o.drawArraysInstancedANGLE.bind(o),
- this._gl.drawElementsInstanced = o.drawElementsInstancedANGLE.bind(o),
- this._gl.vertexAttribDivisor = o.vertexAttribDivisorANGLE.bind(o)) : this._caps.instancedArrays = !1
- }
- if (this._gl.getShaderPrecisionFormat) {
- var a = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT)
- , s = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
- a && s && (this._caps.highPrecisionShaderSupported = 0 !== a.precision && 0 !== s.precision)
- }
- if (this._webGLVersion > 1)
- this._caps.blendMinMax = !0;
- else {
- var l = this._gl.getExtension("EXT_blend_minmax");
- null != l && (this._caps.blendMinMax = !0,
- this._gl.MAX = l.MAX_EXT,
- this._gl.MIN = l.MIN_EXT)
- }
- if (!this._caps.supportSRGBBuffers) {
- if (this._webGLVersion > 1)
- this._caps.supportSRGBBuffers = !0;
- else {
- var c = this._gl.getExtension("EXT_sRGB");
- null != c && (this._caps.supportSRGBBuffers = !0,
- this._gl.SRGB = c.SRGB_EXT,
- this._gl.SRGB8 = c.SRGB_ALPHA_EXT,
- this._gl.SRGB8_ALPHA8 = c.SRGB_ALPHA_EXT)
- }
- this._caps.supportSRGBBuffers = this._caps.supportSRGBBuffers && !(!this._creationOptions || !this._creationOptions.forceSRGBBufferSupportState)
- }
- this._depthCullingState.depthTest = !0,
- this._depthCullingState.depthFunc = this._gl.LEQUAL,
- this._depthCullingState.depthMask = !0,
- this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
- for (var u = 0; u < this._maxSimultaneousTextures; u++)
- this._nextFreeTextureSlots.push(u)
- }
- ,
- e.prototype._initFeatures = function() {
- this._features = {
- forceBitmapOverHTMLImageElement: !1,
- supportRenderAndCopyToLodForFloatTextures: 1 !== this._webGLVersion,
- supportDepthStencilTexture: 1 !== this._webGLVersion,
- supportShadowSamplers: 1 !== this._webGLVersion,
- uniformBufferHardCheckMatrix: !1,
- allowTexturePrefiltering: 1 !== this._webGLVersion,
- trackUbosInFrame: !1,
- checkUbosContentBeforeUpload: !1,
- supportCSM: 1 !== this._webGLVersion,
- basisNeedsPOT: 1 === this._webGLVersion,
- support3DTextures: 1 !== this._webGLVersion,
- needTypeSuffixInShaderConstants: 1 !== this._webGLVersion,
- supportMSAA: 1 !== this._webGLVersion,
- supportSSAO2: 1 !== this._webGLVersion,
- supportExtendedTextureFormats: 1 !== this._webGLVersion,
- supportSwitchCaseInShader: 1 !== this._webGLVersion,
- supportSyncTextureRead: !0,
- needsInvertingBitmap: !0,
- useUBOBindingCache: !0,
- needShaderCodeInlining: !1,
- needToAlwaysBindUniformBuffers: !1,
- supportRenderPasses: !1,
- _collectUbosUpdatedInFrame: !1
- }
- }
- ,
- Object.defineProperty(e.prototype, "webGLVersion", {
- get: function() {
- return this._webGLVersion
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ThinEngine"
- }
- ,
- Object.defineProperty(e.prototype, "isStencilEnable", {
- get: function() {
- return this._isStencilEnable
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._prepareWorkingCanvas = function() {
- if (!this._workingCanvas) {
- this._workingCanvas = this.createCanvas(1, 1);
- var e = this._workingCanvas.getContext("2d");
- e && (this._workingContext = e)
- }
- }
- ,
- e.prototype.resetTextureCache = function() {
- for (var e in this._boundTexturesCache)
- Object.prototype.hasOwnProperty.call(this._boundTexturesCache, e) && (this._boundTexturesCache[e] = null);
- this._currentTextureChannel = -1
- }
- ,
- e.prototype.getInfo = function() {
- return this.getGlInfo()
- }
- ,
- e.prototype.getGlInfo = function() {
- return {
- vendor: this._glVendor,
- renderer: this._glRenderer,
- version: this._glVersion
- }
- }
- ,
- e.prototype.setHardwareScalingLevel = function(e) {
- this._hardwareScalingLevel = e,
- this.resize()
- }
- ,
- e.prototype.getHardwareScalingLevel = function() {
- return this._hardwareScalingLevel
- }
- ,
- e.prototype.getLoadedTexturesCache = function() {
- return this._internalTexturesCache
- }
- ,
- e.prototype.getCaps = function() {
- return this._caps
- }
- ,
- e.prototype.stopRenderLoop = function(e) {
- if (e) {
- var t = this._activeRenderLoops.indexOf(e);
- t >= 0 && this._activeRenderLoops.splice(t, 1)
- } else
- this._activeRenderLoops = []
- }
- ,
- e.prototype._renderLoop = function() {
- if (!this._contextWasLost) {
- var e = !0;
- if (!this.renderEvenInBackground && this._windowIsBackground && (e = !1),
- e) {
- this.beginFrame();
- for (var t = 0; t < this._activeRenderLoops.length; t++)
- (0,
- this._activeRenderLoops[t])();
- this.endFrame()
- }
- }
- this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
- }
- ,
- e.prototype.getRenderingCanvas = function() {
- return this._renderingCanvas
- }
- ,
- e.prototype.getAudioContext = function() {
- return this._audioContext
- }
- ,
- e.prototype.getAudioDestination = function() {
- return this._audioDestination
- }
- ,
- e.prototype.getHostWindow = function() {
- return nt() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null
- }
- ,
- e.prototype.getRenderWidth = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth
- }
- ,
- e.prototype.getRenderHeight = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight
- }
- ,
- e.prototype._queueNewFrame = function(t, i) {
- return e.QueueNewFrame(t, i)
- }
- ,
- e.prototype.runRenderLoop = function(e) {
- -1 === this._activeRenderLoops.indexOf(e) && (this._activeRenderLoops.push(e),
- this._renderingQueueLaunched || (this._renderingQueueLaunched = !0,
- this._boundRenderFunction = this._renderLoop.bind(this),
- this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())))
- }
- ,
- e.prototype.clear = function(e, t, i, n) {
- void 0 === n && (n = !1);
- var r = this.stencilStateComposer.useStencilGlobalOnly;
- this.stencilStateComposer.useStencilGlobalOnly = !0,
- this.applyStates(),
- this.stencilStateComposer.useStencilGlobalOnly = r;
- var o = 0;
- t && e && (this._gl.clearColor(e.r, e.g, e.b, void 0 !== e.a ? e.a : 1),
- o |= this._gl.COLOR_BUFFER_BIT),
- i && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL,
- this._gl.clearDepth(0)) : this._gl.clearDepth(1),
- o |= this._gl.DEPTH_BUFFER_BIT),
- n && (this._gl.clearStencil(0),
- o |= this._gl.STENCIL_BUFFER_BIT),
- this._gl.clear(o)
- }
- ,
- e.prototype._viewport = function(e, t, i, n) {
- e === this._viewportCached.x && t === this._viewportCached.y && i === this._viewportCached.z && n === this._viewportCached.w || (this._viewportCached.x = e,
- this._viewportCached.y = t,
- this._viewportCached.z = i,
- this._viewportCached.w = n,
- this._gl.viewport(e, t, i, n))
- }
- ,
- e.prototype.setViewport = function(e, t, i) {
- var n = t || this.getRenderWidth()
- , r = i || this.getRenderHeight()
- , o = e.x || 0
- , a = e.y || 0;
- this._cachedViewport = e,
- this._viewport(o * n, a * r, n * e.width, r * e.height)
- }
- ,
- e.prototype.beginFrame = function() {}
- ,
- e.prototype.endFrame = function() {
- this._badOS && this.flushFramebuffer(),
- this._frameId++
- }
- ,
- e.prototype.resize = function(e) {
- var t, i;
- if (void 0 === e && (e = !1),
- this._adaptToDeviceRatio) {
- var n = nt() && window.devicePixelRatio || 1
- , r = this._creationOptions.limitDeviceRatio || n;
- this._hardwareScalingLevel = this._adaptToDeviceRatio ? 1 / Math.min(r, n) : 1
- }
- nt() ? (t = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth,
- i = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (t = this._renderingCanvas ? this._renderingCanvas.width : 100,
- i = this._renderingCanvas ? this._renderingCanvas.height : 100),
- this.setSize(t / this._hardwareScalingLevel, i / this._hardwareScalingLevel, e)
- }
- ,
- e.prototype.setSize = function(e, t, i) {
- return void 0 === i && (i = !1),
- !(!this._renderingCanvas || (e |= 0,
- t |= 0,
- !i && this._renderingCanvas.width === e && this._renderingCanvas.height === t || (this._renderingCanvas.width = e,
- this._renderingCanvas.height = t,
- 0)))
- }
- ,
- e.prototype.bindFramebuffer = function(e, t, i, n, r, o, a) {
- var s, l, c, u, h;
- void 0 === t && (t = 0),
- void 0 === o && (o = 0),
- void 0 === a && (a = 0);
- var d = e;
- this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
- this._currentRenderTarget = e,
- this._bindUnboundFramebuffer(d._MSAAFramebuffer ? d._MSAAFramebuffer : d._framebuffer);
- var p = this._gl;
- e.is2DArray ? p.framebufferTextureLayer(p.FRAMEBUFFER, p.COLOR_ATTACHMENT0, null === (s = e.texture._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource, o, a) : e.isCube && p.framebufferTexture2D(p.FRAMEBUFFER, p.COLOR_ATTACHMENT0, p.TEXTURE_CUBE_MAP_POSITIVE_X + t, null === (l = e.texture._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource, o);
- var f = e._depthStencilTexture;
- if (f) {
- var _ = e._depthStencilTextureWithStencil ? p.DEPTH_STENCIL_ATTACHMENT : p.DEPTH_ATTACHMENT;
- e.is2DArray ? p.framebufferTextureLayer(p.FRAMEBUFFER, _, null === (c = f._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource, o, a) : e.isCube ? p.framebufferTexture2D(p.FRAMEBUFFER, _, p.TEXTURE_CUBE_MAP_POSITIVE_X + t, null === (u = f._hardwareTexture) || void 0 === u ? void 0 : u.underlyingResource, o) : p.framebufferTexture2D(p.FRAMEBUFFER, _, p.TEXTURE_2D, null === (h = f._hardwareTexture) || void 0 === h ? void 0 : h.underlyingResource, o)
- }
- this._cachedViewport && !r ? this.setViewport(this._cachedViewport, i, n) : (i || (i = e.width,
- o && (i /= Math.pow(2, o))),
- n || (n = e.height,
- o && (n /= Math.pow(2, o))),
- this._viewport(0, 0, i, n)),
- this.wipeCaches()
- }
- ,
- e.prototype.setState = function(e, t, i, n, r, o, a) {
- var s, l;
- void 0 === t && (t = 0),
- void 0 === n && (n = !1),
- void 0 === a && (a = 0),
- (this._depthCullingState.cull !== e || i) && (this._depthCullingState.cull = e);
- var c = null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : r) || void 0 === l || l ? this._gl.BACK : this._gl.FRONT;
- (this._depthCullingState.cullFace !== c || i) && (this._depthCullingState.cullFace = c),
- this.setZOffset(t),
- this.setZOffsetUnits(a);
- var u = n ? this._gl.CW : this._gl.CCW;
- (this._depthCullingState.frontFace !== u || i) && (this._depthCullingState.frontFace = u),
- this._stencilStateComposer.stencilMaterial = o
- }
- ,
- e.prototype.setZOffset = function(e) {
- this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -e : e
- }
- ,
- e.prototype.getZOffset = function() {
- var e = this._depthCullingState.zOffset;
- return this.useReverseDepthBuffer ? -e : e
- }
- ,
- e.prototype.setZOffsetUnits = function(e) {
- this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -e : e
- }
- ,
- e.prototype.getZOffsetUnits = function() {
- var e = this._depthCullingState.zOffsetUnits;
- return this.useReverseDepthBuffer ? -e : e
- }
- ,
- e.prototype._bindUnboundFramebuffer = function(e) {
- this._currentFramebuffer !== e && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, e),
- this._currentFramebuffer = e)
- }
- ,
- e.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
- return null === this._currentFramebuffer
- }
- ,
- e.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)
- }
- ,
- e.prototype.unBindFramebuffer = function(e, t, i) {
- var n;
- void 0 === t && (t = !1);
- var r = e;
- this._currentRenderTarget = null;
- var o = this._gl;
- if (r._MSAAFramebuffer) {
- if (e.isMulti)
- return void this.unBindMultiColorAttachmentFramebuffer(e, t, i);
- o.bindFramebuffer(o.READ_FRAMEBUFFER, r._MSAAFramebuffer),
- o.bindFramebuffer(o.DRAW_FRAMEBUFFER, r._framebuffer),
- o.blitFramebuffer(0, 0, e.width, e.height, 0, 0, e.width, e.height, o.COLOR_BUFFER_BIT, o.NEAREST)
- }
- !(null === (n = e.texture) || void 0 === n ? void 0 : n.generateMipMaps) || t || e.isCube || this.generateMipmaps(e.texture),
- i && (r._MSAAFramebuffer && this._bindUnboundFramebuffer(r._framebuffer),
- i()),
- this._bindUnboundFramebuffer(null)
- }
- ,
- e.prototype.flushFramebuffer = function() {
- this._gl.flush()
- }
- ,
- e.prototype.restoreDefaultFramebuffer = function() {
- this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null),
- this._cachedViewport && this.setViewport(this._cachedViewport),
- this.wipeCaches()
- }
- ,
- e.prototype._resetVertexBufferBinding = function() {
- this.bindArrayBuffer(null),
- this._cachedVertexBuffers = null
- }
- ,
- e.prototype.createVertexBuffer = function(e) {
- return this._createVertexBuffer(e, this._gl.STATIC_DRAW)
- }
- ,
- e.prototype._createVertexBuffer = function(e, t) {
- var i = this._gl.createBuffer();
- if (!i)
- throw new Error("Unable to create vertex buffer");
- var n = new Ut(i);
- return this.bindArrayBuffer(n),
- e instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(e), t) : this._gl.bufferData(this._gl.ARRAY_BUFFER, e, t),
- this._resetVertexBufferBinding(),
- n.references = 1,
- n
- }
- ,
- e.prototype.createDynamicVertexBuffer = function(e) {
- return this._createVertexBuffer(e, this._gl.DYNAMIC_DRAW)
- }
- ,
- e.prototype._resetIndexBufferBinding = function() {
- this.bindIndexBuffer(null),
- this._cachedIndexBuffer = null
- }
- ,
- e.prototype.createIndexBuffer = function(e, t) {
- var i = this._gl.createBuffer()
- , n = new Ut(i);
- if (!i)
- throw new Error("Unable to create index buffer");
- this.bindIndexBuffer(n);
- var r = this._normalizeIndexData(e);
- return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, r, t ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW),
- this._resetIndexBufferBinding(),
- n.references = 1,
- n.is32Bits = 4 === r.BYTES_PER_ELEMENT,
- n
- }
- ,
- e.prototype._normalizeIndexData = function(e) {
- if (2 === e.BYTES_PER_ELEMENT)
- return e;
- if (this._caps.uintIndices) {
- if (e instanceof Uint32Array)
- return e;
- for (var t = 0; t < e.length; t++)
- if (e[t] >= 65535)
- return new Uint32Array(e);
- return new Uint16Array(e)
- }
- return new Uint16Array(e)
- }
- ,
- e.prototype.bindArrayBuffer = function(e) {
- this._vaoRecordInProgress || this._unbindVertexArrayObject(),
- this._bindBuffer(e, this._gl.ARRAY_BUFFER)
- }
- ,
- e.prototype.bindUniformBlock = function(e, t, i) {
- var n = e.program
- , r = this._gl.getUniformBlockIndex(n, t);
- this._gl.uniformBlockBinding(n, r, i)
- }
- ,
- e.prototype.bindIndexBuffer = function(e) {
- this._vaoRecordInProgress || this._unbindVertexArrayObject(),
- this._bindBuffer(e, this._gl.ELEMENT_ARRAY_BUFFER)
- }
- ,
- e.prototype._bindBuffer = function(e, t) {
- (this._vaoRecordInProgress || this._currentBoundBuffer[t] !== e) && (this._gl.bindBuffer(t, e ? e.underlyingResource : null),
- this._currentBoundBuffer[t] = e)
- }
- ,
- e.prototype.updateArrayBuffer = function(e) {
- this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)
- }
- ,
- e.prototype._vertexAttribPointer = function(e, t, i, n, r, o, a) {
- var s = this._currentBufferPointers[t];
- if (s) {
- var l = !1;
- s.active ? (s.buffer !== e && (s.buffer = e,
- l = !0),
- s.size !== i && (s.size = i,
- l = !0),
- s.type !== n && (s.type = n,
- l = !0),
- s.normalized !== r && (s.normalized = r,
- l = !0),
- s.stride !== o && (s.stride = o,
- l = !0),
- s.offset !== a && (s.offset = a,
- l = !0)) : (l = !0,
- s.active = !0,
- s.index = t,
- s.size = i,
- s.type = n,
- s.normalized = r,
- s.stride = o,
- s.offset = a,
- s.buffer = e),
- (l || this._vaoRecordInProgress) && (this.bindArrayBuffer(e),
- this._gl.vertexAttribPointer(t, i, n, r, o, a))
- }
- }
- ,
- e.prototype._bindIndexBufferWithCache = function(e) {
- null != e && this._cachedIndexBuffer !== e && (this._cachedIndexBuffer = e,
- this.bindIndexBuffer(e),
- this._uintIndicesCurrentlySet = e.is32Bits)
- }
- ,
- e.prototype._bindVertexBuffersAttributes = function(e, t, i) {
- var n = t.getAttributesNames();
- this._vaoRecordInProgress || this._unbindVertexArrayObject(),
- this.unbindAllAttributes();
- for (var r = 0; r < n.length; r++) {
- var o = t.getAttributeLocation(r);
- if (o >= 0) {
- var a = n[r]
- , s = null;
- if (i && (s = i[a]),
- s || (s = e[a]),
- !s)
- continue;
- this._gl.enableVertexAttribArray(o),
- this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[o] = !0);
- var l = s.getBuffer();
- l && (this._vertexAttribPointer(l, o, s.getSize(), s.type, s.normalized, s.byteStride, s.byteOffset),
- s.getIsInstanced() && (this._gl.vertexAttribDivisor(o, s.getInstanceDivisor()),
- this._vaoRecordInProgress || (this._currentInstanceLocations.push(o),
- this._currentInstanceBuffers.push(l))))
- }
- }
- }
- ,
- e.prototype.recordVertexArrayObject = function(e, t, i, n) {
- var r = this._gl.createVertexArray();
- return this._vaoRecordInProgress = !0,
- this._gl.bindVertexArray(r),
- this._mustWipeVertexAttributes = !0,
- this._bindVertexBuffersAttributes(e, i, n),
- this.bindIndexBuffer(t),
- this._vaoRecordInProgress = !1,
- this._gl.bindVertexArray(null),
- r
- }
- ,
- e.prototype.bindVertexArrayObject = function(e, t) {
- this._cachedVertexArrayObject !== e && (this._cachedVertexArrayObject = e,
- this._gl.bindVertexArray(e),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._uintIndicesCurrentlySet = null != t && t.is32Bits,
- this._mustWipeVertexAttributes = !0)
- }
- ,
- e.prototype.bindBuffersDirectly = function(e, t, i, n, r) {
- if (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== r) {
- this._cachedVertexBuffers = e,
- this._cachedEffectForVertexBuffers = r;
- var o = r.getAttributesCount();
- this._unbindVertexArrayObject(),
- this.unbindAllAttributes();
- for (var a = 0, s = 0; s < o; s++)
- if (s < i.length) {
- var l = r.getAttributeLocation(s);
- l >= 0 && (this._gl.enableVertexAttribArray(l),
- this._vertexAttribArraysEnabled[l] = !0,
- this._vertexAttribPointer(e, l, i[s], this._gl.FLOAT, !1, n, a)),
- a += 4 * i[s]
- }
- }
- this._bindIndexBufferWithCache(t)
- }
- ,
- e.prototype._unbindVertexArrayObject = function() {
- this._cachedVertexArrayObject && (this._cachedVertexArrayObject = null,
- this._gl.bindVertexArray(null))
- }
- ,
- e.prototype.bindBuffers = function(e, t, i, n) {
- this._cachedVertexBuffers === e && this._cachedEffectForVertexBuffers === i || (this._cachedVertexBuffers = e,
- this._cachedEffectForVertexBuffers = i,
- this._bindVertexBuffersAttributes(e, i, n)),
- this._bindIndexBufferWithCache(t)
- }
- ,
- e.prototype.unbindInstanceAttributes = function() {
- for (var e, t = 0, i = this._currentInstanceLocations.length; t < i; t++) {
- var n = this._currentInstanceBuffers[t];
- e != n && n.references && (e = n,
- this.bindArrayBuffer(n));
- var r = this._currentInstanceLocations[t];
- this._gl.vertexAttribDivisor(r, 0)
- }
- this._currentInstanceBuffers.length = 0,
- this._currentInstanceLocations.length = 0
- }
- ,
- e.prototype.releaseVertexArrayObject = function(e) {
- this._gl.deleteVertexArray(e)
- }
- ,
- e.prototype._releaseBuffer = function(e) {
- return e.references--,
- 0 === e.references && (this._deleteBuffer(e),
- !0)
- }
- ,
- e.prototype._deleteBuffer = function(e) {
- this._gl.deleteBuffer(e.underlyingResource)
- }
- ,
- e.prototype.updateAndBindInstancesBuffer = function(e, t, i) {
- if (this.bindArrayBuffer(e),
- t && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t),
- void 0 !== i[0].index)
- this.bindInstancesBuffer(e, i, !0);
- else
- for (var n = 0; n < 4; n++) {
- var r = i[n];
- this._vertexAttribArraysEnabled[r] || (this._gl.enableVertexAttribArray(r),
- this._vertexAttribArraysEnabled[r] = !0),
- this._vertexAttribPointer(e, r, 4, this._gl.FLOAT, !1, 64, 16 * n),
- this._gl.vertexAttribDivisor(r, 1),
- this._currentInstanceLocations.push(r),
- this._currentInstanceBuffers.push(e)
- }
- }
- ,
- e.prototype.bindInstancesBuffer = function(e, t, i) {
- void 0 === i && (i = !0),
- this.bindArrayBuffer(e);
- var n = 0;
- if (i)
- for (var r = 0; r < t.length; r++)
- n += 4 * (o = t[r]).attributeSize;
- for (r = 0; r < t.length; r++) {
- var o;
- void 0 === (o = t[r]).index && (o.index = this._currentEffect.getAttributeLocationByName(o.attributeName)),
- o.index < 0 || (this._vertexAttribArraysEnabled[o.index] || (this._gl.enableVertexAttribArray(o.index),
- this._vertexAttribArraysEnabled[o.index] = !0),
- this._vertexAttribPointer(e, o.index, o.attributeSize, o.attributeType || this._gl.FLOAT, o.normalized || !1, n, o.offset),
- this._gl.vertexAttribDivisor(o.index, void 0 === o.divisor ? 1 : o.divisor),
- this._currentInstanceLocations.push(o.index),
- this._currentInstanceBuffers.push(e))
- }
- }
- ,
- e.prototype.disableInstanceAttributeByName = function(e) {
- if (this._currentEffect) {
- var t = this._currentEffect.getAttributeLocationByName(e);
- this.disableInstanceAttribute(t)
- }
- }
- ,
- e.prototype.disableInstanceAttribute = function(e) {
- for (var t, i = !1; -1 !== (t = this._currentInstanceLocations.indexOf(e)); )
- this._currentInstanceLocations.splice(t, 1),
- this._currentInstanceBuffers.splice(t, 1),
- i = !0,
- t = this._currentInstanceLocations.indexOf(e);
- i && (this._gl.vertexAttribDivisor(e, 0),
- this.disableAttributeByIndex(e))
- }
- ,
- e.prototype.disableAttributeByIndex = function(e) {
- this._gl.disableVertexAttribArray(e),
- this._vertexAttribArraysEnabled[e] = !1,
- this._currentBufferPointers[e].active = !1
- }
- ,
- e.prototype.draw = function(e, t, i, n) {
- this.drawElementsType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, n)
- }
- ,
- e.prototype.drawPointClouds = function(e, t, i) {
- this.drawArraysType(a.MATERIAL_PointFillMode, e, t, i)
- }
- ,
- e.prototype.drawUnIndexed = function(e, t, i, n) {
- this.drawArraysType(e ? a.MATERIAL_TriangleFillMode : a.MATERIAL_WireFrameFillMode, t, i, n)
- }
- ,
- e.prototype.drawElementsType = function(e, t, i, n) {
- this.applyStates(),
- this._reportDrawCall();
- var r = this._drawMode(e)
- , o = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT
- , a = this._uintIndicesCurrentlySet ? 4 : 2;
- n ? this._gl.drawElementsInstanced(r, i, o, t * a, n) : this._gl.drawElements(r, i, o, t * a)
- }
- ,
- e.prototype.drawArraysType = function(e, t, i, n) {
- this.applyStates(),
- this._reportDrawCall();
- var r = this._drawMode(e);
- n ? this._gl.drawArraysInstanced(r, t, i, n) : this._gl.drawArrays(r, t, i)
- }
- ,
- e.prototype._drawMode = function(e) {
- switch (e) {
- case a.MATERIAL_TriangleFillMode:
- return this._gl.TRIANGLES;
- case a.MATERIAL_PointFillMode:
- return this._gl.POINTS;
- case a.MATERIAL_WireFrameFillMode:
- return this._gl.LINES;
- case a.MATERIAL_PointListDrawMode:
- return this._gl.POINTS;
- case a.MATERIAL_LineListDrawMode:
- return this._gl.LINES;
- case a.MATERIAL_LineLoopDrawMode:
- return this._gl.LINE_LOOP;
- case a.MATERIAL_LineStripDrawMode:
- return this._gl.LINE_STRIP;
- case a.MATERIAL_TriangleStripDrawMode:
- return this._gl.TRIANGLE_STRIP;
- case a.MATERIAL_TriangleFanDrawMode:
- return this._gl.TRIANGLE_FAN;
- default:
- return this._gl.TRIANGLES
- }
- }
- ,
- e.prototype._reportDrawCall = function() {}
- ,
- e.prototype._releaseEffect = function(e) {
- if (this._compiledEffects[e._key]) {
- delete this._compiledEffects[e._key];
- var t = e.getPipelineContext();
- t && this._deletePipelineContext(t)
- }
- }
- ,
- e.prototype._deletePipelineContext = function(e) {
- var t = e;
- t && t.program && (t.program.__SPECTOR_rebuildProgram = null,
- this._gl.deleteProgram(t.program))
- }
- ,
- e.prototype._getGlobalDefines = function(e) {
- if (e)
- return this.isNDCHalfZRange ? e.IS_NDC_HALF_ZRANGE = "" : delete e.IS_NDC_HALF_ZRANGE,
- void (this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER);
- var t = "";
- return this.isNDCHalfZRange && (t += "#define IS_NDC_HALF_ZRANGE"),
- this.useReverseDepthBuffer && (t && (t += "\n"),
- t += "#define USE_REVERSE_DEPTHBUFFER"),
- t
- }
- ,
- e.prototype.createEffect = function(e, t, i, n, r, o, a, s, l, c) {
- var u;
- void 0 === c && (c = st.GLSL);
- var h = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
- , d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
- , p = this._getGlobalDefines()
- , f = null !== (u = null != r ? r : t.defines) && void 0 !== u ? u : "";
- p && (f += p);
- var _ = h + "+" + d + "@" + f;
- if (this._compiledEffects[_]) {
- var m = this._compiledEffects[_];
- return a && m.isReady() && a(m),
- m
- }
- var g = new Mt(e,t,i,n,this,r,o,a,s,l,_,c);
- return this._compiledEffects[_] = g,
- g
- }
- ,
- e._ConcatenateShader = function(e, t, i) {
- return void 0 === i && (i = ""),
- i + (t ? t + "\n" : "") + e
- }
- ,
- e.prototype._compileShader = function(t, i, n, r) {
- return this._compileRawShader(e._ConcatenateShader(t, n, r), i)
- }
- ,
- e.prototype._compileRawShader = function(e, t) {
- for (var i = this._gl; i.getError() != i.NO_ERROR; )
- ;
- var n = i.createShader("vertex" === t ? i.VERTEX_SHADER : i.FRAGMENT_SHADER);
- if (!n)
- throw new Error("Something went wrong while creating a gl ".concat(t, " shader object. gl error=").concat(i.getError(), ", gl isContextLost=").concat(i.isContextLost(), ", _contextWasLost=").concat(this._contextWasLost));
- return i.shaderSource(n, e),
- i.compileShader(n),
- n
- }
- ,
- e.prototype._getShaderSource = function(e) {
- return this._gl.getShaderSource(e)
- }
- ,
- e.prototype.createRawShaderProgram = function(e, t, i, n, r) {
- void 0 === r && (r = null),
- n = n || this._gl;
- var o = this._compileRawShader(t, "vertex")
- , a = this._compileRawShader(i, "fragment");
- return this._createShaderProgram(e, o, a, n, r)
- }
- ,
- e.prototype.createShaderProgram = function(e, t, i, n, r, o) {
- void 0 === o && (o = null),
- r = r || this._gl;
- var a = this._webGLVersion > 1 ? "#version 300 es\n#define WEBGL2 \n" : ""
- , s = this._compileShader(t, "vertex", n, a)
- , l = this._compileShader(i, "fragment", n, a);
- return this._createShaderProgram(e, s, l, r, o)
- }
- ,
- e.prototype.inlineShaderCode = function(e) {
- return e
- }
- ,
- e.prototype.createPipelineContext = function(e) {
- var t = new Vt;
- return t.engine = this,
- this._caps.parallelShaderCompile && (t.isParallelCompiled = !0),
- t
- }
- ,
- e.prototype.createMaterialContext = function() {}
- ,
- e.prototype.createDrawContext = function() {}
- ,
- e.prototype._createShaderProgram = function(e, t, i, n, r) {
- void 0 === r && (r = null);
- var o = n.createProgram();
- if (e.program = o,
- !o)
- throw new Error("Unable to create program");
- return n.attachShader(o, t),
- n.attachShader(o, i),
- n.linkProgram(o),
- e.context = n,
- e.vertexShader = t,
- e.fragmentShader = i,
- e.isParallelCompiled || this._finalizePipelineContext(e),
- o
- }
- ,
- e.prototype._finalizePipelineContext = function(e) {
- var t = e.context
- , i = e.vertexShader
- , n = e.fragmentShader
- , r = e.program;
- if (!t.getProgramParameter(r, t.LINK_STATUS)) {
- var o, a;
- if (!this._gl.getShaderParameter(i, this._gl.COMPILE_STATUS) && (o = this._gl.getShaderInfoLog(i)))
- throw e.vertexCompilationError = o,
- new Error("VERTEX SHADER " + o);
- if (!this._gl.getShaderParameter(n, this._gl.COMPILE_STATUS) && (o = this._gl.getShaderInfoLog(n)))
- throw e.fragmentCompilationError = o,
- new Error("FRAGMENT SHADER " + o);
- if (a = t.getProgramInfoLog(r))
- throw e.programLinkError = a,
- new Error(a)
- }
- if (this.validateShaderPrograms && (t.validateProgram(r),
- !t.getProgramParameter(r, t.VALIDATE_STATUS) && (a = t.getProgramInfoLog(r))))
- throw e.programValidationError = a,
- new Error(a);
- t.deleteShader(i),
- t.deleteShader(n),
- e.vertexShader = void 0,
- e.fragmentShader = void 0,
- e.onCompiled && (e.onCompiled(),
- e.onCompiled = void 0)
- }
- ,
- e.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s, l, c) {
- var u = e;
- u.program = n ? this.createRawShaderProgram(u, t, i, void 0, l) : this.createShaderProgram(u, t, i, s, void 0, l),
- u.program.__SPECTOR_rebuildProgram = a
- }
- ,
- e.prototype._isRenderingStateCompiled = function(e) {
- var t = e;
- return !!this._gl.getProgramParameter(t.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) && (this._finalizePipelineContext(t),
- !0)
- }
- ,
- e.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
- var i = e;
- if (i.isParallelCompiled) {
- var n = i.onCompiled;
- i.onCompiled = n ? function() {
- n(),
- t()
- }
- : t
- } else
- t()
- }
- ,
- e.prototype.getUniforms = function(e, t) {
- for (var i = new Array, n = e, r = 0; r < t.length; r++)
- i.push(this._gl.getUniformLocation(n.program, t[r]));
- return i
- }
- ,
- e.prototype.getAttributes = function(e, t) {
- for (var i = [], n = e, r = 0; r < t.length; r++)
- try {
- i.push(this._gl.getAttribLocation(n.program, t[r]))
- } catch (e) {
- i.push(-1)
- }
- return i
- }
- ,
- e.prototype.enableEffect = function(e) {
- (e = null !== e && Gt.IsWrapper(e) ? e.effect : 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))
- }
- ,
- e.prototype.setInt = function(e, t) {
- return !!e && (this._gl.uniform1i(e, t),
- !0)
- }
- ,
- e.prototype.setInt2 = function(e, t, i) {
- return !!e && (this._gl.uniform2i(e, t, i),
- !0)
- }
- ,
- e.prototype.setInt3 = function(e, t, i, n) {
- return !!e && (this._gl.uniform3i(e, t, i, n),
- !0)
- }
- ,
- e.prototype.setInt4 = function(e, t, i, n, r) {
- return !!e && (this._gl.uniform4i(e, t, i, n, r),
- !0)
- }
- ,
- e.prototype.setIntArray = function(e, t) {
- return !!e && (this._gl.uniform1iv(e, t),
- !0)
- }
- ,
- e.prototype.setIntArray2 = function(e, t) {
- return !(!e || t.length % 2 != 0 || (this._gl.uniform2iv(e, t),
- 0))
- }
- ,
- e.prototype.setIntArray3 = function(e, t) {
- return !(!e || t.length % 3 != 0 || (this._gl.uniform3iv(e, t),
- 0))
- }
- ,
- e.prototype.setIntArray4 = function(e, t) {
- return !(!e || t.length % 4 != 0 || (this._gl.uniform4iv(e, t),
- 0))
- }
- ,
- e.prototype.setArray = function(e, t) {
- return !(!e || t.length < 1 || (this._gl.uniform1fv(e, t),
- 0))
- }
- ,
- e.prototype.setArray2 = function(e, t) {
- return !(!e || t.length % 2 != 0 || (this._gl.uniform2fv(e, t),
- 0))
- }
- ,
- e.prototype.setArray3 = function(e, t) {
- return !(!e || t.length % 3 != 0 || (this._gl.uniform3fv(e, t),
- 0))
- }
- ,
- e.prototype.setArray4 = function(e, t) {
- return !(!e || t.length % 4 != 0 || (this._gl.uniform4fv(e, t),
- 0))
- }
- ,
- e.prototype.setMatrices = function(e, t) {
- return !!e && (this._gl.uniformMatrix4fv(e, !1, t),
- !0)
- }
- ,
- e.prototype.setMatrix3x3 = function(e, t) {
- return !!e && (this._gl.uniformMatrix3fv(e, !1, t),
- !0)
- }
- ,
- e.prototype.setMatrix2x2 = function(e, t) {
- return !!e && (this._gl.uniformMatrix2fv(e, !1, t),
- !0)
- }
- ,
- e.prototype.setFloat = function(e, t) {
- return !!e && (this._gl.uniform1f(e, t),
- !0)
- }
- ,
- e.prototype.setFloat2 = function(e, t, i) {
- return !!e && (this._gl.uniform2f(e, t, i),
- !0)
- }
- ,
- e.prototype.setFloat3 = function(e, t, i, n) {
- return !!e && (this._gl.uniform3f(e, t, i, n),
- !0)
- }
- ,
- e.prototype.setFloat4 = function(e, t, i, n, r) {
- return !!e && (this._gl.uniform4f(e, t, i, n, r),
- !0)
- }
- ,
- e.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)
- }
- }
- ,
- e.prototype.setColorWrite = function(e) {
- e !== this._colorWrite && (this._colorWriteChanged = !0,
- this._colorWrite = e)
- }
- ,
- e.prototype.getColorWrite = function() {
- return this._colorWrite
- }
- ,
- Object.defineProperty(e.prototype, "depthCullingState", {
- get: function() {
- return this._depthCullingState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alphaState", {
- get: function() {
- return this._alphaState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilState", {
- get: function() {
- return this._stencilState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "stencilStateComposer", {
- get: function() {
- return this._stencilStateComposer
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.clearInternalTexturesCache = function() {
- this._internalTexturesCache = []
- }
- ,
- e.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 = a.ALPHA_ADD,
- this._alphaEquation = a.ALPHA_DISABLE,
- 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))
- }
- ,
- e.prototype._getSamplingParameters = function(e, t) {
- var i = this._gl
- , n = i.NEAREST
- , r = i.NEAREST;
- switch (e) {
- case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
- n = i.LINEAR,
- r = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
- break;
- case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
- n = i.LINEAR,
- r = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
- break;
- case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
- n = i.NEAREST,
- r = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
- break;
- case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
- n = i.NEAREST,
- r = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
- break;
- case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
- n = i.NEAREST,
- r = t ? i.LINEAR_MIPMAP_NEAREST : i.LINEAR;
- break;
- case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
- n = i.NEAREST,
- r = t ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR;
- break;
- case a.TEXTURE_NEAREST_LINEAR:
- n = i.NEAREST,
- r = i.LINEAR;
- break;
- case a.TEXTURE_NEAREST_NEAREST:
- n = i.NEAREST,
- r = i.NEAREST;
- break;
- case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
- n = i.LINEAR,
- r = t ? i.NEAREST_MIPMAP_NEAREST : i.NEAREST;
- break;
- case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
- n = i.LINEAR,
- r = t ? i.NEAREST_MIPMAP_LINEAR : i.NEAREST;
- break;
- case a.TEXTURE_LINEAR_LINEAR:
- n = i.LINEAR,
- r = i.LINEAR;
- break;
- case a.TEXTURE_LINEAR_NEAREST:
- n = i.LINEAR,
- r = i.NEAREST
- }
- return {
- min: r,
- mag: n
- }
- }
- ,
- e.prototype._createTexture = function() {
- var e = this._gl.createTexture();
- if (!e)
- throw new Error("Unable to create texture");
- return e
- }
- ,
- e.prototype._createHardwareTexture = function() {
- return new kt(this._createTexture(),this._gl)
- }
- ,
- e.prototype._createInternalTexture = function(e, t, i, n) {
- void 0 === i && (i = !0),
- void 0 === n && (n = At.Unknown);
- var r = {};
- void 0 !== t && "object" == typeof t ? (r.generateMipMaps = t.generateMipMaps,
- r.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
- r.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
- r.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format) : (r.generateMipMaps = t,
- r.type = a.TEXTURETYPE_UNSIGNED_INT,
- r.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- r.format = a.TEXTUREFORMAT_RGBA),
- (r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (r.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (r.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE),
- r.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (r.type = a.TEXTURETYPE_UNSIGNED_INT,
- K.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
- var o = this._gl
- , s = new Lt(this,n)
- , l = e.width || e
- , c = e.height || e
- , u = e.layers || 0
- , h = this._getSamplingParameters(r.samplingMode, !!r.generateMipMaps)
- , d = 0 !== u ? o.TEXTURE_2D_ARRAY : o.TEXTURE_2D
- , p = this._getRGBABufferInternalSizedFormat(r.type, r.format)
- , f = this._getInternalFormat(r.format)
- , _ = this._getWebGLTextureType(r.type);
- return this._bindTextureDirectly(d, s),
- 0 !== u ? (s.is2DArray = !0,
- o.texImage3D(d, 0, p, l, c, u, 0, f, _, null)) : o.texImage2D(d, 0, p, l, c, 0, f, _, null),
- o.texParameteri(d, o.TEXTURE_MAG_FILTER, h.mag),
- o.texParameteri(d, o.TEXTURE_MIN_FILTER, h.min),
- o.texParameteri(d, o.TEXTURE_WRAP_S, o.CLAMP_TO_EDGE),
- o.texParameteri(d, o.TEXTURE_WRAP_T, o.CLAMP_TO_EDGE),
- r.generateMipMaps && this._gl.generateMipmap(d),
- this._bindTextureDirectly(d, null),
- s.baseWidth = l,
- s.baseHeight = c,
- s.width = l,
- s.height = c,
- s.depth = u,
- s.isReady = !0,
- s.samples = 1,
- s.generateMipMaps = !!r.generateMipMaps,
- s.samplingMode = r.samplingMode,
- s.type = r.type,
- s.format = r.format,
- this._internalTexturesCache.push(s),
- s
- }
- ,
- e.prototype._getUseSRGBBuffer = function(e, t) {
- return e && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || t)
- }
- ,
- e.prototype._createTextureBase = function(t, i, n, r, o, s, l, c, u, h, d, p, f, _, m, g) {
- var v = this;
- void 0 === o && (o = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === h && (h = null),
- void 0 === d && (d = null),
- void 0 === p && (p = null),
- void 0 === f && (f = null);
- var y = "data:" === (t = t || "").substr(0, 5)
- , b = "blob:" === t.substr(0, 5)
- , T = y && -1 !== t.indexOf(";base64,")
- , S = d || new Lt(this,At.Url)
- , A = t;
- !this._transformTextureUrl || T || d || h || (t = this._transformTextureUrl(t)),
- A !== t && (S._originalUrl = A);
- var x = t.lastIndexOf(".")
- , R = f || (x > -1 ? t.substring(x).toLowerCase() : "")
- , C = null;
- R.indexOf("?") > -1 && (R = R.split("?")[0]);
- for (var P = 0, M = e._TextureLoaders; P < M.length; P++) {
- var I = M[P];
- if (I.canLoad(R, _)) {
- C = I;
- break
- }
- }
- r && r._addPendingData(S),
- S.url = t,
- S.generateMipMaps = !i,
- S.samplingMode = o,
- S.invertY = n,
- S._useSRGBBuffer = this._getUseSRGBBuffer(!!g, i),
- this._doNotHandleContextLost || (S._buffer = h);
- var O = null;
- s && !d && (O = S.onLoadedObservable.add(s)),
- d || this._internalTexturesCache.push(S);
- var D = function(e, n) {
- r && r._removePendingData(S),
- t === A ? (O && S.onLoadedObservable.remove(O),
- E.UseFallbackTexture && v._createTextureBase(E.FallbackTexture, i, S.invertY, r, o, null, l, c, u, h, S),
- e = (e || "Unknown error") + (E.UseFallbackTexture ? " - Fallback texture was used" : ""),
- S.onErrorObservable.notifyObservers({
- message: e,
- exception: n
- }),
- l && l(e, n)) : (K.Warn("Failed to load ".concat(t, ", falling back to ").concat(A)),
- v._createTextureBase(A, i, S.invertY, r, o, s, l, c, u, h, S, p, f, _, m, g))
- };
- if (C) {
- var N = function(e) {
- C.loadData(e, S, (function(e, t, i, n, a, s) {
- s ? D("TextureLoader failed to load data") : c(S, R, r, {
- width: e,
- height: t
- }, S.invertY, !i, n, (function() {
- return a(),
- !1
- }
- ), o)
- }
- ), m)
- };
- h ? h instanceof ArrayBuffer ? N(new Uint8Array(h)) : ArrayBuffer.isView(h) ? N(h) : l && l("Unable to load: only ArrayBuffer or ArrayBufferView is supported", null) : this._loadFile(t, (function(e) {
- return N(new Uint8Array(e))
- }
- ), void 0, r ? r.offlineProvider : void 0, !0, (function(e, t) {
- D("Unable to load " + (e && e.responseURL,
- t))
- }
- ))
- } else {
- var L = function(e) {
- b && !v._doNotHandleContextLost && (S._buffer = e),
- c(S, R, r, e, S.invertY, i, !1, u, o)
- };
- !y || T ? h && ("string" == typeof h.decoding || h.close) ? L(h) : e._FileToolsLoadImage(t, L, D, r ? r.offlineProvider : null, _, S.invertY && this._features.needsInvertingBitmap ? {
- imageOrientation: "flipY"
- } : void 0) : "string" == typeof h || h instanceof ArrayBuffer || ArrayBuffer.isView(h) || h instanceof Blob ? e._FileToolsLoadImage(h, L, D, r ? r.offlineProvider : null, _, S.invertY && this._features.needsInvertingBitmap ? {
- imageOrientation: "flipY"
- } : void 0) : h && L(h)
- }
- return S
- }
- ,
- e.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
- var m = this;
- return void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = null),
- this._createTextureBase(e, t, i, n, r, o, s, this._prepareWebGLTexture.bind(this), (function(e, t, i, r, o, a) {
- var s = m._gl
- , l = i.width === e && i.height === t
- , c = u ? m._getInternalFormat(u, o._useSRGBBuffer) : ".jpg" !== r || o._useSRGBBuffer ? o._useSRGBBuffer ? s.SRGB8_ALPHA8 : s.RGBA : s.RGB
- , h = u ? m._getInternalFormat(u) : ".jpg" !== r || o._useSRGBBuffer ? s.RGBA : s.RGB;
- if (o._useSRGBBuffer && 1 === m.webGLVersion && (h = c),
- l)
- return s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, i),
- !1;
- var d = m._caps.maxTextureSize;
- if (i.width > d || i.height > d || !m._supportsHardwareTextureRescaling)
- return m._prepareWorkingCanvas(),
- !(!m._workingCanvas || !m._workingContext || (m._workingCanvas.width = e,
- m._workingCanvas.height = t,
- m._workingContext.drawImage(i, 0, 0, i.width, i.height, 0, 0, e, t),
- s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, m._workingCanvas),
- o.width = e,
- o.height = t,
- 1));
- var p = new Lt(m,At.Temp);
- return m._bindTextureDirectly(s.TEXTURE_2D, p, !0),
- s.texImage2D(s.TEXTURE_2D, 0, c, h, s.UNSIGNED_BYTE, i),
- m._rescaleTexture(p, o, n, c, (function() {
- m._releaseTexture(p),
- m._bindTextureDirectly(s.TEXTURE_2D, o, !0),
- a()
- }
- )),
- !0
- }
- ), l, c, u, h, d, p, _)
- }
- ,
- e._FileToolsLoadImage = function(e, t, i, n, r, o) {
- throw be("FileTools")
- }
- ,
- e.prototype._rescaleTexture = function(e, t, i, n, r) {}
- ,
- e.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c) {
- throw void 0 === l && (l = null),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- be("Engine.RawTexture")
- }
- ,
- e.prototype.createRawCubeTexture = function(e, t, i, n, r, o, a, s) {
- throw void 0 === s && (s = null),
- be("Engine.RawTexture")
- }
- ,
- e.prototype.createRawTexture3D = function(e, t, i, n, r, o, s, l, c, u) {
- throw void 0 === c && (c = null),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- be("Engine.RawTexture")
- }
- ,
- e.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u) {
- throw void 0 === c && (c = null),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- be("Engine.RawTexture")
- }
- ,
- e.prototype._unpackFlipY = function(e) {
- this._unpackFlipYCached !== e && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, e ? 1 : 0),
- this.enableUnpackFlipYCached && (this._unpackFlipYCached = e))
- }
- ,
- e.prototype._getUnpackAlignement = function() {
- return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)
- }
- ,
- e.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
- }
- ,
- e.prototype.updateTextureSamplingMode = function(e, t, i) {
- void 0 === i && (i = !1);
- var n = this._getTextureTarget(t)
- , r = this._getSamplingParameters(e, t.generateMipMaps || i);
- this._setTextureParameterInteger(n, this._gl.TEXTURE_MAG_FILTER, r.mag, t),
- this._setTextureParameterInteger(n, this._gl.TEXTURE_MIN_FILTER, r.min),
- i && (t.generateMipMaps = !0,
- this._gl.generateMipmap(n)),
- this._bindTextureDirectly(n, null),
- t.samplingMode = e
- }
- ,
- e.prototype.updateTextureDimensions = function(e, t, i, n) {
- void 0 === n && (n = 1)
- }
- ,
- e.prototype.updateTextureWrappingMode = function(e, t, i, n) {
- void 0 === i && (i = null),
- void 0 === n && (n = null);
- var r = this._getTextureTarget(e);
- null !== t && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t), e),
- e._cachedWrapU = t),
- null !== i && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(i), e),
- e._cachedWrapV = i),
- (e.is2DArray || e.is3D) && null !== n && (this._setTextureParameterInteger(r, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(n), e),
- e._cachedWrapR = n),
- this._bindTextureDirectly(r, null)
- }
- ,
- e.prototype._setupDepthStencilTexture = function(e, t, i, n, r, o) {
- void 0 === o && (o = 1);
- var s = t.width || t
- , l = t.height || t
- , c = t.layers || 0;
- e.baseWidth = s,
- e.baseHeight = l,
- e.width = s,
- e.height = l,
- e.is2DArray = c > 0,
- e.depth = c,
- e.isReady = !0,
- e.samples = o,
- e.generateMipMaps = !1,
- e.samplingMode = n ? a.TEXTURE_BILINEAR_SAMPLINGMODE : a.TEXTURE_NEAREST_SAMPLINGMODE,
- e.type = a.TEXTURETYPE_UNSIGNED_INT,
- e._comparisonFunction = r;
- var u = this._gl
- , h = this._getTextureTarget(e)
- , d = this._getSamplingParameters(e.samplingMode, !1);
- u.texParameteri(h, u.TEXTURE_MAG_FILTER, d.mag),
- u.texParameteri(h, u.TEXTURE_MIN_FILTER, d.min),
- u.texParameteri(h, u.TEXTURE_WRAP_S, u.CLAMP_TO_EDGE),
- u.texParameteri(h, u.TEXTURE_WRAP_T, u.CLAMP_TO_EDGE),
- 0 === r ? (u.texParameteri(h, u.TEXTURE_COMPARE_FUNC, a.LEQUAL),
- u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.NONE)) : (u.texParameteri(h, u.TEXTURE_COMPARE_FUNC, r),
- u.texParameteri(h, u.TEXTURE_COMPARE_MODE, u.COMPARE_REF_TO_TEXTURE))
- }
- ,
- e.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, s) {
- void 0 === o && (o = 0),
- void 0 === s && (s = 0);
- var l = this._gl
- , c = l.TEXTURE_2D;
- if (e.isCube && (c = l.TEXTURE_CUBE_MAP_POSITIVE_X + o),
- e._useSRGBBuffer)
- switch (t) {
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
- t = l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
- break;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
- t = l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
- break;
- case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
- this._caps.s3tc_srgb ? t = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : e._useSRGBBuffer = !1;
- break;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
- this._caps.s3tc_srgb ? t = l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : e._useSRGBBuffer = !1;
- break;
- default:
- e._useSRGBBuffer = !1
- }
- this._gl.compressedTexImage2D(c, s, t, i, n, 0, r)
- }
- ,
- e.prototype._uploadDataToTextureDirectly = function(e, t, i, n, r, o) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- void 0 === o && (o = !1);
- var a = this._gl
- , s = this._getWebGLTextureType(e.type)
- , l = this._getInternalFormat(e.format)
- , c = void 0 === r ? this._getRGBABufferInternalSizedFormat(e.type, e.format, e._useSRGBBuffer) : this._getInternalFormat(r, e._useSRGBBuffer);
- this._unpackFlipY(e.invertY);
- var u = a.TEXTURE_2D;
- e.isCube && (u = a.TEXTURE_CUBE_MAP_POSITIVE_X + i);
- var h = Math.round(Math.log(e.width) * Math.LOG2E)
- , d = Math.round(Math.log(e.height) * Math.LOG2E)
- , p = o ? e.width : Math.pow(2, Math.max(h - n, 0))
- , f = o ? e.height : Math.pow(2, Math.max(d - n, 0));
- a.texImage2D(u, n, c, p, f, 0, l, s, t)
- }
- ,
- e.prototype.updateTextureData = function(e, t, i, n, r, o, a, s) {
- void 0 === a && (a = 0),
- void 0 === s && (s = 0);
- var l = this._gl
- , c = this._getWebGLTextureType(e.type)
- , u = this._getInternalFormat(e.format);
- this._unpackFlipY(e.invertY);
- var h = l.TEXTURE_2D;
- e.isCube && (h = l.TEXTURE_CUBE_MAP_POSITIVE_X + a),
- l.texSubImage2D(h, s, i, n, r, o, u, c, t)
- }
- ,
- e.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0);
- var r = this._gl
- , o = e.isCube ? r.TEXTURE_CUBE_MAP : r.TEXTURE_2D;
- this._bindTextureDirectly(o, e, !0),
- this._uploadDataToTextureDirectly(e, t, i, n),
- this._bindTextureDirectly(o, null, !0)
- }
- ,
- e.prototype._prepareWebGLTextureContinuation = function(e, t, i, n, r) {
- var o = this._gl;
- if (o) {
- var a = this._getSamplingParameters(r, !i);
- o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MAG_FILTER, a.mag),
- o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MIN_FILTER, a.min),
- i || n || o.generateMipmap(o.TEXTURE_2D),
- this._bindTextureDirectly(o.TEXTURE_2D, null),
- t && t._removePendingData(e),
- e.onLoadedObservable.notifyObservers(e),
- e.onLoadedObservable.clear()
- }
- }
- ,
- e.prototype._prepareWebGLTexture = function(t, i, n, r, o, s, l, c, u) {
- var h = this;
- void 0 === u && (u = a.TEXTURE_TRILINEAR_SAMPLINGMODE);
- var d = this.getCaps().maxTextureSize
- , p = Math.min(d, this.needPOTTextures ? e.GetExponentOfTwo(r.width, d) : r.width)
- , f = Math.min(d, this.needPOTTextures ? e.GetExponentOfTwo(r.height, d) : r.height)
- , _ = this._gl;
- _ && (t._hardwareTexture ? (this._bindTextureDirectly(_.TEXTURE_2D, t, !0),
- this._unpackFlipY(void 0 === o || !!o),
- t.baseWidth = r.width,
- t.baseHeight = r.height,
- t.width = p,
- t.height = f,
- t.isReady = !0,
- c(p, f, r, i, t, (function() {
- h._prepareWebGLTextureContinuation(t, n, s, l, u)
- }
- )) || this._prepareWebGLTextureContinuation(t, n, s, l, u)) : n && n._removePendingData(t))
- }
- ,
- e.prototype._setupFramebufferDepthAttachments = function(e, t, i, n, r) {
- void 0 === r && (r = 1);
- var o = this._gl;
- if (e && t)
- return this._createRenderBuffer(i, n, r, o.DEPTH_STENCIL, o.DEPTH24_STENCIL8, o.DEPTH_STENCIL_ATTACHMENT);
- if (t) {
- var a = o.DEPTH_COMPONENT16;
- return this._webGLVersion > 1 && (a = o.DEPTH_COMPONENT32F),
- this._createRenderBuffer(i, n, r, a, a, o.DEPTH_ATTACHMENT)
- }
- return e ? this._createRenderBuffer(i, n, r, o.STENCIL_INDEX8, o.STENCIL_INDEX8, o.STENCIL_ATTACHMENT) : null
- }
- ,
- e.prototype._createRenderBuffer = function(e, t, i, n, r, o, a) {
- void 0 === a && (a = !0);
- var s = this._gl
- , l = s.createRenderbuffer();
- return s.bindRenderbuffer(s.RENDERBUFFER, l),
- i > 1 && s.renderbufferStorageMultisample ? s.renderbufferStorageMultisample(s.RENDERBUFFER, i, r, e, t) : s.renderbufferStorage(s.RENDERBUFFER, n, e, t),
- s.framebufferRenderbuffer(s.FRAMEBUFFER, o, s.RENDERBUFFER, l),
- a && s.bindRenderbuffer(s.RENDERBUFFER, null),
- l
- }
- ,
- e.prototype._releaseTexture = function(e) {
- var t;
- this._deleteTexture(null === (t = e._hardwareTexture) || void 0 === t ? void 0 : t.underlyingResource),
- this.unbindAllTextures();
- var i = this._internalTexturesCache.indexOf(e);
- -1 !== i && this._internalTexturesCache.splice(i, 1),
- e._lodTextureHigh && e._lodTextureHigh.dispose(),
- e._lodTextureMid && e._lodTextureMid.dispose(),
- e._lodTextureLow && e._lodTextureLow.dispose(),
- e._irradianceTexture && e._irradianceTexture.dispose()
- }
- ,
- e.prototype._releaseRenderTargetWrapper = function(e) {
- var t = this._renderTargetWrapperCache.indexOf(e);
- -1 !== t && this._renderTargetWrapperCache.splice(t, 1)
- }
- ,
- e.prototype._deleteTexture = function(e) {
- e && this._gl.deleteTexture(e)
- }
- ,
- e.prototype._setProgram = function(e) {
- this._currentProgram !== e && (this._gl.useProgram(e),
- this._currentProgram = e)
- }
- ,
- e.prototype.bindSamplers = function(e) {
- var t = e.getPipelineContext();
- this._setProgram(t.program);
- for (var i = e.getSamplers(), n = 0; n < i.length; n++) {
- var r = e.getUniform(i[n]);
- r && (this._boundUniforms[n] = r)
- }
- this._currentEffect = null
- }
- ,
- e.prototype._activateCurrentTexture = function() {
- this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel),
- this._currentTextureChannel = this._activeChannel)
- }
- ,
- e.prototype._bindTextureDirectly = function(e, t, i, n) {
- var r, o;
- void 0 === i && (i = !1),
- void 0 === n && (n = !1);
- var a = !1
- , s = t && t._associatedChannel > -1;
- if (i && s && (this._activeChannel = t._associatedChannel),
- this._boundTexturesCache[this._activeChannel] !== t || n) {
- if (this._activateCurrentTexture(),
- t && t.isMultiview)
- throw console.error(e, t),
- "_bindTextureDirectly called with a multiview texture!";
- this._gl.bindTexture(e, null !== (o = null === (r = null == t ? void 0 : t._hardwareTexture) || void 0 === r ? void 0 : r.underlyingResource) && void 0 !== o ? o : null),
- this._boundTexturesCache[this._activeChannel] = t,
- t && (t._associatedChannel = this._activeChannel)
- } else
- i && (a = !0,
- this._activateCurrentTexture());
- return s && !i && this._bindSamplerUniformToChannel(t._associatedChannel, this._activeChannel),
- a
- }
- ,
- e.prototype._bindTexture = function(e, t, i) {
- if (void 0 !== e) {
- t && (t._associatedChannel = e),
- this._activeChannel = e;
- var n = t ? this._getTextureTarget(t) : this._gl.TEXTURE_2D;
- this._bindTextureDirectly(n, t)
- }
- }
- ,
- e.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))
- }
- ,
- e.prototype.setTexture = function(e, t, i, n) {
- void 0 !== e && (t && (this._boundUniforms[e] = t),
- this._setTexture(e, i))
- }
- ,
- e.prototype._bindSamplerUniformToChannel = function(e, t) {
- var i = this._boundUniforms[e];
- i && i._currentState !== t && (this._gl.uniform1i(i, t),
- i._currentState = t)
- }
- ,
- e.prototype._getTextureWrapMode = function(e) {
- switch (e) {
- case a.TEXTURE_WRAP_ADDRESSMODE:
- return this._gl.REPEAT;
- case a.TEXTURE_CLAMP_ADDRESSMODE:
- return this._gl.CLAMP_TO_EDGE;
- case a.TEXTURE_MIRROR_ADDRESSMODE:
- return this._gl.MIRRORED_REPEAT
- }
- return this._gl.REPEAT
- }
- ,
- e.prototype._setTexture = function(e, t, i, n, r) {
- if (void 0 === i && (i = !1),
- void 0 === n && (n = !1),
- void 0 === r && (r = ""),
- !t)
- return null != this._boundTexturesCache[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))),
- !1;
- if (t.video)
- this._activeChannel = e,
- t.update();
- else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
- return t.delayLoad(),
- !1;
- var o;
- o = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture,
- !i && o && (o._associatedChannel = e);
- var s = !0;
- this._boundTexturesCache[e] === o && (i || this._bindSamplerUniformToChannel(o._associatedChannel, e),
- s = !1),
- this._activeChannel = e;
- var l = this._getTextureTarget(o);
- if (s && this._bindTextureDirectly(l, o, i),
- o && !o.isMultiview) {
- if (o.isCube && o._cachedCoordinatesMode !== t.coordinatesMode) {
- o._cachedCoordinatesMode = t.coordinatesMode;
- var c = t.coordinatesMode !== a.TEXTURE_CUBIC_MODE && t.coordinatesMode !== a.TEXTURE_SKYBOX_MODE ? a.TEXTURE_WRAP_ADDRESSMODE : a.TEXTURE_CLAMP_ADDRESSMODE;
- t.wrapU = c,
- t.wrapV = c
- }
- o._cachedWrapU !== t.wrapU && (o._cachedWrapU = t.wrapU,
- this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(t.wrapU), o)),
- o._cachedWrapV !== t.wrapV && (o._cachedWrapV = t.wrapV,
- this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(t.wrapV), o)),
- o.is3D && o._cachedWrapR !== t.wrapR && (o._cachedWrapR = t.wrapR,
- this._setTextureParameterInteger(l, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(t.wrapR), o)),
- this._setAnisotropicLevel(l, o, t.anisotropicFilteringLevel)
- }
- return !0
- }
- ,
- e.prototype.setTextureArray = function(e, t, i, n) {
- if (void 0 !== e && t) {
- this._textureUnits && this._textureUnits.length === i.length || (this._textureUnits = new Int32Array(i.length));
- for (var r = 0; r < i.length; r++) {
- var o = i[r].getInternalTexture();
- o ? (this._textureUnits[r] = e + r,
- o._associatedChannel = e + r) : this._textureUnits[r] = -1
- }
- this._gl.uniform1iv(t, this._textureUnits);
- for (var a = 0; a < i.length; a++)
- this._setTexture(this._textureUnits[a], i[a], !0)
- }
- }
- ,
- e.prototype._setAnisotropicLevel = function(e, t, i) {
- var n = this._caps.textureAnisotropicFilterExtension;
- t.samplingMode !== a.TEXTURE_LINEAR_LINEAR_MIPNEAREST && t.samplingMode !== a.TEXTURE_LINEAR_LINEAR_MIPLINEAR && t.samplingMode !== a.TEXTURE_LINEAR_LINEAR && (i = 1),
- n && t._cachedAnisotropicFilteringLevel !== i && (this._setTextureParameterFloat(e, n.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(i, this._caps.maxAnisotropy), t),
- t._cachedAnisotropicFilteringLevel = i)
- }
- ,
- e.prototype._setTextureParameterFloat = function(e, t, i, n) {
- this._bindTextureDirectly(e, n, !0, !0),
- this._gl.texParameterf(e, t, i)
- }
- ,
- e.prototype._setTextureParameterInteger = function(e, t, i, n) {
- n && this._bindTextureDirectly(e, n, !0, !0),
- this._gl.texParameteri(e, t, i)
- }
- ,
- e.prototype.unbindAllAttributes = function() {
- if (this._mustWipeVertexAttributes) {
- this._mustWipeVertexAttributes = !1;
- for (var e = 0; e < this._caps.maxVertexAttribs; e++)
- this.disableAttributeByIndex(e)
- } else {
- e = 0;
- for (var t = this._vertexAttribArraysEnabled.length; e < t; e++)
- e >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[e] || this.disableAttributeByIndex(e)
- }
- }
- ,
- e.prototype.releaseEffects = function() {
- for (var e in this._compiledEffects) {
- var t = this._compiledEffects[e].getPipelineContext();
- this._deletePipelineContext(t)
- }
- this._compiledEffects = {}
- }
- ,
- e.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(),
- null === (e = this.releaseComputeEffects) || void 0 === e || e.call(this),
- this.unbindAllAttributes(),
- this._boundUniforms = [],
- nt() && 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,
- Mt.ResetCache();
- for (var t = 0, i = this._activeRequests; t < i.length; t++)
- i[t].abort();
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- e.prototype.attachContextLostEvent = function(e) {
- this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", e, !1)
- }
- ,
- e.prototype.attachContextRestoredEvent = function(e) {
- this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", e, !1)
- }
- ,
- e.prototype.getError = function() {
- return this._gl.getError()
- }
- ,
- e.prototype._canRenderToFloatFramebuffer = function() {
- return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(a.TEXTURETYPE_FLOAT)
- }
- ,
- e.prototype._canRenderToHalfFloatFramebuffer = function() {
- return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(a.TEXTURETYPE_HALF_FLOAT)
- }
- ,
- e.prototype._canRenderToFramebuffer = function(e) {
- for (var t = this._gl; t.getError() !== t.NO_ERROR; )
- ;
- var i = !0
- , n = t.createTexture();
- t.bindTexture(t.TEXTURE_2D, n),
- t.texImage2D(t.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(e), 1, 1, 0, t.RGBA, this._getWebGLTextureType(e), null),
- t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST),
- t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST);
- var r = t.createFramebuffer();
- t.bindFramebuffer(t.FRAMEBUFFER, r),
- t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, n, 0);
- var o = t.checkFramebufferStatus(t.FRAMEBUFFER);
- if ((i = (i = i && o === t.FRAMEBUFFER_COMPLETE) && t.getError() === t.NO_ERROR) && (t.clear(t.COLOR_BUFFER_BIT),
- i = i && t.getError() === t.NO_ERROR),
- i) {
- t.bindFramebuffer(t.FRAMEBUFFER, null);
- var a = t.RGBA
- , s = t.UNSIGNED_BYTE
- , l = new Uint8Array(4);
- t.readPixels(0, 0, 1, 1, a, s, l),
- i = i && t.getError() === t.NO_ERROR
- }
- for (t.deleteTexture(n),
- t.deleteFramebuffer(r),
- t.bindFramebuffer(t.FRAMEBUFFER, null); !i && t.getError() !== t.NO_ERROR; )
- ;
- return i
- }
- ,
- e.prototype._getWebGLTextureType = function(e) {
- if (1 === this._webGLVersion) {
- switch (e) {
- case a.TEXTURETYPE_FLOAT:
- return this._gl.FLOAT;
- case a.TEXTURETYPE_HALF_FLOAT:
- return this._gl.HALF_FLOAT_OES;
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- return this._gl.UNSIGNED_BYTE;
- case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
- return this._gl.UNSIGNED_SHORT_4_4_4_4;
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
- return this._gl.UNSIGNED_SHORT_5_5_5_1;
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
- return this._gl.UNSIGNED_SHORT_5_6_5
- }
- return this._gl.UNSIGNED_BYTE
- }
- switch (e) {
- case a.TEXTURETYPE_BYTE:
- return this._gl.BYTE;
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- return this._gl.UNSIGNED_BYTE;
- case a.TEXTURETYPE_SHORT:
- return this._gl.SHORT;
- case a.TEXTURETYPE_UNSIGNED_SHORT:
- return this._gl.UNSIGNED_SHORT;
- case a.TEXTURETYPE_INT:
- return this._gl.INT;
- case a.TEXTURETYPE_UNSIGNED_INTEGER:
- return this._gl.UNSIGNED_INT;
- case a.TEXTURETYPE_FLOAT:
- return this._gl.FLOAT;
- case a.TEXTURETYPE_HALF_FLOAT:
- return this._gl.HALF_FLOAT;
- case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
- return this._gl.UNSIGNED_SHORT_4_4_4_4;
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
- return this._gl.UNSIGNED_SHORT_5_5_5_1;
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
- return this._gl.UNSIGNED_SHORT_5_6_5;
- case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
- return this._gl.UNSIGNED_INT_2_10_10_10_REV;
- case a.TEXTURETYPE_UNSIGNED_INT_24_8:
- return this._gl.UNSIGNED_INT_24_8;
- case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
- return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
- case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
- return this._gl.UNSIGNED_INT_5_9_9_9_REV;
- case a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
- return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV
- }
- return this._gl.UNSIGNED_BYTE
- }
- ,
- e.prototype._getInternalFormat = function(e, t) {
- void 0 === t && (t = !1);
- var i = t ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
- switch (e) {
- case a.TEXTUREFORMAT_ALPHA:
- i = this._gl.ALPHA;
- break;
- case a.TEXTUREFORMAT_LUMINANCE:
- i = this._gl.LUMINANCE;
- break;
- case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
- i = this._gl.LUMINANCE_ALPHA;
- break;
- case a.TEXTUREFORMAT_RED:
- i = this._gl.RED;
- break;
- case a.TEXTUREFORMAT_RG:
- i = this._gl.RG;
- break;
- case a.TEXTUREFORMAT_RGB:
- i = t ? this._gl.SRGB : this._gl.RGB;
- break;
- case a.TEXTUREFORMAT_RGBA:
- i = t ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA
- }
- if (this._webGLVersion > 1)
- switch (e) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- i = this._gl.RED_INTEGER;
- break;
- case a.TEXTUREFORMAT_RG_INTEGER:
- i = this._gl.RG_INTEGER;
- break;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- i = this._gl.RGB_INTEGER;
- break;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- i = this._gl.RGBA_INTEGER
- }
- return i
- }
- ,
- e.prototype._getRGBABufferInternalSizedFormat = function(e, t, i) {
- if (void 0 === i && (i = !1),
- 1 === this._webGLVersion) {
- if (void 0 !== t)
- switch (t) {
- case a.TEXTUREFORMAT_ALPHA:
- return this._gl.ALPHA;
- case a.TEXTUREFORMAT_LUMINANCE:
- return this._gl.LUMINANCE;
- case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
- return this._gl.LUMINANCE_ALPHA;
- case a.TEXTUREFORMAT_RGB:
- return i ? this._gl.SRGB : this._gl.RGB
- }
- return this._gl.RGBA
- }
- switch (e) {
- case a.TEXTURETYPE_BYTE:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return this._gl.R8_SNORM;
- case a.TEXTUREFORMAT_RG:
- return this._gl.RG8_SNORM;
- case a.TEXTUREFORMAT_RGB:
- return this._gl.RGB8_SNORM;
- case a.TEXTUREFORMAT_RED_INTEGER:
- return this._gl.R8I;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return this._gl.RG8I;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- return this._gl.RGB8I;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- return this._gl.RGBA8I;
- default:
- return this._gl.RGBA8_SNORM
- }
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return this._gl.R8;
- case a.TEXTUREFORMAT_RG:
- return this._gl.RG8;
- case a.TEXTUREFORMAT_RGB:
- return i ? this._gl.SRGB8 : this._gl.RGB8;
- case a.TEXTUREFORMAT_RGBA:
- return i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8;
- case a.TEXTUREFORMAT_RED_INTEGER:
- return this._gl.R8UI;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return this._gl.RG8UI;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- return this._gl.RGB8UI;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- return this._gl.RGBA8UI;
- case a.TEXTUREFORMAT_ALPHA:
- return this._gl.ALPHA;
- case a.TEXTUREFORMAT_LUMINANCE:
- return this._gl.LUMINANCE;
- case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
- return this._gl.LUMINANCE_ALPHA;
- default:
- return this._gl.RGBA8
- }
- case a.TEXTURETYPE_SHORT:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return this._gl.R16I;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return this._gl.RG16I;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- return this._gl.RGB16I;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return this._gl.RGBA16I
- }
- case a.TEXTURETYPE_UNSIGNED_SHORT:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return this._gl.R16UI;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return this._gl.RG16UI;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- return this._gl.RGB16UI;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return this._gl.RGBA16UI
- }
- case a.TEXTURETYPE_INT:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return this._gl.R32I;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return this._gl.RG32I;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- return this._gl.RGB32I;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return this._gl.RGBA32I
- }
- case a.TEXTURETYPE_UNSIGNED_INTEGER:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return this._gl.R32UI;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return this._gl.RG32UI;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- return this._gl.RGB32UI;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return this._gl.RGBA32UI
- }
- case a.TEXTURETYPE_FLOAT:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return this._gl.R32F;
- case a.TEXTUREFORMAT_RG:
- return this._gl.RG32F;
- case a.TEXTUREFORMAT_RGB:
- return this._gl.RGB32F;
- case a.TEXTUREFORMAT_RGBA:
- default:
- return this._gl.RGBA32F
- }
- case a.TEXTURETYPE_HALF_FLOAT:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return this._gl.R16F;
- case a.TEXTUREFORMAT_RG:
- return this._gl.RG16F;
- case a.TEXTUREFORMAT_RGB:
- return this._gl.RGB16F;
- case a.TEXTUREFORMAT_RGBA:
- default:
- return this._gl.RGBA16F
- }
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
- return this._gl.RGB565;
- case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
- return this._gl.R11F_G11F_B10F;
- case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
- return this._gl.RGB9_E5;
- case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
- return this._gl.RGBA4;
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
- return this._gl.RGB5_A1;
- case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
- switch (t) {
- case a.TEXTUREFORMAT_RGBA:
- return this._gl.RGB10_A2;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- return this._gl.RGB10_A2UI;
- default:
- return this._gl.RGB10_A2
- }
- }
- return i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8
- }
- ,
- e.prototype._getRGBAMultiSampleBufferFormat = function(e) {
- return e === a.TEXTURETYPE_FLOAT ? this._gl.RGBA32F : e === a.TEXTURETYPE_HALF_FLOAT ? this._gl.RGBA16F : this._gl.RGBA8
- }
- ,
- e.prototype._loadFile = function(t, i, n, r, o, a) {
- var s = this
- , l = e._FileToolsLoadFile(t, i, n, r, o, a);
- return this._activeRequests.push(l),
- l.onCompleteObservable.add((function(e) {
- s._activeRequests.splice(s._activeRequests.indexOf(e), 1)
- }
- )),
- l
- }
- ,
- e._FileToolsLoadFile = function(e, t, i, n, r, o) {
- throw be("FileTools")
- }
- ,
- e.prototype.readPixels = function(e, t, i, n, r, o) {
- void 0 === r && (r = !0),
- void 0 === o && (o = !0);
- var a = r ? 4 : 3
- , s = r ? this._gl.RGBA : this._gl.RGB
- , l = new Uint8Array(n * i * a);
- return o && this.flushFramebuffer(),
- this._gl.readPixels(e, t, i, n, s, this._gl.UNSIGNED_BYTE, l),
- Promise.resolve(l)
- }
- ,
- Object.defineProperty(e, "IsSupportedAsync", {
- get: function() {
- return Promise.resolve(this.isSupported())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "IsSupported", {
- get: function() {
- return this.isSupported()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.isSupported = function() {
- if (null !== this._HasMajorPerformanceCaveat)
- return !this._HasMajorPerformanceCaveat;
- if (null === this._IsSupported)
- try {
- var e = this._CreateCanvas(1, 1)
- , t = e.getContext("webgl") || e.getContext("experimental-webgl");
- this._IsSupported = null != t && !!window.WebGLRenderingContext
- } catch (e) {
- this._IsSupported = !1
- }
- return this._IsSupported
- }
- ,
- Object.defineProperty(e, "HasMajorPerformanceCaveat", {
- get: function() {
- if (null === this._HasMajorPerformanceCaveat)
- try {
- var e = this._CreateCanvas(1, 1)
- , t = e.getContext("webgl", {
- failIfMajorPerformanceCaveat: !0
- }) || e.getContext("experimental-webgl", {
- failIfMajorPerformanceCaveat: !0
- });
- this._HasMajorPerformanceCaveat = !t
- } catch (e) {
- this._HasMajorPerformanceCaveat = !1
- }
- return this._HasMajorPerformanceCaveat
- },
- enumerable: !1,
- configurable: !0
- }),
- e.CeilingPOT = function(e) {
- return e--,
- e |= e >> 1,
- e |= e >> 2,
- e |= e >> 4,
- e |= e >> 8,
- e |= e >> 16,
- ++e
- }
- ,
- e.FloorPOT = function(e) {
- return e |= e >> 1,
- e |= e >> 2,
- e |= e >> 4,
- e |= e >> 8,
- (e |= e >> 16) - (e >> 1)
- }
- ,
- e.NearestPOT = function(t) {
- var i = e.CeilingPOT(t)
- , n = e.FloorPOT(t);
- return i - t > t - n ? n : i
- }
- ,
- e.GetExponentOfTwo = function(t, i, n) {
- var r;
- switch (void 0 === n && (n = a.SCALEMODE_NEAREST),
- n) {
- case a.SCALEMODE_FLOOR:
- r = e.FloorPOT(t);
- break;
- case a.SCALEMODE_NEAREST:
- r = e.NearestPOT(t);
- break;
- case a.SCALEMODE_CEILING:
- default:
- r = e.CeilingPOT(t)
- }
- return Math.min(r, i)
- }
- ,
- e.QueueNewFrame = function(e, t) {
- return nt() ? (t || (t = window),
- t.requestPostAnimationFrame ? t.requestPostAnimationFrame(e) : t.requestAnimationFrame ? t.requestAnimationFrame(e) : t.msRequestAnimationFrame ? t.msRequestAnimationFrame(e) : t.webkitRequestAnimationFrame ? t.webkitRequestAnimationFrame(e) : t.mozRequestAnimationFrame ? t.mozRequestAnimationFrame(e) : t.oRequestAnimationFrame ? t.oRequestAnimationFrame(e) : window.setTimeout(e, 16)) : "undefined" != typeof requestAnimationFrame ? requestAnimationFrame(e) : setTimeout(e, 16)
- }
- ,
- e.prototype.getHostDocument = function() {
- return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document
- }
- ,
- e.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"]
- }],
- e._TextureLoaders = [],
- e.CollisionsEpsilon = .001,
- e._IsSupported = null,
- e._HasMajorPerformanceCaveat = null,
- e
- }()
- , Xt = function() {
- function e() {}
- return e.SetImmediate = function(e) {
- nt() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1)
- }
- ,
- e
- }()
- , jt = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i)
- , Yt = function(e) {
- function t(i, n) {
- var r = e.call(this, i, pt.LoadFileError) || this;
- return r.name = "LoadFileError",
- dt._setPrototypeOf(r, t.prototype),
- n instanceof Ye ? r.request = n : r.file = n,
- r
- }
- return U(t, e),
- t
- }(ft)
- , Kt = function(e) {
- function t(i, n) {
- var r = e.call(this, i, pt.RequestFileError) || this;
- return r.request = n,
- r.name = "RequestFileError",
- dt._setPrototypeOf(r, t.prototype),
- r
- }
- return U(t, e),
- t
- }(ft)
- , Qt = function(e) {
- function t(i, n) {
- var r = e.call(this, i, pt.ReadFileError) || this;
- return r.file = n,
- r.name = "ReadFileError",
- dt._setPrototypeOf(r, t.prototype),
- r
- }
- return U(t, e),
- t
- }(ft)
- , qt = {
- DefaultRetryStrategy: ht.ExponentialBackoff(),
- BaseUrl: "",
- CorsBehavior: "anonymous",
- PreprocessUrl: function(e) {
- return e
- }
- }
- , Zt = function(e) {
- return e.replace(/#/gm, "%23")
- }
- , Jt = function(e, t) {
- if ((!e || 0 !== e.indexOf("data:")) && qt.CorsBehavior)
- if ("string" == typeof qt.CorsBehavior || qt.CorsBehavior instanceof String)
- t.crossOrigin = qt.CorsBehavior;
- else {
- var i = qt.CorsBehavior(e);
- i && (t.crossOrigin = i)
- }
- }
- , $t = function(e, t, i, n, r, o) {
- var a, s;
- void 0 === r && (r = "");
- var l = !1;
- e instanceof ArrayBuffer || ArrayBuffer.isView(e) ? "undefined" != typeof Blob ? (s = URL.createObjectURL(new Blob([e],{
- type: r
- })),
- l = !0) : s = "data:".concat(r, ";base64,") + le(e) : e instanceof Blob ? (s = URL.createObjectURL(e),
- l = !0) : (s = Zt(e),
- s = qt.PreprocessUrl(e));
- var c = E.LastCreatedEngine
- , u = function(t) {
- if (i) {
- var n = s || e.toString();
- i("Error while trying to load image: ".concat(0 === n.indexOf("http") || n.length <= 128 ? n : n.slice(0, 128) + "..."), t)
- }
- };
- if ("undefined" == typeof Image || null !== (a = null == c ? void 0 : c._features.forceBitmapOverHTMLImageElement) && void 0 !== a && a)
- return ti(s, (function(n) {
- c.createImageBitmap(new Blob([n],{
- type: r
- }), V({
- premultiplyAlpha: "none"
- }, o)).then((function(e) {
- t(e),
- l && URL.revokeObjectURL(s)
- }
- )).catch((function(t) {
- i && i("Error while trying to load image: " + e, t)
- }
- ))
- }
- ), void 0, n || void 0, !0, (function(e, t) {
- u(t)
- }
- )),
- null;
- var h = new Image;
- Jt(s, h);
- var d = function() {
- h.removeEventListener("load", d),
- h.removeEventListener("error", p),
- t(h),
- l && h.src && URL.revokeObjectURL(h.src)
- }
- , p = function(e) {
- h.removeEventListener("load", d),
- h.removeEventListener("error", p),
- u(e),
- l && h.src && URL.revokeObjectURL(h.src)
- };
- h.addEventListener("load", d),
- h.addEventListener("error", p);
- var f = function() {
- h.src = s
- };
- if ("blob:" !== s.substr(0, 5) && "data:" !== s.substr(0, 5) && n && n.enableTexturesOffline)
- n.open((function() {
- n && n.loadImage(s, h)
- }
- ), f);
- else {
- if (-1 !== s.indexOf("file:")) {
- var _ = decodeURIComponent(s.substring(5).toLowerCase());
- if (ut.FilesToLoad[_]) {
- try {
- var m = void 0;
- try {
- m = URL.createObjectURL(ut.FilesToLoad[_])
- } catch (e) {
- m = URL.createObjectURL(ut.FilesToLoad[_])
- }
- h.src = m,
- l = !0
- } catch (e) {
- h.src = ""
- }
- return h
- }
- }
- f()
- }
- return h
- }
- , ei = function(e, t, i, n, r) {
- var o = new FileReader
- , a = {
- onCompleteObservable: new h,
- abort: function() {
- return o.abort()
- }
- };
- return o.onloadend = function() {
- return a.onCompleteObservable.notifyObservers(a)
- }
- ,
- r && (o.onerror = function() {
- r(new Qt("Unable to read ".concat(e.name),e))
- }
- ),
- o.onload = function(e) {
- t(e.target.result)
- }
- ,
- i && (o.onprogress = i),
- n ? o.readAsArrayBuffer(e) : o.readAsText(e),
- a
- }
- , ti = function(e, t, i, n, r, o, a) {
- if (e.name)
- return ei(e, t, i, r, o ? function(e) {
- o(void 0, e)
- }
- : void 0);
- var s = e;
- if (-1 !== s.indexOf("file:")) {
- var l = decodeURIComponent(s.substring(5).toLowerCase());
- 0 === l.indexOf("./") && (l = l.substring(2));
- var c = ut.FilesToLoad[l];
- if (c)
- return ei(c, t, i, r, o ? function(e) {
- return o(void 0, new Yt(e.message,e.file))
- }
- : void 0)
- }
- if (ri(s)) {
- var u = {
- onCompleteObservable: new h,
- abort: function() {
- return function() {}
- }
- };
- try {
- t(r ? oi(s) : si(s))
- } catch (e) {
- o ? o(void 0, e) : K.Error(e.message || "Failed to parse the Data URL")
- }
- return Xt.SetImmediate((function() {
- u.onCompleteObservable.notifyObservers(u)
- }
- )),
- u
- }
- return ii(s, (function(e, i) {
- t(e, i ? i.responseURL : void 0)
- }
- ), i, n, r, o ? function(e) {
- o(e.request, new Yt(e.message,e.request))
- }
- : void 0, a)
- }
- , ii = function(e, t, i, n, r, o, a) {
- e = Zt(e),
- e = qt.PreprocessUrl(e);
- var s = qt.BaseUrl + e
- , l = !1
- , c = {
- onCompleteObservable: new h,
- abort: function() {
- return l = !0
- }
- }
- , u = function() {
- var e, n = new Ye, u = null, h = function() {
- n && (i && n.removeEventListener("progress", i),
- e && n.removeEventListener("readystatechange", e),
- n.removeEventListener("loadend", d))
- }, d = function() {
- h(),
- c.onCompleteObservable.notifyObservers(c),
- c.onCompleteObservable.clear(),
- i = void 0,
- e = null,
- d = null,
- o = void 0,
- a = void 0,
- t = void 0
- };
- c.abort = function() {
- l = !0,
- d && d(),
- n && n.readyState !== (XMLHttpRequest.DONE || 4) && n.abort(),
- null !== u && (clearTimeout(u),
- u = null),
- n = null
- }
- ;
- var p = function(e) {
- var t = e.message || "Unknown error";
- o && n ? o(new Kt(t,n)) : K.Error(t)
- }
- , f = function(c) {
- if (n) {
- if (n.open("GET", s),
- a)
- try {
- a(n)
- } catch (e) {
- return void p(e)
- }
- r && (n.responseType = "arraybuffer"),
- i && n.addEventListener("progress", i),
- d && n.addEventListener("loadend", d),
- e = function() {
- if (!l && n && n.readyState === (XMLHttpRequest.DONE || 4)) {
- if (e && n.removeEventListener("readystatechange", e),
- n.status >= 200 && n.status < 300 || 0 === n.status && (!nt() || ni())) {
- try {
- t && t(r ? n.response : n.responseText, n)
- } catch (e) {
- p(e)
- }
- return
- }
- var i = qt.DefaultRetryStrategy;
- if (i) {
- var a = i(s, n, c);
- if (-1 !== a)
- return h(),
- n = new Ye,
- void (u = setTimeout((function() {
- return f(c + 1)
- }
- ), a))
- }
- var d = new Kt("Error status: " + n.status + " " + n.statusText + " - Unable to load " + s,n);
- o && o(d)
- }
- }
- ,
- n.addEventListener("readystatechange", e),
- n.send()
- }
- };
- f(0)
- };
- if (n && n.enableSceneOffline) {
- var d = function(e) {
- e && e.status > 400 ? o && o(e) : u()
- };
- n.open((function() {
- n && n.loadFile(qt.BaseUrl + e, (function(e) {
- !l && t && t(e),
- c.onCompleteObservable.notifyObservers(c)
- }
- ), i ? function(e) {
- !l && i && i(e)
- }
- : void 0, d, r)
- }
- ), d)
- } else
- u();
- return c
- }
- , ni = function() {
- return "undefined" != typeof location && "file:" === location.protocol
- }
- , ri = function(e) {
- return jt.test(e)
- };
- function oi(e) {
- return ue(e.split(",")[1])
- }
- var ai, si = function(e) {
- return ce(e.split(",")[1])
- };
- Ht._FileToolsLoadImage = $t,
- Ht._FileToolsLoadFile = ti,
- Ct._FileToolsLoadFile = ti;
- var li, ci = function(e, t, i, n, r, o, a, s, l, c) {
- ai = {
- DecodeBase64UrlToBinary: e,
- DecodeBase64UrlToString: t,
- DefaultRetryStrategy: i.DefaultRetryStrategy,
- BaseUrl: i.BaseUrl,
- CorsBehavior: i.CorsBehavior,
- PreprocessUrl: i.PreprocessUrl,
- IsBase64DataUrl: n,
- IsFileURL: r,
- LoadFile: o,
- LoadImage: a,
- ReadFile: s,
- RequestFile: l,
- SetCorsBehavior: c
- },
- Object.defineProperty(ai, "DefaultRetryStrategy", {
- get: function() {
- return i.DefaultRetryStrategy
- },
- set: function(e) {
- i.DefaultRetryStrategy = e
- }
- }),
- Object.defineProperty(ai, "BaseUrl", {
- get: function() {
- return i.BaseUrl
- },
- set: function(e) {
- i.BaseUrl = e
- }
- }),
- Object.defineProperty(ai, "PreprocessUrl", {
- get: function() {
- return i.PreprocessUrl
- },
- set: function(e) {
- i.PreprocessUrl = e
- }
- }),
- Object.defineProperty(ai, "CorsBehavior", {
- get: function() {
- return i.CorsBehavior
- },
- set: function(e) {
- i.CorsBehavior = e
- }
- })
- };
- ci(oi, si, qt, ri, ni, ti, $t, ei, ii, Jt),
- function(e) {
- e[e.Pending = 0] = "Pending",
- e[e.Fulfilled = 1] = "Fulfilled",
- e[e.Rejected = 2] = "Rejected"
- }(li || (li = {}));
- var ui = function() {
- this.count = 0,
- this.target = 0,
- this.results = []
- }
- , hi = function() {
- function e(e) {
- var t = this;
- if (this._state = li.Pending,
- this._children = new Array,
- this._rejectWasConsumed = !1,
- e)
- try {
- e((function(e) {
- t._resolve(e)
- }
- ), (function(e) {
- t._reject(e)
- }
- ))
- } catch (e) {
- this._reject(e)
- }
- }
- return Object.defineProperty(e.prototype, "_result", {
- get: function() {
- return this._resultValue
- },
- set: function(e) {
- this._resultValue = e,
- this._parent && void 0 === this._parent._result && (this._parent._result = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.catch = function(e) {
- return this.then(void 0, e)
- }
- ,
- e.prototype.then = function(t, i) {
- var n = this
- , r = new e;
- return r._onFulfilled = t,
- r._onRejected = i,
- this._children.push(r),
- r._parent = this,
- this._state !== li.Pending && setTimeout((function() {
- n._state === li.Fulfilled || n._rejectWasConsumed ? r._resolve(n._result) : r._reject(n._reason)
- }
- )),
- r
- }
- ,
- e.prototype._moveChildren = function(e) {
- var t, i = this;
- if ((t = this._children).push.apply(t, e.splice(0, e.length)),
- this._children.forEach((function(e) {
- e._parent = i
- }
- )),
- this._state === li.Fulfilled)
- for (var n = 0, r = this._children; n < r.length; n++)
- r[n]._resolve(this._result);
- else if (this._state === li.Rejected)
- for (var o = 0, a = this._children; o < a.length; o++)
- a[o]._reject(this._reason)
- }
- ,
- e.prototype._resolve = function(e) {
- try {
- this._state = li.Fulfilled;
- var t = null;
- if (this._onFulfilled && (t = this._onFulfilled(e)),
- null != t)
- if (void 0 !== t._state) {
- var i = t;
- i._parent = this,
- i._moveChildren(this._children),
- e = i._result
- } else
- e = t;
- this._result = e;
- for (var n = 0, r = this._children; n < r.length; n++)
- r[n]._resolve(e);
- this._children.length = 0,
- delete this._onFulfilled,
- delete this._onRejected
- } catch (e) {
- this._reject(e, !0)
- }
- }
- ,
- e.prototype._reject = function(e, t) {
- if (void 0 === t && (t = !1),
- this._state = li.Rejected,
- this._reason = e,
- this._onRejected && !t)
- try {
- this._onRejected(e),
- this._rejectWasConsumed = !0
- } catch (t) {
- e = t
- }
- for (var i = 0, n = this._children; i < n.length; i++) {
- var r = n[i];
- this._rejectWasConsumed ? r._resolve(null) : r._reject(e)
- }
- this._children.length = 0,
- delete this._onFulfilled,
- delete this._onRejected
- }
- ,
- e.resolve = function(t) {
- var i = new e;
- return i._resolve(t),
- i
- }
- ,
- e._RegisterForFulfillment = function(e, t, i) {
- e.then((function(e) {
- return t.results[i] = e,
- t.count++,
- t.count === t.target && t.rootPromise._resolve(t.results),
- null
- }
- ), (function(e) {
- t.rootPromise._state !== li.Rejected && t.rootPromise._reject(e)
- }
- ))
- }
- ,
- e.all = function(t) {
- var i = new e
- , n = new ui;
- if (n.target = t.length,
- n.rootPromise = i,
- t.length)
- for (var r = 0; r < t.length; r++)
- e._RegisterForFulfillment(t[r], n, r);
- else
- i._resolve([]);
- return i
- }
- ,
- e.race = function(t) {
- var i = new e;
- if (t.length)
- for (var n = 0, r = t; n < r.length; n++)
- r[n].then((function(e) {
- return i && (i._resolve(e),
- i = null),
- null
- }
- ), (function(e) {
- i && (i._reject(e),
- i = null)
- }
- ));
- return i
- }
- ,
- e
- }()
- , di = function() {
- function e() {}
- return e.Apply = function(e) {
- void 0 === e && (e = !1),
- (e || "undefined" == typeof Promise) && (window.Promise = hi)
- }
- ,
- e
- }()
- , pi = function() {
- function e() {}
- return e.Instantiate = function(e) {
- if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[e])
- return this.RegisteredExternalClasses[e];
- var t = b(e);
- if (t)
- return t;
- K.Warn(e + " not found, you may have missed an import.");
- for (var i = e.split("."), n = window || this, r = 0, o = i.length; r < o; r++)
- n = n[i[r]];
- return "function" != typeof n ? null : n
- }
- ,
- e.RegisteredExternalClasses = {},
- e
- }();
- function fi() {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (function(e) {
- var t = 16 * Math.random() | 0;
- return ("x" === e ? t : 3 & t | 8).toString(16)
- }
- ))
- }
- var _i = {
- RandomId: fi
- }
- , mi = function() {
- function e() {}
- return e.Slice = function(e, t, i) {
- return e.slice ? e.slice(t, i) : Array.prototype.slice.call(e, t, i)
- }
- ,
- e.SliceToArray = function(e, t, i) {
- return Array.isArray(e) ? e.slice(t, i) : Array.prototype.slice.call(e, t, i)
- }
- ,
- e
- }()
- , gi = function() {
- function e() {}
- return Object.defineProperty(e, "BaseUrl", {
- get: function() {
- return qt.BaseUrl
- },
- set: function(e) {
- qt.BaseUrl = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "DefaultRetryStrategy", {
- get: function() {
- return qt.DefaultRetryStrategy
- },
- set: function(e) {
- qt.DefaultRetryStrategy = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "CorsBehavior", {
- get: function() {
- return qt.CorsBehavior
- },
- set: function(e) {
- qt.CorsBehavior = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "UseFallbackTexture", {
- get: function() {
- return E.UseFallbackTexture
- },
- set: function(e) {
- E.UseFallbackTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "RegisteredExternalClasses", {
- get: function() {
- return pi.RegisteredExternalClasses
- },
- set: function(e) {
- pi.RegisteredExternalClasses = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "fallbackTexture", {
- get: function() {
- return E.FallbackTexture
- },
- set: function(e) {
- E.FallbackTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.FetchToRef = function(e, t, i, n, r, o) {
- var a = 4 * ((Math.abs(e) * i % i | 0) + (Math.abs(t) * n % n | 0) * i);
- o.r = r[a] / 255,
- o.g = r[a + 1] / 255,
- o.b = r[a + 2] / 255,
- o.a = r[a + 3] / 255
- }
- ,
- e.Mix = function(e, t, i) {
- return e * (1 - i) + t * i
- }
- ,
- e.Instantiate = function(e) {
- return pi.Instantiate(e)
- }
- ,
- e.Slice = function(e, t, i) {
- return mi.Slice(e, t, i)
- }
- ,
- e.SliceToArray = function(e, t, i) {
- return mi.SliceToArray(e, t, i)
- }
- ,
- e.SetImmediate = function(e) {
- Xt.SetImmediate(e)
- }
- ,
- e.IsExponentOfTwo = function(e) {
- var t = 1;
- do {
- t *= 2
- } while (t < e);
- return t === e
- }
- ,
- e.FloatRound = function(t) {
- return Math.fround ? Math.fround(t) : (e._TmpFloatArray[0] = t,
- e._TmpFloatArray[0])
- }
- ,
- e.GetFilename = function(e) {
- var t = e.lastIndexOf("/");
- return t < 0 ? e : e.substring(t + 1)
- }
- ,
- e.GetFolderPath = function(e, t) {
- void 0 === t && (t = !1);
- var i = e.lastIndexOf("/");
- return i < 0 ? t ? e : "" : e.substring(0, i + 1)
- }
- ,
- e.ToDegrees = function(e) {
- return 180 * e / Math.PI
- }
- ,
- e.ToRadians = function(e) {
- return e * Math.PI / 180
- }
- ,
- e.MakeArray = function(e, t) {
- return !0 === t || void 0 !== e && null != e ? Array.isArray(e) ? e : [e] : null
- }
- ,
- e.GetPointerPrefix = function(e) {
- var t = "pointer";
- return nt() && !window.PointerEvent && (t = "mouse"),
- !e._badDesktopOS || e._badOS || document && "ontouchend"in document || (t = "mouse"),
- t
- }
- ,
- e.SetCorsBehavior = function(e, t) {
- Jt(e, t)
- }
- ,
- e.CleanUrl = function(e) {
- return e.replace(/#/gm, "%23")
- }
- ,
- Object.defineProperty(e, "PreprocessUrl", {
- get: function() {
- return qt.PreprocessUrl
- },
- set: function(e) {
- qt.PreprocessUrl = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.LoadImage = function(e, t, i, n, r, o) {
- return $t(e, t, i, n, r, o)
- }
- ,
- e.LoadFile = function(e, t, i, n, r, o) {
- return ti(e, t, i, n, r, o)
- }
- ,
- e.LoadFileAsync = function(e, t) {
- return void 0 === t && (t = !0),
- new Promise((function(i, n) {
- ti(e, (function(e) {
- i(e)
- }
- ), void 0, void 0, t, (function(e, t) {
- n(t)
- }
- ))
- }
- ))
- }
- ,
- e.LoadScript = function(e, t, i, n) {
- if (nt()) {
- var r = document.getElementsByTagName("head")[0]
- , o = document.createElement("script");
- o.setAttribute("type", "text/javascript"),
- o.setAttribute("src", e),
- n && (o.id = n),
- o.onload = function() {
- t && t()
- }
- ,
- o.onerror = function(t) {
- i && i("Unable to load script '".concat(e, "'"), t)
- }
- ,
- r.appendChild(o)
- }
- }
- ,
- e.LoadScriptAsync = function(e) {
- var t = this;
- return new Promise((function(i, n) {
- t.LoadScript(e, (function() {
- i()
- }
- ), (function(e, t) {
- n(t)
- }
- ))
- }
- ))
- }
- ,
- e.ReadFileAsDataURL = function(e, t, i) {
- var n = new FileReader
- , r = {
- onCompleteObservable: new h,
- abort: function() {
- return n.abort()
- }
- };
- return n.onloadend = function() {
- r.onCompleteObservable.notifyObservers(r)
- }
- ,
- n.onload = function(e) {
- t(e.target.result)
- }
- ,
- n.onprogress = i,
- n.readAsDataURL(e),
- r
- }
- ,
- e.ReadFile = function(e, t, i, n, r) {
- return ei(e, t, i, n, r)
- }
- ,
- e.FileAsURL = function(e) {
- var t = new Blob([e]);
- return (window.URL || window.webkitURL).createObjectURL(t)
- }
- ,
- e.Format = function(e, t) {
- return void 0 === t && (t = 2),
- e.toFixed(t)
- }
- ,
- e.DeepCopy = function(e, t, i, n) {
- fe.DeepCopy(e, t, i, n)
- }
- ,
- e.IsEmpty = function(e) {
- for (var t in e)
- if (Object.prototype.hasOwnProperty.call(e, t))
- return !1;
- return !0
- }
- ,
- e.RegisterTopRootEvents = function(e, t) {
- for (var i = 0; i < t.length; i++) {
- var n = t[i];
- e.addEventListener(n.name, n.handler, !1);
- try {
- window.parent && window.parent.addEventListener(n.name, n.handler, !1)
- } catch (e) {}
- }
- }
- ,
- e.UnregisterTopRootEvents = function(e, t) {
- for (var i = 0; i < t.length; i++) {
- var n = t[i];
- e.removeEventListener(n.name, n.handler);
- try {
- e.parent && e.parent.removeEventListener(n.name, n.handler)
- } catch (e) {}
- }
- }
- ,
- e.DumpFramebuffer = function(t, i, n, r, o, a) {
- return void 0 === o && (o = "image/png"),
- G(this, void 0, void 0, (function() {
- var s, l;
- return z(this, (function(c) {
- switch (c.label) {
- case 0:
- return [4, n.readPixels(0, 0, t, i)];
- case 1:
- return s = c.sent(),
- l = new Uint8Array(s.buffer),
- e.DumpData(t, i, l, r, o, a, !0),
- [2]
- }
- }
- ))
- }
- ))
- }
- ,
- e.DumpData = function(t, i, n, r, o, a, s, l, c) {
- void 0 === o && (o = "image/png"),
- void 0 === s && (s = !1),
- void 0 === l && (l = !1),
- e._ScreenshotCanvas || (e._ScreenshotCanvas = document.createElement("canvas")),
- e._ScreenshotCanvas.width = t,
- e._ScreenshotCanvas.height = i;
- var u = e._ScreenshotCanvas.getContext("2d");
- if (u) {
- if (n instanceof Float32Array) {
- for (var h = new Uint8Array(n.length), d = n.length; d--; ) {
- var p = n[d];
- h[d] = p < 0 ? 0 : p > 1 ? 1 : Math.round(255 * p)
- }
- n = h
- }
- var f = u.createImageData(t, i);
- f.data.set(n),
- u.putImageData(f, 0, 0);
- var _ = e._ScreenshotCanvas;
- if (s) {
- var m = document.createElement("canvas");
- m.width = t,
- m.height = i;
- var g = m.getContext("2d");
- if (!g)
- return;
- g.translate(0, i),
- g.scale(1, -1),
- g.drawImage(e._ScreenshotCanvas, 0, 0),
- _ = m
- }
- l ? e.ToBlob(_, (function(e) {
- var t = new FileReader;
- t.onload = function(e) {
- var t = e.target.result;
- r && r(t)
- }
- ,
- t.readAsArrayBuffer(e)
- }
- ), o, c) : e.EncodeScreenshotCanvasData(r, o, a, _, c)
- }
- }
- ,
- e.DumpDataAsync = function(t, i, n, r, o, a, s, l) {
- return void 0 === r && (r = "image/png"),
- void 0 === a && (a = !1),
- void 0 === s && (s = !1),
- new Promise((function(c) {
- e.DumpData(t, i, n, (function(e) {
- return c(e)
- }
- ), r, o, a, s, l)
- }
- ))
- }
- ,
- e.ToBlob = function(e, t, i, n) {
- void 0 === i && (i = "image/png"),
- e.toBlob || (e.toBlob = function(e, t, i) {
- var n = this;
- setTimeout((function() {
- for (var r = atob(n.toDataURL(t, i).split(",")[1]), o = r.length, a = new Uint8Array(o), s = 0; s < o; s++)
- a[s] = r.charCodeAt(s);
- e(new Blob([a]))
- }
- ))
- }
- ),
- e.toBlob((function(e) {
- t(e)
- }
- ), i, n)
- }
- ,
- e.EncodeScreenshotCanvasData = function(t, i, n, r, o) {
- void 0 === i && (i = "image/png"),
- t ? t((null != r ? r : e._ScreenshotCanvas).toDataURL(i, o)) : this.ToBlob(null != r ? r : e._ScreenshotCanvas, (function(t) {
- if ("download"in document.createElement("a")) {
- if (!n) {
- var i = new Date
- , r = (i.getFullYear() + "-" + (i.getMonth() + 1)).slice(2) + "-" + i.getDate() + "_" + i.getHours() + "-" + ("0" + i.getMinutes()).slice(-2);
- n = "screenshot_" + r + ".png"
- }
- e.Download(t, n)
- } else if (t) {
- var o = URL.createObjectURL(t)
- , a = window.open("");
- if (!a)
- return;
- var s = a.document.createElement("img");
- s.onload = function() {
- URL.revokeObjectURL(o)
- }
- ,
- s.src = o,
- a.document.body.appendChild(s)
- }
- }
- ), i, o)
- }
- ,
- e.Download = function(e, t) {
- if (navigator && navigator.msSaveBlob)
- navigator.msSaveBlob(e, t);
- else {
- var i = window.URL.createObjectURL(e)
- , n = document.createElement("a");
- document.body.appendChild(n),
- n.style.display = "none",
- n.href = i,
- n.download = t,
- n.addEventListener("click", (function() {
- n.parentElement && n.parentElement.removeChild(n)
- }
- )),
- n.click(),
- window.URL.revokeObjectURL(i)
- }
- }
- ,
- e.BackCompatCameraNoPreventDefault = function(e) {
- return "boolean" == typeof e[0] ? e[0] : "boolean" == typeof e[1] && e[1]
- }
- ,
- e.CreateScreenshot = function(e, t, i, n, r) {
- throw void 0 === r && (r = "image/png"),
- be("ScreenshotTools")
- }
- ,
- e.CreateScreenshotAsync = function(e, t, i, n) {
- throw void 0 === n && (n = "image/png"),
- be("ScreenshotTools")
- }
- ,
- e.CreateScreenshotUsingRenderTarget = function(e, t, i, n, r, o, a, s) {
- throw void 0 === r && (r = "image/png"),
- void 0 === o && (o = 1),
- void 0 === a && (a = !1),
- be("ScreenshotTools")
- }
- ,
- e.CreateScreenshotUsingRenderTargetAsync = function(e, t, i, n, r, o, a) {
- throw void 0 === n && (n = "image/png"),
- void 0 === r && (r = 1),
- void 0 === o && (o = !1),
- be("ScreenshotTools")
- }
- ,
- e.RandomId = function() {
- return fi()
- }
- ,
- e.IsBase64 = function(e) {
- return ri(e)
- }
- ,
- e.DecodeBase64 = function(e) {
- return oi(e)
- }
- ,
- Object.defineProperty(e, "errorsCount", {
- get: function() {
- return K.errorsCount
- },
- enumerable: !1,
- configurable: !0
- }),
- e.Log = function(e) {
- K.Log(e)
- }
- ,
- e.Warn = function(e) {
- K.Warn(e)
- }
- ,
- e.Error = function(e) {
- K.Error(e)
- }
- ,
- Object.defineProperty(e, "LogCache", {
- get: function() {
- return K.LogCache
- },
- enumerable: !1,
- configurable: !0
- }),
- e.ClearLogCache = function() {
- K.ClearLogCache()
- }
- ,
- Object.defineProperty(e, "LogLevels", {
- set: function(e) {
- K.LogLevels = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "PerformanceLogLevel", {
- set: function(t) {
- return (t & e.PerformanceUserMarkLogLevel) === e.PerformanceUserMarkLogLevel ? (e.StartPerformanceCounter = e._StartUserMark,
- void (e.EndPerformanceCounter = e._EndUserMark)) : (t & e.PerformanceConsoleLogLevel) === e.PerformanceConsoleLogLevel ? (e.StartPerformanceCounter = e._StartPerformanceConsole,
- void (e.EndPerformanceCounter = e._EndPerformanceConsole)) : (e.StartPerformanceCounter = e._StartPerformanceCounterDisabled,
- void (e.EndPerformanceCounter = e._EndPerformanceCounterDisabled))
- },
- enumerable: !1,
- configurable: !0
- }),
- e._StartPerformanceCounterDisabled = function(e, t) {}
- ,
- e._EndPerformanceCounterDisabled = function(e, t) {}
- ,
- e._StartUserMark = function(t, i) {
- if (void 0 === i && (i = !0),
- !e._Performance) {
- if (!nt())
- return;
- e._Performance = window.performance
- }
- i && e._Performance.mark && e._Performance.mark(t + "-Begin")
- }
- ,
- e._EndUserMark = function(t, i) {
- void 0 === i && (i = !0),
- i && e._Performance.mark && (e._Performance.mark(t + "-End"),
- e._Performance.measure(t, t + "-Begin", t + "-End"))
- }
- ,
- e._StartPerformanceConsole = function(t, i) {
- void 0 === i && (i = !0),
- i && (e._StartUserMark(t, i),
- console.time && console.time(t))
- }
- ,
- e._EndPerformanceConsole = function(t, i) {
- void 0 === i && (i = !0),
- i && (e._EndUserMark(t, i),
- console.timeEnd(t))
- }
- ,
- Object.defineProperty(e, "Now", {
- get: function() {
- return ct.Now
- },
- enumerable: !1,
- configurable: !0
- }),
- e.GetClassName = function(e, t) {
- void 0 === t && (t = !1);
- var i = null;
- return !t && e.getClassName ? i = e.getClassName() : (e instanceof Object && (i = (t ? e : Object.getPrototypeOf(e)).constructor.__bjsclassName__),
- i || (i = typeof e)),
- i
- }
- ,
- e.First = function(e, t) {
- for (var i = 0, n = e; i < n.length; i++) {
- var r = n[i];
- if (t(r))
- return r
- }
- return null
- }
- ,
- e.getFullClassName = function(e, t) {
- void 0 === t && (t = !1);
- var i = null
- , n = null;
- if (!t && e.getClassName)
- i = e.getClassName();
- else {
- if (e instanceof Object) {
- var r = t ? e : Object.getPrototypeOf(e);
- i = r.constructor.__bjsclassName__,
- n = r.constructor.__bjsmoduleName__
- }
- i || (i = typeof e)
- }
- return i ? (null != n ? n + "." : "") + i : null
- }
- ,
- e.DelayAsync = function(e) {
- return new Promise((function(t) {
- setTimeout((function() {
- t()
- }
- ), e)
- }
- ))
- }
- ,
- e.IsSafari = function() {
- return !!rt() && /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
- }
- ,
- e.UseCustomRequestHeaders = !1,
- e.CustomRequestHeaders = Ye.CustomRequestHeaders,
- e._TmpFloatArray = new Float32Array(1),
- e.GetDOMTextContent = at,
- e.GetAbsoluteUrl = "object" == typeof document ? function(e) {
- var t = document.createElement("a");
- return t.href = e,
- t.href
- }
- : "function" == typeof URL && "object" == typeof location ? function(e) {
- return new URL(e,location.origin).href
- }
- : function() {
- throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")
- }
- ,
- e.NoneLogLevel = K.NoneLogLevel,
- e.MessageLogLevel = K.MessageLogLevel,
- e.WarningLogLevel = K.WarningLogLevel,
- e.ErrorLogLevel = K.ErrorLogLevel,
- e.AllLogLevel = K.AllLogLevel,
- e.IsWindowObjectExist = nt,
- e.PerformanceNoneLogLevel = 0,
- e.PerformanceUserMarkLogLevel = 1,
- e.PerformanceConsoleLogLevel = 2,
- e.StartPerformanceCounter = e._StartPerformanceCounterDisabled,
- e.EndPerformanceCounter = e._EndPerformanceCounterDisabled,
- e
- }();
- function vi(e, t) {
- return function(i) {
- i.__bjsclassName__ = e,
- i.__bjsmoduleName__ = null != t ? t : null
- }
- }
- var yi = function() {
- function e(e, t, i, n) {
- void 0 === n && (n = 0),
- this.iterations = e,
- this.index = n - 1,
- this._done = !1,
- this._fn = t,
- this._successCallback = i
- }
- return e.prototype.executeNext = function() {
- this._done || (this.index + 1 < this.iterations ? (++this.index,
- this._fn(this)) : this.breakLoop())
- }
- ,
- e.prototype.breakLoop = function() {
- this._done = !0,
- this._successCallback()
- }
- ,
- e.Run = function(t, i, n, r) {
- void 0 === r && (r = 0);
- var o = new e(t,i,n,r);
- return o.executeNext(),
- o
- }
- ,
- e.SyncAsyncForLoop = function(t, i, n, r, o, a) {
- return void 0 === a && (a = 0),
- e.Run(Math.ceil(t / i), (function(e) {
- o && o() ? e.breakLoop() : setTimeout((function() {
- for (var r = 0; r < i; ++r) {
- var a = e.index * i + r;
- if (a >= t)
- break;
- if (n(a),
- o && o()) {
- e.breakLoop();
- break
- }
- }
- e.executeNext()
- }
- ), a)
- }
- ), r)
- }
- ,
- e
- }();
- E.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",
- di.Apply();
- var bi = function() {
- function e(t) {
- this.length = 0,
- this.data = new Array(t),
- this._id = e._GlobalId++
- }
- return e.prototype.push = function(e) {
- this.data[this.length++] = e,
- this.length > this.data.length && (this.data.length *= 2)
- }
- ,
- e.prototype.forEach = function(e) {
- for (var t = 0; t < this.length; t++)
- e(this.data[t])
- }
- ,
- e.prototype.sort = function(e) {
- this.data.sort(e)
- }
- ,
- e.prototype.reset = function() {
- this.length = 0
- }
- ,
- e.prototype.dispose = function() {
- this.reset(),
- this.data && (this.data.length = 0,
- this.data = [])
- }
- ,
- e.prototype.concat = function(e) {
- if (0 !== e.length) {
- this.length + e.length > this.data.length && (this.data.length = 2 * (this.length + e.length));
- for (var t = 0; t < e.length; t++)
- this.data[this.length++] = (e.data || e)[t]
- }
- }
- ,
- e.prototype.indexOf = function(e) {
- var t = this.data.indexOf(e);
- return t >= this.length ? -1 : t
- }
- ,
- e.prototype.contains = function(e) {
- return -1 !== this.indexOf(e)
- }
- ,
- e._GlobalId = 0,
- e
- }()
- , Ti = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t._duplicateId = 0,
- t
- }
- return U(t, e),
- t.prototype.push = function(t) {
- e.prototype.push.call(this, t),
- t.__smartArrayFlags || (t.__smartArrayFlags = {}),
- t.__smartArrayFlags[this._id] = this._duplicateId
- }
- ,
- t.prototype.pushNoDuplicate = function(e) {
- return !(e.__smartArrayFlags && e.__smartArrayFlags[this._id] === this._duplicateId || (this.push(e),
- 0))
- }
- ,
- t.prototype.reset = function() {
- e.prototype.reset.call(this),
- this._duplicateId++
- }
- ,
- t.prototype.concatWithNoDuplicate = function(e) {
- if (0 !== e.length) {
- this.length + e.length > this.data.length && (this.data.length = 2 * (this.length + e.length));
- for (var t = 0; t < e.length; t++) {
- var i = (e.data || e)[t];
- this.pushNoDuplicate(i)
- }
- }
- }
- ,
- t
- }(bi)
- , Ei = function() {
- function e() {
- this._count = 0,
- this._data = {}
- }
- return e.prototype.copyFrom = function(e) {
- var t = this;
- this.clear(),
- e.forEach((function(e, i) {
- return t.add(e, i)
- }
- ))
- }
- ,
- e.prototype.get = function(e) {
- var t = this._data[e];
- if (void 0 !== t)
- return t
- }
- ,
- e.prototype.getOrAddWithFactory = function(e, t) {
- var i = this.get(e);
- return void 0 !== i || (i = t(e)) && this.add(e, i),
- i
- }
- ,
- e.prototype.getOrAdd = function(e, t) {
- var i = this.get(e);
- return void 0 !== i ? i : (this.add(e, t),
- t)
- }
- ,
- e.prototype.contains = function(e) {
- return void 0 !== this._data[e]
- }
- ,
- e.prototype.add = function(e, t) {
- return void 0 === this._data[e] && (this._data[e] = t,
- ++this._count,
- !0)
- }
- ,
- e.prototype.set = function(e, t) {
- return void 0 !== this._data[e] && (this._data[e] = t,
- !0)
- }
- ,
- e.prototype.getAndRemove = function(e) {
- var t = this.get(e);
- return void 0 !== t ? (delete this._data[e],
- --this._count,
- t) : null
- }
- ,
- e.prototype.remove = function(e) {
- return !!this.contains(e) && (delete this._data[e],
- --this._count,
- !0)
- }
- ,
- e.prototype.clear = function() {
- this._data = {},
- this._count = 0
- }
- ,
- Object.defineProperty(e.prototype, "count", {
- get: function() {
- return this._count
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.forEach = function(e) {
- for (var t in this._data)
- e(t, this._data[t])
- }
- ,
- e.prototype.first = function(e) {
- for (var t in this._data) {
- var i = e(t, this._data[t]);
- if (i)
- return i
- }
- return null
- }
- ,
- e
- }()
- , Si = function() {
- function e(e) {
- if (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,
- this._externalProperties = e,
- e)
- for (var t in e)
- Object.prototype.hasOwnProperty.call(e, t) && this._setDefaultValue(t)
- }
- return Object.defineProperty(e.prototype, "isDirty", {
- get: function() {
- return this._isDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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
- }
- ,
- e.prototype.markAsUnprocessed = function() {
- this._isDirty = !0
- }
- ,
- e.prototype.markAllAsDirty = function() {
- this._areTexturesDirty = !0,
- this._areAttributesDirty = !0,
- this._areLightsDirty = !0,
- this._areFresnelDirty = !0,
- this._areMiscDirty = !0,
- this._areImageProcessingDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsImageProcessingDirty = function() {
- this._areImageProcessingDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsLightDirty = function(e) {
- void 0 === e && (e = !1),
- this._areLightsDirty = !0,
- this._areLightsDisposed = this._areLightsDisposed || e,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsAttributesDirty = function() {
- this._areAttributesDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsTexturesDirty = function() {
- this._areTexturesDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsFresnelDirty = function() {
- this._areFresnelDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsMiscDirty = function() {
- this._areMiscDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.markAsPrePassDirty = function() {
- this._arePrePassDirty = !0,
- this._isDirty = !0
- }
- ,
- e.prototype.rebuild = function() {
- this._keys = [];
- for (var e = 0, t = Object.keys(this); e < t.length; e++) {
- var i = t[e];
- "_" !== i[0] && this._keys.push(i)
- }
- if (this._externalProperties)
- for (var n in this._externalProperties)
- this._keys.push(n)
- }
- ,
- e.prototype.isEqual = function(e) {
- if (this._keys.length !== e._keys.length)
- return !1;
- for (var t = 0; t < this._keys.length; t++) {
- var i = this._keys[t];
- if (this[i] !== e[i])
- return !1
- }
- return !0
- }
- ,
- e.prototype.cloneTo = function(e) {
- this._keys.length !== e._keys.length && (e._keys = this._keys.slice(0));
- for (var t = 0; t < this._keys.length; t++) {
- var i = this._keys[t];
- e[i] = this[i]
- }
- }
- ,
- e.prototype.reset = function() {
- var e = this;
- this._keys.forEach((function(t) {
- return e._setDefaultValue(t)
- }
- ))
- }
- ,
- e.prototype._setDefaultValue = function(e) {
- var t, i, n, r, o, a = null !== (n = null === (i = null === (t = this._externalProperties) || void 0 === t ? void 0 : t[e]) || void 0 === i ? void 0 : i.type) && void 0 !== n ? n : typeof this[e], s = null === (o = null === (r = this._externalProperties) || void 0 === r ? void 0 : r[e]) || void 0 === o ? void 0 : o.default;
- switch (a) {
- case "number":
- this[e] = null != s ? s : 0;
- break;
- case "string":
- this[e] = null != s ? s : "";
- break;
- default:
- this[e] = null != s && s
- }
- }
- ,
- e.prototype.toString = function() {
- for (var e = "", t = 0; t < this._keys.length; t++) {
- var i = this._keys[t]
- , n = this[i];
- switch (typeof n) {
- case "number":
- case "string":
- e += "#define " + i + " " + n + "\n";
- break;
- default:
- n && (e += "#define " + i + "\n")
- }
- }
- return e
- }
- ,
- e
- }()
- , Ai = function() {
- function e() {
- this._dirty = !0,
- this._tempColor = new N(0,0,0,0),
- this._globalCurve = new N(0,0,0,0),
- this._highlightsCurve = new N(0,0,0,0),
- this._midtonesCurve = new N(0,0,0,0),
- this._shadowsCurve = new N(0,0,0,0),
- this._positiveCurve = new N(0,0,0,0),
- this._negativeCurve = new N(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(e.prototype, "globalHue", {
- get: function() {
- return this._globalHue
- },
- set: function(e) {
- this._globalHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "globalDensity", {
- get: function() {
- return this._globalDensity
- },
- set: function(e) {
- this._globalDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "globalSaturation", {
- get: function() {
- return this._globalSaturation
- },
- set: function(e) {
- this._globalSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "globalExposure", {
- get: function() {
- return this._globalExposure
- },
- set: function(e) {
- this._globalExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "highlightsHue", {
- get: function() {
- return this._highlightsHue
- },
- set: function(e) {
- this._highlightsHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "highlightsDensity", {
- get: function() {
- return this._highlightsDensity
- },
- set: function(e) {
- this._highlightsDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "highlightsSaturation", {
- get: function() {
- return this._highlightsSaturation
- },
- set: function(e) {
- this._highlightsSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "highlightsExposure", {
- get: function() {
- return this._highlightsExposure
- },
- set: function(e) {
- this._highlightsExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "midtonesHue", {
- get: function() {
- return this._midtonesHue
- },
- set: function(e) {
- this._midtonesHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "midtonesDensity", {
- get: function() {
- return this._midtonesDensity
- },
- set: function(e) {
- this._midtonesDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "midtonesSaturation", {
- get: function() {
- return this._midtonesSaturation
- },
- set: function(e) {
- this._midtonesSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "midtonesExposure", {
- get: function() {
- return this._midtonesExposure
- },
- set: function(e) {
- this._midtonesExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowsHue", {
- get: function() {
- return this._shadowsHue
- },
- set: function(e) {
- this._shadowsHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowsDensity", {
- get: function() {
- return this._shadowsDensity
- },
- set: function(e) {
- this._shadowsDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowsSaturation", {
- get: function() {
- return this._shadowsSaturation
- },
- set: function(e) {
- this._shadowsSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowsExposure", {
- get: function() {
- return this._shadowsExposure
- },
- set: function(e) {
- this._shadowsExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ColorCurves"
- }
- ,
- e.Bind = function(e, t, i, n, r) {
- void 0 === i && (i = "vCameraColorCurvePositive"),
- void 0 === n && (n = "vCameraColorCurveNeutral"),
- void 0 === r && (r = "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)),
- t && (t.setFloat4(i, e._positiveCurve.r, e._positiveCurve.g, e._positiveCurve.b, e._positiveCurve.a),
- t.setFloat4(n, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a),
- t.setFloat4(r, e._negativeCurve.r, e._negativeCurve.g, e._negativeCurve.b, e._negativeCurve.a))
- }
- ,
- e.PrepareUniforms = function(e) {
- e.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative")
- }
- ,
- e.prototype._getColorGradingDataToRef = function(t, i, n, r, o) {
- null != t && (t = e._Clamp(t, 0, 360),
- i = e._Clamp(i, -100, 100),
- n = e._Clamp(n, -100, 100),
- r = e._Clamp(r, -100, 100),
- i = e._ApplyColorGradingSliderNonlinear(i),
- i *= .5,
- r = e._ApplyColorGradingSliderNonlinear(r),
- i < 0 && (i *= -1,
- t = (t + 180) % 360),
- e._FromHSBToRef(t, i, 50 + .25 * r, o),
- o.scaleToRef(2, o),
- o.a = 1 + .01 * n)
- }
- ,
- e._ApplyColorGradingSliderNonlinear = function(e) {
- e /= 100;
- var t = Math.abs(e);
- return t = Math.pow(t, 2),
- e < 0 && (t *= -1),
- 100 * t
- }
- ,
- e._FromHSBToRef = function(t, i, n, r) {
- var o = e._Clamp(t, 0, 360)
- , a = e._Clamp(i / 100, 0, 1)
- , s = e._Clamp(n / 100, 0, 1);
- if (0 === a)
- r.r = s,
- r.g = s,
- r.b = s;
- else {
- o /= 60;
- var l = Math.floor(o)
- , c = o - l
- , u = s * (1 - a)
- , h = s * (1 - a * c)
- , d = s * (1 - a * (1 - c));
- switch (l) {
- case 0:
- r.r = s,
- r.g = d,
- r.b = u;
- break;
- case 1:
- r.r = h,
- r.g = s,
- r.b = u;
- break;
- case 2:
- r.r = u,
- r.g = s,
- r.b = d;
- break;
- case 3:
- r.r = u,
- r.g = h,
- r.b = s;
- break;
- case 4:
- r.r = d,
- r.g = u,
- r.b = s;
- break;
- default:
- r.r = s,
- r.g = u,
- r.b = h
- }
- }
- r.a = 1
- }
- ,
- e._Clamp = function(e, t, i) {
- return Math.min(Math.max(e, t), i)
- }
- ,
- e.prototype.clone = function() {
- return Ge.Clone((function() {
- return new e
- }
- ), this)
- }
- ,
- e.prototype.serialize = function() {
- return Ge.Serialize(this)
- }
- ,
- e.Parse = function(t) {
- return Ge.Parse((function() {
- return new e
- }
- ), t, null, null)
- }
- ,
- k([Ce()], e.prototype, "_globalHue", void 0),
- k([Ce()], e.prototype, "_globalDensity", void 0),
- k([Ce()], e.prototype, "_globalSaturation", void 0),
- k([Ce()], e.prototype, "_globalExposure", void 0),
- k([Ce()], e.prototype, "_highlightsHue", void 0),
- k([Ce()], e.prototype, "_highlightsDensity", void 0),
- k([Ce()], e.prototype, "_highlightsSaturation", void 0),
- k([Ce()], e.prototype, "_highlightsExposure", void 0),
- k([Ce()], e.prototype, "_midtonesHue", void 0),
- k([Ce()], e.prototype, "_midtonesDensity", void 0),
- k([Ce()], e.prototype, "_midtonesSaturation", void 0),
- k([Ce()], e.prototype, "_midtonesExposure", void 0),
- e
- }();
- Ge._ColorCurvesParser = Ai.Parse;
- var xi = function(e) {
- function t() {
- var t = e.call(this) || this;
- return t.IMAGEPROCESSING = !1,
- t.VIGNETTE = !1,
- t.VIGNETTEBLENDMODEMULTIPLY = !1,
- t.VIGNETTEBLENDMODEOPAQUE = !1,
- t.TONEMAPPING = !1,
- t.TONEMAPPING_ACES = !1,
- t.CONTRAST = !1,
- t.COLORCURVES = !1,
- t.COLORGRADING = !1,
- t.COLORGRADING3D = !1,
- t.SAMPLER3DGREENDEPTH = !1,
- t.SAMPLER3DBGRMAP = !1,
- t.IMAGEPROCESSINGPOSTPROCESS = !1,
- t.EXPOSURE = !1,
- t.SKIPFINALCOLORCLAMP = !1,
- t.rebuild(),
- t
- }
- return U(t, e),
- t
- }(Si)
- , Ri = function() {
- function e() {
- this.colorCurves = new Ai,
- this._colorCurvesEnabled = !1,
- this._colorGradingEnabled = !1,
- this._colorGradingWithGreenDepth = !0,
- this._colorGradingBGR = !0,
- this._exposure = 1,
- this._toneMappingEnabled = !1,
- this._toneMappingType = e.TONEMAPPING_STANDARD,
- this._contrast = 1,
- this.vignetteStretch = 0,
- this.vignetteCentreX = 0,
- this.vignetteCentreY = 0,
- this.vignetteWeight = 1.5,
- this.vignetteColor = new N(0,0,0,0),
- this.vignetteCameraFov = .5,
- this._vignetteBlendMode = e.VIGNETTEMODE_MULTIPLY,
- this._vignetteEnabled = !1,
- this._skipFinalColorClamp = !1,
- this._applyByPostProcess = !1,
- this._isEnabled = !0,
- this.onUpdateParameters = new h
- }
- return Object.defineProperty(e.prototype, "colorCurvesEnabled", {
- get: function() {
- return this._colorCurvesEnabled
- },
- set: function(e) {
- this._colorCurvesEnabled !== e && (this._colorCurvesEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorGradingTexture", {
- get: function() {
- return this._colorGradingTexture
- },
- set: function(e) {
- this._colorGradingTexture !== e && (this._colorGradingTexture = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorGradingEnabled", {
- get: function() {
- return this._colorGradingEnabled
- },
- set: function(e) {
- this._colorGradingEnabled !== e && (this._colorGradingEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorGradingWithGreenDepth", {
- get: function() {
- return this._colorGradingWithGreenDepth
- },
- set: function(e) {
- this._colorGradingWithGreenDepth !== e && (this._colorGradingWithGreenDepth = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorGradingBGR", {
- get: function() {
- return this._colorGradingBGR
- },
- set: function(e) {
- this._colorGradingBGR !== e && (this._colorGradingBGR = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "exposure", {
- get: function() {
- return this._exposure
- },
- set: function(e) {
- this._exposure !== e && (this._exposure = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "toneMappingEnabled", {
- get: function() {
- return this._toneMappingEnabled
- },
- set: function(e) {
- this._toneMappingEnabled !== e && (this._toneMappingEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "toneMappingType", {
- get: function() {
- return this._toneMappingType
- },
- set: function(e) {
- this._toneMappingType !== e && (this._toneMappingType = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "contrast", {
- get: function() {
- return this._contrast
- },
- set: function(e) {
- this._contrast !== e && (this._contrast = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteBlendMode", {
- get: function() {
- return this._vignetteBlendMode
- },
- set: function(e) {
- this._vignetteBlendMode !== e && (this._vignetteBlendMode = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteEnabled", {
- get: function() {
- return this._vignetteEnabled
- },
- set: function(e) {
- this._vignetteEnabled !== e && (this._vignetteEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skipFinalColorClamp", {
- get: function() {
- return this._skipFinalColorClamp
- },
- set: function(e) {
- this._skipFinalColorClamp !== e && (this._skipFinalColorClamp = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "applyByPostProcess", {
- get: function() {
- return this._applyByPostProcess
- },
- set: function(e) {
- this._applyByPostProcess !== e && (this._applyByPostProcess = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled !== e && (this._isEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._updateParameters = function() {
- this.onUpdateParameters.notifyObservers(this)
- }
- ,
- e.prototype.getClassName = function() {
- return "ImageProcessingConfiguration"
- }
- ,
- e.PrepareUniforms = function(e, t) {
- t.EXPOSURE && e.push("exposureLinear"),
- t.CONTRAST && e.push("contrast"),
- t.COLORGRADING && e.push("colorTransformSettings"),
- t.VIGNETTE && (e.push("vInverseScreenSize"),
- e.push("vignetteSettings1"),
- e.push("vignetteSettings2")),
- t.COLORCURVES && Ai.PrepareUniforms(e)
- }
- ,
- e.PrepareSamplers = function(e, t) {
- t.COLORGRADING && e.push("txColorTransform")
- }
- ,
- e.prototype.prepareDefines = function(t, i) {
- if (void 0 === i && (i = !1),
- i !== this.applyByPostProcess || !this._isEnabled)
- return t.VIGNETTE = !1,
- t.TONEMAPPING = !1,
- t.TONEMAPPING_ACES = !1,
- t.CONTRAST = !1,
- t.EXPOSURE = !1,
- t.COLORCURVES = !1,
- t.COLORGRADING = !1,
- t.COLORGRADING3D = !1,
- t.IMAGEPROCESSING = !1,
- t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
- void (t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled);
- t.VIGNETTE = this.vignetteEnabled,
- t.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === e._VIGNETTEMODE_MULTIPLY,
- t.VIGNETTEBLENDMODEOPAQUE = !t.VIGNETTEBLENDMODEMULTIPLY,
- t.TONEMAPPING = this.toneMappingEnabled,
- this._toneMappingType === e.TONEMAPPING_ACES ? t.TONEMAPPING_ACES = !0 : t.TONEMAPPING_ACES = !1,
- t.CONTRAST = 1 !== this.contrast,
- t.EXPOSURE = 1 !== this.exposure,
- t.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves,
- t.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture,
- t.COLORGRADING ? t.COLORGRADING3D = this.colorGradingTexture.is3D : t.COLORGRADING3D = !1,
- t.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth,
- t.SAMPLER3DBGRMAP = this.colorGradingBGR,
- t.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess,
- t.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
- t.IMAGEPROCESSING = t.VIGNETTE || t.TONEMAPPING || t.CONTRAST || t.EXPOSURE || t.COLORCURVES || t.COLORGRADING
- }
- ,
- e.prototype.isReady = function() {
- return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady()
- }
- ,
- e.prototype.bind = function(e, t) {
- if (this._colorCurvesEnabled && this.colorCurves && Ai.Bind(this.colorCurves, e),
- this._vignetteEnabled) {
- var i = 1 / e.getEngine().getRenderWidth()
- , n = 1 / e.getEngine().getRenderHeight();
- e.setFloat2("vInverseScreenSize", i, n);
- var r = null != t ? t : n / i
- , o = Math.tan(.5 * this.vignetteCameraFov)
- , a = o * r
- , s = Math.sqrt(a * o);
- a = gi.Mix(a, s, this.vignetteStretch),
- o = gi.Mix(o, s, this.vignetteStretch),
- e.setFloat4("vignetteSettings1", a, o, -a * this.vignetteCentreX, -o * this.vignetteCentreY);
- var l = -2 * this.vignetteWeight;
- e.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, l)
- }
- if (e.setFloat("exposureLinear", this.exposure),
- e.setFloat("contrast", this.contrast),
- this.colorGradingTexture) {
- e.setTexture("txColorTransform", this.colorGradingTexture);
- var c = this.colorGradingTexture.getSize().height;
- e.setFloat4("colorTransformSettings", (c - 1) / c, .5 / c, c, this.colorGradingTexture.level)
- }
- }
- ,
- e.prototype.clone = function() {
- return Ge.Clone((function() {
- return new e
- }
- ), this)
- }
- ,
- e.prototype.serialize = function() {
- return Ge.Serialize(this)
- }
- ,
- e.Parse = function(t) {
- return Ge.Parse((function() {
- return new e
- }
- ), t, null, null)
- }
- ,
- Object.defineProperty(e, "VIGNETTEMODE_MULTIPLY", {
- get: function() {
- return this._VIGNETTEMODE_MULTIPLY
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "VIGNETTEMODE_OPAQUE", {
- get: function() {
- return this._VIGNETTEMODE_OPAQUE
- },
- enumerable: !1,
- configurable: !0
- }),
- e.TONEMAPPING_STANDARD = 0,
- e.TONEMAPPING_ACES = 1,
- e._VIGNETTEMODE_MULTIPLY = 0,
- e._VIGNETTEMODE_OPAQUE = 1,
- k([Le()], e.prototype, "colorCurves", void 0),
- k([Ce()], e.prototype, "_colorCurvesEnabled", void 0),
- k([Pe("colorGradingTexture")], e.prototype, "_colorGradingTexture", void 0),
- k([Ce()], e.prototype, "_colorGradingEnabled", void 0),
- k([Ce()], e.prototype, "_colorGradingWithGreenDepth", void 0),
- k([Ce()], e.prototype, "_colorGradingBGR", void 0),
- k([Ce()], e.prototype, "_exposure", void 0),
- k([Ce()], e.prototype, "_toneMappingEnabled", void 0),
- k([Ce()], e.prototype, "_toneMappingType", void 0),
- k([Ce()], e.prototype, "_contrast", void 0),
- k([Ce()], e.prototype, "vignetteStretch", void 0),
- k([Ce()], e.prototype, "vignetteCentreX", void 0),
- k([Ce()], e.prototype, "vignetteCentreY", void 0),
- k([Ce()], e.prototype, "vignetteWeight", void 0),
- k([Fe()], e.prototype, "vignetteColor", void 0),
- k([Ce()], e.prototype, "vignetteCameraFov", void 0),
- k([Ce()], e.prototype, "_vignetteBlendMode", void 0),
- k([Ce()], e.prototype, "_vignetteEnabled", void 0),
- k([Ce()], e.prototype, "_skipFinalColorClamp", void 0),
- k([Ce()], e.prototype, "_applyByPostProcess", void 0),
- k([Ce()], e.prototype, "_isEnabled", void 0),
- e
- }();
- Ge._ImageProcessingConfigurationParser = Ri.Parse,
- Ht.prototype.createUniformBuffer = function(e) {
- var t = this._gl.createBuffer();
- if (!t)
- throw new Error("Unable to create uniform buffer");
- var i = new Ut(t);
- return this.bindUniformBuffer(i),
- e instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, e, this._gl.STATIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(e), this._gl.STATIC_DRAW),
- this.bindUniformBuffer(null),
- i.references = 1,
- i
- }
- ,
- Ht.prototype.createDynamicUniformBuffer = function(e) {
- var t = this._gl.createBuffer();
- if (!t)
- throw new Error("Unable to create dynamic uniform buffer");
- var i = new Ut(t);
- return this.bindUniformBuffer(i),
- e instanceof Float32Array ? this._gl.bufferData(this._gl.UNIFORM_BUFFER, e, this._gl.DYNAMIC_DRAW) : this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(e), this._gl.DYNAMIC_DRAW),
- this.bindUniformBuffer(null),
- i.references = 1,
- i
- }
- ,
- Ht.prototype.updateUniformBuffer = function(e, t, i, n) {
- this.bindUniformBuffer(e),
- void 0 === i && (i = 0),
- void 0 === n ? t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, t) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, i, new Float32Array(t)) : t instanceof Float32Array ? this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, t.subarray(i, i + n)) : this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(t).subarray(i, i + n)),
- this.bindUniformBuffer(null)
- }
- ,
- Ht.prototype.bindUniformBuffer = function(e) {
- this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, e ? e.underlyingResource : null)
- }
- ,
- Ht.prototype.bindUniformBufferBase = function(e, t, i) {
- this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, t, e ? e.underlyingResource : null)
- }
- ,
- Ht.prototype.bindUniformBlock = function(e, t, i) {
- var n = e.program
- , r = this._gl.getUniformBlockIndex(n, t);
- 4294967295 !== r && this._gl.uniformBlockBinding(n, r, i)
- }
- ;
- var Ci, Pi, Mi, Ii, Oi, Di, Ni, Li, Fi = function() {
- function e(e, t, i, n, r) {
- void 0 === r && (r = !1),
- this._valueCache = {},
- this._engine = e,
- this._noUBO = !e.supportsUniformBuffers || r,
- this._dynamic = i,
- this._name = null != n ? n : "no-name",
- this._data = t || [],
- 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(e.prototype, "useUbo", {
- get: function() {
- return !this._noUBO
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isSync", {
- get: function() {
- return !this._needSync
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isDynamic = function() {
- return void 0 !== this._dynamic
- }
- ,
- e.prototype.getData = function() {
- return this._bufferData
- }
- ,
- e.prototype.getBuffer = function() {
- return this._buffer
- }
- ,
- e.prototype._fillAlignment = function(e) {
- var t;
- if (t = e <= 2 ? e : 4,
- this._uniformLocationPointer % t != 0) {
- var i = this._uniformLocationPointer;
- this._uniformLocationPointer += t - this._uniformLocationPointer % t;
- for (var n = this._uniformLocationPointer - i, r = 0; r < n; r++)
- this._data.push(0)
- }
- }
- ,
- e.prototype.addUniform = function(e, t, i) {
- if (void 0 === i && (i = 0),
- !this._noUBO && void 0 === this._uniformLocations[e]) {
- var n;
- if (i > 0) {
- if (t instanceof Array)
- throw "addUniform should not be use with Array in UBO: " + e;
- this._fillAlignment(4),
- this._uniformArraySizes[e] = {
- strideSize: t,
- arraySize: i
- },
- 16 == t ? t *= i : t = t * i + (4 - t) * i,
- n = [];
- for (var r = 0; r < t; r++)
- n.push(0)
- } else {
- if (t instanceof Array)
- t = (n = t).length;
- else
- for (t = t,
- n = [],
- r = 0; r < t; r++)
- n.push(0);
- this._fillAlignment(t)
- }
- for (this._uniformSizes[e] = t,
- this._uniformLocations[e] = this._uniformLocationPointer,
- this._uniformLocationPointer += t,
- r = 0; r < t; r++)
- this._data.push(n[r]);
- this._needSync = !0
- }
- }
- ,
- e.prototype.addMatrix = function(e, t) {
- this.addUniform(e, Array.prototype.slice.call(t.toArray()))
- }
- ,
- e.prototype.addFloat2 = function(e, t, i) {
- var n = [t, i];
- this.addUniform(e, n)
- }
- ,
- e.prototype.addFloat3 = function(e, t, i, n) {
- var r = [t, i, n];
- this.addUniform(e, r)
- }
- ,
- e.prototype.addColor3 = function(e, t) {
- var i = [t.r, t.g, t.b];
- this.addUniform(e, i)
- }
- ,
- e.prototype.addColor4 = function(e, t, i) {
- var n = [t.r, t.g, t.b, i];
- this.addUniform(e, n)
- }
- ,
- e.prototype.addVector3 = function(e, t) {
- var i = [t.x, t.y, t.z];
- this.addUniform(e, i)
- }
- ,
- e.prototype.addMatrix3x3 = function(e) {
- this.addUniform(e, 12)
- }
- ,
- e.prototype.addMatrix2x2 = function(e) {
- this.addUniform(e, 8)
- }
- ,
- e.prototype.create = function() {
- this._noUBO || this._buffer || (this._fillAlignment(4),
- this._bufferData = new Float32Array(this._data),
- this._rebuild(),
- this._needSync = !0)
- }
- ,
- e.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(e.prototype, "_numBuffers", {
- get: function() {
- return this._buffers.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_indexBuffer", {
- get: function() {
- return this._bufferIndex
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "name", {
- get: function() {
- return this._name
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buffersEqual = function(e, t) {
- for (var i = 0; i < e.length; ++i)
- if (e[i] !== t[i])
- return !1;
- return !0
- }
- ,
- e.prototype._copyBuffer = function(e, t) {
- for (var i = 0; i < e.length; ++i)
- t[i] = e[i]
- }
- ,
- e.prototype.update = function() {
- if (!this._noUBO)
- if (this.bindUniformBuffer(),
- this._buffer)
- if (this._dynamic || this._needSync) {
- if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1]) {
- if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1]))
- return this._needSync = !1,
- void (this._createBufferOnWrite = this._engine._features.trackUbosInFrame);
- this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1])
- }
- this._engine.updateUniformBuffer(this._buffer, this._bufferData),
- this._engine._features._collectUbosUpdatedInFrame && (e._UpdatedUbosInFrame[this._name] || (e._UpdatedUbosInFrame[this._name] = 0),
- e._UpdatedUbosInFrame[this._name]++),
- this._needSync = !1,
- this._createBufferOnWrite = this._engine._features.trackUbosInFrame
- } else
- this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
- else
- this.create()
- }
- ,
- e.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()
- }
- ,
- e.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 = 0 !== this._bufferIndex,
- this._bufferIndex = 0,
- this._buffer = this._buffers[this._bufferIndex][0]) : this._bufferIndex = -1)
- }
- ,
- e.prototype.updateUniform = function(e, t, i) {
- this._checkNewFrame();
- var n = this._uniformLocations[e];
- if (void 0 === n) {
- if (this._buffer)
- return void K.Error("Cannot add an uniform after UBO has been created.");
- this.addUniform(e, i),
- n = this._uniformLocations[e]
- }
- if (this._buffer || this.create(),
- this._dynamic)
- for (o = 0; o < i; o++)
- this._bufferData[n + o] = t[o];
- else {
- for (var r = !1, o = 0; o < i; o++)
- (16 === i && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[n + o] !== gi.FloatRound(t[o])) && (r = !0,
- this._createBufferOnWrite && this._createNewBuffer(),
- this._bufferData[n + o] = t[o]);
- this._needSync = this._needSync || r
- }
- }
- ,
- e.prototype.updateUniformArray = function(e, t, i) {
- this._checkNewFrame();
- var n = this._uniformLocations[e];
- if (void 0 !== n) {
- this._buffer || this.create();
- var r = this._uniformArraySizes[e];
- if (this._dynamic)
- for (l = 0; l < i; l++)
- this._bufferData[n + l] = t[l];
- else {
- for (var o = !1, a = 0, s = 0, l = 0; l < i; l++)
- if (this._bufferData[n + 4 * s + a] !== gi.FloatRound(t[l]) && (o = !0,
- this._createBufferOnWrite && this._createNewBuffer(),
- this._bufferData[n + 4 * s + a] = t[l]),
- ++a === r.strideSize) {
- for (; a < 4; a++)
- this._bufferData[n + 4 * s + a] = 0;
- a = 0,
- s++
- }
- this._needSync = this._needSync || o
- }
- } else
- K.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform.")
- }
- ,
- e.prototype._cacheMatrix = function(e, t) {
- this._checkNewFrame();
- var i = this._valueCache[e]
- , n = t.updateFlag;
- return (void 0 === i || i !== n) && (this._valueCache[e] = n,
- !0)
- }
- ,
- e.prototype._updateMatrix3x3ForUniform = function(t, i) {
- for (var n = 0; n < 3; n++)
- e._TempBuffer[4 * n] = i[3 * n],
- e._TempBuffer[4 * n + 1] = i[3 * n + 1],
- e._TempBuffer[4 * n + 2] = i[3 * n + 2],
- e._TempBuffer[4 * n + 3] = 0;
- this.updateUniform(t, e._TempBuffer, 12)
- }
- ,
- e.prototype._updateMatrix3x3ForEffect = function(e, t) {
- this._currentEffect.setMatrix3x3(e, t)
- }
- ,
- e.prototype._updateMatrix2x2ForEffect = function(e, t) {
- this._currentEffect.setMatrix2x2(e, t)
- }
- ,
- e.prototype._updateMatrix2x2ForUniform = function(t, i) {
- for (var n = 0; n < 2; n++)
- e._TempBuffer[4 * n] = i[2 * n],
- e._TempBuffer[4 * n + 1] = i[2 * n + 1],
- e._TempBuffer[4 * n + 2] = 0,
- e._TempBuffer[4 * n + 3] = 0;
- this.updateUniform(t, e._TempBuffer, 8)
- }
- ,
- e.prototype._updateFloatForEffect = function(e, t) {
- this._currentEffect.setFloat(e, t)
- }
- ,
- e.prototype._updateFloatForUniform = function(t, i) {
- e._TempBuffer[0] = i,
- this.updateUniform(t, e._TempBuffer, 1)
- }
- ,
- e.prototype._updateFloat2ForEffect = function(e, t, i, n) {
- void 0 === n && (n = ""),
- this._currentEffect.setFloat2(e + n, t, i)
- }
- ,
- e.prototype._updateFloat2ForUniform = function(t, i, n) {
- e._TempBuffer[0] = i,
- e._TempBuffer[1] = n,
- this.updateUniform(t, e._TempBuffer, 2)
- }
- ,
- e.prototype._updateFloat3ForEffect = function(e, t, i, n, r) {
- void 0 === r && (r = ""),
- this._currentEffect.setFloat3(e + r, t, i, n)
- }
- ,
- e.prototype._updateFloat3ForUniform = function(t, i, n, r) {
- e._TempBuffer[0] = i,
- e._TempBuffer[1] = n,
- e._TempBuffer[2] = r,
- this.updateUniform(t, e._TempBuffer, 3)
- }
- ,
- e.prototype._updateFloat4ForEffect = function(e, t, i, n, r, o) {
- void 0 === o && (o = ""),
- this._currentEffect.setFloat4(e + o, t, i, n, r)
- }
- ,
- e.prototype._updateFloat4ForUniform = function(t, i, n, r, o) {
- e._TempBuffer[0] = i,
- e._TempBuffer[1] = n,
- e._TempBuffer[2] = r,
- e._TempBuffer[3] = o,
- this.updateUniform(t, e._TempBuffer, 4)
- }
- ,
- e.prototype._updateFloatArrayForEffect = function(e, t) {
- this._currentEffect.setFloatArray(e, t)
- }
- ,
- e.prototype._updateFloatArrayForUniform = function(e, t) {
- this.updateUniformArray(e, t, t.length)
- }
- ,
- e.prototype._updateArrayForEffect = function(e, t) {
- this._currentEffect.setArray(e, t)
- }
- ,
- e.prototype._updateArrayForUniform = function(e, t) {
- this.updateUniformArray(e, t, t.length)
- }
- ,
- e.prototype._updateIntArrayForEffect = function(e, t) {
- this._currentEffect.setIntArray(e, t)
- }
- ,
- e.prototype._updateIntArrayForUniform = function(t, i) {
- e._TempBufferInt32View.set(i),
- this.updateUniformArray(t, e._TempBuffer, i.length)
- }
- ,
- e.prototype._updateMatrixForEffect = function(e, t) {
- this._currentEffect.setMatrix(e, t)
- }
- ,
- e.prototype._updateMatrixForUniform = function(e, t) {
- this._cacheMatrix(e, t) && this.updateUniform(e, t.toArray(), 16)
- }
- ,
- e.prototype._updateMatricesForEffect = function(e, t) {
- this._currentEffect.setMatrices(e, t)
- }
- ,
- e.prototype._updateMatricesForUniform = function(e, t) {
- this.updateUniform(e, t, t.length)
- }
- ,
- e.prototype._updateVector3ForEffect = function(e, t) {
- this._currentEffect.setVector3(e, t)
- }
- ,
- e.prototype._updateVector3ForUniform = function(t, i) {
- e._TempBuffer[0] = i.x,
- e._TempBuffer[1] = i.y,
- e._TempBuffer[2] = i.z,
- this.updateUniform(t, e._TempBuffer, 3)
- }
- ,
- e.prototype._updateVector4ForEffect = function(e, t) {
- this._currentEffect.setVector4(e, t)
- }
- ,
- e.prototype._updateVector4ForUniform = function(t, i) {
- e._TempBuffer[0] = i.x,
- e._TempBuffer[1] = i.y,
- e._TempBuffer[2] = i.z,
- e._TempBuffer[3] = i.w,
- this.updateUniform(t, e._TempBuffer, 4)
- }
- ,
- e.prototype._updateColor3ForEffect = function(e, t, i) {
- void 0 === i && (i = ""),
- this._currentEffect.setColor3(e + i, t)
- }
- ,
- e.prototype._updateColor3ForUniform = function(t, i) {
- e._TempBuffer[0] = i.r,
- e._TempBuffer[1] = i.g,
- e._TempBuffer[2] = i.b,
- this.updateUniform(t, e._TempBuffer, 3)
- }
- ,
- e.prototype._updateColor4ForEffect = function(e, t, i, n) {
- void 0 === n && (n = ""),
- this._currentEffect.setColor4(e + n, t, i)
- }
- ,
- e.prototype._updateDirectColor4ForEffect = function(e, t, i) {
- void 0 === i && (i = ""),
- this._currentEffect.setDirectColor4(e + i, t)
- }
- ,
- e.prototype._updateColor4ForUniform = function(t, i, n) {
- e._TempBuffer[0] = i.r,
- e._TempBuffer[1] = i.g,
- e._TempBuffer[2] = i.b,
- e._TempBuffer[3] = n,
- this.updateUniform(t, e._TempBuffer, 4)
- }
- ,
- e.prototype._updateDirectColor4ForUniform = function(t, i) {
- e._TempBuffer[0] = i.r,
- e._TempBuffer[1] = i.g,
- e._TempBuffer[2] = i.b,
- e._TempBuffer[3] = i.a,
- this.updateUniform(t, e._TempBuffer, 4)
- }
- ,
- e.prototype._updateIntForEffect = function(e, t, i) {
- void 0 === i && (i = ""),
- this._currentEffect.setInt(e + i, t)
- }
- ,
- e.prototype._updateIntForUniform = function(t, i) {
- e._TempBufferInt32View[0] = i,
- this.updateUniform(t, e._TempBuffer, 1)
- }
- ,
- e.prototype._updateInt2ForEffect = function(e, t, i, n) {
- void 0 === n && (n = ""),
- this._currentEffect.setInt2(e + n, t, i)
- }
- ,
- e.prototype._updateInt2ForUniform = function(t, i, n) {
- e._TempBufferInt32View[0] = i,
- e._TempBufferInt32View[1] = n,
- this.updateUniform(t, e._TempBuffer, 2)
- }
- ,
- e.prototype._updateInt3ForEffect = function(e, t, i, n, r) {
- void 0 === r && (r = ""),
- this._currentEffect.setInt3(e + r, t, i, n)
- }
- ,
- e.prototype._updateInt3ForUniform = function(t, i, n, r) {
- e._TempBufferInt32View[0] = i,
- e._TempBufferInt32View[1] = n,
- e._TempBufferInt32View[2] = r,
- this.updateUniform(t, e._TempBuffer, 3)
- }
- ,
- e.prototype._updateInt4ForEffect = function(e, t, i, n, r, o) {
- void 0 === o && (o = ""),
- this._currentEffect.setInt4(e + o, t, i, n, r)
- }
- ,
- e.prototype._updateInt4ForUniform = function(t, i, n, r, o) {
- e._TempBufferInt32View[0] = i,
- e._TempBufferInt32View[1] = n,
- e._TempBufferInt32View[2] = r,
- e._TempBufferInt32View[3] = o,
- this.updateUniform(t, e._TempBuffer, 4)
- }
- ,
- e.prototype.setTexture = function(e, t) {
- this._currentEffect.setTexture(e, t)
- }
- ,
- e.prototype.updateUniformDirectly = function(e, t) {
- this.updateUniform(e, t, t.length),
- this.update()
- }
- ,
- e.prototype.bindToEffect = function(e, t) {
- this._currentEffect = e,
- this._currentEffectName = t
- }
- ,
- e.prototype.bindUniformBuffer = function() {
- !this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName)
- }
- ,
- e.prototype.unbindEffect = function() {
- this._currentEffect = void 0,
- this._currentEffectName = void 0
- }
- ,
- e.prototype.setDataBuffer = function(e) {
- if (!this._buffers)
- return this._buffer === e;
- for (var t = 0; t < this._buffers.length; ++t)
- if (this._buffers[t][0] === e)
- return this._bufferIndex = t,
- this._buffer = e,
- this._createBufferOnWrite = !1,
- this._currentEffect = void 0,
- !0;
- return !1
- }
- ,
- e.prototype.dispose = function() {
- if (!this._noUBO) {
- var e = this._engine._uniformBuffers
- , t = e.indexOf(this);
- if (-1 !== t && (e[t] = e[e.length - 1],
- e.pop()),
- this._engine._features.trackUbosInFrame && this._buffers)
- for (var i = 0; i < this._buffers.length; ++i) {
- var n = this._buffers[i][0];
- this._engine._releaseBuffer(n)
- }
- else
- this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null)
- }
- }
- ,
- e._UpdatedUbosInFrame = {},
- e._MAX_UNIFORM_SIZE = 256,
- e._TempBuffer = new Float32Array(e._MAX_UNIFORM_SIZE),
- e._TempBufferInt32View = new Uint32Array(e._TempBuffer.buffer),
- e
- }(), wi = function() {
- function e(e, t, i, n, r, o, a, s) {
- void 0 === n && (n = 0),
- void 0 === r && (r = !1),
- void 0 === o && (o = !1),
- void 0 === a && (a = !1),
- this._isAlreadyOwned = !1,
- e.getScene ? this._engine = e.getScene().getEngine() : this._engine = e,
- this._updatable = i,
- this._instanced = o,
- this._divisor = s || 1,
- t instanceof Bt ? (this._data = null,
- this._buffer = t) : (this._data = t,
- this._buffer = null),
- this.byteStride = a ? n : n * Float32Array.BYTES_PER_ELEMENT,
- r || this.create()
- }
- return e.prototype.createVertexBuffer = function(e, t, i, n, r, o, a) {
- void 0 === o && (o = !1);
- var s = o ? t : t * Float32Array.BYTES_PER_ELEMENT
- , l = n ? o ? n : n * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
- return new Bi(this._engine,this,e,this._updatable,!0,l,void 0 === r ? this._instanced : r,s,i,void 0,void 0,!0,this._divisor || a)
- }
- ,
- e.prototype.isUpdatable = function() {
- return this._updatable
- }
- ,
- e.prototype.getData = function() {
- return this._data
- }
- ,
- e.prototype.getBuffer = function() {
- return this._buffer
- }
- ,
- e.prototype.getStrideSize = function() {
- return this.byteStride / Float32Array.BYTES_PER_ELEMENT
- }
- ,
- e.prototype.create = function(e) {
- void 0 === e && (e = null),
- !e && this._buffer || (e = e || this._data) && (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))
- }
- ,
- e.prototype._rebuild = function() {
- this._buffer = null,
- this.create(this._data)
- }
- ,
- e.prototype.update = function(e) {
- this.create(e)
- }
- ,
- e.prototype.updateDirectly = function(e, t, i, n) {
- void 0 === n && (n = !1),
- this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, n ? t : t * Float32Array.BYTES_PER_ELEMENT, i ? i * this.byteStride : void 0),
- this._data = 0 === t && void 0 === i ? e : null)
- }
- ,
- e.prototype._increaseReferences = function() {
- this._buffer && (this._isAlreadyOwned ? this._buffer.references++ : this._isAlreadyOwned = !0)
- }
- ,
- e.prototype.dispose = function() {
- this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null,
- this._data = null)
- }
- ,
- e
- }(), Bi = function() {
- function e(t, i, n, r, o, a, s, l, c, u, h, d, p, f) {
- if (void 0 === h && (h = !1),
- void 0 === d && (d = !1),
- void 0 === p && (p = 1),
- void 0 === f && (f = !1),
- i instanceof wi ? (this._buffer = i,
- this._ownsBuffer = f) : (this._buffer = new wi(t,i,r,a,o,s,d),
- this._ownsBuffer = !0),
- this.uniqueId = e._Counter++,
- this._kind = n,
- null == u) {
- var _ = this.getData();
- this.type = e.FLOAT,
- _ instanceof Int8Array ? this.type = e.BYTE : _ instanceof Uint8Array ? this.type = e.UNSIGNED_BYTE : _ instanceof Int16Array ? this.type = e.SHORT : _ instanceof Uint16Array ? this.type = e.UNSIGNED_SHORT : _ instanceof Int32Array ? this.type = e.INT : _ instanceof Uint32Array && (this.type = e.UNSIGNED_INT)
- } else
- this.type = u;
- var m = e.GetTypeByteLength(this.type);
- d ? (this._size = c || (a ? a / m : e.DeduceStride(n)),
- this.byteStride = a || this._buffer.byteStride || this._size * m,
- this.byteOffset = l || 0) : (this._size = c || a || e.DeduceStride(n),
- this.byteStride = a ? a * m : this._buffer.byteStride || this._size * m,
- this.byteOffset = (l || 0) * m),
- this.normalized = h,
- this._instanced = void 0 !== s && s,
- this._instanceDivisor = s ? p : 0,
- this._computeHashCode()
- }
- return Object.defineProperty(e.prototype, "instanceDivisor", {
- get: function() {
- return this._instanceDivisor
- },
- set: function(e) {
- this._instanceDivisor = e,
- this._instanced = 0 != e,
- this._computeHashCode()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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)
- }
- ,
- e.prototype._rebuild = function() {
- this._buffer && this._buffer._rebuild()
- }
- ,
- e.prototype.getKind = function() {
- return this._kind
- }
- ,
- e.prototype.isUpdatable = function() {
- return this._buffer.isUpdatable()
- }
- ,
- e.prototype.getData = function() {
- return this._buffer.getData()
- }
- ,
- e.prototype.getFloatData = function(t, i) {
- var n = this.getData();
- if (!n)
- return null;
- var r = this.getSize() * e.GetTypeByteLength(this.type)
- , o = t * this.getSize();
- if (this.type !== e.FLOAT || this.byteStride !== r) {
- var a = new Float32Array(o);
- return this.forEach(o, (function(e, t) {
- return a[t] = e
- }
- )),
- a
- }
- if (!(n instanceof Array || n instanceof Float32Array) || 0 !== this.byteOffset || n.length !== o) {
- if (n instanceof Array) {
- var s = this.byteOffset / 4;
- return mi.Slice(n, s, s + o)
- }
- if (n instanceof ArrayBuffer)
- return new Float32Array(n,this.byteOffset,o);
- if (s = n.byteOffset + this.byteOffset,
- i) {
- var l = new Float32Array(o)
- , c = new Float32Array(n.buffer,s,o);
- return l.set(c),
- l
- }
- var u = s % 4;
- return u && (s = Math.max(0, s - u)),
- new Float32Array(n.buffer,s,o)
- }
- return i ? mi.Slice(n) : n
- }
- ,
- e.prototype.getBuffer = function() {
- return this._buffer.getBuffer()
- }
- ,
- e.prototype.getStrideSize = function() {
- return this.byteStride / e.GetTypeByteLength(this.type)
- }
- ,
- e.prototype.getOffset = function() {
- return this.byteOffset / e.GetTypeByteLength(this.type)
- }
- ,
- e.prototype.getSize = function(t) {
- return void 0 === t && (t = !1),
- t ? this._size * e.GetTypeByteLength(this.type) : this._size
- }
- ,
- e.prototype.getIsInstanced = function() {
- return this._instanced
- }
- ,
- e.prototype.getInstanceDivisor = function() {
- return this._instanceDivisor
- }
- ,
- e.prototype.create = function(e) {
- this._buffer.create(e)
- }
- ,
- e.prototype.update = function(e) {
- this._buffer.update(e)
- }
- ,
- e.prototype.updateDirectly = function(e, t, i) {
- void 0 === i && (i = !1),
- this._buffer.updateDirectly(e, t, void 0, i)
- }
- ,
- e.prototype.dispose = function() {
- this._ownsBuffer && this._buffer.dispose()
- }
- ,
- e.prototype.forEach = function(t, i) {
- e.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, t, this.normalized, i)
- }
- ,
- e.DeduceStride = function(t) {
- switch (t) {
- case e.UVKind:
- case e.UV2Kind:
- case e.UV3Kind:
- case e.UV4Kind:
- case e.UV5Kind:
- case e.UV6Kind:
- return 2;
- case e.NormalKind:
- case e.PositionKind:
- return 3;
- case e.ColorKind:
- case e.MatricesIndicesKind:
- case e.MatricesIndicesExtraKind:
- case e.MatricesWeightsKind:
- case e.MatricesWeightsExtraKind:
- case e.TangentKind:
- return 4;
- default:
- throw new Error("Invalid kind '" + t + "'")
- }
- }
- ,
- e.GetTypeByteLength = function(t) {
- switch (t) {
- case e.BYTE:
- case e.UNSIGNED_BYTE:
- return 1;
- case e.SHORT:
- case e.UNSIGNED_SHORT:
- return 2;
- case e.INT:
- case e.UNSIGNED_INT:
- case e.FLOAT:
- return 4;
- default:
- throw new Error("Invalid type '".concat(t, "'"))
- }
- }
- ,
- e.ForEach = function(t, i, n, r, o, a, s, l) {
- if (t instanceof Array)
- for (var c = i / 4, u = n / 4, h = 0; h < a; h += r) {
- for (var d = 0; d < r; d++)
- l(t[c + d], h + d);
- c += u
- }
- else {
- var p = t instanceof ArrayBuffer ? new DataView(t) : new DataView(t.buffer,t.byteOffset,t.byteLength)
- , f = e.GetTypeByteLength(o);
- for (h = 0; h < a; h += r) {
- var _ = i;
- for (d = 0; d < r; d++)
- l(e._GetFloatValue(p, o, _, s), h + d),
- _ += f;
- i += n
- }
- }
- }
- ,
- e._GetFloatValue = function(t, i, n, r) {
- switch (i) {
- case e.BYTE:
- var o = t.getInt8(n);
- return r && (o = Math.max(o / 127, -1)),
- o;
- case e.UNSIGNED_BYTE:
- return o = t.getUint8(n),
- r && (o /= 255),
- o;
- case e.SHORT:
- return o = t.getInt16(n, !0),
- r && (o = Math.max(o / 32767, -1)),
- o;
- case e.UNSIGNED_SHORT:
- return o = t.getUint16(n, !0),
- r && (o /= 65535),
- o;
- case e.INT:
- return t.getInt32(n, !0);
- case e.UNSIGNED_INT:
- return t.getUint32(n, !0);
- case e.FLOAT:
- return t.getFloat32(n, !0);
- default:
- throw new Error("Invalid component type ".concat(i))
- }
- }
- ,
- e._Counter = 0,
- e.BYTE = 5120,
- e.UNSIGNED_BYTE = 5121,
- e.SHORT = 5122,
- e.UNSIGNED_SHORT = 5123,
- e.INT = 5124,
- e.UNSIGNED_INT = 5125,
- e.FLOAT = 5126,
- e.PositionKind = "position",
- e.NormalKind = "normal",
- e.TangentKind = "tangent",
- e.UVKind = "uv",
- e.UV2Kind = "uv2",
- e.UV3Kind = "uv3",
- e.UV4Kind = "uv4",
- e.UV5Kind = "uv5",
- e.UV6Kind = "uv6",
- e.ColorKind = "color",
- e.ColorInstanceKind = "instanceColor",
- e.MatricesIndicesKind = "matricesIndices",
- e.MatricesWeightsKind = "matricesWeights",
- e.MatricesIndicesExtraKind = "matricesIndicesExtra",
- e.MatricesWeightsExtraKind = "matricesWeightsExtra",
- e
- }(), Ui = function() {
- function e() {
- 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 e.prototype.getNormal = function(e, t) {
- if (void 0 === e && (e = !1),
- void 0 === t && (t = !0),
- !this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(Bi.NormalKind))
- return null;
- var i, n = this.pickedMesh.getIndices();
- if (!n)
- return null;
- if (t) {
- var r = this.pickedMesh.getVerticesData(Bi.NormalKind)
- , o = x.FromArray(r, 3 * n[3 * this.faceId])
- , a = x.FromArray(r, 3 * n[3 * this.faceId + 1])
- , s = x.FromArray(r, 3 * n[3 * this.faceId + 2]);
- o = o.scale(this.bu),
- a = a.scale(this.bv),
- s = s.scale(1 - this.bu - this.bv),
- i = new x(o.x + a.x + s.x,o.y + a.y + s.y,o.z + a.z + s.z)
- } else {
- var l = this.pickedMesh.getVerticesData(Bi.PositionKind)
- , c = x.FromArray(l, 3 * n[3 * this.faceId])
- , u = x.FromArray(l, 3 * n[3 * this.faceId + 1])
- , h = x.FromArray(l, 3 * n[3 * this.faceId + 2])
- , d = c.subtract(u)
- , p = h.subtract(u);
- i = x.Cross(d, p)
- }
- if (e) {
- var f = this.pickedMesh.getWorldMatrix();
- this.pickedMesh.nonUniformScaling && (I.Matrix[0].copyFrom(f),
- (f = I.Matrix[0]).setTranslationFromFloats(0, 0, 0),
- f.invert(),
- f.transposeToRef(I.Matrix[1]),
- f = I.Matrix[1]),
- i = x.TransformNormal(i, f)
- }
- return i.normalize(),
- i
- }
- ,
- e.prototype.getTextureCoordinates = function() {
- if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(Bi.UVKind))
- return null;
- var e = this.pickedMesh.getIndices();
- if (!e)
- return null;
- var t = this.pickedMesh.getVerticesData(Bi.UVKind);
- if (!t)
- return null;
- var i = A.FromArray(t, 2 * e[3 * this.faceId])
- , n = A.FromArray(t, 2 * e[3 * this.faceId + 1])
- , r = A.FromArray(t, 2 * e[3 * this.faceId + 2]);
- return i = i.scale(this.bu),
- n = n.scale(this.bv),
- r = r.scale(1 - this.bu - this.bv),
- new A(i.x + n.x + r.x,i.y + n.y + r.y)
- }
- ,
- e
- }(), Vi = function() {
- function e(e) {
- this._vertexBuffers = {},
- this._scene = e
- }
- return e.prototype._prepareBuffers = function() {
- if (!this._vertexBuffers[Bi.PositionKind]) {
- var e = [];
- e.push(1, 1),
- e.push(-1, 1),
- e.push(-1, -1),
- e.push(1, -1),
- this._vertexBuffers[Bi.PositionKind] = new Bi(this._scene.getEngine(),e,Bi.PositionKind,!1,!1,2),
- this._buildIndexBuffer()
- }
- }
- ,
- e.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)
- }
- ,
- e.prototype._rebuild = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && (e._rebuild(),
- this._buildIndexBuffer())
- }
- ,
- e.prototype._prepareFrame = function(e, t) {
- void 0 === e && (e = null),
- void 0 === t && (t = null);
- var i = this._scene.activeCamera;
- return !(!i || !(t = t || i._postProcesses.filter((function(e) {
- return null != e
- }
- ))) || 0 === t.length || !this._scene.postProcessesEnabled || (t[0].activate(i, e, null != t),
- 0))
- }
- ,
- e.prototype.directRender = function(e, t, i, n, r, o) {
- var s;
- void 0 === t && (t = null),
- void 0 === i && (i = !1),
- void 0 === n && (n = 0),
- void 0 === r && (r = 0),
- void 0 === o && (o = !1);
- for (var l = this._scene.getEngine(), c = 0; c < e.length; c++) {
- c < e.length - 1 ? e[c + 1].activate(this._scene.activeCamera, null == t ? void 0 : t.texture) : (t ? l.bindFramebuffer(t, n, void 0, void 0, i, r) : o || l.restoreDefaultFramebuffer(),
- null === (s = l._debugInsertMarker) || void 0 === s || s.call(l, "post process ".concat(e[c].name, " output")));
- var u = e[c]
- , h = u.apply();
- h && (u.onBeforeRenderObservable.notifyObservers(h),
- this._prepareBuffers(),
- l.bindBuffers(this._vertexBuffers, this._indexBuffer, h),
- l.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6),
- u.onAfterRenderObservable.notifyObservers(h))
- }
- l.setDepthBuffer(!0),
- l.setDepthWrite(!0)
- }
- ,
- e.prototype._finalizeFrame = function(e, t, i, n, r) {
- var o;
- void 0 === r && (r = !1);
- var s = this._scene.activeCamera;
- if (s && (n = n || s._postProcesses.filter((function(e) {
- return null != e
- }
- )),
- 0 !== n.length && this._scene.postProcessesEnabled)) {
- for (var l = this._scene.getEngine(), c = 0, u = n.length; c < u; c++) {
- var h = n[c];
- if (c < u - 1 ? h._outputTexture = n[c + 1].activate(s, null == t ? void 0 : t.texture) : (t ? (l.bindFramebuffer(t, i, void 0, void 0, r),
- h._outputTexture = t) : (l.restoreDefaultFramebuffer(),
- h._outputTexture = null),
- null === (o = l._debugInsertMarker) || void 0 === o || o.call(l, "post process ".concat(n[c].name, " output"))),
- e)
- break;
- var d = h.apply();
- d && (h.onBeforeRenderObservable.notifyObservers(d),
- this._prepareBuffers(),
- l.bindBuffers(this._vertexBuffers, this._indexBuffer, d),
- l.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6),
- h.onAfterRenderObservable.notifyObservers(d))
- }
- l.setDepthBuffer(!0),
- l.setDepthWrite(!0),
- l.setAlphaMode(a.ALPHA_DISABLE)
- }
- }
- ,
- e.prototype.dispose = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[Bi.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null)
- }
- ,
- e
- }(), ki = function() {
- function e(e, t, i, n, r) {
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- void 0 === r && (r = null),
- this.index = e,
- this._opaqueSubMeshes = new bi(256),
- this._transparentSubMeshes = new bi(256),
- this._alphaTestSubMeshes = new bi(256),
- this._depthOnlySubMeshes = new bi(256),
- this._particleSystems = new bi(256),
- this._spriteManagers = new bi(256),
- this._empty = !0,
- this._edgesRenderers = new Ti(16),
- this._scene = t,
- this.opaqueSortCompareFn = i,
- this.alphaTestSortCompareFn = n,
- this.transparentSortCompareFn = r
- }
- return Object.defineProperty(e.prototype, "opaqueSortCompareFn", {
- set: function(t) {
- this._opaqueSortCompareFn = t,
- this._renderOpaque = t ? this._renderOpaqueSorted : e._RenderUnsorted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alphaTestSortCompareFn", {
- set: function(t) {
- this._alphaTestSortCompareFn = t,
- this._renderAlphaTest = t ? this._renderAlphaTestSorted : e._RenderUnsorted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "transparentSortCompareFn", {
- set: function(t) {
- this._transparentSortCompareFn = t || e.defaultTransparentSortCompare,
- this._renderTransparent = this._renderTransparentSorted
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.render = function(e, t, i, n) {
- if (e)
- e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
- else {
- var r = this._scene.getEngine();
- 0 !== this._depthOnlySubMeshes.length && (r.setColorWrite(!1),
- this._renderAlphaTest(this._depthOnlySubMeshes),
- r.setColorWrite(!0)),
- 0 !== this._opaqueSubMeshes.length && this._renderOpaque(this._opaqueSubMeshes),
- 0 !== this._alphaTestSubMeshes.length && this._renderAlphaTest(this._alphaTestSubMeshes);
- var o = r.getStencilBuffer();
- if (r.setStencilBuffer(!1),
- t && this._renderSprites(),
- i && this._renderParticles(n),
- this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(),
- 0 !== this._transparentSubMeshes.length || this._scene.useOrderIndependentTransparency) {
- if (r.setStencilBuffer(o),
- this._scene.useOrderIndependentTransparency) {
- var s = this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);
- s.length && this._renderTransparent(s)
- } else
- this._renderTransparent(this._transparentSubMeshes);
- r.setAlphaMode(a.ALPHA_DISABLE)
- }
- if (r.setStencilBuffer(!1),
- this._edgesRenderers.length) {
- for (var l = 0; l < this._edgesRenderers.length; l++)
- this._edgesRenderers.data[l].render();
- r.setAlphaMode(a.ALPHA_DISABLE)
- }
- r.setStencilBuffer(o)
- }
- }
- ,
- e.prototype._renderOpaqueSorted = function(t) {
- return e._RenderSorted(t, this._opaqueSortCompareFn, this._scene.activeCamera, !1)
- }
- ,
- e.prototype._renderAlphaTestSorted = function(t) {
- return e._RenderSorted(t, this._alphaTestSortCompareFn, this._scene.activeCamera, !1)
- }
- ,
- e.prototype._renderTransparentSorted = function(t) {
- return e._RenderSorted(t, this._transparentSortCompareFn, this._scene.activeCamera, !0)
- }
- ,
- e._RenderSorted = function(t, i, n, r) {
- for (var o, s = 0, l = n ? n.globalPosition : e._ZeroVector; s < t.length; s++)
- (o = t.data[s])._alphaIndex = o.getMesh().alphaIndex,
- o._distanceToCamera = x.Distance(o.getBoundingInfo().boundingSphere.centerWorld, l);
- var c = t.data.slice(0, t.length);
- for (i && c.sort(i),
- s = 0; s < c.length; s++) {
- if (o = c[s],
- r) {
- var u = o.getMaterial();
- if (u && u.needDepthPrePass) {
- var h = u.getScene().getEngine();
- h.setColorWrite(!1),
- h.setAlphaMode(a.ALPHA_DISABLE),
- o.render(!1),
- h.setColorWrite(!0)
- }
- }
- o.render(r)
- }
- }
- ,
- e._RenderUnsorted = function(e) {
- for (var t = 0; t < e.length; t++)
- e.data[t].render(!1)
- }
- ,
- e.defaultTransparentSortCompare = function(t, i) {
- return t._alphaIndex > i._alphaIndex ? 1 : t._alphaIndex < i._alphaIndex ? -1 : e.backToFrontSortCompare(t, i)
- }
- ,
- e.backToFrontSortCompare = function(e, t) {
- return e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0
- }
- ,
- e.frontToBackSortCompare = function(e, t) {
- return e._distanceToCamera < t._distanceToCamera ? -1 : e._distanceToCamera > t._distanceToCamera ? 1 : 0
- }
- ,
- e.prototype.prepare = function() {
- this._opaqueSubMeshes.reset(),
- this._transparentSubMeshes.reset(),
- this._alphaTestSubMeshes.reset(),
- this._depthOnlySubMeshes.reset(),
- this._particleSystems.reset(),
- this._spriteManagers.reset(),
- this._edgesRenderers.reset(),
- this._empty = !0
- }
- ,
- e.prototype.dispose = function() {
- this._opaqueSubMeshes.dispose(),
- this._transparentSubMeshes.dispose(),
- this._alphaTestSubMeshes.dispose(),
- this._depthOnlySubMeshes.dispose(),
- this._particleSystems.dispose(),
- this._spriteManagers.dispose(),
- this._edgesRenderers.dispose()
- }
- ,
- e.prototype.dispatch = function(e, t, i) {
- void 0 === t && (t = e.getMesh()),
- void 0 === i && (i = e.getMaterial()),
- null != i && (i.needAlphaBlendingForMesh(t) ? this._transparentSubMeshes.push(e) : i.needAlphaTesting() ? (i.needDepthPrePass && this._depthOnlySubMeshes.push(e),
- this._alphaTestSubMeshes.push(e)) : (i.needDepthPrePass && this._depthOnlySubMeshes.push(e),
- this._opaqueSubMeshes.push(e)),
- t._renderingGroup = this,
- t._edgesRenderer && t._edgesRenderer.isEnabled && this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),
- this._empty = !1)
- }
- ,
- e.prototype.dispatchSprites = function(e) {
- this._spriteManagers.push(e),
- this._empty = !1
- }
- ,
- e.prototype.dispatchParticles = function(e) {
- this._particleSystems.push(e),
- this._empty = !1
- }
- ,
- e.prototype._renderParticles = function(e) {
- if (0 !== this._particleSystems.length) {
- var t = this._scene.activeCamera;
- this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
- for (var i = 0; i < this._particleSystems.length; i++) {
- var n = this._particleSystems.data[i];
- if (0 !== (t && t.layerMask & n.layerMask)) {
- var r = n.emitter;
- r.position && e && -1 === e.indexOf(r) || this._scene._activeParticles.addCount(n.render(), !1)
- }
- }
- this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)
- }
- }
- ,
- e.prototype._renderSprites = function() {
- if (this._scene.spritesEnabled && 0 !== this._spriteManagers.length) {
- var e = this._scene.activeCamera;
- this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
- for (var t = 0; t < this._spriteManagers.length; t++) {
- var i = this._spriteManagers.data[t];
- 0 !== (e && e.layerMask & i.layerMask) && i.render()
- }
- this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)
- }
- }
- ,
- e._ZeroVector = x.Zero(),
- e
- }(), Gi = function() {}, zi = function() {
- function e(t) {
- this._useSceneAutoClearSetup = !1,
- this._renderingGroups = new Array,
- this._autoClearDepthStencil = {},
- this._customOpaqueSortCompareFn = {},
- this._customAlphaTestSortCompareFn = {},
- this._customTransparentSortCompareFn = {},
- this._renderingGroupInfo = new Gi,
- this._scene = t;
- for (var i = e.MIN_RENDERINGGROUPS; i < e.MAX_RENDERINGGROUPS; i++)
- this._autoClearDepthStencil[i] = {
- autoClear: !0,
- depth: !0,
- stencil: !0
- }
- }
- return e.prototype._clearDepthStencilBuffer = function(e, t) {
- void 0 === e && (e = !0),
- void 0 === t && (t = !0),
- this._depthStencilBufferAlreadyCleaned || (this._scene.getEngine().clear(null, !1, e, t),
- this._depthStencilBufferAlreadyCleaned = !0)
- }
- ,
- e.prototype.render = function(t, i, n, r) {
- var o = this._renderingGroupInfo;
- if (o.scene = this._scene,
- o.camera = this._scene.activeCamera,
- this._scene.spriteManagers && r)
- for (var a = 0; a < this._scene.spriteManagers.length; a++) {
- var s = this._scene.spriteManagers[a];
- this.dispatchSprites(s)
- }
- for (a = e.MIN_RENDERINGGROUPS; a < e.MAX_RENDERINGGROUPS; a++) {
- this._depthStencilBufferAlreadyCleaned = a === e.MIN_RENDERINGGROUPS;
- var l = this._renderingGroups[a];
- if (l && !l._empty) {
- var c = Math.pow(2, a);
- if (o.renderingGroupId = a,
- this._scene.onBeforeRenderingGroupObservable.notifyObservers(o, c),
- e.AUTOCLEAR) {
- var u = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(a) : this._autoClearDepthStencil[a];
- u && u.autoClear && this._clearDepthStencilBuffer(u.depth, u.stencil)
- }
- for (var h = 0, d = this._scene._beforeRenderingGroupDrawStage; h < d.length; h++)
- d[h].action(a);
- l.render(t, r, n, i);
- for (var p = 0, f = this._scene._afterRenderingGroupDrawStage; p < f.length; p++)
- f[p].action(a);
- this._scene.onAfterRenderingGroupObservable.notifyObservers(o, c)
- }
- }
- }
- ,
- e.prototype.reset = function() {
- for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) {
- var i = this._renderingGroups[t];
- i && i.prepare()
- }
- }
- ,
- e.prototype.dispose = function() {
- this.freeRenderingGroups(),
- this._renderingGroups.length = 0,
- this._renderingGroupInfo = null
- }
- ,
- e.prototype.freeRenderingGroups = function() {
- for (var t = e.MIN_RENDERINGGROUPS; t < e.MAX_RENDERINGGROUPS; t++) {
- var i = this._renderingGroups[t];
- i && i.dispose()
- }
- }
- ,
- e.prototype._prepareRenderingGroup = function(e) {
- void 0 === this._renderingGroups[e] && (this._renderingGroups[e] = new ki(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))
- }
- ,
- e.prototype.dispatchSprites = function(e) {
- var t = e.renderingGroupId || 0;
- this._prepareRenderingGroup(t),
- this._renderingGroups[t].dispatchSprites(e)
- }
- ,
- e.prototype.dispatchParticles = function(e) {
- var t = e.renderingGroupId || 0;
- this._prepareRenderingGroup(t),
- this._renderingGroups[t].dispatchParticles(e)
- }
- ,
- e.prototype.dispatch = function(e, t, i) {
- void 0 === t && (t = e.getMesh());
- var n = t.renderingGroupId || 0;
- this._prepareRenderingGroup(n),
- this._renderingGroups[n].dispatch(e, t, i)
- }
- ,
- e.prototype.setRenderingOrder = function(e, t, i, n) {
- if (void 0 === t && (t = null),
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- this._customOpaqueSortCompareFn[e] = t,
- this._customAlphaTestSortCompareFn[e] = i,
- this._customTransparentSortCompareFn[e] = n,
- this._renderingGroups[e]) {
- var r = this._renderingGroups[e];
- r.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e],
- r.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e],
- r.transparentSortCompareFn = this._customTransparentSortCompareFn[e]
- }
- }
- ,
- e.prototype.setRenderingAutoClearDepthStencil = function(e, t, i, n) {
- void 0 === i && (i = !0),
- void 0 === n && (n = !0),
- this._autoClearDepthStencil[e] = {
- autoClear: t,
- depth: i,
- stencil: n
- }
- }
- ,
- e.prototype.getAutoClearDepthStencilSetup = function(e) {
- return this._autoClearDepthStencil[e]
- }
- ,
- e.MAX_RENDERINGGROUPS = 4,
- e.MIN_RENDERINGGROUPS = 0,
- e.AUTOCLEAR = !0,
- e
- }(), Wi = function() {
- function e() {}
- return e.NAME_EFFECTLAYER = "EffectLayer",
- e.NAME_LAYER = "Layer",
- e.NAME_LENSFLARESYSTEM = "LensFlareSystem",
- e.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer",
- e.NAME_PARTICLESYSTEM = "ParticleSystem",
- e.NAME_GAMEPAD = "Gamepad",
- e.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue",
- e.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer",
- e.NAME_PREPASSRENDERER = "PrePassRenderer",
- e.NAME_DEPTHRENDERER = "DepthRenderer",
- e.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer",
- e.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager",
- e.NAME_SPRITE = "Sprite",
- e.NAME_SUBSURFACE = "SubSurface",
- e.NAME_OUTLINERENDERER = "Outline",
- e.NAME_PROCEDURALTEXTURE = "ProceduralTexture",
- e.NAME_SHADOWGENERATOR = "ShadowGenerator",
- e.NAME_OCTREE = "Octree",
- e.NAME_PHYSICSENGINE = "PhysicsEngine",
- e.NAME_AUDIO = "Audio",
- e.STEP_ISREADYFORMESH_EFFECTLAYER = 0,
- e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0,
- e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0,
- e.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0,
- e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1,
- e.STEP_BEFORECAMERADRAW_PREPASS = 0,
- e.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1,
- e.STEP_BEFORECAMERADRAW_LAYER = 2,
- e.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0,
- e.STEP_BEFORERENDERTARGETDRAW_LAYER = 1,
- e.STEP_BEFORERENDERINGMESH_PREPASS = 0,
- e.STEP_BEFORERENDERINGMESH_OUTLINE = 1,
- e.STEP_AFTERRENDERINGMESH_PREPASS = 0,
- e.STEP_AFTERRENDERINGMESH_OUTLINE = 1,
- e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0,
- e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1,
- e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0,
- e.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1,
- e.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0,
- e.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0,
- e.STEP_AFTERRENDERTARGETDRAW_LAYER = 1,
- e.STEP_AFTERCAMERADRAW_PREPASS = 0,
- e.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1,
- e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2,
- e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3,
- e.STEP_AFTERCAMERADRAW_LAYER = 4,
- e.STEP_AFTERRENDER_AUDIO = 0,
- e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0,
- e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1,
- e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2,
- e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3,
- e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0,
- e.STEP_BEFORECLEARSTAGE_PREPASS = 0,
- e.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS = 0,
- e.STEP_POINTERMOVE_SPRITE = 0,
- e.STEP_POINTERDOWN_SPRITE = 0,
- e.STEP_POINTERUP_SPRITE = 0,
- e
- }(), Hi = function(e) {
- function t(t) {
- return e.apply(this, t) || this
- }
- return U(t, e),
- t.Create = function() {
- return Object.create(t.prototype)
- }
- ,
- t.prototype.registerStep = function(e, t, i) {
- var n = 0;
- for (Number.MAX_VALUE; n < this.length && !(e < this[n].index); n++)
- ;
- this.splice(n, 0, {
- index: e,
- component: t,
- action: i.bind(t)
- })
- }
- ,
- t.prototype.clear = function() {
- this.length = 0
- }
- ,
- t
- }(Array), Xi = function() {
- function e() {}
- return e.POINTERDOWN = 1,
- e.POINTERUP = 2,
- e.POINTERMOVE = 4,
- e.POINTERWHEEL = 8,
- e.POINTERPICK = 16,
- e.POINTERTAP = 32,
- e.POINTERDOUBLETAP = 64,
- e
- }(), ji = function(e, t) {
- this.type = e,
- this.event = t
- }, Yi = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, i) || this;
- return o.ray = null,
- o.skipOnPointerObservable = !1,
- o.localPosition = new A(n,r),
- o
- }
- return U(t, e),
- t
- }(ji), Ki = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i) || this;
- return r.pickInfo = n,
- r
- }
- return U(t, e),
- t
- }(ji), Qi = function() {
- function e() {}
- return e.KEYDOWN = 1,
- e.KEYUP = 2,
- e
- }(), qi = function(e, t) {
- this.type = e,
- this.event = t
- }, Zi = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n.type = t,
- n.event = i,
- n.skipOnKeyboardObservable = !1,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "skipOnPointerObservable", {
- get: function() {
- return this.skipOnKeyboardObservable
- },
- set: function(e) {
- this.skipOnKeyboardObservable = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t
- }(qi);
- !function(e) {
- e[e.Generic = 0] = "Generic",
- e[e.Keyboard = 1] = "Keyboard",
- e[e.Mouse = 2] = "Mouse",
- e[e.Touch = 3] = "Touch",
- e[e.DualShock = 4] = "DualShock",
- e[e.Xbox = 5] = "Xbox",
- e[e.Switch = 6] = "Switch",
- e[e.DualSense = 7] = "DualSense"
- }(Ci || (Ci = {})),
- function(e) {
- e[e.Horizontal = 0] = "Horizontal",
- e[e.Vertical = 1] = "Vertical",
- e[e.LeftClick = 2] = "LeftClick",
- e[e.MiddleClick = 3] = "MiddleClick",
- e[e.RightClick = 4] = "RightClick",
- e[e.BrowserBack = 5] = "BrowserBack",
- e[e.BrowserForward = 6] = "BrowserForward",
- e[e.MouseWheelX = 7] = "MouseWheelX",
- e[e.MouseWheelY = 8] = "MouseWheelY",
- e[e.MouseWheelZ = 9] = "MouseWheelZ",
- e[e.Move = 12] = "Move"
- }(Pi || (Pi = {})),
- function(e) {
- e[e.Horizontal = 0] = "Horizontal",
- e[e.Vertical = 1] = "Vertical",
- e[e.LeftClick = 2] = "LeftClick",
- e[e.MiddleClick = 3] = "MiddleClick",
- e[e.RightClick = 4] = "RightClick",
- e[e.BrowserBack = 5] = "BrowserBack",
- e[e.BrowserForward = 6] = "BrowserForward",
- e[e.MouseWheelX = 7] = "MouseWheelX",
- e[e.MouseWheelY = 8] = "MouseWheelY",
- e[e.MouseWheelZ = 9] = "MouseWheelZ",
- e[e.DeltaHorizontal = 10] = "DeltaHorizontal",
- e[e.DeltaVertical = 11] = "DeltaVertical"
- }(Mi || (Mi = {})),
- function(e) {
- e[e.Cross = 0] = "Cross",
- e[e.Circle = 1] = "Circle",
- e[e.Square = 2] = "Square",
- e[e.Triangle = 3] = "Triangle",
- e[e.L1 = 4] = "L1",
- e[e.R1 = 5] = "R1",
- e[e.L2 = 6] = "L2",
- e[e.R2 = 7] = "R2",
- e[e.Share = 8] = "Share",
- e[e.Options = 9] = "Options",
- e[e.L3 = 10] = "L3",
- e[e.R3 = 11] = "R3",
- e[e.DPadUp = 12] = "DPadUp",
- e[e.DPadDown = 13] = "DPadDown",
- e[e.DPadLeft = 14] = "DPadLeft",
- e[e.DPadRight = 15] = "DPadRight",
- e[e.Home = 16] = "Home",
- e[e.TouchPad = 17] = "TouchPad",
- e[e.LStickXAxis = 18] = "LStickXAxis",
- e[e.LStickYAxis = 19] = "LStickYAxis",
- e[e.RStickXAxis = 20] = "RStickXAxis",
- e[e.RStickYAxis = 21] = "RStickYAxis"
- }(Ii || (Ii = {})),
- function(e) {
- e[e.Cross = 0] = "Cross",
- e[e.Circle = 1] = "Circle",
- e[e.Square = 2] = "Square",
- e[e.Triangle = 3] = "Triangle",
- e[e.L1 = 4] = "L1",
- e[e.R1 = 5] = "R1",
- e[e.L2 = 6] = "L2",
- e[e.R2 = 7] = "R2",
- e[e.Create = 8] = "Create",
- e[e.Options = 9] = "Options",
- e[e.L3 = 10] = "L3",
- e[e.R3 = 11] = "R3",
- e[e.DPadUp = 12] = "DPadUp",
- e[e.DPadDown = 13] = "DPadDown",
- e[e.DPadLeft = 14] = "DPadLeft",
- e[e.DPadRight = 15] = "DPadRight",
- e[e.Home = 16] = "Home",
- e[e.TouchPad = 17] = "TouchPad",
- e[e.LStickXAxis = 18] = "LStickXAxis",
- e[e.LStickYAxis = 19] = "LStickYAxis",
- e[e.RStickXAxis = 20] = "RStickXAxis",
- e[e.RStickYAxis = 21] = "RStickYAxis"
- }(Oi || (Oi = {})),
- function(e) {
- e[e.A = 0] = "A",
- e[e.B = 1] = "B",
- e[e.X = 2] = "X",
- e[e.Y = 3] = "Y",
- e[e.LB = 4] = "LB",
- e[e.RB = 5] = "RB",
- e[e.LT = 6] = "LT",
- e[e.RT = 7] = "RT",
- e[e.Back = 8] = "Back",
- e[e.Start = 9] = "Start",
- e[e.LS = 10] = "LS",
- e[e.RS = 11] = "RS",
- e[e.DPadUp = 12] = "DPadUp",
- e[e.DPadDown = 13] = "DPadDown",
- e[e.DPadLeft = 14] = "DPadLeft",
- e[e.DPadRight = 15] = "DPadRight",
- e[e.Home = 16] = "Home",
- e[e.LStickXAxis = 17] = "LStickXAxis",
- e[e.LStickYAxis = 18] = "LStickYAxis",
- e[e.RStickXAxis = 19] = "RStickXAxis",
- e[e.RStickYAxis = 20] = "RStickYAxis"
- }(Di || (Di = {})),
- function(e) {
- e[e.B = 0] = "B",
- e[e.A = 1] = "A",
- e[e.Y = 2] = "Y",
- e[e.X = 3] = "X",
- e[e.L = 4] = "L",
- e[e.R = 5] = "R",
- e[e.ZL = 6] = "ZL",
- e[e.ZR = 7] = "ZR",
- e[e.Minus = 8] = "Minus",
- e[e.Plus = 9] = "Plus",
- e[e.LS = 10] = "LS",
- e[e.RS = 11] = "RS",
- e[e.DPadUp = 12] = "DPadUp",
- e[e.DPadDown = 13] = "DPadDown",
- e[e.DPadLeft = 14] = "DPadLeft",
- e[e.DPadRight = 15] = "DPadRight",
- e[e.Home = 16] = "Home",
- e[e.Capture = 17] = "Capture",
- e[e.LStickXAxis = 18] = "LStickXAxis",
- e[e.LStickYAxis = 19] = "LStickYAxis",
- e[e.RStickXAxis = 20] = "RStickXAxis",
- e[e.RStickYAxis = 21] = "RStickYAxis"
- }(Ni || (Ni = {})),
- function(e) {
- e[e.PointerMove = 0] = "PointerMove",
- e[e.PointerDown = 1] = "PointerDown",
- e[e.PointerUp = 2] = "PointerUp"
- }(Li || (Li = {}));
- var Ji, $i = function() {
- function e() {}
- return e.DOM_DELTA_PIXEL = 0,
- e.DOM_DELTA_LINE = 1,
- e.DOM_DELTA_PAGE = 2,
- e
- }(), en = function() {
- function e() {}
- return e.CreateDeviceEvent = function(e, t, i, n, r, o) {
- switch (e) {
- case Ci.Keyboard:
- return this._CreateKeyboardEvent(i, n, r, o);
- case Ci.Mouse:
- if (i === Pi.MouseWheelX || i === Pi.MouseWheelY || i === Pi.MouseWheelZ)
- return this._CreateWheelEvent(e, t, i, n, r, o);
- case Ci.Touch:
- return this._CreatePointerEvent(e, t, i, n, r, o);
- default:
- throw "Unable to generate event for device ".concat(Ci[e])
- }
- }
- ,
- e._CreatePointerEvent = function(e, t, i, n, r, o) {
- var a = this._CreateMouseEvent(e, t, i, n, r, o);
- return e === Ci.Mouse ? (a.deviceType = Ci.Mouse,
- a.pointerId = 1,
- a.pointerType = "mouse") : (a.deviceType = Ci.Touch,
- a.pointerId = t,
- a.pointerType = "touch"),
- i === Pi.Move ? a.type = "pointermove" : i >= Pi.LeftClick && i <= Pi.RightClick && (a.type = 1 === n ? "pointerdown" : "pointerup",
- a.button = i - 2),
- a
- }
- ,
- e._CreateWheelEvent = function(e, t, i, n, r, o) {
- var a = this._CreateMouseEvent(e, t, i, n, r, o);
- return a.type = "wheel",
- a.deltaMode = $i.DOM_DELTA_PIXEL,
- a.deltaX = i === Pi.MouseWheelX ? n : r.pollInput(e, t, Pi.MouseWheelX),
- a.deltaY = i === Pi.MouseWheelY ? n : r.pollInput(e, t, Pi.MouseWheelY),
- a.deltaZ = i === Pi.MouseWheelZ ? n : r.pollInput(e, t, Pi.MouseWheelZ),
- a
- }
- ,
- e._CreateMouseEvent = function(e, t, i, n, r, o) {
- var a = this._CreateEvent(o)
- , s = r.pollInput(e, t, Pi.Horizontal)
- , l = r.pollInput(e, t, Pi.Vertical);
- return o ? (a.movementX = 0,
- a.movementY = 0,
- a.offsetX = a.movementX - o.getBoundingClientRect().x,
- a.offsetY = a.movementY - o.getBoundingClientRect().y) : (a.movementX = r.pollInput(e, t, Mi.DeltaHorizontal),
- a.movementY = r.pollInput(e, t, Mi.DeltaVertical),
- a.offsetX = 0,
- a.offsetY = 0),
- this._CheckNonCharacterKeys(a, r),
- a.clientX = s,
- a.clientY = l,
- a.x = s,
- a.y = l,
- a.deviceType = e,
- a.deviceSlot = t,
- a.inputIndex = i,
- a
- }
- ,
- e._CreateKeyboardEvent = function(e, t, i, n) {
- var r = this._CreateEvent(n);
- return this._CheckNonCharacterKeys(r, i),
- r.deviceType = Ci.Keyboard,
- r.deviceSlot = 0,
- r.inputIndex = e,
- r.type = 1 === t ? "keydown" : "keyup",
- r.key = String.fromCharCode(e),
- r.keyCode = e,
- r
- }
- ,
- e._CheckNonCharacterKeys = function(e, t) {
- var i = t.isDeviceAvailable(Ci.Keyboard)
- , n = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_ALT_KEY)
- , r = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_CTRL_KEY)
- , o = i && (1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY1) || 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY2) || 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_META_KEY3))
- , s = i && 1 === t.pollInput(Ci.Keyboard, 0, a.INPUT_SHIFT_KEY);
- e.altKey = n,
- e.ctrlKey = r,
- e.metaKey = o,
- e.shiftKey = s
- }
- ,
- e._CreateEvent = function(e) {
- var t = {
- preventDefault: function() {}
- };
- return t.target = e,
- t
- }
- ,
- e
- }(), tn = function() {
- function e(e, t, i) {
- var n = this;
- this._nativeInput = _native.DeviceInputSystem ? new _native.DeviceInputSystem(e,t,(function(e, t, r, o) {
- var a = r === Mi.Horizontal || r === Mi.Vertical || r === Mi.DeltaHorizontal || r === Mi.DeltaVertical ? Pi.Move : r
- , s = en.CreateDeviceEvent(e, t, a, o, n);
- i(e, t, s)
- }
- )) : this._createDummyNativeInput()
- }
- return e.prototype.pollInput = function(e, t, i) {
- return this._nativeInput.pollInput(e, t, i)
- }
- ,
- e.prototype.isDeviceAvailable = function(e) {
- return e === Ci.Mouse || e === Ci.Touch
- }
- ,
- e.prototype.dispose = function() {
- this._nativeInput.dispose()
- }
- ,
- e.prototype._createDummyNativeInput = function() {
- return {
- pollInput: function() {
- return 0
- },
- isDeviceAvailable: function() {
- return !1
- },
- dispose: function() {}
- }
- }
- ,
- e
- }(), nn = Object.keys(Pi).length / 2, rn = function() {
- function e(e, t, i, n) {
- var r = this;
- this._inputs = [],
- this._keyboardActive = !1,
- this._pointerActive = !1,
- this._usingSafari = gi.IsSafari(),
- this._keyboardDownEvent = function(e) {}
- ,
- this._keyboardUpEvent = function(e) {}
- ,
- this._keyboardBlurEvent = function(e) {}
- ,
- this._pointerMoveEvent = function(e) {}
- ,
- this._pointerDownEvent = function(e) {}
- ,
- this._pointerUpEvent = function(e) {}
- ,
- this._pointerCancelEvent = function(e) {}
- ,
- this._pointerWheelEvent = function(e) {}
- ,
- this._pointerBlurEvent = function(e) {}
- ,
- this._eventsAttached = !1,
- this._mouseId = -1,
- this._isUsingFirefox = lt.IsNavigatorAvailable() && navigator.userAgent && -1 !== navigator.userAgent.indexOf("Firefox"),
- this._maxTouchPoints = 0,
- this._pointerInputClearObserver = null,
- this._gamepadConnectedEvent = function(e) {}
- ,
- this._gamepadDisconnectedEvent = function(e) {}
- ,
- this._eventPrefix = gi.GetPointerPrefix(e),
- this._engine = e,
- this._onDeviceConnected = t,
- this._onDeviceDisconnected = i,
- this._onInputChanged = n,
- this._enableEvents(),
- this._engine._onEngineViewChanged || (this._engine._onEngineViewChanged = function() {
- r._enableEvents()
- }
- )
- }
- return e.prototype.pollInput = function(e, t, i) {
- var n = this._inputs[e][t];
- if (!n)
- throw "Unable to find device ".concat(Ci[e]);
- e >= Ci.DualShock && e <= Ci.DualSense && navigator.getGamepads && this._updateDevice(e, t, i);
- var r = n[i];
- if (void 0 === r)
- throw "Unable to find input ".concat(i, " for device ").concat(Ci[e], " in slot ").concat(t);
- return i === Pi.Move && gi.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),
- r
- }
- ,
- e.prototype.isDeviceAvailable = function(e) {
- return void 0 !== this._inputs[e]
- }
- ,
- e.prototype.dispose = function() {
- this._onDeviceConnected = function() {}
- ,
- this._onDeviceDisconnected = function() {}
- ,
- this._onInputChanged = function() {}
- ,
- delete this._engine._onEngineViewChanged,
- this._elementToAttachTo && this._disableEvents()
- }
- ,
- e.prototype._enableEvents = function() {
- var e = null == this ? void 0 : this._engine.getInputElement();
- if (e && (!this._eventsAttached || this._elementToAttachTo !== e)) {
- if (this._disableEvents(),
- this._inputs)
- for (var t = 0, i = this._inputs; t < i.length; t++) {
- var n = i[t];
- if (n)
- for (var r in n) {
- var o = n[+r];
- if (o)
- for (var a = 0; a < o.length; a++)
- o[a] = 0
- }
- }
- this._elementToAttachTo = e,
- this._elementToAttachTo.tabIndex = -1 !== this._elementToAttachTo.tabIndex ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex,
- this._handleKeyActions(),
- this._handlePointerActions(),
- this._handleGamepadActions(),
- this._eventsAttached = !0,
- this._checkForConnectedDevices()
- }
- }
- ,
- e.prototype._disableEvents = function() {
- this._elementToAttachTo && (this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent),
- this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent),
- this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent),
- this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent),
- 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._eventPrefix + "cancel", this._pointerCancelEvent),
- this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent),
- window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent),
- window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)),
- this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver),
- this._eventsAttached = !1
- }
- ,
- e.prototype._checkForConnectedDevices = function() {
- if (navigator.getGamepads)
- for (var e = 0, t = navigator.getGamepads(); e < t.length; e++) {
- var i = t[e];
- i && this._addGamePad(i)
- }
- matchMedia("(pointer:fine)").matches && this._addPointerDevice(Ci.Mouse, 0, 0, 0)
- }
- ,
- e.prototype._addGamePad = function(e) {
- var t = this._getGamepadDeviceType(e.id)
- , i = e.index;
- this._gamepads = this._gamepads || new Array(e.index + 1),
- this._registerDevice(t, i, e.buttons.length + e.axes.length),
- this._gamepads[i] = t
- }
- ,
- e.prototype._addPointerDevice = function(e, t, i, n) {
- this._pointerActive || (this._pointerActive = !0),
- this._registerDevice(e, t, nn);
- var r = this._inputs[e][t];
- r[0] = i,
- r[1] = n
- }
- ,
- e.prototype._registerDevice = function(e, t, i) {
- if (void 0 === t)
- throw "Unable to register device ".concat(Ci[e], " to undefined slot.");
- if (this._inputs[e] || (this._inputs[e] = {}),
- !this._inputs[e][t]) {
- for (var n = new Array(i), r = 0; r < i; r++)
- n[r] = 0;
- this._inputs[e][t] = n,
- this._onDeviceConnected(e, t)
- }
- }
- ,
- e.prototype._unregisterDevice = function(e, t) {
- this._inputs[e][t] && (delete this._inputs[e][t],
- this._onDeviceDisconnected(e, t))
- }
- ,
- e.prototype._handleKeyActions = function() {
- var e = this;
- this._keyboardDownEvent = function(t) {
- e._keyboardActive || (e._keyboardActive = !0,
- e._registerDevice(Ci.Keyboard, 0, 255));
- var i = e._inputs[Ci.Keyboard][0];
- if (i) {
- i[t.keyCode] = 1;
- var n = t;
- n.inputIndex = t.keyCode,
- e._onInputChanged(Ci.Keyboard, 0, n)
- }
- }
- ,
- this._keyboardUpEvent = function(t) {
- e._keyboardActive || (e._keyboardActive = !0,
- e._registerDevice(Ci.Keyboard, 0, 255));
- var i = e._inputs[Ci.Keyboard][0];
- if (i) {
- i[t.keyCode] = 0;
- var n = t;
- n.inputIndex = t.keyCode,
- e._onInputChanged(Ci.Keyboard, 0, n)
- }
- }
- ,
- this._keyboardBlurEvent = function() {
- if (e._keyboardActive)
- for (var t = e._inputs[Ci.Keyboard][0], i = 0; i < t.length; i++)
- if (0 !== t[i]) {
- t[i] = 0;
- var n = en.CreateDeviceEvent(Ci.Keyboard, 0, i, 0, e, e._elementToAttachTo);
- e._onInputChanged(Ci.Keyboard, 0, n)
- }
- }
- ,
- this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent),
- this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent),
- this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent)
- }
- ,
- e.prototype._handlePointerActions = function() {
- var e = this;
- this._maxTouchPoints = lt.IsNavigatorAvailable() && navigator.maxTouchPoints || 2,
- this._activeTouchIds || (this._activeTouchIds = new Array(this._maxTouchPoints));
- for (var t = 0; t < this._maxTouchPoints; t++)
- this._activeTouchIds[t] = -1;
- this._pointerMoveEvent = function(t) {
- var i = e._getPointerType(t)
- , n = i === Ci.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId);
- e._inputs[i] || (e._inputs[i] = {}),
- e._inputs[i][n] || e._addPointerDevice(i, n, t.clientX, t.clientY);
- var r = e._inputs[i][n];
- if (r) {
- r[Pi.Horizontal] = t.clientX,
- r[Pi.Vertical] = t.clientY;
- var o = t;
- o.inputIndex = Pi.Move,
- e._onInputChanged(i, n, o),
- e._usingSafari || -1 === t.button || (o.inputIndex = t.button + 2,
- r[t.button + 2] = r[t.button + 2] ? 0 : 1,
- e._onInputChanged(i, n, o))
- }
- }
- ,
- this._pointerDownEvent = function(t) {
- var i = e._getPointerType(t)
- , n = i === Ci.Mouse ? 0 : t.pointerId;
- if (i === Ci.Touch) {
- var r = e._activeTouchIds.indexOf(-1);
- if (!(r >= 0))
- return void gi.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(e._maxTouchPoints));
- n = r,
- e._activeTouchIds[r] = t.pointerId
- }
- e._inputs[i] || (e._inputs[i] = {}),
- e._inputs[i][n] ? i === Ci.Touch && e._onDeviceConnected(i, n) : e._addPointerDevice(i, n, t.clientX, t.clientY);
- var o = e._inputs[i][n];
- if (o) {
- var a = o[Pi.Horizontal]
- , s = o[Pi.Vertical];
- if (i === Ci.Mouse) {
- if (-1 === e._mouseId && (void 0 === t.pointerId ? e._mouseId = e._isUsingFirefox ? 0 : 1 : e._mouseId = t.pointerId),
- !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
- try {
- e._elementToAttachTo.setPointerCapture(e._mouseId)
- } catch (e) {}
- } else if (t.pointerId && !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
- try {
- e._elementToAttachTo.setPointerCapture(t.pointerId)
- } catch (e) {}
- o[Pi.Horizontal] = t.clientX,
- o[Pi.Vertical] = t.clientY,
- o[t.button + 2] = 1;
- var l = t;
- l.inputIndex = t.button + 2,
- e._onInputChanged(i, n, l),
- a === t.clientX && s === t.clientY || (l.inputIndex = Pi.Move,
- e._onInputChanged(i, n, l))
- }
- }
- ,
- this._pointerUpEvent = function(t) {
- var i, n, r, o, a, s = e._getPointerType(t), l = s === Ci.Mouse ? 0 : e._activeTouchIds.indexOf(t.pointerId);
- if (s === Ci.Touch) {
- if (-1 === l)
- return;
- e._activeTouchIds[l] = -1
- }
- var c = null === (i = e._inputs[s]) || void 0 === i ? void 0 : i[l];
- if (c && 0 !== c[t.button + 2]) {
- var u = c[Pi.Horizontal]
- , h = c[Pi.Vertical];
- c[Pi.Horizontal] = t.clientX,
- c[Pi.Vertical] = t.clientY,
- c[t.button + 2] = 0;
- var d = t;
- u === t.clientX && h === t.clientY || (d.inputIndex = Pi.Move,
- e._onInputChanged(s, l, d)),
- d.inputIndex = t.button + 2,
- s === Ci.Mouse && e._mouseId >= 0 && (null === (r = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === r ? void 0 : r.call(n, e._mouseId)) ? e._elementToAttachTo.releasePointerCapture(e._mouseId) : t.pointerId && (null === (a = (o = e._elementToAttachTo).hasPointerCapture) || void 0 === a ? void 0 : a.call(o, t.pointerId)) && e._elementToAttachTo.releasePointerCapture(t.pointerId),
- e._onInputChanged(s, l, d),
- s === Ci.Touch && e._onDeviceDisconnected(s, l)
- }
- }
- ,
- this._pointerCancelEvent = function(t) {
- var i, n, r, o;
- if ("mouse" === t.pointerType) {
- var a = e._inputs[Ci.Mouse][0];
- e._mouseId >= 0 && (null === (n = (i = e._elementToAttachTo).hasPointerCapture) || void 0 === n ? void 0 : n.call(i, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
- for (var s = Pi.LeftClick; s <= Pi.BrowserForward; s++)
- if (1 === a[s]) {
- a[s] = 0;
- var l = en.CreateDeviceEvent(Ci.Mouse, 0, s, 0, e, e._elementToAttachTo);
- e._onInputChanged(Ci.Mouse, 0, l)
- }
- } else {
- var c = e._activeTouchIds.indexOf(t.pointerId);
- (null === (o = (r = e._elementToAttachTo).hasPointerCapture) || void 0 === o ? void 0 : o.call(r, t.pointerId)) && e._elementToAttachTo.releasePointerCapture(t.pointerId),
- e._inputs[Ci.Touch][c][Pi.LeftClick] = 0,
- l = en.CreateDeviceEvent(Ci.Touch, c, Pi.LeftClick, 0, e, e._elementToAttachTo),
- e._onInputChanged(Ci.Touch, c, l),
- e._activeTouchIds[c] = -1,
- e._onDeviceDisconnected(Ci.Touch, c)
- }
- }
- ,
- this._wheelEventName = "onwheel"in document.createElement("div") ? "wheel" : void 0 !== document.onmousewheel ? "mousewheel" : "DOMMouseScroll";
- var i = !1
- , n = function() {};
- try {
- var r = {
- passive: {
- get: function() {
- i = !0
- }
- }
- };
- this._elementToAttachTo.addEventListener("test", n, r),
- this._elementToAttachTo.removeEventListener("test", n, r)
- } catch (e) {}
- this._pointerBlurEvent = function() {
- var t, i, n, r, o;
- if (e.isDeviceAvailable(Ci.Mouse)) {
- var a = e._inputs[Ci.Mouse][0];
- e._mouseId >= 0 && (null === (i = (t = e._elementToAttachTo).hasPointerCapture) || void 0 === i ? void 0 : i.call(t, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
- for (var s = Pi.LeftClick; s <= Pi.BrowserForward; s++)
- if (1 === a[s]) {
- a[s] = 0;
- var l = en.CreateDeviceEvent(Ci.Mouse, 0, s, 0, e, e._elementToAttachTo);
- e._onInputChanged(Ci.Mouse, 0, l)
- }
- }
- if (e.isDeviceAvailable(Ci.Touch)) {
- a = e._inputs[Ci.Touch];
- for (var c = 0; c < e._activeTouchIds.length; c++) {
- var u = e._activeTouchIds[c];
- (null === (r = (n = e._elementToAttachTo).hasPointerCapture) || void 0 === r ? void 0 : r.call(n, u)) && e._elementToAttachTo.releasePointerCapture(u),
- -1 !== u && 1 === (null === (o = a[c]) || void 0 === o ? void 0 : o[Pi.LeftClick]) && (a[c][Pi.LeftClick] = 0,
- l = en.CreateDeviceEvent(Ci.Touch, c, Pi.LeftClick, 0, e, e._elementToAttachTo),
- e._onInputChanged(Ci.Touch, c, l),
- e._activeTouchIds[c] = -1,
- e._onDeviceDisconnected(Ci.Touch, c))
- }
- }
- }
- ,
- this._pointerWheelEvent = function(t) {
- var i = Ci.Mouse;
- e._inputs[i] || (e._inputs[i] = []),
- e._inputs[i][0] || (e._pointerActive = !0,
- e._registerDevice(i, 0, nn));
- var n = e._inputs[i][0];
- if (n) {
- n[Pi.MouseWheelX] = t.deltaX || 0,
- n[Pi.MouseWheelY] = t.deltaY || t.wheelDelta || 0,
- n[Pi.MouseWheelZ] = t.deltaZ || 0;
- var r = t;
- 0 !== n[Pi.MouseWheelX] && (r.inputIndex = Pi.MouseWheelX,
- e._onInputChanged(i, 0, r)),
- 0 !== n[Pi.MouseWheelY] && (r.inputIndex = Pi.MouseWheelY,
- e._onInputChanged(i, 0, r)),
- 0 !== n[Pi.MouseWheelZ] && (r.inputIndex = Pi.MouseWheelZ,
- e._onInputChanged(i, 0, r))
- }
- }
- ,
- 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(this._eventPrefix + "cancel", this._pointerCancelEvent),
- this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent),
- this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, !!i && {
- passive: !1
- }),
- this._pointerInputClearObserver = this._engine.onEndFrameObservable.add((function() {
- if (e.isDeviceAvailable(Ci.Mouse)) {
- var t = e._inputs[Ci.Mouse][0];
- t[Pi.MouseWheelX] = 0,
- t[Pi.MouseWheelY] = 0,
- t[Pi.MouseWheelZ] = 0
- }
- }
- ))
- }
- ,
- e.prototype._handleGamepadActions = function() {
- var e = this;
- this._gamepadConnectedEvent = function(t) {
- e._addGamePad(t.gamepad)
- }
- ,
- this._gamepadDisconnectedEvent = function(t) {
- if (e._gamepads) {
- var i = e._getGamepadDeviceType(t.gamepad.id)
- , n = t.gamepad.index;
- e._unregisterDevice(i, n),
- delete e._gamepads[n]
- }
- }
- ,
- window.addEventListener("gamepadconnected", this._gamepadConnectedEvent),
- window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)
- }
- ,
- e.prototype._updateDevice = function(e, t, i) {
- var n = navigator.getGamepads()[t];
- if (n && e === this._gamepads[t]) {
- var r = this._inputs[e][t];
- i >= n.buttons.length ? r[i] = n.axes[i - n.buttons.length].valueOf() : r[i] = n.buttons[i].value
- }
- }
- ,
- e.prototype._getGamepadDeviceType = function(e) {
- return -1 !== e.indexOf("054c") ? -1 !== e.indexOf("0ce6") ? Ci.DualSense : Ci.DualShock : -1 !== e.indexOf("Xbox One") || -1 !== e.search("Xbox 360") || -1 !== e.search("xinput") ? Ci.Xbox : -1 !== e.indexOf("057e") ? Ci.Switch : Ci.Generic
- }
- ,
- e.prototype._getPointerType = function(e) {
- var t = Ci.Mouse;
- return ("touch" === e.pointerType || "pen" === e.pointerType || e.touches) && (t = Ci.Touch),
- t
- }
- ,
- e
- }(), on = function() {
- function e(e, t, i) {
- void 0 === i && (i = 0),
- this.deviceType = t,
- this.deviceSlot = i,
- this.onInputChangedObservable = new h,
- this._deviceInputSystem = e
- }
- return e.prototype.getInput = function(e) {
- return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, e)
- }
- ,
- e
- }(), an = function() {
- function e(e) {
- var t = this;
- this._registeredManagers = new Array,
- this._refCount = 0,
- this.registerManager = function(e) {
- for (var i = 0; i < t._devices.length; i++) {
- var n = t._devices[i];
- for (var r in n) {
- var o = +r;
- e._addDevice(new on(t._deviceInputSystem,i,o))
- }
- }
- t._registeredManagers.push(e)
- }
- ,
- this.unregisterManager = function(e) {
- var i = t._registeredManagers.indexOf(e);
- i > -1 && t._registeredManagers.splice(i, 1)
- }
- ;
- var i = Object.keys(Ci).length / 2;
- this._devices = new Array(i);
- var n = function(e, i) {
- t._devices[e] || (t._devices[e] = new Array),
- t._devices[e][i] || (t._devices[e][i] = i);
- for (var n = 0, r = t._registeredManagers; n < r.length; n++) {
- var o = r[n]
- , a = new on(t._deviceInputSystem,e,i);
- o._addDevice(a)
- }
- }
- , r = function(e, i) {
- var n;
- (null === (n = t._devices[e]) || void 0 === n ? void 0 : n[i]) && delete t._devices[e][i];
- for (var r = 0, o = t._registeredManagers; r < o.length; r++)
- o[r]._removeDevice(e, i)
- }
- , o = function(e, i, n) {
- if (n)
- for (var r = 0, o = t._registeredManagers; r < o.length; r++)
- o[r]._onInputChanged(e, i, n)
- };
- "undefined" != typeof _native ? this._deviceInputSystem = new tn(n,r,o) : this._deviceInputSystem = new rn(e,n,r,o)
- }
- return e.prototype.dispose = function() {
- this._deviceInputSystem.dispose()
- }
- ,
- e
- }(), sn = function() {
- function e(e) {
- var t = this
- , i = Object.keys(Ci).length / 2;
- this._devices = new Array(i),
- this._firstDevice = new Array(i),
- this._engine = e,
- this._engine._deviceSourceManager || (this._engine._deviceSourceManager = new an(e)),
- this._engine._deviceSourceManager._refCount++,
- this.onDeviceConnectedObservable = new h((function(e) {
- t.getDevices().forEach((function(i) {
- t.onDeviceConnectedObservable.notifyObserver(e, i)
- }
- ))
- }
- )),
- this.onDeviceDisconnectedObservable = new h,
- this._engine._deviceSourceManager.registerManager(this),
- this._onDisposeObserver = e.onDisposeObservable.add((function() {
- t.dispose()
- }
- ))
- }
- return e.prototype.getDeviceSource = function(e, t) {
- if (void 0 === t) {
- if (void 0 === this._firstDevice[e])
- return null;
- t = this._firstDevice[e]
- }
- return this._devices[e] && void 0 !== this._devices[e][t] ? this._devices[e][t] : null
- }
- ,
- e.prototype.getDeviceSources = function(e) {
- return this._devices[e].filter((function(e) {
- return !!e
- }
- ))
- }
- ,
- e.prototype.getDevices = function() {
- for (var e = new Array, t = 0, i = this._devices; t < i.length; t++) {
- var n = i[t];
- e.push.apply(e, n)
- }
- return e
- }
- ,
- e.prototype.dispose = function() {
- this.onDeviceConnectedObservable.clear(),
- this.onDeviceDisconnectedObservable.clear(),
- this._engine._deviceSourceManager && (this._engine._deviceSourceManager.unregisterManager(this),
- --this._engine._deviceSourceManager._refCount < 1 && (this._engine._deviceSourceManager.dispose(),
- delete this._engine._deviceSourceManager)),
- this._engine.onDisposeObservable.remove(this._onDisposeObserver)
- }
- ,
- e.prototype._addDevice = function(e) {
- this._devices[e.deviceType] || (this._devices[e.deviceType] = new Array),
- this._devices[e.deviceType][e.deviceSlot] || (this._devices[e.deviceType][e.deviceSlot] = e,
- this._updateFirstDevices(e.deviceType)),
- this.onDeviceConnectedObservable.notifyObservers(e)
- }
- ,
- e.prototype._removeDevice = function(e, t) {
- var i, n, r = null === (i = this._devices[e]) || void 0 === i ? void 0 : i[t];
- this.onDeviceDisconnectedObservable.notifyObservers(r),
- (null === (n = this._devices[e]) || void 0 === n ? void 0 : n[t]) && delete this._devices[e][t],
- this._updateFirstDevices(e)
- }
- ,
- e.prototype._onInputChanged = function(e, t, i) {
- var n, r;
- null === (r = null === (n = this._devices[e]) || void 0 === n ? void 0 : n[t]) || void 0 === r || r.onInputChangedObservable.notifyObservers(i)
- }
- ,
- e.prototype._updateFirstDevices = function(e) {
- switch (e) {
- case Ci.Keyboard:
- case Ci.Mouse:
- this._firstDevice[e] = 0;
- break;
- case Ci.Touch:
- case Ci.DualSense:
- case Ci.DualShock:
- case Ci.Xbox:
- case Ci.Switch:
- case Ci.Generic:
- delete this._firstDevice[e];
- var t = this._devices[e];
- if (t)
- for (var i = 0; i < t.length; i++)
- if (t[i]) {
- this._firstDevice[e] = i;
- break
- }
- }
- }
- ,
- e
- }(), ln = function() {
- function e() {
- this._singleClick = !1,
- this._doubleClick = !1,
- this._hasSwiped = !1,
- this._ignore = !1
- }
- return Object.defineProperty(e.prototype, "singleClick", {
- get: function() {
- return this._singleClick
- },
- set: function(e) {
- this._singleClick = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "doubleClick", {
- get: function() {
- return this._doubleClick
- },
- set: function(e) {
- this._doubleClick = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasSwiped", {
- get: function() {
- return this._hasSwiped
- },
- set: function(e) {
- this._hasSwiped = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ignore", {
- get: function() {
- return this._ignore
- },
- set: function(e) {
- this._ignore = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(), cn = function() {
- function e(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 A(0,0),
- this._previousStartingPointerPosition = new A(0,0),
- this._startingPointerTime = 0,
- this._previousStartingPointerTime = 0,
- this._pointerCaptures = {},
- this._meshUnderPointerId = {},
- this._deviceSourceManager = null,
- this._scene = e || E.LastCreatedScene,
- this._scene
- }
- return Object.defineProperty(e.prototype, "meshUnderPointer", {
- get: function() {
- return this._pointerOverMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getMeshUnderPointerByPointerId = function(e) {
- return this._meshUnderPointerId[e] || null
- }
- ,
- Object.defineProperty(e.prototype, "unTranslatedPointer", {
- get: function() {
- return new A(this._unTranslatedPointerX,this._unTranslatedPointerY)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pointerX", {
- get: function() {
- return this._pointerX
- },
- set: function(e) {
- this._pointerX = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pointerY", {
- get: function() {
- return this._pointerY
- },
- set: function(e) {
- this._pointerY = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._updatePointerPosition = function(e) {
- var t = this._scene.getEngine().getInputElementClientRect();
- t && (this._pointerX = e.clientX - t.left,
- this._pointerY = e.clientY - t.top,
- this._unTranslatedPointerX = this._pointerX,
- this._unTranslatedPointerY = this._pointerY)
- }
- ,
- e.prototype._processPointerMove = function(e, t) {
- var i = this._scene
- , n = i.getEngine()
- , r = n.getInputElement();
- r && (r.tabIndex = n.canvasTabIndex,
- i.doNotHandleCursors || (r.style.cursor = i.defaultCursor));
- var o = !!(e && e.hit && e.pickedMesh);
- o ? (i.setPointerOverMesh(e.pickedMesh, t.pointerId, e),
- this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers && !i.doNotHandleCursors && r && (this._pointerOverMesh.actionManager.hoverCursor ? r.style.cursor = this._pointerOverMesh.actionManager.hoverCursor : r.style.cursor = i.hoverCursor)) : i.setPointerOverMesh(null, t.pointerId, e);
- for (var a = 0, s = i._pointerMoveStage; a < s.length; a++)
- e = s[a].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, o, r);
- if (e) {
- var l = "wheel" === t.type || "mousewheel" === t.type || "DOMMouseScroll" === t.type ? Xi.POINTERWHEEL : Xi.POINTERMOVE;
- if (i.onPointerMove && i.onPointerMove(t, e, l),
- i.onPointerObservable.hasObservers()) {
- var c = new Ki(l,t,e);
- this._setRayOnPointerInfo(c),
- i.onPointerObservable.notifyObservers(c, l)
- }
- }
- }
- ,
- e.prototype._setRayOnPointerInfo = function(e) {
- var t = this._scene;
- e.pickInfo && !e.pickInfo._pickingUnavailable && (e.pickInfo.ray || (e.pickInfo.ray = t.createPickingRay(e.event.offsetX, e.event.offsetY, P.Identity(), t.activeCamera)))
- }
- ,
- e.prototype._checkPrePointerObservable = function(e, t, i) {
- var n = this._scene
- , r = new Yi(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);
- return e && (r.ray = e.ray,
- e.originMesh && (r.nearInteractionPickingInfo = e)),
- n.onPrePointerObservable.notifyObservers(r, i),
- !!r.skipOnPointerObservable
- }
- ,
- e.prototype.simulatePointerMove = function(e, t) {
- var i = new PointerEvent("pointermove",t);
- i.inputIndex = Pi.Move,
- this._checkPrePointerObservable(e, i, Xi.POINTERMOVE) || this._processPointerMove(e, i)
- }
- ,
- e.prototype.simulatePointerDown = function(e, t) {
- var i = new PointerEvent("pointerdown",t);
- i.inputIndex = i.button + 2,
- this._checkPrePointerObservable(e, i, Xi.POINTERDOWN) || this._processPointerDown(e, i)
- }
- ,
- e.prototype._processPointerDown = function(t, i) {
- var n = this
- , r = this._scene;
- if (t && t.hit && t.pickedMesh) {
- this._pickedDownMesh = t.pickedMesh;
- var o = t.pickedMesh._getActionManagerForTrigger();
- if (o) {
- if (o.hasPickTriggers)
- switch (o.processTrigger(a.ACTION_OnPickDownTrigger, w.CreateNew(t.pickedMesh, i)),
- i.button) {
- case 0:
- o.processTrigger(a.ACTION_OnLeftPickTrigger, w.CreateNew(t.pickedMesh, i));
- break;
- case 1:
- o.processTrigger(a.ACTION_OnCenterPickTrigger, w.CreateNew(t.pickedMesh, i));
- break;
- case 2:
- o.processTrigger(a.ACTION_OnRightPickTrigger, w.CreateNew(t.pickedMesh, i))
- }
- o.hasSpecificTrigger(a.ACTION_OnLongPressTrigger) && window.setTimeout((function() {
- var t = r.pick(n._unTranslatedPointerX, n._unTranslatedPointerY, (function(e) {
- return e.isPickable && e.isVisible && e.isReady() && e.actionManager && e.actionManager.hasSpecificTrigger(a.ACTION_OnLongPressTrigger) && e === n._pickedDownMesh
- }
- ), !1, r.cameraToUseForPointers);
- t && t.hit && t.pickedMesh && o && 0 !== n._totalPointersPressed && Date.now() - n._startingPointerTime > e.LongPressDelay && !n._isPointerSwiping() && (n._startingPointerTime = 0,
- o.processTrigger(a.ACTION_OnLongPressTrigger, w.CreateNew(t.pickedMesh, i)))
- }
- ), e.LongPressDelay)
- }
- } else
- for (var s = 0, l = r._pointerDownStage; s < l.length; s++)
- t = l[s].action(this._unTranslatedPointerX, this._unTranslatedPointerY, t, i);
- if (t) {
- var c = Xi.POINTERDOWN;
- if (r.onPointerDown && r.onPointerDown(i, t, c),
- r.onPointerObservable.hasObservers()) {
- var u = new Ki(c,i,t);
- this._setRayOnPointerInfo(u),
- r.onPointerObservable.notifyObservers(u, c)
- }
- }
- }
- ,
- e.prototype._isPointerSwiping = function() {
- return Math.abs(this._startingPointerPosition.x - this._pointerX) > e.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > e.DragMovementThreshold
- }
- ,
- e.prototype.simulatePointerUp = function(e, t, i) {
- var n = new PointerEvent("pointerup",t);
- n.inputIndex = Pi.Move;
- var r = new ln;
- i ? r.doubleClick = !0 : r.singleClick = !0,
- this._checkPrePointerObservable(e, n, Xi.POINTERUP) || this._processPointerUp(e, n, r)
- }
- ,
- e.prototype._processPointerUp = function(e, t, i) {
- var n = this._scene;
- if (e && e && e.pickedMesh) {
- if (this._pickedUpMesh = e.pickedMesh,
- this._pickedDownMesh === this._pickedUpMesh && (n.onPointerPick && n.onPointerPick(t, e),
- i.singleClick && !i.ignore && n.onPointerObservable.hasObservers())) {
- var r = Xi.POINTERPICK
- , o = new Ki(r,t,e);
- this._setRayOnPointerInfo(o),
- n.onPointerObservable.notifyObservers(o, r)
- }
- var s = e.pickedMesh._getActionManagerForTrigger();
- if (s && !i.ignore) {
- s.processTrigger(a.ACTION_OnPickUpTrigger, w.CreateNew(e.pickedMesh, t, e)),
- !i.hasSwiped && i.singleClick && s.processTrigger(a.ACTION_OnPickTrigger, w.CreateNew(e.pickedMesh, t, e));
- var l = e.pickedMesh._getActionManagerForTrigger(a.ACTION_OnDoublePickTrigger);
- i.doubleClick && l && l.processTrigger(a.ACTION_OnDoublePickTrigger, w.CreateNew(e.pickedMesh, t, e))
- }
- } else if (!i.ignore)
- for (var c = 0, u = n._pointerUpStage; c < u.length; c++)
- e = u[c].action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, t);
- if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
- var h = this._pickedDownMesh._getActionManagerForTrigger(a.ACTION_OnPickOutTrigger);
- h && h.processTrigger(a.ACTION_OnPickOutTrigger, w.CreateNew(this._pickedDownMesh, t))
- }
- var d = 0;
- n.onPointerObservable.hasObservers() && (i.ignore || i.hasSwiped || (i.singleClick && n.onPointerObservable.hasSpecificMask(Xi.POINTERTAP) ? d = Xi.POINTERTAP : i.doubleClick && n.onPointerObservable.hasSpecificMask(Xi.POINTERDOUBLETAP) && (d = Xi.POINTERDOUBLETAP),
- !d) || (o = new Ki(d,t,e),
- this._setRayOnPointerInfo(o),
- n.onPointerObservable.notifyObservers(o, d)),
- i.ignore || (d = Xi.POINTERUP,
- o = new Ki(d,t,e),
- this._setRayOnPointerInfo(o),
- n.onPointerObservable.notifyObservers(o, d))),
- n.onPointerUp && !i.ignore && n.onPointerUp(t, e, d)
- }
- ,
- e.prototype.isPointerCaptured = function(e) {
- return void 0 === e && (e = 0),
- this._pointerCaptures[e]
- }
- ,
- e.prototype.attachControl = function(t, i, n, r) {
- var o = this;
- void 0 === t && (t = !0),
- void 0 === i && (i = !0),
- void 0 === n && (n = !0),
- void 0 === r && (r = null);
- var l = this._scene
- , c = l.getEngine();
- r || (r = c.getInputElement()),
- this._alreadyAttached && this.detachControl(),
- r && (this._alreadyAttachedTo = r),
- this._deviceSourceManager = new sn(c),
- this._initActionManager = function(e) {
- if (!o._meshPickProceed) {
- var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, !1, l.cameraToUseForPointers);
- o._currentPickResult = t,
- t && (e = t.hit && t.pickedMesh ? t.pickedMesh._getActionManagerForTrigger() : null),
- o._meshPickProceed = !0
- }
- return e
- }
- ,
- this._delayedSimpleClick = function(t, i, n) {
- (Date.now() - o._previousStartingPointerTime > e.DoubleClickDelay && !o._doubleClickOccured || t !== o._previousButtonPressed) && (o._doubleClickOccured = !1,
- i.singleClick = !0,
- i.ignore = !1,
- n(i, o._currentPickResult))
- }
- ,
- this._initClickEvent = function(t, i, n, r) {
- var l = new ln;
- o._currentPickResult = null;
- var c = null
- , u = t.hasSpecificMask(Xi.POINTERPICK) || i.hasSpecificMask(Xi.POINTERPICK) || t.hasSpecificMask(Xi.POINTERTAP) || i.hasSpecificMask(Xi.POINTERTAP) || t.hasSpecificMask(Xi.POINTERDOUBLETAP) || i.hasSpecificMask(Xi.POINTERDOUBLETAP);
- !u && s && (c = o._initActionManager(c, l)) && (u = c.hasPickTriggers);
- var h = !1;
- if (u) {
- var d = n.button;
- if (l.hasSwiped = o._isPointerSwiping(),
- !l.hasSwiped) {
- var p = !e.ExclusiveDoubleClickMode;
- p || (p = !t.hasSpecificMask(Xi.POINTERDOUBLETAP) && !i.hasSpecificMask(Xi.POINTERDOUBLETAP)) && !s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger) && (c = o._initActionManager(c, l)) && (p = !c.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),
- p ? (Date.now() - o._previousStartingPointerTime > e.DoubleClickDelay || d !== o._previousButtonPressed) && (l.singleClick = !0,
- r(l, o._currentPickResult),
- h = !0) : (o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
- o._delayedSimpleClickTimeout = window.setTimeout(o._delayedSimpleClick.bind(o, d, l, r), e.DoubleClickDelay));
- var f = t.hasSpecificMask(Xi.POINTERDOUBLETAP) || i.hasSpecificMask(Xi.POINTERDOUBLETAP);
- !f && s.HasSpecificTrigger(a.ACTION_OnDoublePickTrigger) && (c = o._initActionManager(c, l)) && (f = c.hasSpecificTrigger(a.ACTION_OnDoublePickTrigger)),
- f && (d === o._previousButtonPressed && Date.now() - o._previousStartingPointerTime < e.DoubleClickDelay && !o._doubleClickOccured ? (l.hasSwiped || o._isPointerSwiping() ? (o._doubleClickOccured = !1,
- o._previousStartingPointerTime = o._startingPointerTime,
- o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
- o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
- o._previousButtonPressed = d,
- e.ExclusiveDoubleClickMode ? (o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
- o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
- r(l, o._previousPickResult)) : r(l, o._currentPickResult)) : (o._previousStartingPointerTime = 0,
- o._doubleClickOccured = !0,
- l.doubleClick = !0,
- l.ignore = !1,
- e.ExclusiveDoubleClickMode && o._previousDelayedSimpleClickTimeout && clearTimeout(o._previousDelayedSimpleClickTimeout),
- o._previousDelayedSimpleClickTimeout = o._delayedSimpleClickTimeout,
- r(l, o._currentPickResult)),
- h = !0) : (o._doubleClickOccured = !1,
- o._previousStartingPointerTime = o._startingPointerTime,
- o._previousStartingPointerPosition.x = o._startingPointerPosition.x,
- o._previousStartingPointerPosition.y = o._startingPointerPosition.y,
- o._previousButtonPressed = d))
- }
- }
- h || r(l, o._currentPickResult)
- }
- ,
- this._onPointerMove = function(e) {
- if (void 0 === e.pointerId && (e.pointerId = 0),
- o._updatePointerPosition(e),
- !o._checkPrePointerObservable(null, e, "wheel" === e.type || "mousewheel" === e.type || "DOMMouseScroll" === e.type ? Xi.POINTERWHEEL : Xi.POINTERMOVE) && (l.cameraToUseForPointers || l.activeCamera))
- if (l.skipPointerMovePicking)
- o._processPointerMove(new Ui, e);
- else {
- l.pointerMovePredicate || (l.pointerMovePredicate = function(e) {
- return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (e.enablePointerMoveEvents || l.constantlyUpdateMeshUnderPointer || null !== e._getActionManagerForTrigger()) && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask))
- }
- );
- var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerMovePredicate, !1, l.cameraToUseForPointers, l.pointerMoveTrianglePredicate);
- o._processPointerMove(t, e)
- }
- }
- ,
- this._onPointerDown = function(e) {
- if (o._totalPointersPressed++,
- o._pickedDownMesh = null,
- o._meshPickProceed = !1,
- void 0 === e.pointerId && (e.pointerId = 0),
- o._updatePointerPosition(e),
- l.preventDefaultOnPointerDown && r && (e.preventDefault(),
- r.focus()),
- o._startingPointerPosition.x = o._pointerX,
- o._startingPointerPosition.y = o._pointerY,
- o._startingPointerTime = Date.now(),
- !o._checkPrePointerObservable(null, e, Xi.POINTERDOWN) && (l.cameraToUseForPointers || l.activeCamera)) {
- o._pointerCaptures[e.pointerId] = !0,
- l.pointerDownPredicate || (l.pointerDownPredicate = function(e) {
- return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask))
- }
- ),
- o._pickedDownMesh = null;
- var t = l.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, l.pointerDownPredicate, !1, l.cameraToUseForPointers);
- o._processPointerDown(t, e)
- }
- }
- ,
- this._onPointerUp = function(e) {
- 0 !== o._totalPointersPressed && (o._totalPointersPressed--,
- o._pickedUpMesh = null,
- o._meshPickProceed = !1,
- void 0 === e.pointerId && (e.pointerId = 0),
- o._updatePointerPosition(e),
- l.preventDefaultOnPointerUp && r && (e.preventDefault(),
- r.focus()),
- o._initClickEvent(l.onPrePointerObservable, l.onPointerObservable, e, (function(t, i) {
- if (l.onPrePointerObservable.hasObservers() && !t.ignore) {
- if (!t.hasSwiped) {
- if (t.singleClick && l.onPrePointerObservable.hasSpecificMask(Xi.POINTERTAP) && o._checkPrePointerObservable(null, e, Xi.POINTERTAP))
- return;
- if (t.doubleClick && l.onPrePointerObservable.hasSpecificMask(Xi.POINTERDOUBLETAP) && o._checkPrePointerObservable(null, e, Xi.POINTERDOUBLETAP))
- return
- }
- if (o._checkPrePointerObservable(null, e, Xi.POINTERUP))
- return
- }
- !o._pointerCaptures[e.pointerId] && e.buttons > 0 || (o._pointerCaptures[e.pointerId] = !1,
- (l.cameraToUseForPointers || l.activeCamera) && (l.pointerUpPredicate || (l.pointerUpPredicate = function(e) {
- return e.isPickable && e.isVisible && e.isReady() && e.isEnabled() && (!l.cameraToUseForPointers || 0 != (l.cameraToUseForPointers.layerMask & e.layerMask))
- }
- ),
- !o._meshPickProceed && (s && s.HasTriggers || l.onPointerObservable.hasObservers()) && o._initActionManager(null, t),
- i || (i = o._currentPickResult),
- o._processPointerUp(i, e, t),
- o._previousPickResult = o._currentPickResult))
- }
- )))
- }
- ,
- this._onKeyDown = function(e) {
- var t = Qi.KEYDOWN;
- if (l.onPreKeyboardObservable.hasObservers()) {
- var i = new Zi(t,e);
- if (l.onPreKeyboardObservable.notifyObservers(i, t),
- i.skipOnKeyboardObservable)
- return
- }
- l.onKeyboardObservable.hasObservers() && (i = new qi(t,e),
- l.onKeyboardObservable.notifyObservers(i, t)),
- l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyDownTrigger, w.CreateNewFromScene(l, e))
- }
- ,
- this._onKeyUp = function(e) {
- var t = Qi.KEYUP;
- if (l.onPreKeyboardObservable.hasObservers()) {
- var i = new Zi(t,e);
- if (l.onPreKeyboardObservable.notifyObservers(i, t),
- i.skipOnKeyboardObservable)
- return
- }
- l.onKeyboardObservable.hasObservers() && (i = new qi(t,e),
- l.onKeyboardObservable.notifyObservers(i, t)),
- l.actionManager && l.actionManager.processTrigger(a.ACTION_OnKeyUpTrigger, w.CreateNewFromScene(l, e))
- }
- ,
- this._deviceSourceManager.onDeviceConnectedObservable.add((function(e) {
- e.deviceType === Ci.Mouse ? e.onInputChangedObservable.add((function(r) {
- if (r.inputIndex === Pi.LeftClick || r.inputIndex === Pi.MiddleClick || r.inputIndex === Pi.RightClick) {
- var a = r;
- i && 1 === e.getInput(a.inputIndex) ? o._onPointerDown(a) : t && 0 === e.getInput(a.inputIndex) && o._onPointerUp(a)
- } else
- n && (r.inputIndex === Pi.Move ? o._onPointerMove(r) : r.inputIndex !== Pi.MouseWheelX && r.inputIndex !== Pi.MouseWheelY && r.inputIndex !== Pi.MouseWheelZ || o._onPointerMove(r))
- }
- )) : e.deviceType === Ci.Touch ? e.onInputChangedObservable.add((function(r) {
- var a = r;
- r.inputIndex === Pi.LeftClick && (i && 1 === e.getInput(a.inputIndex) ? o._onPointerDown(r) : t && 0 === e.getInput(a.inputIndex) && o._onPointerUp(r)),
- n && r.inputIndex === Pi.Move && o._onPointerMove(r)
- }
- )) : e.deviceType === Ci.Keyboard && e.onInputChangedObservable.add((function(e) {
- var t = e;
- "keydown" === t.type ? o._onKeyDown(t) : "keyup" === t.type && o._onKeyUp(t)
- }
- ))
- }
- )),
- this._alreadyAttached = !0
- }
- ,
- e.prototype.detachControl = function() {
- this._alreadyAttached && (this._deviceSourceManager.dispose(),
- this._deviceSourceManager = null,
- this._alreadyAttachedTo && !this._scene.doNotHandleCursors && (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor),
- this._alreadyAttached = !1,
- this._alreadyAttachedTo = null)
- }
- ,
- e.prototype.setPointerOverMesh = function(e, t, i) {
- if (void 0 === t && (t = 0),
- this._meshUnderPointerId[t] !== e) {
- var n, r = this._meshUnderPointerId[t];
- r && (n = r._getActionManagerForTrigger(a.ACTION_OnPointerOutTrigger)) && n.processTrigger(a.ACTION_OnPointerOutTrigger, w.CreateNew(r, void 0, {
- pointerId: t
- })),
- e ? (this._meshUnderPointerId[t] = e,
- this._pointerOverMesh = e,
- (n = e._getActionManagerForTrigger(a.ACTION_OnPointerOverTrigger)) && n.processTrigger(a.ACTION_OnPointerOverTrigger, w.CreateNew(e, void 0, {
- pointerId: t,
- pickResult: i
- }))) : (delete this._meshUnderPointerId[t],
- this._pointerOverMesh = null)
- }
- }
- ,
- e.prototype.getPointerOverMesh = function() {
- return this._pointerOverMesh
- }
- ,
- e.prototype._invalidateMesh = function(e) {
- for (var t in this._pointerOverMesh === e && (this._pointerOverMesh = null),
- this._pickedDownMesh === e && (this._pickedDownMesh = null),
- this._pickedUpMesh === e && (this._pickedUpMesh = null),
- this._meshUnderPointerId)
- this._meshUnderPointerId[t] === e && delete this._meshUnderPointerId[t]
- }
- ,
- e.DragMovementThreshold = 10,
- e.LongPressDelay = 500,
- e.DoubleClickDelay = 300,
- e.ExclusiveDoubleClickMode = !1,
- e
- }(), un = function() {
- function e() {
- 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(e.prototype, "min", {
- get: function() {
- return this._min
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "max", {
- get: function() {
- return this._max
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "average", {
- get: function() {
- return this._average
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lastSecAverage", {
- get: function() {
- return this._lastSecAverage
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "current", {
- get: function() {
- return this._current
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "total", {
- get: function() {
- return this._totalAccumulated
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "count", {
- get: function() {
- return this._totalValueCount
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.fetchNewFrame = function() {
- this._totalValueCount++,
- this._current = 0,
- this._lastSecValueCount++
- }
- ,
- e.prototype.addCount = function(t, i) {
- e.Enabled && (this._current += t,
- i && this._fetchResult())
- }
- ,
- e.prototype.beginMonitoring = function() {
- e.Enabled && (this._startMonitoringTime = ct.Now)
- }
- ,
- e.prototype.endMonitoring = function(t) {
- if (void 0 === t && (t = !0),
- e.Enabled) {
- t && this.fetchNewFrame();
- var i = ct.Now;
- this._current = i - this._startMonitoringTime,
- t && this._fetchResult()
- }
- }
- ,
- e.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 = ct.Now;
- e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount,
- this._lastSecTime = e,
- this._lastSecAccumulated = 0,
- this._lastSecValueCount = 0)
- }
- ,
- e.Enabled = !0,
- e
- }(), hn = function() {
- function e(e, t, i, n) {
- this.normal = new x(e,t,i),
- this.d = n
- }
- return e.prototype.asArray = function() {
- return [this.normal.x, this.normal.y, this.normal.z, this.d]
- }
- ,
- e.prototype.clone = function() {
- return new e(this.normal.x,this.normal.y,this.normal.z,this.d)
- }
- ,
- e.prototype.getClassName = function() {
- return "Plane"
- }
- ,
- e.prototype.getHashCode = function() {
- var e = this.normal.getHashCode();
- return 397 * e ^ (0 | this.d)
- }
- ,
- e.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)
- , t = 0;
- return 0 !== e && (t = 1 / e),
- this.normal.x *= t,
- this.normal.y *= t,
- this.normal.z *= t,
- this.d *= t,
- this
- }
- ,
- e.prototype.transform = function(t) {
- var i = e._TmpMatrix;
- t.invertToRef(i);
- var n = i.m
- , r = this.normal.x
- , o = this.normal.y
- , a = this.normal.z
- , s = this.d;
- return new e(r * n[0] + o * n[1] + a * n[2] + s * n[3],r * n[4] + o * n[5] + a * n[6] + s * n[7],r * n[8] + o * n[9] + a * n[10] + s * n[11],r * n[12] + o * n[13] + a * n[14] + s * n[15])
- }
- ,
- e.prototype.dotCoordinate = function(e) {
- return this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z + this.d
- }
- ,
- e.prototype.copyFromPoints = function(e, t, i) {
- var n, r = t.x - e.x, o = t.y - e.y, a = t.z - e.z, s = i.x - e.x, l = i.y - e.y, c = i.z - e.z, u = o * c - a * l, h = a * s - r * c, d = r * l - o * s, p = Math.sqrt(u * u + h * h + d * d);
- return n = 0 !== p ? 1 / p : 0,
- this.normal.x = u * n,
- this.normal.y = h * n,
- this.normal.z = d * n,
- this.d = -(this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z),
- this
- }
- ,
- e.prototype.isFrontFacingTo = function(e, t) {
- return x.Dot(this.normal, e) <= t
- }
- ,
- e.prototype.signedDistanceTo = function(e) {
- return x.Dot(e, this.normal) + this.d
- }
- ,
- e.FromArray = function(t) {
- return new e(t[0],t[1],t[2],t[3])
- }
- ,
- e.FromPoints = function(t, i, n) {
- var r = new e(0,0,0,0);
- return r.copyFromPoints(t, i, n),
- r
- }
- ,
- e.FromPositionAndNormal = function(t, i) {
- var n = new e(0,0,0,0);
- return i.normalize(),
- n.normal = i,
- n.d = -(i.x * t.x + i.y * t.y + i.z * t.z),
- n
- }
- ,
- e.SignedDistanceToPlaneFromPositionAndNormal = function(e, t, i) {
- var n = -(t.x * e.x + t.y * e.y + t.z * e.z);
- return x.Dot(i, t) + n
- }
- ,
- e._TmpMatrix = P.Identity(),
- e
- }(), dn = function() {
- function e() {}
- return e.GetPlanes = function(t) {
- for (var i = [], n = 0; n < 6; n++)
- i.push(new hn(0,0,0,0));
- return e.GetPlanesToRef(t, i),
- i
- }
- ,
- e.GetNearPlaneToRef = function(e, t) {
- var i = e.m;
- t.normal.x = i[3] + i[2],
- t.normal.y = i[7] + i[6],
- t.normal.z = i[11] + i[10],
- t.d = i[15] + i[14],
- t.normalize()
- }
- ,
- e.GetFarPlaneToRef = function(e, t) {
- var i = e.m;
- t.normal.x = i[3] - i[2],
- t.normal.y = i[7] - i[6],
- t.normal.z = i[11] - i[10],
- t.d = i[15] - i[14],
- t.normalize()
- }
- ,
- e.GetLeftPlaneToRef = function(e, t) {
- var i = e.m;
- t.normal.x = i[3] + i[0],
- t.normal.y = i[7] + i[4],
- t.normal.z = i[11] + i[8],
- t.d = i[15] + i[12],
- t.normalize()
- }
- ,
- e.GetRightPlaneToRef = function(e, t) {
- var i = e.m;
- t.normal.x = i[3] - i[0],
- t.normal.y = i[7] - i[4],
- t.normal.z = i[11] - i[8],
- t.d = i[15] - i[12],
- t.normalize()
- }
- ,
- e.GetTopPlaneToRef = function(e, t) {
- var i = e.m;
- t.normal.x = i[3] - i[1],
- t.normal.y = i[7] - i[5],
- t.normal.z = i[11] - i[9],
- t.d = i[15] - i[13],
- t.normalize()
- }
- ,
- e.GetBottomPlaneToRef = function(e, t) {
- var i = e.m;
- t.normal.x = i[3] + i[1],
- t.normal.y = i[7] + i[5],
- t.normal.z = i[11] + i[9],
- t.d = i[15] + i[13],
- t.normalize()
- }
- ,
- e.GetPlanesToRef = function(t, i) {
- e.GetNearPlaneToRef(t, i[0]),
- e.GetFarPlaneToRef(t, i[1]),
- e.GetLeftPlaneToRef(t, i[2]),
- e.GetRightPlaneToRef(t, i[3]),
- e.GetTopPlaneToRef(t, i[4]),
- e.GetBottomPlaneToRef(t, i[5])
- }
- ,
- e
- }(), pn = function() {
- function e() {}
- return Object.defineProperty(e, "UniqueId", {
- get: function() {
- var e = this._UniqueIdCounter;
- return this._UniqueIdCounter++,
- e
- },
- enumerable: !1,
- configurable: !0
- }),
- e._UniqueIdCounter = 1,
- e
- }(), fn = function() {
- function e() {}
- return e.CompareLightsPriority = function(e, t) {
- return e.shadowEnabled !== t.shadowEnabled ? (t.shadowEnabled ? 1 : 0) - (e.shadowEnabled ? 1 : 0) : t.renderPriority - e.renderPriority
- }
- ,
- e.FALLOFF_DEFAULT = 0,
- e.FALLOFF_PHYSICAL = 1,
- e.FALLOFF_GLTF = 2,
- e.FALLOFF_STANDARD = 3,
- e.LIGHTMAP_DEFAULT = 0,
- e.LIGHTMAP_SPECULAR = 1,
- e.LIGHTMAP_SHADOWSONLY = 2,
- e.INTENSITYMODE_AUTOMATIC = 0,
- e.INTENSITYMODE_LUMINOUSPOWER = 1,
- e.INTENSITYMODE_LUMINOUSINTENSITY = 2,
- e.INTENSITYMODE_ILLUMINANCE = 3,
- e.INTENSITYMODE_LUMINANCE = 4,
- e.LIGHTTYPEID_POINTLIGHT = 0,
- e.LIGHTTYPEID_DIRECTIONALLIGHT = 1,
- e.LIGHTTYPEID_SPOTLIGHT = 2,
- e.LIGHTTYPEID_HEMISPHERICLIGHT = 3,
- e
- }(), _n = function() {
- function e(t, i) {
- e.IsAvailable && (this._observer = new window.ComputePressureObserver(t,i))
- }
- return Object.defineProperty(e, "IsAvailable", {
- get: function() {
- return nt() && "ComputePressureObserver"in window
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.observe = function() {
- var e, t;
- (null === (e = this._observer) || void 0 === e ? void 0 : e.observe) && (null === (t = this._observer) || void 0 === t || t.observe())
- }
- ,
- e.prototype.unobserve = function() {
- var e, t;
- (null === (e = this._observer) || void 0 === e ? void 0 : e.unobserve) && (null === (t = this._observer) || void 0 === t || t.unobserve())
- }
- ,
- e
- }(), mn = function(e) {
- function t(i, n) {
- var r = e.call(this) || this;
- r._inputManager = new cn(r),
- r.cameraToUseForPointers = null,
- r._isScene = !0,
- r._blockEntityCollection = !1,
- r.autoClear = !0,
- r.autoClearDepthAndStencil = !0,
- r.clearColor = new N(.2,.2,.3,1),
- r.ambientColor = new D(0,0,0),
- r.environmentIntensity = 1,
- r._forceWireframe = !1,
- r._skipFrustumClipping = !1,
- r._forcePointsCloud = !1,
- r.animationsEnabled = !0,
- r._animationPropertiesOverride = null,
- r.useConstantAnimationDeltaTime = !1,
- r.constantlyUpdateMeshUnderPointer = !1,
- r.hoverCursor = "pointer",
- r.defaultCursor = "",
- r.doNotHandleCursors = !1,
- r.preventDefaultOnPointerDown = !0,
- r.preventDefaultOnPointerUp = !0,
- r.metadata = null,
- r.reservedDataStore = null,
- r.disableOfflineSupportExceptionRules = new Array,
- r.onDisposeObservable = new h,
- r._onDisposeObserver = null,
- r.onBeforeRenderObservable = new h,
- r._onBeforeRenderObserver = null,
- r.onAfterRenderObservable = new h,
- r.onBeforeRunRegisterBeforeRenderObservable = new h,
- r.onAfterRunRegisterBeforeRenderObservable = new h,
- r.onBeforeRunRegisterAfterRenderObservable = new h,
- r.onAfterRunRegisterAfterRenderObservable = new h,
- r.onBeforeRTT1Observable = new h,
- r.onAfterRTT1Observable = new h,
- r.onAfterRenderCameraObservable = new h,
- r._onAfterRenderObserver = null,
- r.onBeforeAnimationsObservable = new h,
- r.onAfterAnimationsObservable = new h,
- r.onBeforeDrawPhaseObservable = new h,
- r.onAfterDrawPhaseObservable = new h,
- r.onReadyObservable = new h,
- r.onBeforeCameraRenderObservable = new h,
- r._onBeforeCameraRenderObserver = null,
- r.onAfterCameraRenderObservable = new h,
- r._onAfterCameraRenderObserver = null,
- r.onBeforeActiveMeshesEvaluationObservable = new h,
- r.onAfterActiveMeshesEvaluationObservable = new h,
- r.onBeforeParticlesRenderingObservable = new h,
- r.onAfterParticlesRenderingObservable = new h,
- r.onDataLoadedObservable = new h,
- r.onNewCameraAddedObservable = new h,
- r.onCameraRemovedObservable = new h,
- r.onNewLightAddedObservable = new h,
- r.onLightRemovedObservable = new h,
- r.onNewGeometryAddedObservable = new h,
- r.onGeometryRemovedObservable = new h,
- r.onNewTransformNodeAddedObservable = new h,
- r.onTransformNodeRemovedObservable = new h,
- r.onNewMeshAddedObservable = new h,
- r.onMeshRemovedObservable = new h,
- r.onNewSkeletonAddedObservable = new h,
- r.onSkeletonRemovedObservable = new h,
- r.onNewMaterialAddedObservable = new h,
- r.onNewMultiMaterialAddedObservable = new h,
- r.onMaterialRemovedObservable = new h,
- r.onMultiMaterialRemovedObservable = new h,
- r.onNewTextureAddedObservable = new h,
- r.onTextureRemovedObservable = new h,
- r.onBeforeRenderTargetsRenderObservable = new h,
- r.onAfterRenderTargetsRenderObservable = new h,
- r.onBeforeStepObservable = new h,
- r.onAfterStepObservable = new h,
- r.onActiveCameraChanged = new h,
- r.onBeforeRenderingGroupObservable = new h,
- r.onAfterRenderingGroupObservable = new h,
- r.onMeshImportedObservable = new h,
- r.onAnimationFileImportedObservable = new h,
- r._registeredForLateAnimationBindings = new Ti(256),
- r.skipPointerMovePicking = !1,
- r.onPrePointerObservable = new h,
- r.onPointerObservable = new h,
- r.onPreKeyboardObservable = new h,
- r.onKeyboardObservable = new h,
- r._useRightHandedSystem = !1,
- r._timeAccumulator = 0,
- r._currentStepId = 0,
- r._currentInternalStep = 0,
- r._fogEnabled = !0,
- r._fogMode = t.FOGMODE_NONE,
- r.fogColor = new D(.2,.2,.3),
- r.fogDensity = .1,
- r.fogStart = 0,
- r.fogEnd = 1e3,
- r.needsPreviousWorldMatrices = !1,
- r._shadowsEnabled = !0,
- r._lightsEnabled = !0,
- r.activeCameras = new Array,
- r._texturesEnabled = !0,
- r.physicsEnabled = !0,
- r.particlesEnabled = !0,
- r.spritesEnabled = !0,
- r._skeletonsEnabled = !0,
- r.lensFlaresEnabled = !0,
- r.collisionsEnabled = !0,
- r.gravity = new x(0,-9.807,0),
- r.postProcessesEnabled = !0,
- r.renderTargetsEnabled = !0,
- r.dumpNextRenderTargets = !1,
- r.customRenderTargets = new Array,
- r.importedMeshesFiles = new Array,
- r.probesEnabled = !0,
- r._meshesForIntersections = new Ti(256),
- r.proceduralTexturesEnabled = !0,
- r._totalVertices = new un,
- r._activeIndices = new un,
- r._activeParticles = new un,
- r._activeBones = new un,
- r._animationTime = 0,
- r.animationTimeScale = 1,
- r._renderId = 0,
- r._frameId = 0,
- r._executeWhenReadyTimeoutId = null,
- r._intermediateRendering = !1,
- r._defaultFrameBufferCleared = !1,
- r._viewUpdateFlag = -1,
- r._projectionUpdateFlag = -1,
- r._toBeDisposed = new Array(256),
- r._activeRequests = new Array,
- r._pendingData = new Array,
- r._isDisposed = !1,
- r.dispatchAllSubMeshesOfActiveMeshes = !1,
- r._activeMeshes = new bi(256),
- r._processedMaterials = new bi(256),
- r._renderTargets = new Ti(256),
- r._materialsRenderTargets = new Ti(256),
- r._activeParticleSystems = new bi(256),
- r._activeSkeletons = new Ti(32),
- r._softwareSkinnedMeshes = new Ti(32),
- r._activeAnimatables = new Array,
- r._transformMatrix = P.Zero(),
- r.requireLightSorting = !1,
- r._components = [],
- r._serializableComponents = [],
- r._transientComponents = [],
- r._beforeCameraUpdateStage = Hi.Create(),
- r._beforeClearStage = Hi.Create(),
- r._beforeRenderTargetClearStage = Hi.Create(),
- r._gatherRenderTargetsStage = Hi.Create(),
- r._gatherActiveCameraRenderTargetsStage = Hi.Create(),
- r._isReadyForMeshStage = Hi.Create(),
- r._beforeEvaluateActiveMeshStage = Hi.Create(),
- r._evaluateSubMeshStage = Hi.Create(),
- r._preActiveMeshStage = Hi.Create(),
- r._cameraDrawRenderTargetStage = Hi.Create(),
- r._beforeCameraDrawStage = Hi.Create(),
- r._beforeRenderTargetDrawStage = Hi.Create(),
- r._beforeRenderingGroupDrawStage = Hi.Create(),
- r._beforeRenderingMeshStage = Hi.Create(),
- r._afterRenderingMeshStage = Hi.Create(),
- r._afterRenderingGroupDrawStage = Hi.Create(),
- r._afterCameraDrawStage = Hi.Create(),
- r._afterRenderTargetDrawStage = Hi.Create(),
- r._afterRenderStage = Hi.Create(),
- r._pointerMoveStage = Hi.Create(),
- r._pointerDownStage = Hi.Create(),
- r._pointerUpStage = Hi.Create(),
- r._geometriesByUniqueId = null,
- r._defaultMeshCandidates = {
- data: [],
- length: 0
- },
- r._defaultSubMeshCandidates = {
- data: [],
- length: 0
- },
- r._preventFreeActiveMeshesAndRenderingGroups = !1,
- r._activeMeshesFrozen = !1,
- r._skipEvaluateActiveMeshesCompletely = !1,
- r._allowPostProcessClearColor = !0,
- r.getDeterministicFrameTime = function() {
- return r._engine.getTimeStep()
- }
- ,
- r._blockMaterialDirtyMechanism = !1,
- r._perfCollector = null,
- r.onComputePressureChanged = new h;
- var o = V({
- useGeometryUniqueIdsMap: !0,
- useMaterialMeshMap: !0,
- useClonedMeshMap: !0,
- virtual: !1
- }, n);
- return r._engine = i || E.LastCreatedEngine,
- o.virtual ? r._engine._virtualScenes.push(r) : (E._LastCreatedScene = r,
- r._engine.scenes.push(r)),
- r._uid = null,
- r._renderingManager = new zi(r),
- Vi && (r.postProcessManager = new Vi(r)),
- nt() && r.attachControl(),
- r._createUbo(),
- Ri && (r._imageProcessingConfiguration = new Ri),
- r.setDefaultCandidateProviders(),
- o.useGeometryUniqueIdsMap && (r._geometriesByUniqueId = {}),
- r.useMaterialMeshMap = o.useMaterialMeshMap,
- r.useClonedMeshMap = o.useClonedMeshMap,
- n && n.virtual || r._engine.onNewSceneAddedObservable.notifyObservers(r),
- _n.IsAvailable && (r._computePressureObserver = new _n((function(e) {
- r.onComputePressureChanged.notifyObservers(e)
- }
- ),{
- cpuUtilizationThresholds: [.25, .5, .75, .9],
- cpuSpeedThresholds: [.5]
- }),
- r._computePressureObserver.observe()),
- r
- }
- return U(t, e),
- t.DefaultMaterialFactory = function(e) {
- throw be("StandardMaterial")
- }
- ,
- t.CollisionCoordinatorFactory = function() {
- throw be("DefaultCollisionCoordinator")
- }
- ,
- Object.defineProperty(t.prototype, "environmentTexture", {
- get: function() {
- return this._environmentTexture
- },
- set: function(e) {
- this._environmentTexture !== e && (this._environmentTexture = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "forceWireframe", {
- get: function() {
- return this._forceWireframe
- },
- set: function(e) {
- this._forceWireframe !== e && (this._forceWireframe = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "skipFrustumClipping", {
- get: function() {
- return this._skipFrustumClipping
- },
- set: function(e) {
- this._skipFrustumClipping !== e && (this._skipFrustumClipping = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "forcePointsCloud", {
- get: function() {
- return this._forcePointsCloud
- },
- set: function(e) {
- this._forcePointsCloud !== e && (this._forcePointsCloud = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._animationPropertiesOverride
- },
- set: function(e) {
- this._animationPropertiesOverride = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "beforeRender", {
- set: function(e) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- e && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "afterRender", {
- set: function(e) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- e && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "beforeCameraRender", {
- set: function(e) {
- this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
- this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "afterCameraRender", {
- set: function(e) {
- this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
- this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "unTranslatedPointer", {
- get: function() {
- return this._inputManager.unTranslatedPointer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "DragMovementThreshold", {
- get: function() {
- return cn.DragMovementThreshold
- },
- set: function(e) {
- cn.DragMovementThreshold = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "LongPressDelay", {
- get: function() {
- return cn.LongPressDelay
- },
- set: function(e) {
- cn.LongPressDelay = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "DoubleClickDelay", {
- get: function() {
- return cn.DoubleClickDelay
- },
- set: function(e) {
- cn.DoubleClickDelay = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "ExclusiveDoubleClickMode", {
- get: function() {
- return cn.ExclusiveDoubleClickMode
- },
- set: function(e) {
- cn.ExclusiveDoubleClickMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.bindEyePosition = function(e, t, i) {
- var n;
- void 0 === t && (t = "vEyePosition"),
- void 0 === i && (i = !1);
- var r = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : null !== (n = this.activeCamera.globalPosition) && void 0 !== n ? n : this.activeCamera.devicePosition
- , o = this.useRightHandedSystem === (null != this._mirroredCameraPosition);
- return I.Vector4[0].set(r.x, r.y, r.z, o ? -1 : 1),
- e && (i ? e.setFloat3(t, I.Vector4[0].x, I.Vector4[0].y, I.Vector4[0].z) : e.setVector4(t, I.Vector4[0])),
- I.Vector4[0]
- }
- ,
- t.prototype.finalizeSceneUbo = function() {
- var e = this.getSceneUniformBuffer()
- , t = this.bindEyePosition(null);
- return e.updateFloat4("vEyePosition", t.x, t.y, t.z, t.w),
- e.update(),
- e
- }
- ,
- Object.defineProperty(t.prototype, "useRightHandedSystem", {
- get: function() {
- return this._useRightHandedSystem
- },
- set: function(e) {
- this._useRightHandedSystem !== e && (this._useRightHandedSystem = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setStepId = function(e) {
- this._currentStepId = e
- }
- ,
- t.prototype.getStepId = function() {
- return this._currentStepId
- }
- ,
- t.prototype.getInternalStep = function() {
- return this._currentInternalStep
- }
- ,
- Object.defineProperty(t.prototype, "fogEnabled", {
- get: function() {
- return this._fogEnabled
- },
- set: function(e) {
- this._fogEnabled !== e && (this._fogEnabled = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fogMode", {
- get: function() {
- return this._fogMode
- },
- set: function(e) {
- this._fogMode !== e && (this._fogMode = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "prePass", {
- get: function() {
- return !!this.prePassRenderer && this.prePassRenderer.defaultRT.enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadowsEnabled", {
- get: function() {
- return this._shadowsEnabled
- },
- set: function(e) {
- this._shadowsEnabled !== e && (this._shadowsEnabled = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_LightDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lightsEnabled", {
- get: function() {
- return this._lightsEnabled
- },
- set: function(e) {
- this._lightsEnabled !== e && (this._lightsEnabled = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_LightDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "activeCamera", {
- get: function() {
- return this._activeCamera
- },
- set: function(e) {
- e !== this._activeCamera && (this._activeCamera = e,
- this.onActiveCameraChanged.notifyObservers(this))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "defaultMaterial", {
- get: function() {
- return this._defaultMaterial || (this._defaultMaterial = t.DefaultMaterialFactory(this)),
- this._defaultMaterial
- },
- set: function(e) {
- this._defaultMaterial = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "texturesEnabled", {
- get: function() {
- return this._texturesEnabled
- },
- set: function(e) {
- this._texturesEnabled !== e && (this._texturesEnabled = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "skeletonsEnabled", {
- get: function() {
- return this._skeletonsEnabled
- },
- set: function(e) {
- this._skeletonsEnabled !== e && (this._skeletonsEnabled = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_AttributesDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "collisionCoordinator", {
- get: function() {
- return this._collisionCoordinator || (this._collisionCoordinator = t.CollisionCoordinatorFactory(),
- this._collisionCoordinator.init(this)),
- this._collisionCoordinator
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "frustumPlanes", {
- get: function() {
- return this._frustumPlanes
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._registerTransientComponents = function() {
- if (this._transientComponents.length > 0) {
- for (var e = 0, t = this._transientComponents; e < t.length; e++)
- t[e].register();
- this._transientComponents = []
- }
- }
- ,
- t.prototype._addComponent = function(e) {
- this._components.push(e),
- this._transientComponents.push(e);
- var t = e;
- t.addFromContainer && t.serialize && this._serializableComponents.push(t)
- }
- ,
- t.prototype._getComponent = function(e) {
- for (var t = 0, i = this._components; t < i.length; t++) {
- var n = i[t];
- if (n.name === e)
- return n
- }
- return null
- }
- ,
- t.prototype.getClassName = function() {
- return "Scene"
- }
- ,
- t.prototype._getDefaultMeshCandidates = function() {
- return this._defaultMeshCandidates.data = this.meshes,
- this._defaultMeshCandidates.length = this.meshes.length,
- this._defaultMeshCandidates
- }
- ,
- t.prototype._getDefaultSubMeshCandidates = function(e) {
- return this._defaultSubMeshCandidates.data = e.subMeshes,
- this._defaultSubMeshCandidates.length = e.subMeshes.length,
- this._defaultSubMeshCandidates
- }
- ,
- t.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(t.prototype, "meshUnderPointer", {
- get: function() {
- return this._inputManager.meshUnderPointer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "pointerX", {
- get: function() {
- return this._inputManager.pointerX
- },
- set: function(e) {
- this._inputManager.pointerX = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "pointerY", {
- get: function() {
- return this._inputManager.pointerY
- },
- set: function(e) {
- this._inputManager.pointerY = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getCachedMaterial = function() {
- return this._cachedMaterial
- }
- ,
- t.prototype.getCachedEffect = function() {
- return this._cachedEffect
- }
- ,
- t.prototype.getCachedVisibility = function() {
- return this._cachedVisibility
- }
- ,
- t.prototype.isCachedMaterialInvalid = function(e, t, i) {
- return void 0 === i && (i = 1),
- this._cachedEffect !== t || this._cachedMaterial !== e || this._cachedVisibility !== i
- }
- ,
- t.prototype.getEngine = function() {
- return this._engine
- }
- ,
- t.prototype.getTotalVertices = function() {
- return this._totalVertices.current
- }
- ,
- Object.defineProperty(t.prototype, "totalVerticesPerfCounter", {
- get: function() {
- return this._totalVertices
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getActiveIndices = function() {
- return this._activeIndices.current
- }
- ,
- Object.defineProperty(t.prototype, "totalActiveIndicesPerfCounter", {
- get: function() {
- return this._activeIndices
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getActiveParticles = function() {
- return this._activeParticles.current
- }
- ,
- Object.defineProperty(t.prototype, "activeParticlesPerfCounter", {
- get: function() {
- return this._activeParticles
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getActiveBones = function() {
- return this._activeBones.current
- }
- ,
- Object.defineProperty(t.prototype, "activeBonesPerfCounter", {
- get: function() {
- return this._activeBones
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getActiveMeshes = function() {
- return this._activeMeshes
- }
- ,
- t.prototype.getAnimationRatio = function() {
- return void 0 !== this._animationRatio ? this._animationRatio : 1
- }
- ,
- t.prototype.getRenderId = function() {
- return this._renderId
- }
- ,
- t.prototype.getFrameId = function() {
- return this._frameId
- }
- ,
- t.prototype.incrementRenderId = function() {
- this._renderId++
- }
- ,
- t.prototype._createUbo = function() {
- this.setSceneUniformBuffer(this.createSceneUniformBuffer())
- }
- ,
- t.prototype.simulatePointerMove = function(e, t) {
- return this._inputManager.simulatePointerMove(e, t),
- this
- }
- ,
- t.prototype.simulatePointerDown = function(e, t) {
- return this._inputManager.simulatePointerDown(e, t),
- this
- }
- ,
- t.prototype.simulatePointerUp = function(e, t, i) {
- return this._inputManager.simulatePointerUp(e, t, i),
- this
- }
- ,
- t.prototype.isPointerCaptured = function(e) {
- return void 0 === e && (e = 0),
- this._inputManager.isPointerCaptured(e)
- }
- ,
- t.prototype.attachControl = function(e, t, i) {
- void 0 === e && (e = !0),
- void 0 === t && (t = !0),
- void 0 === i && (i = !0),
- this._inputManager.attachControl(e, t, i)
- }
- ,
- t.prototype.detachControl = function() {
- this._inputManager.detachControl()
- }
- ,
- t.prototype.isReady = function(e) {
- if (void 0 === e && (e = !0),
- this._isDisposed)
- return !1;
- var t, i = this.getEngine();
- if (this._pendingData.length > 0)
- return !1;
- e && (this._processedMaterials.reset(),
- this._materialsRenderTargets.reset());
- var n = !0;
- for (t = 0; t < this.meshes.length; t++) {
- var r = this.meshes[t];
- if (r.isEnabled() && r.subMeshes && 0 !== r.subMeshes.length)
- if (r.isReady(!0)) {
- for (var o = r.hasThinInstances || "InstancedMesh" === r.getClassName() || "InstancedLinesMesh" === r.getClassName() || i.getCaps().instancedArrays && r.instances.length > 0, s = 0, l = this._isReadyForMeshStage; s < l.length; s++)
- l[s].action(r, o) || (n = !1);
- if (e) {
- var c = r.material || this.defaultMaterial;
- if (c)
- if (c._storeEffectOnSubMeshes)
- for (var u = 0, h = r.subMeshes; u < h.length; u++) {
- var d = h[u].getMaterial();
- d && d.hasRenderTargetTextures && null != d.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(d) && (this._processedMaterials.push(d),
- this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))
- }
- else
- c.hasRenderTargetTextures && null != c.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(c) && (this._processedMaterials.push(c),
- this._materialsRenderTargets.concatWithNoDuplicate(c.getRenderTargetTextures()))
- }
- } else
- n = !1
- }
- if (!n)
- return !1;
- if (!i.areAllEffectsReady())
- return !1;
- if (e)
- for (t = 0; t < this._materialsRenderTargets.length; ++t)
- if (!this._materialsRenderTargets.data[t].isReadyForRendering())
- return !1;
- for (t = 0; t < this.geometries.length; t++)
- if (this.geometries[t].delayLoadState === a.DELAYLOADSTATE_LOADING)
- return !1;
- if (this.activeCameras && this.activeCameras.length > 0) {
- for (var p = 0, f = this.activeCameras; p < f.length; p++)
- if (!f[p].isReady(!0))
- return !1
- } else if (this.activeCamera && !this.activeCamera.isReady(!0))
- return !1;
- for (var _ = 0, m = this.particleSystems; _ < m.length; _++)
- if (!m[_].isReady())
- return !1;
- return !0
- }
- ,
- t.prototype.resetCachedMaterial = function() {
- this._cachedMaterial = null,
- this._cachedEffect = null,
- this._cachedVisibility = null
- }
- ,
- t.prototype.registerBeforeRender = function(e) {
- this.onBeforeRenderObservable.add(e)
- }
- ,
- t.prototype.unregisterBeforeRender = function(e) {
- this.onBeforeRenderObservable.removeCallback(e)
- }
- ,
- t.prototype.registerAfterRender = function(e) {
- this.onAfterRenderObservable.add(e)
- }
- ,
- t.prototype.unregisterAfterRender = function(e) {
- this.onAfterRenderObservable.removeCallback(e)
- }
- ,
- t.prototype._executeOnceBeforeRender = function(e) {
- var t = this
- , i = function() {
- e(),
- setTimeout((function() {
- t.unregisterBeforeRender(i)
- }
- ))
- };
- this.registerBeforeRender(i)
- }
- ,
- t.prototype.executeOnceBeforeRender = function(e, t) {
- var i = this;
- void 0 !== t ? setTimeout((function() {
- i._executeOnceBeforeRender(e)
- }
- ), t) : this._executeOnceBeforeRender(e)
- }
- ,
- t.prototype._addPendingData = function(e) {
- this._pendingData.push(e)
- }
- ,
- t.prototype._removePendingData = function(e) {
- var t = this.isLoading
- , i = this._pendingData.indexOf(e);
- -1 !== i && this._pendingData.splice(i, 1),
- t && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this)
- }
- ,
- t.prototype.getWaitingItemsCount = function() {
- return this._pendingData.length
- }
- ,
- Object.defineProperty(t.prototype, "isLoading", {
- get: function() {
- return this._pendingData.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.executeWhenReady = function(e, t) {
- var i = this;
- void 0 === t && (t = !1),
- this.onReadyObservable.add(e),
- null === this._executeWhenReadyTimeoutId && (this._executeWhenReadyTimeoutId = setTimeout((function() {
- i._checkIsReady(t)
- }
- ), 150))
- }
- ,
- t.prototype.whenReadyAsync = function(e) {
- var t = this;
- return void 0 === e && (e = !1),
- new Promise((function(i) {
- t.executeWhenReady((function() {
- i()
- }
- ), e)
- }
- ))
- }
- ,
- t.prototype._checkIsReady = function(e) {
- var t = this;
- return void 0 === e && (e = !1),
- this._registerTransientComponents(),
- this.isReady(e) ? (this.onReadyObservable.notifyObservers(this),
- this.onReadyObservable.clear(),
- void (this._executeWhenReadyTimeoutId = null)) : this._isDisposed ? (this.onReadyObservable.clear(),
- void (this._executeWhenReadyTimeoutId = null)) : void (this._executeWhenReadyTimeoutId = setTimeout((function() {
- t._checkIsReady(e)
- }
- ), 100))
- }
- ,
- Object.defineProperty(t.prototype, "animatables", {
- get: function() {
- return this._activeAnimatables
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.resetLastAnimationTimeFrame = function() {
- this._animationTimeLast = ct.Now
- }
- ,
- t.prototype.getViewMatrix = function() {
- return this._viewMatrix
- }
- ,
- t.prototype.getProjectionMatrix = function() {
- return this._projectionMatrix
- }
- ,
- t.prototype.getTransformMatrix = function() {
- return this._transformMatrix
- }
- ,
- t.prototype.setTransformMatrix = function(e, t, i, n) {
- i || n || !this._multiviewSceneUbo || (this._multiviewSceneUbo.dispose(),
- this._multiviewSceneUbo = null),
- this._viewUpdateFlag === e.updateFlag && this._projectionUpdateFlag === t.updateFlag || (this._viewUpdateFlag = e.updateFlag,
- this._projectionUpdateFlag = t.updateFlag,
- this._viewMatrix = e,
- this._projectionMatrix = t,
- this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
- this._frustumPlanes ? dn.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = dn.GetPlanes(this._transformMatrix),
- this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(i, n) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix),
- this._sceneUbo.updateMatrix("view", this._viewMatrix),
- this._sceneUbo.updateMatrix("projection", this._projectionMatrix)))
- }
- ,
- t.prototype.getSceneUniformBuffer = function() {
- return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo
- }
- ,
- t.prototype.createSceneUniformBuffer = function(e) {
- var t = new Fi(this._engine,void 0,!1,null != e ? e : "scene");
- return t.addUniform("viewProjection", 16),
- t.addUniform("view", 16),
- t.addUniform("projection", 16),
- t.addUniform("vEyePosition", 4),
- t
- }
- ,
- t.prototype.setSceneUniformBuffer = function(e) {
- this._sceneUbo = e,
- this._viewUpdateFlag = -1,
- this._projectionUpdateFlag = -1
- }
- ,
- t.prototype.getUniqueId = function() {
- return pn.UniqueId
- }
- ,
- t.prototype.addMesh = function(e, t) {
- var i = this;
- void 0 === t && (t = !1),
- this._blockEntityCollection || (this.meshes.push(e),
- e._resyncLightSources(),
- e.parent || e._addToSceneRootNodes(),
- this.onNewMeshAddedObservable.notifyObservers(e),
- t && e.getChildMeshes().forEach((function(e) {
- i.addMesh(e)
- }
- )))
- }
- ,
- t.prototype.removeMesh = function(e, t) {
- var i = this;
- void 0 === t && (t = !1);
- var n = this.meshes.indexOf(e);
- return -1 !== n && (this.meshes[n] = this.meshes[this.meshes.length - 1],
- this.meshes.pop(),
- e.parent || e._removeFromSceneRootNodes()),
- this._inputManager._invalidateMesh(e),
- this.onMeshRemovedObservable.notifyObservers(e),
- t && e.getChildMeshes().forEach((function(e) {
- i.removeMesh(e)
- }
- )),
- n
- }
- ,
- t.prototype.addTransformNode = function(e) {
- this._blockEntityCollection || (e._indexInSceneTransformNodesArray = this.transformNodes.length,
- this.transformNodes.push(e),
- e.parent || e._addToSceneRootNodes(),
- this.onNewTransformNodeAddedObservable.notifyObservers(e))
- }
- ,
- t.prototype.removeTransformNode = function(e) {
- var t = e._indexInSceneTransformNodesArray;
- if (-1 !== t) {
- if (t !== this.transformNodes.length - 1) {
- var i = this.transformNodes[this.transformNodes.length - 1];
- this.transformNodes[t] = i,
- i._indexInSceneTransformNodesArray = t
- }
- e._indexInSceneTransformNodesArray = -1,
- this.transformNodes.pop(),
- e.parent || e._removeFromSceneRootNodes()
- }
- return this.onTransformNodeRemovedObservable.notifyObservers(e),
- t
- }
- ,
- t.prototype.removeSkeleton = function(e) {
- var t = this.skeletons.indexOf(e);
- return -1 !== t && (this.skeletons.splice(t, 1),
- this.onSkeletonRemovedObservable.notifyObservers(e),
- this._executeActiveContainerCleanup(this._activeSkeletons)),
- t
- }
- ,
- t.prototype.removeMorphTargetManager = function(e) {
- var t = this.morphTargetManagers.indexOf(e);
- return -1 !== t && this.morphTargetManagers.splice(t, 1),
- t
- }
- ,
- t.prototype.removeLight = function(e) {
- var t = this.lights.indexOf(e);
- if (-1 !== t) {
- for (var i = 0, n = this.meshes; i < n.length; i++)
- n[i]._removeLightSource(e, !1);
- this.lights.splice(t, 1),
- this.sortLightsByPriority(),
- e.parent || e._removeFromSceneRootNodes()
- }
- return this.onLightRemovedObservable.notifyObservers(e),
- t
- }
- ,
- t.prototype.removeCamera = function(e) {
- var t = this.cameras.indexOf(e);
- if (-1 !== t && (this.cameras.splice(t, 1),
- e.parent || e._removeFromSceneRootNodes()),
- this.activeCameras) {
- var i = this.activeCameras.indexOf(e);
- -1 !== i && this.activeCameras.splice(i, 1)
- }
- return this.activeCamera === e && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null),
- this.onCameraRemovedObservable.notifyObservers(e),
- t
- }
- ,
- t.prototype.removeParticleSystem = function(e) {
- var t = this.particleSystems.indexOf(e);
- return -1 !== t && (this.particleSystems.splice(t, 1),
- this._executeActiveContainerCleanup(this._activeParticleSystems)),
- t
- }
- ,
- t.prototype.removeAnimation = function(e) {
- var t = this.animations.indexOf(e);
- return -1 !== t && this.animations.splice(t, 1),
- t
- }
- ,
- t.prototype.stopAnimation = function(e, t, i) {}
- ,
- t.prototype.removeAnimationGroup = function(e) {
- var t = this.animationGroups.indexOf(e);
- return -1 !== t && this.animationGroups.splice(t, 1),
- t
- }
- ,
- t.prototype.removeMultiMaterial = function(e) {
- var t = this.multiMaterials.indexOf(e);
- return -1 !== t && this.multiMaterials.splice(t, 1),
- this.onMultiMaterialRemovedObservable.notifyObservers(e),
- t
- }
- ,
- t.prototype.removeMaterial = function(e) {
- var t = e._indexInSceneMaterialArray;
- if (-1 !== t && t < this.materials.length) {
- if (t !== this.materials.length - 1) {
- var i = this.materials[this.materials.length - 1];
- this.materials[t] = i,
- i._indexInSceneMaterialArray = t
- }
- e._indexInSceneMaterialArray = -1,
- this.materials.pop()
- }
- return this.onMaterialRemovedObservable.notifyObservers(e),
- t
- }
- ,
- t.prototype.removeActionManager = function(e) {
- var t = this.actionManagers.indexOf(e);
- return -1 !== t && this.actionManagers.splice(t, 1),
- t
- }
- ,
- t.prototype.removeTexture = function(e) {
- var t = this.textures.indexOf(e);
- return -1 !== t && this.textures.splice(t, 1),
- this.onTextureRemovedObservable.notifyObservers(e),
- t
- }
- ,
- t.prototype.addLight = function(e) {
- if (!this._blockEntityCollection) {
- this.lights.push(e),
- this.sortLightsByPriority(),
- e.parent || e._addToSceneRootNodes();
- for (var t = 0, i = this.meshes; t < i.length; t++) {
- var n = i[t];
- -1 === n.lightSources.indexOf(e) && (n.lightSources.push(e),
- n._resyncLightSources())
- }
- this.onNewLightAddedObservable.notifyObservers(e)
- }
- }
- ,
- t.prototype.sortLightsByPriority = function() {
- this.requireLightSorting && this.lights.sort(fn.CompareLightsPriority)
- }
- ,
- t.prototype.addCamera = function(e) {
- this._blockEntityCollection || (this.cameras.push(e),
- this.onNewCameraAddedObservable.notifyObservers(e),
- e.parent || e._addToSceneRootNodes())
- }
- ,
- t.prototype.addSkeleton = function(e) {
- this._blockEntityCollection || (this.skeletons.push(e),
- this.onNewSkeletonAddedObservable.notifyObservers(e))
- }
- ,
- t.prototype.addParticleSystem = function(e) {
- this._blockEntityCollection || this.particleSystems.push(e)
- }
- ,
- t.prototype.addAnimation = function(e) {
- this._blockEntityCollection || this.animations.push(e)
- }
- ,
- t.prototype.addAnimationGroup = function(e) {
- this._blockEntityCollection || this.animationGroups.push(e)
- }
- ,
- t.prototype.addMultiMaterial = function(e) {
- this._blockEntityCollection || (this.multiMaterials.push(e),
- this.onNewMultiMaterialAddedObservable.notifyObservers(e))
- }
- ,
- t.prototype.addMaterial = function(e) {
- this._blockEntityCollection || (e._indexInSceneMaterialArray = this.materials.length,
- this.materials.push(e),
- this.onNewMaterialAddedObservable.notifyObservers(e))
- }
- ,
- t.prototype.addMorphTargetManager = function(e) {
- this._blockEntityCollection || this.morphTargetManagers.push(e)
- }
- ,
- t.prototype.addGeometry = function(e) {
- this._blockEntityCollection || (this._geometriesByUniqueId && (this._geometriesByUniqueId[e.uniqueId] = this.geometries.length),
- this.geometries.push(e))
- }
- ,
- t.prototype.addActionManager = function(e) {
- this.actionManagers.push(e)
- }
- ,
- t.prototype.addTexture = function(e) {
- this._blockEntityCollection || (this.textures.push(e),
- this.onNewTextureAddedObservable.notifyObservers(e))
- }
- ,
- t.prototype.switchActiveCamera = function(e, t) {
- void 0 === t && (t = !0),
- this._engine.getInputElement() && (this.activeCamera && this.activeCamera.detachControl(),
- this.activeCamera = e,
- t && e.attachControl())
- }
- ,
- t.prototype.setActiveCameraById = function(e) {
- var t = this.getCameraById(e);
- return t ? (this.activeCamera = t,
- t) : null
- }
- ,
- t.prototype.setActiveCameraByName = function(e) {
- var t = this.getCameraByName(e);
- return t ? (this.activeCamera = t,
- t) : null
- }
- ,
- t.prototype.getAnimationGroupByName = function(e) {
- for (var t = 0; t < this.animationGroups.length; t++)
- if (this.animationGroups[t].name === e)
- return this.animationGroups[t];
- return null
- }
- ,
- t.prototype.getMaterialByUniqueID = function(e) {
- for (var t = 0; t < this.materials.length; t++)
- if (this.materials[t].uniqueId === e)
- return this.materials[t];
- return null
- }
- ,
- t.prototype.getMaterialById = function(e) {
- for (var t = 0; t < this.materials.length; t++)
- if (this.materials[t].id === e)
- return this.materials[t];
- return null
- }
- ,
- t.prototype.getLastMaterialById = function(e, t) {
- void 0 === t && (t = !1);
- for (var i = this.materials.length - 1; i >= 0; i--)
- if (this.materials[i].id === e)
- return this.materials[i];
- if (t)
- for (i = this.multiMaterials.length - 1; i >= 0; i--)
- if (this.multiMaterials[i].id === e)
- return this.multiMaterials[i];
- return null
- }
- ,
- t.prototype.getMaterialByName = function(e) {
- for (var t = 0; t < this.materials.length; t++)
- if (this.materials[t].name === e)
- return this.materials[t];
- return null
- }
- ,
- t.prototype.getTextureByUniqueId = function(e) {
- for (var t = 0; t < this.textures.length; t++)
- if (this.textures[t].uniqueId === e)
- return this.textures[t];
- return null
- }
- ,
- t.prototype.getTextureByName = function(e) {
- for (var t = 0; t < this.textures.length; t++)
- if (this.textures[t].name === e)
- return this.textures[t];
- return null
- }
- ,
- t.prototype.getCameraById = function(e) {
- for (var t = 0; t < this.cameras.length; t++)
- if (this.cameras[t].id === e)
- return this.cameras[t];
- return null
- }
- ,
- t.prototype.getCameraByUniqueId = function(e) {
- for (var t = 0; t < this.cameras.length; t++)
- if (this.cameras[t].uniqueId === e)
- return this.cameras[t];
- return null
- }
- ,
- t.prototype.getCameraByName = function(e) {
- for (var t = 0; t < this.cameras.length; t++)
- if (this.cameras[t].name === e)
- return this.cameras[t];
- return null
- }
- ,
- t.prototype.getBoneById = function(e) {
- for (var t = 0; t < this.skeletons.length; t++)
- for (var i = this.skeletons[t], n = 0; n < i.bones.length; n++)
- if (i.bones[n].id === e)
- return i.bones[n];
- return null
- }
- ,
- t.prototype.getBoneByName = function(e) {
- for (var t = 0; t < this.skeletons.length; t++)
- for (var i = this.skeletons[t], n = 0; n < i.bones.length; n++)
- if (i.bones[n].name === e)
- return i.bones[n];
- return null
- }
- ,
- t.prototype.getLightByName = function(e) {
- for (var t = 0; t < this.lights.length; t++)
- if (this.lights[t].name === e)
- return this.lights[t];
- return null
- }
- ,
- t.prototype.getLightById = function(e) {
- for (var t = 0; t < this.lights.length; t++)
- if (this.lights[t].id === e)
- return this.lights[t];
- return null
- }
- ,
- t.prototype.getLightByUniqueId = function(e) {
- for (var t = 0; t < this.lights.length; t++)
- if (this.lights[t].uniqueId === e)
- return this.lights[t];
- return null
- }
- ,
- t.prototype.getParticleSystemById = function(e) {
- for (var t = 0; t < this.particleSystems.length; t++)
- if (this.particleSystems[t].id === e)
- return this.particleSystems[t];
- return null
- }
- ,
- t.prototype.getGeometryById = function(e) {
- for (var t = 0; t < this.geometries.length; t++)
- if (this.geometries[t].id === e)
- return this.geometries[t];
- return null
- }
- ,
- t.prototype._getGeometryByUniqueId = function(e) {
- if (this._geometriesByUniqueId) {
- if (void 0 !== (t = this._geometriesByUniqueId[e]))
- return this.geometries[t]
- } else
- for (var t = 0; t < this.geometries.length; t++)
- if (this.geometries[t].uniqueId === e)
- return this.geometries[t];
- return null
- }
- ,
- t.prototype.pushGeometry = function(e, t) {
- return !(!t && this._getGeometryByUniqueId(e.uniqueId) || (this.addGeometry(e),
- this.onNewGeometryAddedObservable.notifyObservers(e),
- 0))
- }
- ,
- t.prototype.removeGeometry = function(e) {
- var t;
- if (this._geometriesByUniqueId) {
- if (void 0 === (t = this._geometriesByUniqueId[e.uniqueId]))
- return !1
- } else if ((t = this.geometries.indexOf(e)) < 0)
- return !1;
- if (t !== this.geometries.length - 1) {
- var i = this.geometries[this.geometries.length - 1];
- i && (this.geometries[t] = i,
- this._geometriesByUniqueId && (this._geometriesByUniqueId[i.uniqueId] = t,
- this._geometriesByUniqueId[e.uniqueId] = void 0))
- }
- return this.geometries.pop(),
- this.onGeometryRemovedObservable.notifyObservers(e),
- !0
- }
- ,
- t.prototype.getGeometries = function() {
- return this.geometries
- }
- ,
- t.prototype.getMeshById = function(e) {
- for (var t = 0; t < this.meshes.length; t++)
- if (this.meshes[t].id === e)
- return this.meshes[t];
- return null
- }
- ,
- t.prototype.getMeshesById = function(e) {
- return this.meshes.filter((function(t) {
- return t.id === e
- }
- ))
- }
- ,
- t.prototype.getTransformNodeById = function(e) {
- for (var t = 0; t < this.transformNodes.length; t++)
- if (this.transformNodes[t].id === e)
- return this.transformNodes[t];
- return null
- }
- ,
- t.prototype.getTransformNodeByUniqueId = function(e) {
- for (var t = 0; t < this.transformNodes.length; t++)
- if (this.transformNodes[t].uniqueId === e)
- return this.transformNodes[t];
- return null
- }
- ,
- t.prototype.getTransformNodesById = function(e) {
- return this.transformNodes.filter((function(t) {
- return t.id === e
- }
- ))
- }
- ,
- t.prototype.getMeshByUniqueId = function(e) {
- for (var t = 0; t < this.meshes.length; t++)
- if (this.meshes[t].uniqueId === e)
- return this.meshes[t];
- return null
- }
- ,
- t.prototype.getLastMeshById = function(e) {
- for (var t = this.meshes.length - 1; t >= 0; t--)
- if (this.meshes[t].id === e)
- return this.meshes[t];
- return null
- }
- ,
- t.prototype.getLastEntryById = function(e) {
- var t;
- for (t = this.meshes.length - 1; t >= 0; t--)
- if (this.meshes[t].id === e)
- return this.meshes[t];
- for (t = this.transformNodes.length - 1; t >= 0; t--)
- if (this.transformNodes[t].id === e)
- return this.transformNodes[t];
- for (t = this.cameras.length - 1; t >= 0; t--)
- if (this.cameras[t].id === e)
- return this.cameras[t];
- for (t = this.lights.length - 1; t >= 0; t--)
- if (this.lights[t].id === e)
- return this.lights[t];
- return null
- }
- ,
- t.prototype.getNodeById = function(e) {
- var t = this.getMeshById(e);
- if (t)
- return t;
- var i = this.getTransformNodeById(e);
- if (i)
- return i;
- var n = this.getLightById(e);
- if (n)
- return n;
- var r = this.getCameraById(e);
- return r || (this.getBoneById(e) || null)
- }
- ,
- t.prototype.getNodeByName = function(e) {
- var t = this.getMeshByName(e);
- if (t)
- return t;
- var i = this.getTransformNodeByName(e);
- if (i)
- return i;
- var n = this.getLightByName(e);
- if (n)
- return n;
- var r = this.getCameraByName(e);
- return r || (this.getBoneByName(e) || null)
- }
- ,
- t.prototype.getMeshByName = function(e) {
- for (var t = 0; t < this.meshes.length; t++)
- if (this.meshes[t].name === e)
- return this.meshes[t];
- return null
- }
- ,
- t.prototype.getTransformNodeByName = function(e) {
- for (var t = 0; t < this.transformNodes.length; t++)
- if (this.transformNodes[t].name === e)
- return this.transformNodes[t];
- return null
- }
- ,
- t.prototype.getLastSkeletonById = function(e) {
- for (var t = this.skeletons.length - 1; t >= 0; t--)
- if (this.skeletons[t].id === e)
- return this.skeletons[t];
- return null
- }
- ,
- t.prototype.getSkeletonByUniqueId = function(e) {
- for (var t = 0; t < this.skeletons.length; t++)
- if (this.skeletons[t].uniqueId === e)
- return this.skeletons[t];
- return null
- }
- ,
- t.prototype.getSkeletonById = function(e) {
- for (var t = 0; t < this.skeletons.length; t++)
- if (this.skeletons[t].id === e)
- return this.skeletons[t];
- return null
- }
- ,
- t.prototype.getSkeletonByName = function(e) {
- for (var t = 0; t < this.skeletons.length; t++)
- if (this.skeletons[t].name === e)
- return this.skeletons[t];
- return null
- }
- ,
- t.prototype.getMorphTargetManagerById = function(e) {
- for (var t = 0; t < this.morphTargetManagers.length; t++)
- if (this.morphTargetManagers[t].uniqueId === e)
- return this.morphTargetManagers[t];
- return null
- }
- ,
- t.prototype.getMorphTargetById = function(e) {
- for (var t = 0; t < this.morphTargetManagers.length; ++t)
- for (var i = this.morphTargetManagers[t], n = 0; n < i.numTargets; ++n) {
- var r = i.getTarget(n);
- if (r.id === e)
- return r
- }
- return null
- }
- ,
- t.prototype.getMorphTargetByName = function(e) {
- for (var t = 0; t < this.morphTargetManagers.length; ++t)
- for (var i = this.morphTargetManagers[t], n = 0; n < i.numTargets; ++n) {
- var r = i.getTarget(n);
- if (r.name === e)
- return r
- }
- return null
- }
- ,
- t.prototype.getPostProcessByName = function(e) {
- for (var t = 0; t < this.postProcesses.length; ++t) {
- var i = this.postProcesses[t];
- if (i.name === e)
- return i
- }
- return null
- }
- ,
- t.prototype.isActiveMesh = function(e) {
- return -1 !== this._activeMeshes.indexOf(e)
- }
- ,
- Object.defineProperty(t.prototype, "uid", {
- get: function() {
- return this._uid || (this._uid = gi.RandomId()),
- this._uid
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addExternalData = function(e, t) {
- return this._externalData || (this._externalData = new Ei),
- this._externalData.add(e, t)
- }
- ,
- t.prototype.getExternalData = function(e) {
- return this._externalData ? this._externalData.get(e) : null
- }
- ,
- t.prototype.getOrAddExternalDataWithFactory = function(e, t) {
- return this._externalData || (this._externalData = new Ei),
- this._externalData.getOrAddWithFactory(e, t)
- }
- ,
- t.prototype.removeExternalData = function(e) {
- return this._externalData.remove(e)
- }
- ,
- t.prototype._evaluateSubMesh = function(e, t, i) {
- if (i.hasInstances || i.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || t.alwaysSelectAsActiveMesh || 1 === t.subMeshes.length || e.isInFrustum(this._frustumPlanes)) {
- for (var n = 0, r = this._evaluateSubMeshStage; n < r.length; n++)
- r[n].action(t, e);
- var o = e.getMaterial();
- null != o && (o.hasRenderTargetTextures && null != o.getRenderTargetTextures && -1 === this._processedMaterials.indexOf(o) && (this._processedMaterials.push(o),
- this._materialsRenderTargets.concatWithNoDuplicate(o.getRenderTargetTextures())),
- this._renderingManager.dispatch(e, t, o))
- }
- }
- ,
- t.prototype.freeProcessedMaterials = function() {
- this._processedMaterials.dispose()
- }
- ,
- Object.defineProperty(t.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
- get: function() {
- return this._preventFreeActiveMeshesAndRenderingGroups
- },
- set: function(e) {
- this._preventFreeActiveMeshesAndRenderingGroups !== e && (e && (this.freeActiveMeshes(),
- this.freeRenderingGroups()),
- this._preventFreeActiveMeshesAndRenderingGroups = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.freeActiveMeshes = function() {
- if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(),
- this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(),
- this.activeCameras))
- for (var e = 0; e < this.activeCameras.length; e++) {
- var t = this.activeCameras[e];
- t && t._activeMeshes && t._activeMeshes.dispose()
- }
- }
- ,
- t.prototype.freeRenderingGroups = function() {
- if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(),
- this.textures))
- for (var e = 0; e < this.textures.length; e++) {
- var t = this.textures[e];
- t && t.renderList && t.freeRenderingGroups()
- }
- }
- ,
- t.prototype._isInIntermediateRendering = function() {
- return this._intermediateRendering
- }
- ,
- t.prototype.freezeActiveMeshes = function(e, t, i, n) {
- var r = this;
- return void 0 === e && (e = !1),
- void 0 === n && (n = !0),
- this.executeWhenReady((function() {
- if (r.activeCamera) {
- if (r._frustumPlanes || r.updateTransformMatrix(),
- r._evaluateActiveMeshes(),
- r._activeMeshesFrozen = !0,
- r._skipEvaluateActiveMeshesCompletely = e,
- n)
- for (var o = 0; o < r._activeMeshes.length; o++)
- r._activeMeshes.data[o]._freeze();
- t && t()
- } else
- i && i("No active camera found")
- }
- )),
- this
- }
- ,
- t.prototype.unfreezeActiveMeshes = function() {
- for (var e = 0; e < this.meshes.length; e++) {
- var t = this.meshes[e];
- t._internalAbstractMeshDataInfo && (t._internalAbstractMeshDataInfo._isActive = !1)
- }
- for (e = 0; e < this._activeMeshes.length; e++)
- this._activeMeshes.data[e]._unFreeze();
- return this._activeMeshesFrozen = !1,
- this
- }
- ,
- t.prototype._executeActiveContainerCleanup = function(e) {
- (!this._engine.snapshotRendering || this._engine.snapshotRenderingMode !== a.SNAPSHOTRENDERING_FAST) && this._activeMeshesFrozen && this._activeMeshes.length || this.onBeforeRenderObservable.addOnce((function() {
- return e.dispose()
- }
- ))
- }
- ,
- t.prototype._evaluateActiveMeshes = function() {
- var e;
- if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST)
- this._activeMeshes.length > 0 && (null === (e = this.activeCamera) || void 0 === e || e._activeMeshes.reset(),
- this._activeMeshes.reset(),
- this._renderingManager.reset(),
- this._processedMaterials.reset(),
- this._activeParticleSystems.reset(),
- this._activeSkeletons.reset(),
- this._softwareSkinnedMeshes.reset());
- else if (this._activeMeshesFrozen && this._activeMeshes.length) {
- if (!this._skipEvaluateActiveMeshesCompletely)
- for (var t = this._activeMeshes.length, i = 0; i < t; i++)
- (c = this._activeMeshes.data[i]).computeWorldMatrix();
- if (this._activeParticleSystems) {
- var n = this._activeParticleSystems.length;
- for (i = 0; i < n; i++)
- this._activeParticleSystems.data[i].animate()
- }
- } else 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(),
- this._materialsRenderTargets.reset();
- for (var r = 0, o = this._beforeEvaluateActiveMeshStage; r < o.length; r++)
- o[r].action();
- var s = this.getActiveMeshCandidates()
- , l = s.length;
- for (i = 0; i < l; i++) {
- var c;
- if ((c = s.data[i])._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1,
- !c.isBlocked && (this._totalVertices.addCount(c.getTotalVertices(), !1),
- c.isReady() && c.isEnabled() && 0 !== c.scaling.lengthSquared())) {
- c.computeWorldMatrix(),
- c.actionManager && c.actionManager.hasSpecificTriggers2(a.ACTION_OnIntersectionEnterTrigger, a.ACTION_OnIntersectionExitTrigger) && this._meshesForIntersections.pushNoDuplicate(c);
- var u = this.customLODSelector ? this.customLODSelector(c, this.activeCamera) : c.getLOD(this.activeCamera);
- if (c._internalAbstractMeshDataInfo._currentLOD = u,
- c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0,
- null != u && (u !== c && 0 !== u.billboardMode && u.computeWorldMatrix(),
- c._preActivate(),
- c.isVisible && c.visibility > 0 && 0 != (c.layerMask & this.activeCamera.layerMask) && (this._skipFrustumClipping || c.alwaysSelectAsActiveMesh || c.isInFrustum(this._frustumPlanes)))) {
- this._activeMeshes.push(c),
- this.activeCamera._activeMeshes.push(c),
- u !== c && u._activate(this._renderId, !1);
- for (var h = 0, d = this._preActiveMeshStage; h < d.length; h++)
- d[h].action(c);
- c._activate(this._renderId, !1) && (c.isAnInstance ? c._internalAbstractMeshDataInfo._actAsRegularMesh && (u = c) : u._internalAbstractMeshDataInfo._onlyForInstances = !1,
- u._internalAbstractMeshDataInfo._isActive = !0,
- this._activeMesh(c, u)),
- c._postActivate()
- }
- }
- }
- if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),
- this.particlesEnabled) {
- this.onBeforeParticlesRenderingObservable.notifyObservers(this);
- for (var p = 0; p < this.particleSystems.length; p++) {
- var f = this.particleSystems[p];
- if (f.isStarted() && f.emitter) {
- var _ = f.emitter;
- _.position && !_.isEnabled() || (this._activeParticleSystems.push(f),
- f.animate(),
- this._renderingManager.dispatchParticles(f))
- }
- }
- this.onAfterParticlesRenderingObservable.notifyObservers(this)
- }
- }
- }
- ,
- t.prototype._activeMesh = function(e, t) {
- if (this._skeletonsEnabled && null !== t.skeleton && void 0 !== t.skeleton && (this._activeSkeletons.pushNoDuplicate(t.skeleton) && (t.skeleton.prepare(),
- this._activeBones.addCount(t.skeleton.bones.length, !1)),
- t.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(t)),
- null != t && void 0 !== t.subMeshes && null !== t.subMeshes && t.subMeshes.length > 0)
- for (var i = this.getActiveSubMeshCandidates(t), n = i.length, r = 0; r < n; r++) {
- var o = i.data[r];
- this._evaluateSubMesh(o, t, e)
- }
- }
- ,
- t.prototype.updateTransformMatrix = function(e) {
- if (this.activeCamera)
- if (this.activeCamera._renderingMultiview) {
- var t = this.activeCamera._rigCameras[0]
- , i = this.activeCamera._rigCameras[1];
- this.setTransformMatrix(t.getViewMatrix(), t.getProjectionMatrix(e), i.getViewMatrix(), i.getProjectionMatrix(e))
- } else
- this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(e))
- }
- ,
- t.prototype._bindFrameBuffer = function(e, t) {
- void 0 === t && (t = !0),
- e && e._multiviewTexture ? e._multiviewTexture._bindFrameBuffer() : e && e.outputRenderTarget ? e.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(),
- t && this._clearFrameBuffer(e)
- }
- ,
- t.prototype._clearFrameBuffer = function(e) {
- if (e && e._multiviewTexture)
- ;
- else if (e && e.outputRenderTarget) {
- var t = e.outputRenderTarget;
- t.onClearObservable.hasObservers() ? t.onClearObservable.notifyObservers(this._engine) : t.skipInitialClear || (this._engine.clear(t.clearColor || this.clearColor, !t._cleared, !0, !0),
- t._cleared = !0)
- } else
- this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0,
- this._clear())
- }
- ,
- t.prototype._renderForCamera = function(e, t, i) {
- var n, r, o;
- if (void 0 === i && (i = !0),
- !e || !e._skipRendering) {
- var s = this._engine;
- if (this._activeCamera = e,
- !this.activeCamera)
- throw new Error("Active camera not set");
- if (s.setViewport(this.activeCamera.viewport),
- this.resetCachedMaterial(),
- this._renderId++,
- !this.prePass && i) {
- var l = !0;
- e._renderingMultiview && e.outputRenderTarget && (l = e.outputRenderTarget.skipInitialClear,
- this.autoClear && (e.outputRenderTarget.skipInitialClear = !1)),
- this._bindFrameBuffer(this._activeCamera),
- e._renderingMultiview && e.outputRenderTarget && (e.outputRenderTarget.skipInitialClear = l)
- }
- this.updateTransformMatrix(),
- this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),
- this._evaluateActiveMeshes();
- for (var c = 0; c < this._softwareSkinnedMeshes.length; c++) {
- var u = this._softwareSkinnedMeshes.data[c];
- u.applySkeleton(u.skeleton)
- }
- this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),
- this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets),
- e.customRenderTargets && e.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),
- t && t.customRenderTargets && t.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),
- this.environmentTexture && this.environmentTexture.isRenderTarget && this._renderTargets.pushNoDuplicate(this.environmentTexture);
- for (var h = 0, d = this._gatherActiveCameraRenderTargetsStage; h < d.length; h++)
- d[h].action(this._renderTargets);
- var p = !1;
- if (this.renderTargetsEnabled) {
- if (this._intermediateRendering = !0,
- this._renderTargets.length > 0) {
- gi.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
- for (var f = 0; f < this._renderTargets.length; f++) {
- var _ = this._renderTargets.data[f];
- if (_._shouldRender()) {
- this._renderId++;
- var m = _.activeCamera && _.activeCamera !== this.activeCamera;
- _.render(m, this.dumpNextRenderTargets),
- p = !0
- }
- }
- gi.EndPerformanceCounter("Render targets", this._renderTargets.length > 0),
- this._renderId++
- }
- for (var g = 0, v = this._cameraDrawRenderTargetStage; g < v.length; g++)
- p = v[g].action(this.activeCamera) || p;
- this._intermediateRendering = !1
- }
- this._engine.currentRenderPassId = null !== (o = null !== (r = null === (n = e.outputRenderTarget) || void 0 === n ? void 0 : n.renderPassId) && void 0 !== r ? r : e.renderPassId) && void 0 !== o ? o : a.RENDERPASS_MAIN,
- p && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
- this.onAfterRenderTargetsRenderObservable.notifyObservers(this),
- !this.postProcessManager || e._multiviewTexture || this.prePass || this.postProcessManager._prepareFrame();
- for (var y = 0, b = this._beforeCameraDrawStage; y < b.length; y++)
- b[y].action(this.activeCamera);
- this.onBeforeDrawPhaseObservable.notifyObservers(this),
- s.snapshotRendering && s.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST && this.finalizeSceneUbo(),
- this._renderingManager.render(null, null, !0, !0),
- this.onAfterDrawPhaseObservable.notifyObservers(this);
- for (var T = 0, E = this._afterCameraDrawStage; T < E.length; T++)
- E[T].action(this.activeCamera);
- if (this.postProcessManager && !e._multiviewTexture) {
- var S = e.outputRenderTarget ? e.outputRenderTarget.renderTarget : void 0;
- this.postProcessManager._finalizeFrame(e.isIntermediate, S)
- }
- this._renderTargets.reset(),
- this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)
- }
- }
- ,
- t.prototype._processSubCameras = function(e, t) {
- if (void 0 === t && (t = !0),
- e.cameraRigMode === a.RIG_MODE_NONE || e._renderingMultiview)
- return e._renderingMultiview && !this._multiviewSceneUbo && this._createMultiviewUbo(),
- this._renderForCamera(e, void 0, t),
- void this.onAfterRenderCameraObservable.notifyObservers(e);
- if (e._useMultiviewToSingleView)
- this._renderMultiviewToSingleView(e);
- else {
- this.onBeforeCameraRenderObservable.notifyObservers(e);
- for (var i = 0; i < e._rigCameras.length; i++)
- this._renderForCamera(e._rigCameras[i], e)
- }
- this._activeCamera = e,
- this.updateTransformMatrix(),
- this.onAfterRenderCameraObservable.notifyObservers(e)
- }
- ,
- t.prototype._checkIntersections = function() {
- for (var e = 0; e < this._meshesForIntersections.length; e++) {
- var t = this._meshesForIntersections.data[e];
- if (t.actionManager)
- for (var i = function(e) {
- var i = t.actionManager.actions[e];
- if (i.trigger === a.ACTION_OnIntersectionEnterTrigger || i.trigger === a.ACTION_OnIntersectionExitTrigger) {
- var n = i.getTriggerParameter()
- , r = n.mesh ? n.mesh : n
- , o = r.intersectsMesh(t, n.usePreciseIntersection)
- , s = t._intersectionsInProgress.indexOf(r);
- o && -1 === s ? i.trigger === a.ACTION_OnIntersectionEnterTrigger ? (i._executeCurrent(w.CreateNew(t, void 0, r)),
- t._intersectionsInProgress.push(r)) : i.trigger === a.ACTION_OnIntersectionExitTrigger && t._intersectionsInProgress.push(r) : !o && s > -1 && (i.trigger === a.ACTION_OnIntersectionExitTrigger && i._executeCurrent(w.CreateNew(t, void 0, r)),
- t.actionManager.hasSpecificTrigger(a.ACTION_OnIntersectionExitTrigger, (function(e) {
- var t = e.mesh ? e.mesh : e;
- return r === t
- }
- )) && i.trigger !== a.ACTION_OnIntersectionExitTrigger || t._intersectionsInProgress.splice(s, 1))
- }
- }, n = 0; t.actionManager && n < t.actionManager.actions.length; n++)
- i(n)
- }
- }
- ,
- t.prototype._advancePhysicsEngineStep = function(e) {}
- ,
- t.prototype._animate = function() {}
- ,
- t.prototype.animate = function() {
- if (this._engine.isDeterministicLockStep()) {
- var e = Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)) + this._timeAccumulator
- , i = this._engine.getTimeStep()
- , n = 1e3 / i / 1e3
- , r = 0
- , o = this._engine.getLockstepMaxSteps()
- , a = Math.floor(e / i);
- for (a = Math.min(a, o); e > 0 && r < a; )
- this.onBeforeStepObservable.notifyObservers(this),
- this._animationRatio = i * n,
- this._animate(),
- this.onAfterAnimationsObservable.notifyObservers(this),
- this.physicsEnabled && this._advancePhysicsEngineStep(i),
- this.onAfterStepObservable.notifyObservers(this),
- this._currentStepId++,
- r++,
- e -= i;
- this._timeAccumulator = e < 0 ? 0 : e
- } else
- e = this.useConstantAnimationDeltaTime ? 16 : Math.max(t.MinDeltaTime, Math.min(this._engine.getDeltaTime(), t.MaxDeltaTime)),
- this._animationRatio = .06 * e,
- this._animate(),
- this.onAfterAnimationsObservable.notifyObservers(this),
- this.physicsEnabled && this._advancePhysicsEngineStep(e)
- }
- ,
- t.prototype._clear = function() {
- (this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil)
- }
- ,
- t.prototype._checkCameraRenderTarget = function(e) {
- var t;
- if ((null == e ? void 0 : e.outputRenderTarget) && !(null == e ? void 0 : e.isRigCamera) && (e.outputRenderTarget._cleared = !1),
- null === (t = null == e ? void 0 : e.rigCameras) || void 0 === t ? void 0 : t.length)
- for (var i = 0; i < e.rigCameras.length; ++i) {
- var n = e.rigCameras[i].outputRenderTarget;
- n && (n._cleared = !1)
- }
- }
- ,
- t.prototype.resetDrawCache = function(e) {
- if (this.meshes)
- for (var t = 0, i = this.meshes; t < i.length; t++)
- i[t].resetDrawCache(e)
- }
- ,
- t.prototype.render = function(e, t) {
- var i, n, r;
- if (void 0 === e && (e = !0),
- void 0 === t && (t = !1),
- !this.isDisposed) {
- this.onReadyObservable.hasObservers() && null === this._executeWhenReadyTimeoutId && this._checkIsReady(),
- this._frameId++,
- this._defaultFrameBufferCleared = !1,
- this._checkCameraRenderTarget(this.activeCamera),
- (null === (i = this.activeCameras) || void 0 === i ? void 0 : i.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(a.ACTION_OnEveryFrameTrigger),
- t || this.animate();
- for (var o = 0, s = this._beforeCameraUpdateStage; o < s.length; o++)
- s[o].action();
- if (e)
- if (this.activeCameras && this.activeCameras.length > 0)
- for (var l = 0; l < this.activeCameras.length; l++) {
- var c = this.activeCameras[l];
- if (c.update(),
- c.cameraRigMode !== a.RIG_MODE_NONE)
- for (var u = 0; u < c._rigCameras.length; u++)
- c._rigCameras[u].update()
- }
- else if (this.activeCamera && (this.activeCamera.update(),
- this.activeCamera.cameraRigMode !== a.RIG_MODE_NONE))
- for (u = 0; u < this.activeCamera._rigCameras.length; u++)
- this.activeCamera._rigCameras[u].update();
- this.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
- this.onBeforeRenderObservable.notifyObservers(this),
- this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
- this.onBeforeRenderObservable.notifyObservers(this);
- var h = this.getEngine();
- this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
- var d = (null === (n = this.activeCameras) || void 0 === n ? void 0 : n.length) ? this.activeCameras[0] : this.activeCamera;
- if (this.renderTargetsEnabled) {
- gi.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
- this._intermediateRendering = !0;
- for (var p = 0; p < this.customRenderTargets.length; p++) {
- var f = this.customRenderTargets[p];
- if (f._shouldRender()) {
- if (this._renderId++,
- this.activeCamera = f.activeCamera || this.activeCamera,
- !this.activeCamera)
- throw new Error("Active camera not set");
- h.setViewport(this.activeCamera.viewport),
- this.updateTransformMatrix(),
- f.render(d !== this.activeCamera, this.dumpNextRenderTargets)
- }
- }
- gi.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
- this._intermediateRendering = !1,
- this._renderId++
- }
- this._engine.currentRenderPassId = null !== (r = null == d ? void 0 : d.renderPassId) && void 0 !== r ? r : a.RENDERPASS_MAIN,
- this.activeCamera = d,
- this._activeCamera && this._activeCamera.cameraRigMode !== a.RIG_MODE_CUSTOM && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
- this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
- for (var _ = 0, m = this._beforeClearStage; _ < m.length; _++)
- m[_].action();
- this._clearFrameBuffer(this.activeCamera);
- for (var g = 0, v = this._gatherRenderTargetsStage; g < v.length; g++)
- v[g].action(this._renderTargets);
- if (this.activeCameras && this.activeCameras.length > 0)
- for (l = 0; l < this.activeCameras.length; l++)
- this._processSubCameras(this.activeCameras[l], l > 0);
- else {
- if (!this.activeCamera)
- throw new Error("No camera defined");
- this._processSubCameras(this.activeCamera, !!this.activeCamera.outputRenderTarget)
- }
- this._checkIntersections();
- for (var y = 0, b = this._afterRenderStage; y < b.length; y++)
- b[y].action();
- if (this.afterRender && this.afterRender(),
- this.onAfterRenderObservable.notifyObservers(this),
- this._toBeDisposed.length) {
- for (u = 0; u < this._toBeDisposed.length; u++) {
- var T = this._toBeDisposed[u];
- T && T.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()
- }
- }
- ,
- t.prototype.freezeMaterials = function() {
- for (var e = 0; e < this.materials.length; e++)
- this.materials[e].freeze()
- }
- ,
- t.prototype.unfreezeMaterials = function() {
- for (var e = 0; e < this.materials.length; e++)
- this.materials[e].unfreeze()
- }
- ,
- t.prototype.dispose = function() {
- var e;
- 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(),
- 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._materialsRenderTargets.dispose(),
- this._registeredForLateAnimationBindings.dispose(),
- this._meshesForIntersections.dispose(),
- this._toBeDisposed = [];
- for (var t = 0, i = this._activeRequests.slice(); t < i.length; t++)
- i[t].abort();
- this.onBeforeRunRegisterBeforeRenderObservable.clear(),
- this.onAfterRunRegisterBeforeRenderObservable.clear(),
- this.onBeforeRTT1Observable.clear(),
- this.onAfterRTT1Observable.clear(),
- this.onBeforeRunRegisterAfterRenderObservable.clear(),
- this.onAfterRunRegisterAfterRenderObservable.clear()
-
- if (this._activeRequests = [],
- 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(),
- null === (e = this._computePressureObserver) || void 0 === e || e.unobserve(),
- this._computePressureObserver = void 0,
- this.detachControl(),
- this._engine.getInputElement())
- for (var n = 0; n < this.cameras.length; n++)
- this.cameras[n].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();
- for (var r = 0, o = this._components; r < o.length; r++)
- o[r].dispose();
- var a = this._engine.scenes.indexOf(this);
- a > -1 && this._engine.scenes.splice(a, 1),
- E._LastCreatedScene === this && (this._engine.scenes.length > 0 ? E._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : E._LastCreatedScene = null),
- (a = this._engine._virtualScenes.indexOf(this)) > -1 && this._engine._virtualScenes.splice(a, 1),
- this._engine.wipeCaches(!0),
- this._isDisposed = !0
- }
- }
- ,
- Object.defineProperty(t.prototype, "isDisposed", {
- get: function() {
- return this._isDisposed
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.clearCachedVertexData = function() {
- for (var e = 0; e < this.meshes.length; e++) {
- var t = this.meshes[e].geometry;
- t && t.clearCachedData()
- }
- }
- ,
- t.prototype.cleanCachedTextureBuffer = function() {
- for (var e = 0, t = this.textures; e < t.length; e++) {
- var i = t[e];
- i._buffer && (i._buffer = null)
- }
- }
- ,
- t.prototype.getWorldExtends = function(e) {
- var t = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- , i = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- return e = e || function() {
- return !0
- }
- ,
- this.meshes.filter(e).forEach((function(e) {
- if (e.computeWorldMatrix(!0),
- e.subMeshes && 0 !== e.subMeshes.length && !e.infiniteDistance) {
- var n = e.getBoundingInfo()
- , r = n.boundingBox.minimumWorld
- , o = n.boundingBox.maximumWorld;
- x.CheckExtends(r, t, i),
- x.CheckExtends(o, t, i)
- }
- }
- )),
- {
- min: t,
- max: i
- }
- }
- ,
- t.prototype.createPickingRay = function(e, t, i, n, r) {
- throw void 0 === r && (r = !1),
- be("Ray")
- }
- ,
- t.prototype.createPickingRayToRef = function(e, t, i, n, r, o, a) {
- throw void 0 === o && (o = !1),
- void 0 === a && (a = !1),
- be("Ray")
- }
- ,
- t.prototype.createPickingRayInCameraSpace = function(e, t, i) {
- throw be("Ray")
- }
- ,
- t.prototype.createPickingRayInCameraSpaceToRef = function(e, t, i, n) {
- throw be("Ray")
- }
- ,
- t.prototype.pick = function(e, t, i, n, r, o) {
- var a = new Ui;
- return a._pickingUnavailable = !0,
- a
- }
- ,
- t.prototype.pickWithBoundingInfo = function(e, t, i, n, r) {
- var o = new Ui;
- return o._pickingUnavailable = !0,
- o
- }
- ,
- t.prototype.pickWithRay = function(e, t, i, n) {
- throw be("Ray")
- }
- ,
- t.prototype.multiPick = function(e, t, i, n, r) {
- throw be("Ray")
- }
- ,
- t.prototype.multiPickWithRay = function(e, t, i) {
- throw be("Ray")
- }
- ,
- t.prototype.setPointerOverMesh = function(e, t, i) {
- this._inputManager.setPointerOverMesh(e, t, i)
- }
- ,
- t.prototype.getPointerOverMesh = function() {
- return this._inputManager.getPointerOverMesh()
- }
- ,
- t.prototype._rebuildGeometries = function() {
- for (var e = 0, t = this.geometries; e < t.length; e++)
- t[e]._rebuild();
- for (var i = 0, n = this.meshes; i < n.length; i++)
- n[i]._rebuild();
- this.postProcessManager && this.postProcessManager._rebuild();
- for (var r = 0, o = this._components; r < o.length; r++)
- o[r].rebuild();
- for (var a = 0, s = this.particleSystems; a < s.length; a++)
- s[a].rebuild();
- if (this.spriteManagers)
- for (var l = 0, c = this.spriteManagers; l < c.length; l++)
- c[l].rebuild()
- }
- ,
- t.prototype._rebuildTextures = function() {
- for (var e = 0, t = this.textures; e < t.length; e++)
- t[e]._rebuild();
- this.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
- }
- ,
- t.prototype._getByTags = function(e, t, i) {
- if (void 0 === t)
- return e;
- var n = [];
- for (var r in i = i || function(e) {}
- ,
- e) {
- var o = e[r];
- ye && ye.MatchesQuery(o, t) && (n.push(o),
- i(o))
- }
- return n
- }
- ,
- t.prototype.getMeshesByTags = function(e, t) {
- return this._getByTags(this.meshes, e, t)
- }
- ,
- t.prototype.getCamerasByTags = function(e, t) {
- return this._getByTags(this.cameras, e, t)
- }
- ,
- t.prototype.getLightsByTags = function(e, t) {
- return this._getByTags(this.lights, e, t)
- }
- ,
- t.prototype.getMaterialByTags = function(e, t) {
- return this._getByTags(this.materials, e, t).concat(this._getByTags(this.multiMaterials, e, t))
- }
- ,
- t.prototype.getTransformNodesByTags = function(e, t) {
- return this._getByTags(this.transformNodes, e, t)
- }
- ,
- t.prototype.setRenderingOrder = function(e, t, i, n) {
- void 0 === t && (t = null),
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- this._renderingManager.setRenderingOrder(e, t, i, n)
- }
- ,
- t.prototype.setRenderingAutoClearDepthStencil = function(e, t, i, n) {
- void 0 === i && (i = !0),
- void 0 === n && (n = !0),
- this._renderingManager.setRenderingAutoClearDepthStencil(e, t, i, n)
- }
- ,
- t.prototype.getAutoClearDepthStencilSetup = function(e) {
- return this._renderingManager.getAutoClearDepthStencilSetup(e)
- }
- ,
- Object.defineProperty(t.prototype, "blockMaterialDirtyMechanism", {
- get: function() {
- return this._blockMaterialDirtyMechanism
- },
- set: function(e) {
- this._blockMaterialDirtyMechanism !== e && (this._blockMaterialDirtyMechanism = e,
- e || this.markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.markAllMaterialsAsDirty = function(e, t) {
- if (!this._blockMaterialDirtyMechanism)
- for (var i = 0, n = this.materials; i < n.length; i++) {
- var r = n[i];
- t && !t(r) || r.markAsDirty(e)
- }
- }
- ,
- t.prototype._loadFile = function(e, t, i, n, r, o, a) {
- var s = this
- , l = ti(e, t, i, n ? this.offlineProvider : void 0, r, o, a);
- return this._activeRequests.push(l),
- l.onCompleteObservable.add((function(e) {
- s._activeRequests.splice(s._activeRequests.indexOf(e), 1)
- }
- )),
- l
- }
- ,
- t.prototype._loadFileAsync = function(e, t, i, n, r) {
- var o = this;
- return new Promise((function(a, s) {
- o._loadFile(e, (function(e) {
- a(e)
- }
- ), t, i, n, (function(e, t) {
- s(t)
- }
- ), r)
- }
- ))
- }
- ,
- t.prototype._requestFile = function(e, t, i, n, r, o, a) {
- var s = this
- , l = ii(e, t, i, n ? this.offlineProvider : void 0, r, o, a);
- return this._activeRequests.push(l),
- l.onCompleteObservable.add((function(e) {
- s._activeRequests.splice(s._activeRequests.indexOf(e), 1)
- }
- )),
- l
- }
- ,
- t.prototype._requestFileAsync = function(e, t, i, n, r) {
- var o = this;
- return new Promise((function(a, s) {
- o._requestFile(e, (function(e) {
- a(e)
- }
- ), t, i, n, (function(e) {
- s(e)
- }
- ), r)
- }
- ))
- }
- ,
- t.prototype._readFile = function(e, t, i, n, r) {
- var o = this
- , a = ei(e, t, i, n, r);
- return this._activeRequests.push(a),
- a.onCompleteObservable.add((function(e) {
- o._activeRequests.splice(o._activeRequests.indexOf(e), 1)
- }
- )),
- a
- }
- ,
- t.prototype._readFileAsync = function(e, t, i) {
- var n = this;
- return new Promise((function(r, o) {
- n._readFile(e, (function(e) {
- r(e)
- }
- ), t, i, (function(e) {
- o(e)
- }
- ))
- }
- ))
- }
- ,
- t.prototype.getPerfCollector = function() {
- throw be("performanceViewerSceneExtension")
- }
- ,
- t.FOGMODE_NONE = 0,
- t.FOGMODE_EXP = 1,
- t.FOGMODE_EXP2 = 2,
- t.FOGMODE_LINEAR = 3,
- t.MinDeltaTime = 1,
- t.MaxDeltaTime = 1e3,
- t
- }(o);
- mn.prototype.setActiveCameraByID = function(e) {
- return this.setActiveCameraById(e)
- }
- ,
- mn.prototype.getLastMaterialByID = function(e) {
- return this.getLastMaterialById(e)
- }
- ,
- mn.prototype.getMaterialByID = function(e) {
- return this.getMaterialById(e)
- }
- ,
- mn.prototype.getTextureByUniqueID = function(e) {
- return this.getTextureByUniqueId(e)
- }
- ,
- mn.prototype.getCameraByID = function(e) {
- return this.getCameraById(e)
- }
- ,
- mn.prototype.getCameraByUniqueID = function(e) {
- return this.getCameraByUniqueId(e)
- }
- ,
- mn.prototype.getBoneByID = function(e) {
- return this.getBoneById(e)
- }
- ,
- mn.prototype.getLightByID = function(e) {
- return this.getLightById(e)
- }
- ,
- mn.prototype.getLightByUniqueID = function(e) {
- return this.getLightByUniqueId(e)
- }
- ,
- mn.prototype.getParticleSystemByID = function(e) {
- return this.getParticleSystemById(e)
- }
- ,
- mn.prototype.getGeometryByID = function(e) {
- return this.getGeometryById(e)
- }
- ,
- mn.prototype.getMeshByID = function(e) {
- return this.getMeshById(e)
- }
- ,
- mn.prototype.getMeshesByID = function(e) {
- return this.getMeshesById(e)
- }
- ,
- mn.prototype.getTransformNodeByID = function(e) {
- return this.getTransformNodeById(e)
- }
- ,
- mn.prototype.getTransformNodeByUniqueID = function(e) {
- return this.getTransformNodeByUniqueId(e)
- }
- ,
- mn.prototype.getTransformNodesByID = function(e) {
- return this.getTransformNodesById(e)
- }
- ,
- mn.prototype.getMeshByUniqueID = function(e) {
- return this.getMeshByUniqueId(e)
- }
- ,
- mn.prototype.getLastMeshByID = function(e) {
- return this.getLastMeshById(e)
- }
- ,
- mn.prototype.getLastEntryByID = function(e) {
- return this.getLastEntryById(e)
- }
- ,
- mn.prototype.getNodeByID = function(e) {
- return this.getNodeById(e)
- }
- ,
- mn.prototype.getLastSkeletonByID = function(e) {
- return this.getLastSkeletonById(e)
- }
- ,
- function(e) {
- e[e.LOCAL = 0] = "LOCAL",
- e[e.WORLD = 1] = "WORLD",
- e[e.BONE = 2] = "BONE"
- }(Ji || (Ji = {}));
- var gn, vn = function() {
- function e() {}
- return e.X = new x(1,0,0),
- e.Y = new x(0,1,0),
- e.Z = new x(0,0,1),
- e
- }();
- !function(e) {
- e[e.X = 0] = "X",
- e[e.Y = 1] = "Y",
- e[e.Z = 2] = "Z"
- }(gn || (gn = {}));
- var yn = function(e) {
- function t(t, i, n, r, o, a, s) {
- void 0 === n && (n = null),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null);
- var l = e.call(this, t, i.getScene()) || this;
- return l.name = t,
- l.children = new Array,
- l.animations = new Array,
- l._index = null,
- l._absoluteTransform = new P,
- l._invertedAbsoluteTransform = new P,
- l._scalingDeterminant = 1,
- l._worldTransform = new P,
- l._needToDecompose = !0,
- l._needToCompose = !1,
- l._linkedTransformNode = null,
- l._waitingTransformNodeId = null,
- l._skeleton = i,
- l._localMatrix = r ? r.clone() : P.Identity(),
- l._restPose = o || l._localMatrix.clone(),
- l._baseMatrix = a || l._localMatrix.clone(),
- l._index = s,
- i.bones.push(l),
- l.setParent(n, !1),
- (a || r) && l._updateDifferenceMatrix(),
- l
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "_matrix", {
- get: function() {
- return this._compose(),
- this._localMatrix
- },
- set: function(e) {
- this._needToCompose = !1,
- e.updateFlag !== this._localMatrix.updateFlag && (this._localMatrix.copyFrom(e),
- this._markAsDirtyAndDecompose())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "Bone"
- }
- ,
- t.prototype.getSkeleton = function() {
- return this._skeleton
- }
- ,
- Object.defineProperty(t.prototype, "parent", {
- get: function() {
- return this._parentNode
- },
- set: function(e) {
- this.setParent(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getParent = function() {
- return this.parent
- }
- ,
- t.prototype.getChildren = function() {
- return this.children
- }
- ,
- t.prototype.getIndex = function() {
- return null === this._index ? this.getSkeleton().bones.indexOf(this) : this._index
- }
- ,
- t.prototype.setParent = function(e, t) {
- if (void 0 === t && (t = !0),
- this.parent !== e) {
- if (this.parent) {
- var i = this.parent.children.indexOf(this);
- -1 !== i && this.parent.children.splice(i, 1)
- }
- this._parentNode = e,
- this.parent && this.parent.children.push(this),
- t && this._updateDifferenceMatrix(),
- this.markAsDirty()
- }
- }
- ,
- t.prototype.getLocalMatrix = function() {
- return this._compose(),
- this._localMatrix
- }
- ,
- t.prototype.getBaseMatrix = function() {
- return this._baseMatrix
- }
- ,
- t.prototype.getRestPose = function() {
- return this._restPose
- }
- ,
- t.prototype.setRestPose = function(e) {
- this._restPose.copyFrom(e)
- }
- ,
- t.prototype.getBindPose = function() {
- return this._baseMatrix
- }
- ,
- t.prototype.setBindPose = function(e) {
- this.updateMatrix(e)
- }
- ,
- t.prototype.getWorldMatrix = function() {
- return this._worldTransform
- }
- ,
- t.prototype.returnToRest = function() {
- var e;
- if (this._linkedTransformNode) {
- var t = I.Vector3[0]
- , i = I.Quaternion[0]
- , n = I.Vector3[1];
- this.getRestPose().decompose(t, i, n),
- this._linkedTransformNode.position.copyFrom(n),
- this._linkedTransformNode.rotationQuaternion = null !== (e = this._linkedTransformNode.rotationQuaternion) && void 0 !== e ? e : C.Identity(),
- this._linkedTransformNode.rotationQuaternion.copyFrom(i),
- this._linkedTransformNode.scaling.copyFrom(t)
- } else
- this._matrix = this._restPose
- }
- ,
- t.prototype.getInvertedAbsoluteTransform = function() {
- return this._invertedAbsoluteTransform
- }
- ,
- t.prototype.getAbsoluteTransform = function() {
- return this._absoluteTransform
- }
- ,
- t.prototype.linkTransformNode = function(e) {
- this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--,
- this._linkedTransformNode = e,
- this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++
- }
- ,
- t.prototype.getTransformNode = function() {
- return this._linkedTransformNode
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._decompose(),
- this._localPosition
- },
- set: function(e) {
- this._decompose(),
- this._localPosition.copyFrom(e),
- this._markAsDirtyAndCompose()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotation", {
- get: function() {
- return this.getRotation()
- },
- set: function(e) {
- this.setRotation(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationQuaternion", {
- get: function() {
- return this._decompose(),
- this._localRotation
- },
- set: function(e) {
- this.setRotationQuaternion(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scaling", {
- get: function() {
- return this.getScale()
- },
- set: function(e) {
- this.setScale(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._skeleton.animationPropertiesOverride
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._decompose = function() {
- this._needToDecompose && (this._needToDecompose = !1,
- this._localScaling || (this._localScaling = x.Zero(),
- this._localRotation = C.Zero(),
- this._localPosition = x.Zero()),
- this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition))
- }
- ,
- t.prototype._compose = function() {
- this._needToCompose && (this._localScaling ? (this._needToCompose = !1,
- P.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)) : this._needToCompose = !1)
- }
- ,
- t.prototype.updateMatrix = function(e, t, i) {
- void 0 === t && (t = !0),
- void 0 === i && (i = !0),
- this._baseMatrix.copyFrom(e),
- t && this._updateDifferenceMatrix(),
- i ? this._matrix = e : this.markAsDirty()
- }
- ,
- t.prototype._updateDifferenceMatrix = function(e, t) {
- if (void 0 === t && (t = !0),
- e || (e = this._baseMatrix),
- this.parent ? e.multiplyToRef(this.parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(e),
- this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),
- t)
- for (var i = 0; i < this.children.length; i++)
- this.children[i]._updateDifferenceMatrix();
- this._scalingDeterminant = this._absoluteTransform.determinant() < 0 ? -1 : 1
- }
- ,
- t.prototype.markAsDirty = function() {
- return this._currentRenderId++,
- this._childUpdateId++,
- this._skeleton._markAsDirty(),
- this
- }
- ,
- t.prototype._markAsDirtyAndCompose = function() {
- this.markAsDirty(),
- this._needToCompose = !0
- }
- ,
- t.prototype._markAsDirtyAndDecompose = function() {
- this.markAsDirty(),
- this._needToDecompose = !0
- }
- ,
- t.prototype.translate = function(e, i, n) {
- void 0 === i && (i = Ji.LOCAL);
- var r = this.getLocalMatrix();
- if (i == Ji.LOCAL)
- r.addAtIndex(12, e.x),
- r.addAtIndex(13, e.y),
- r.addAtIndex(14, e.z);
- else {
- var o = null;
- n && (o = n.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var a = t._TmpMats[0]
- , s = t._TmpVecs[0];
- this.parent ? n && o ? (a.copyFrom(this.parent.getAbsoluteTransform()),
- a.multiplyToRef(o, a)) : a.copyFrom(this.parent.getAbsoluteTransform()) : P.IdentityToRef(a),
- a.setTranslationFromFloats(0, 0, 0),
- a.invert(),
- x.TransformCoordinatesToRef(e, a, s),
- r.addAtIndex(12, s.x),
- r.addAtIndex(13, s.y),
- r.addAtIndex(14, s.z)
- }
- this._markAsDirtyAndDecompose()
- }
- ,
- t.prototype.setPosition = function(e, i, n) {
- void 0 === i && (i = Ji.LOCAL);
- var r = this.getLocalMatrix();
- if (i == Ji.LOCAL)
- r.setTranslationFromFloats(e.x, e.y, e.z);
- else {
- var o = null;
- n && (o = n.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var a = t._TmpMats[0]
- , s = t._TmpVecs[0];
- this.parent ? (n && o ? (a.copyFrom(this.parent.getAbsoluteTransform()),
- a.multiplyToRef(o, a)) : a.copyFrom(this.parent.getAbsoluteTransform()),
- a.invert()) : P.IdentityToRef(a),
- x.TransformCoordinatesToRef(e, a, s),
- r.setTranslationFromFloats(s.x, s.y, s.z)
- }
- this._markAsDirtyAndDecompose()
- }
- ,
- t.prototype.setAbsolutePosition = function(e, t) {
- this.setPosition(e, Ji.WORLD, t)
- }
- ,
- t.prototype.scale = function(e, i, n, r) {
- void 0 === r && (r = !1);
- var o = this.getLocalMatrix()
- , a = t._TmpMats[0];
- P.ScalingToRef(e, i, n, a),
- a.multiplyToRef(o, o),
- a.invert();
- for (var s = 0, l = this.children; s < l.length; s++) {
- var c = (d = l[s]).getLocalMatrix();
- c.multiplyToRef(a, c),
- c.multiplyAtIndex(12, e),
- c.multiplyAtIndex(13, i),
- c.multiplyAtIndex(14, n),
- d._markAsDirtyAndDecompose()
- }
- if (this._markAsDirtyAndDecompose(),
- r)
- for (var u = 0, h = this.children; u < h.length; u++) {
- var d;
- (d = h[u]).scale(e, i, n, r)
- }
- }
- ,
- t.prototype.setScale = function(e) {
- this._decompose(),
- this._localScaling.copyFrom(e),
- this._markAsDirtyAndCompose()
- }
- ,
- t.prototype.getScale = function() {
- return this._decompose(),
- this._localScaling
- }
- ,
- t.prototype.getScaleToRef = function(e) {
- this._decompose(),
- e.copyFrom(this._localScaling)
- }
- ,
- t.prototype.setYawPitchRoll = function(e, i, n, r, o) {
- if (void 0 === r && (r = Ji.LOCAL),
- r === Ji.LOCAL) {
- var a = t._TmpQuat;
- return C.RotationYawPitchRollToRef(e, i, n, a),
- void this.setRotationQuaternion(a, r, o)
- }
- var s = t._TmpMats[0];
- if (this._getNegativeRotationToRef(s, o)) {
- var l = t._TmpMats[1];
- P.RotationYawPitchRollToRef(e, i, n, l),
- s.multiplyToRef(l, l),
- this._rotateWithMatrix(l, r, o)
- }
- }
- ,
- t.prototype.rotate = function(e, i, n, r) {
- void 0 === n && (n = Ji.LOCAL);
- var o = t._TmpMats[0];
- o.setTranslationFromFloats(0, 0, 0),
- P.RotationAxisToRef(e, i, o),
- this._rotateWithMatrix(o, n, r)
- }
- ,
- t.prototype.setAxisAngle = function(e, i, n, r) {
- if (void 0 === n && (n = Ji.LOCAL),
- n === Ji.LOCAL) {
- var o = t._TmpQuat;
- return C.RotationAxisToRef(e, i, o),
- void this.setRotationQuaternion(o, n, r)
- }
- var a = t._TmpMats[0];
- if (this._getNegativeRotationToRef(a, r)) {
- var s = t._TmpMats[1];
- P.RotationAxisToRef(e, i, s),
- a.multiplyToRef(s, s),
- this._rotateWithMatrix(s, n, r)
- }
- }
- ,
- t.prototype.setRotation = function(e, t, i) {
- void 0 === t && (t = Ji.LOCAL),
- this.setYawPitchRoll(e.y, e.x, e.z, t, i)
- }
- ,
- t.prototype.setRotationQuaternion = function(e, i, n) {
- if (void 0 === i && (i = Ji.LOCAL),
- i === Ji.LOCAL)
- return this._decompose(),
- this._localRotation.copyFrom(e),
- void this._markAsDirtyAndCompose();
- var r = t._TmpMats[0];
- if (this._getNegativeRotationToRef(r, n)) {
- var o = t._TmpMats[1];
- P.FromQuaternionToRef(e, o),
- r.multiplyToRef(o, o),
- this._rotateWithMatrix(o, i, n)
- }
- }
- ,
- t.prototype.setRotationMatrix = function(e, i, n) {
- if (void 0 === i && (i = Ji.LOCAL),
- i === Ji.LOCAL) {
- var r = t._TmpQuat;
- return C.FromRotationMatrixToRef(e, r),
- void this.setRotationQuaternion(r, i, n)
- }
- var o = t._TmpMats[0];
- if (this._getNegativeRotationToRef(o, n)) {
- var a = t._TmpMats[1];
- a.copyFrom(e),
- o.multiplyToRef(e, a),
- this._rotateWithMatrix(a, i, n)
- }
- }
- ,
- t.prototype._rotateWithMatrix = function(e, i, n) {
- void 0 === i && (i = Ji.LOCAL);
- var r = this.getLocalMatrix()
- , o = r.m[12]
- , a = r.m[13]
- , s = r.m[14]
- , l = this.getParent()
- , c = t._TmpMats[3]
- , u = t._TmpMats[4];
- l && i == Ji.WORLD ? (n ? (c.copyFrom(n.getWorldMatrix()),
- l.getAbsoluteTransform().multiplyToRef(c, c)) : c.copyFrom(l.getAbsoluteTransform()),
- u.copyFrom(c),
- u.invert(),
- r.multiplyToRef(c, r),
- r.multiplyToRef(e, r),
- r.multiplyToRef(u, r)) : i == Ji.WORLD && n ? (c.copyFrom(n.getWorldMatrix()),
- u.copyFrom(c),
- u.invert(),
- r.multiplyToRef(c, r),
- r.multiplyToRef(e, r),
- r.multiplyToRef(u, r)) : r.multiplyToRef(e, r),
- r.setTranslationFromFloats(o, a, s),
- this.computeAbsoluteTransforms(),
- this._markAsDirtyAndDecompose()
- }
- ,
- t.prototype._getNegativeRotationToRef = function(e, i) {
- var n = t._TmpMats[2];
- return e.copyFrom(this.getAbsoluteTransform()),
- i ? (e.multiplyToRef(i.getWorldMatrix(), e),
- P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, n)) : P.IdentityToRef(n),
- e.invert(),
- !isNaN(e.m[0]) && (n.multiplyAtIndex(0, this._scalingDeterminant),
- e.multiplyToRef(n, e),
- !0)
- }
- ,
- t.prototype.getPosition = function(e, t) {
- void 0 === e && (e = Ji.LOCAL),
- void 0 === t && (t = null);
- var i = x.Zero();
- return this.getPositionToRef(e, t, i),
- i
- }
- ,
- t.prototype.getPositionToRef = function(e, i, n) {
- if (void 0 === e && (e = Ji.LOCAL),
- e == Ji.LOCAL) {
- var r = this.getLocalMatrix();
- n.x = r.m[12],
- n.y = r.m[13],
- n.z = r.m[14]
- } else {
- var o = null;
- i && (o = i.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var a = t._TmpMats[0];
- i && o ? (a.copyFrom(this.getAbsoluteTransform()),
- a.multiplyToRef(o, a)) : a = this.getAbsoluteTransform(),
- n.x = a.m[12],
- n.y = a.m[13],
- n.z = a.m[14]
- }
- }
- ,
- t.prototype.getAbsolutePosition = function(e) {
- void 0 === e && (e = null);
- var t = x.Zero();
- return this.getPositionToRef(Ji.WORLD, e, t),
- t
- }
- ,
- t.prototype.getAbsolutePositionToRef = function(e, t) {
- this.getPositionToRef(Ji.WORLD, e, t)
- }
- ,
- t.prototype.computeAbsoluteTransforms = function() {
- if (this._compose(),
- this.parent)
- this._localMatrix.multiplyToRef(this.parent._absoluteTransform, this._absoluteTransform);
- else {
- this._absoluteTransform.copyFrom(this._localMatrix);
- var e = this._skeleton.getPoseMatrix();
- e && this._absoluteTransform.multiplyToRef(e, this._absoluteTransform)
- }
- for (var t = this.children, i = t.length, n = 0; n < i; n++)
- t[n].computeAbsoluteTransforms()
- }
- ,
- t.prototype.getDirection = function(e, t) {
- void 0 === t && (t = null);
- var i = x.Zero();
- return this.getDirectionToRef(e, t, i),
- i
- }
- ,
- t.prototype.getDirectionToRef = function(e, i, n) {
- void 0 === i && (i = null);
- var r = null;
- i && (r = i.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var o = t._TmpMats[0];
- o.copyFrom(this.getAbsoluteTransform()),
- i && r && o.multiplyToRef(r, o),
- x.TransformNormalToRef(e, o, n),
- n.normalize()
- }
- ,
- t.prototype.getRotation = function(e, t) {
- void 0 === e && (e = Ji.LOCAL),
- void 0 === t && (t = null);
- var i = x.Zero();
- return this.getRotationToRef(e, t, i),
- i
- }
- ,
- t.prototype.getRotationToRef = function(e, i, n) {
- void 0 === e && (e = Ji.LOCAL),
- void 0 === i && (i = null);
- var r = t._TmpQuat;
- this.getRotationQuaternionToRef(e, i, r),
- r.toEulerAnglesToRef(n)
- }
- ,
- t.prototype.getRotationQuaternion = function(e, t) {
- void 0 === e && (e = Ji.LOCAL),
- void 0 === t && (t = null);
- var i = C.Identity();
- return this.getRotationQuaternionToRef(e, t, i),
- i
- }
- ,
- t.prototype.getRotationQuaternionToRef = function(e, i, n) {
- if (void 0 === e && (e = Ji.LOCAL),
- void 0 === i && (i = null),
- e == Ji.LOCAL)
- this._decompose(),
- n.copyFrom(this._localRotation);
- else {
- var r = t._TmpMats[0]
- , o = this.getAbsoluteTransform();
- i ? o.multiplyToRef(i.getWorldMatrix(), r) : r.copyFrom(o),
- r.multiplyAtIndex(0, this._scalingDeterminant),
- r.multiplyAtIndex(1, this._scalingDeterminant),
- r.multiplyAtIndex(2, this._scalingDeterminant),
- r.decompose(void 0, n, void 0)
- }
- }
- ,
- t.prototype.getRotationMatrix = function(e, t) {
- void 0 === e && (e = Ji.LOCAL);
- var i = P.Identity();
- return this.getRotationMatrixToRef(e, t, i),
- i
- }
- ,
- t.prototype.getRotationMatrixToRef = function(e, i, n) {
- if (void 0 === e && (e = Ji.LOCAL),
- e == Ji.LOCAL)
- this.getLocalMatrix().getRotationMatrixToRef(n);
- else {
- var r = t._TmpMats[0]
- , o = this.getAbsoluteTransform();
- i ? o.multiplyToRef(i.getWorldMatrix(), r) : r.copyFrom(o),
- r.multiplyAtIndex(0, this._scalingDeterminant),
- r.multiplyAtIndex(1, this._scalingDeterminant),
- r.multiplyAtIndex(2, this._scalingDeterminant),
- r.getRotationMatrixToRef(n)
- }
- }
- ,
- t.prototype.getAbsolutePositionFromLocal = function(e, t) {
- void 0 === t && (t = null);
- var i = x.Zero();
- return this.getAbsolutePositionFromLocalToRef(e, t, i),
- i
- }
- ,
- t.prototype.getAbsolutePositionFromLocalToRef = function(e, i, n) {
- void 0 === i && (i = null);
- var r = null;
- i && (r = i.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var o = t._TmpMats[0];
- i && r ? (o.copyFrom(this.getAbsoluteTransform()),
- o.multiplyToRef(r, o)) : o = this.getAbsoluteTransform(),
- x.TransformCoordinatesToRef(e, o, n)
- }
- ,
- t.prototype.getLocalPositionFromAbsolute = function(e, t) {
- void 0 === t && (t = null);
- var i = x.Zero();
- return this.getLocalPositionFromAbsoluteToRef(e, t, i),
- i
- }
- ,
- t.prototype.getLocalPositionFromAbsoluteToRef = function(e, i, n) {
- void 0 === i && (i = null);
- var r = null;
- i && (r = i.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var o = t._TmpMats[0];
- o.copyFrom(this.getAbsoluteTransform()),
- i && r && o.multiplyToRef(r, o),
- o.invert(),
- x.TransformCoordinatesToRef(e, o, n)
- }
- ,
- t.prototype.setCurrentPoseAsRest = function() {
- this.setRestPose(this.getLocalMatrix())
- }
- ,
- t._TmpVecs = g.BuildArray(2, x.Zero),
- t._TmpQuat = C.Identity(),
- t._TmpMats = g.BuildArray(5, P.Identity),
- t
- }(Xe)
- , bn = function() {
- function e(e, t, i, n, r, o, a, s, l, c) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 100),
- void 0 === r && (r = !1),
- void 0 === o && (o = 1),
- void 0 === c && (c = !1),
- this.target = t,
- this.fromFrame = i,
- this.toFrame = n,
- this.loopAnimation = r,
- this.onAnimationEnd = a,
- this.onAnimationLoop = l,
- this.isAdditive = c,
- 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 h,
- this.onAnimationLoopObservable = new h,
- this._scene = e,
- s && this.appendAnimations(t, s),
- this._speedRatio = o,
- e._activeAnimatables.push(this)
- }
- return Object.defineProperty(e.prototype, "syncRoot", {
- get: function() {
- return this._syncRoot
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "masterFrame", {
- get: function() {
- return 0 === this._runtimeAnimations.length ? 0 : this._runtimeAnimations[0].currentFrame
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "weight", {
- get: function() {
- return this._weight
- },
- set: function(e) {
- this._weight = -1 !== e ? Math.min(Math.max(e, 0), 1) : -1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "speedRatio", {
- get: function() {
- return this._speedRatio
- },
- set: function(e) {
- for (var t = 0; t < this._runtimeAnimations.length; t++)
- this._runtimeAnimations[t]._prepareForSpeedRatioChange(e);
- this._speedRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.syncWith = function(e) {
- if (this._syncRoot = e,
- e) {
- var t = this._scene._activeAnimatables.indexOf(this);
- t > -1 && (this._scene._activeAnimatables.splice(t, 1),
- this._scene._activeAnimatables.push(this))
- }
- return this
- }
- ,
- e.prototype.getAnimations = function() {
- return this._runtimeAnimations
- }
- ,
- e.prototype.appendAnimations = function(e, t) {
- for (var i = this, n = 0; n < t.length; n++) {
- var r = t[n]
- , o = new it(e,r,this._scene,this);
- o._onLoop = function() {
- i.onAnimationLoopObservable.notifyObservers(i),
- i.onAnimationLoop && i.onAnimationLoop()
- }
- ,
- this._runtimeAnimations.push(o)
- }
- }
- ,
- e.prototype.getAnimationByTargetProperty = function(e) {
- for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)
- if (t[i].animation.targetProperty === e)
- return t[i].animation;
- return null
- }
- ,
- e.prototype.getRuntimeAnimationByTargetProperty = function(e) {
- for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)
- if (t[i].animation.targetProperty === e)
- return t[i];
- return null
- }
- ,
- e.prototype.reset = function() {
- for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)
- e[t].reset(!0);
- this._localDelayOffset = null,
- this._pausedDelay = null
- }
- ,
- e.prototype.enableBlending = function(e) {
- for (var t = this._runtimeAnimations, i = 0; i < t.length; i++)
- t[i].animation.enableBlending = !0,
- t[i].animation.blendingSpeed = e
- }
- ,
- e.prototype.disableBlending = function() {
- for (var e = this._runtimeAnimations, t = 0; t < e.length; t++)
- e[t].animation.enableBlending = !1
- }
- ,
- e.prototype.goToFrame = function(e) {
- var t, i = this._runtimeAnimations;
- if (i[0]) {
- var n = i[0].animation.framePerSecond;
- this._frameToSyncFromJump = null !== (t = this._frameToSyncFromJump) && void 0 !== t ? t : i[0].currentFrame;
- var r = 0 === this.speedRatio ? 0 : (e - this._frameToSyncFromJump) / n * 1e3 / this.speedRatio;
- this._manualJumpDelay = -r
- }
- for (var o = 0; o < i.length; o++)
- i[o].goToFrame(e)
- }
- ,
- e.prototype.pause = function() {
- this._paused || (this._paused = !0)
- }
- ,
- e.prototype.restart = function() {
- this._paused = !1
- }
- ,
- e.prototype._raiseOnAnimationEnd = function() {
- this.onAnimationEnd && this.onAnimationEnd(),
- this.onAnimationEndObservable.notifyObservers(this)
- }
- ,
- e.prototype.stop = function(e, t) {
- if (e || t) {
- var i = this._scene._activeAnimatables.indexOf(this);
- if (i > -1) {
- for (var n = (o = this._runtimeAnimations).length - 1; n >= 0; n--) {
- var r = o[n];
- e && r.animation.name != e || t && !t(r.target) || (r.dispose(),
- o.splice(n, 1))
- }
- 0 == o.length && (this._scene._activeAnimatables.splice(i, 1),
- this._raiseOnAnimationEnd())
- }
- } else if ((n = this._scene._activeAnimatables.indexOf(this)) > -1) {
- this._scene._activeAnimatables.splice(n, 1);
- for (var o = this._runtimeAnimations, a = 0; a < o.length; a++)
- o[a].dispose();
- this._raiseOnAnimationEnd()
- }
- }
- ,
- e.prototype.waitAsync = function() {
- var e = this;
- return new Promise((function(t) {
- e.onAnimationEndObservable.add((function() {
- t(e)
- }
- ), void 0, void 0, e, !0)
- }
- ))
- }
- ,
- e.prototype._animate = function(e) {
- if (this._paused)
- return this.animationStarted = !1,
- null === this._pausedDelay && (this._pausedDelay = e),
- !0;
- if (null === this._localDelayOffset ? (this._localDelayOffset = e,
- this._pausedDelay = null) : null !== this._pausedDelay && (this._localDelayOffset += e - this._pausedDelay,
- this._pausedDelay = null),
- null !== this._manualJumpDelay && (this._localDelayOffset += this._manualJumpDelay,
- this._manualJumpDelay = null,
- this._frameToSyncFromJump = null),
- 0 === this._weight)
- return !0;
- var t, i = !1, n = this._runtimeAnimations;
- for (t = 0; t < n.length; t++) {
- var r = n[t].animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
- i = i || r
- }
- if (this.animationStarted = i,
- !i) {
- if (this.disposeOnEnd)
- for (t = this._scene._activeAnimatables.indexOf(this),
- this._scene._activeAnimatables.splice(t, 1),
- t = 0; t < n.length; t++)
- n[t].dispose();
- this._raiseOnAnimationEnd(),
- this.disposeOnEnd && (this.onAnimationEnd = null,
- this.onAnimationLoop = null,
- this.onAnimationLoopObservable.clear(),
- this.onAnimationEndObservable.clear())
- }
- return i
- }
- ,
- e
- }();
- mn.prototype._animate = function() {
- if (this.animationsEnabled) {
- var e = ct.Now;
- if (!this._animationTimeLast) {
- if (this._pendingData.length > 0)
- return;
- this._animationTimeLast = e
- }
- this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (e - this._animationTimeLast) * this.animationTimeScale,
- this._animationTimeLast = e;
- var t = this._activeAnimatables;
- if (0 !== t.length) {
- this._animationTime += this.deltaTime;
- for (var i = this._animationTime, n = 0; n < t.length; n++) {
- var r = t[n];
- !r._animate(i) && r.disposeOnEnd && n--
- }
- this._processLateAnimationBindings()
- }
- }
- }
- ,
- mn.prototype.beginWeightedAnimation = function(e, t, i, n, r, o, a, s, l, c, u) {
- void 0 === n && (n = 1),
- void 0 === o && (o = 1),
- void 0 === u && (u = !1);
- var h = this.beginAnimation(e, t, i, r, o, a, s, !1, l, c, u);
- return h.weight = n,
- h
- }
- ,
- mn.prototype.beginAnimation = function(e, t, i, n, r, o, a, s, l, c, u) {
- void 0 === r && (r = 1),
- void 0 === s && (s = !0),
- void 0 === u && (u = !1),
- t > i && r > 0 && (r *= -1),
- s && this.stopAnimation(e, void 0, l),
- a || (a = new bn(this,e,t,i,n,r,o,void 0,c,u));
- var h = !l || l(e);
- if (e.animations && h && a.appendAnimations(e, e.animations),
- e.getAnimatables)
- for (var d = e.getAnimatables(), p = 0; p < d.length; p++)
- this.beginAnimation(d[p], t, i, n, r, o, a, s, l, c);
- return a.reset(),
- a
- }
- ,
- mn.prototype.beginHierarchyAnimation = function(e, t, i, n, r, o, a, s, l, c, u, h) {
- void 0 === o && (o = 1),
- void 0 === l && (l = !0),
- void 0 === h && (h = !1);
- var d = e.getDescendants(t)
- , p = [];
- p.push(this.beginAnimation(e, i, n, r, o, a, s, l, c, void 0, h));
- for (var f = 0, _ = d; f < _.length; f++) {
- var m = _[f];
- p.push(this.beginAnimation(m, i, n, r, o, a, s, l, c, void 0, h))
- }
- return p
- }
- ,
- mn.prototype.beginDirectAnimation = function(e, t, i, n, r, o, a, s, l) {
- if (void 0 === l && (l = !1),
- void 0 === o && (o = 1),
- i > n && o > 0)
- o *= -1;
- else if (n > i && o < 0) {
- var c = n;
- n = i,
- i = c
- }
- return new bn(this,e,i,n,r,o,a,t,s,l)
- }
- ,
- mn.prototype.beginDirectHierarchyAnimation = function(e, t, i, n, r, o, a, s, l, c) {
- void 0 === c && (c = !1);
- var u = e.getDescendants(t)
- , h = [];
- h.push(this.beginDirectAnimation(e, i, n, r, o, a, s, l, c));
- for (var d = 0, p = u; d < p.length; d++) {
- var f = p[d];
- h.push(this.beginDirectAnimation(f, i, n, r, o, a, s, l, c))
- }
- return h
- }
- ,
- mn.prototype.getAnimatableByTarget = function(e) {
- for (var t = 0; t < this._activeAnimatables.length; t++)
- if (this._activeAnimatables[t].target === e)
- return this._activeAnimatables[t];
- return null
- }
- ,
- mn.prototype.getAllAnimatablesByTarget = function(e) {
- for (var t = [], i = 0; i < this._activeAnimatables.length; i++)
- this._activeAnimatables[i].target === e && t.push(this._activeAnimatables[i]);
- return t
- }
- ,
- mn.prototype.stopAnimation = function(e, t, i) {
- for (var n = 0, r = this.getAllAnimatablesByTarget(e); n < r.length; n++)
- r[n].stop(t, i)
- }
- ,
- mn.prototype.stopAllAnimations = function() {
- if (this._activeAnimatables) {
- for (var e = 0; e < this._activeAnimatables.length; e++)
- this._activeAnimatables[e].stop();
- this._activeAnimatables = []
- }
- for (var t = 0, i = this.animationGroups; t < i.length; t++)
- i[t].stop()
- }
- ,
- mn.prototype._registerTargetForLateAnimationBinding = function(e, t) {
- var i = e.target;
- this._registeredForLateAnimationBindings.pushNoDuplicate(i),
- i._lateAnimationHolders || (i._lateAnimationHolders = {}),
- i._lateAnimationHolders[e.targetPath] || (i._lateAnimationHolders[e.targetPath] = {
- totalWeight: 0,
- totalAdditiveWeight: 0,
- animations: [],
- additiveAnimations: [],
- originalValue: t
- }),
- e.isAdditive ? (i._lateAnimationHolders[e.targetPath].additiveAnimations.push(e),
- i._lateAnimationHolders[e.targetPath].totalAdditiveWeight += e.weight) : (i._lateAnimationHolders[e.targetPath].animations.push(e),
- i._lateAnimationHolders[e.targetPath].totalWeight += e.weight)
- }
- ,
- mn.prototype._processLateAnimationBindingsForMatrices = function(e) {
- if (0 === e.totalWeight && 0 === e.totalAdditiveWeight)
- return e.originalValue;
- var t = 1
- , i = I.Vector3[0]
- , n = I.Vector3[1]
- , r = I.Quaternion[0]
- , o = 0
- , a = e.animations[0]
- , s = e.originalValue
- , l = 1
- , c = !1;
- if (e.totalWeight < 1)
- l = 1 - e.totalWeight,
- s.decompose(n, r, i);
- else {
- if (o = 1,
- t = e.totalWeight,
- 1 == (l = a.weight / t)) {
- if (!e.totalAdditiveWeight)
- return a.currentValue;
- c = !0
- }
- a.currentValue.decompose(n, r, i)
- }
- if (!c) {
- n.scaleInPlace(l),
- i.scaleInPlace(l),
- r.scaleInPlace(l);
- for (var u = o; u < e.animations.length; u++)
- if (0 !== (f = e.animations[u]).weight) {
- l = f.weight / t;
- var h = I.Vector3[2]
- , d = I.Vector3[3]
- , p = I.Quaternion[1];
- f.currentValue.decompose(d, p, h),
- d.scaleAndAddToRef(l, n),
- p.scaleAndAddToRef(l, r),
- h.scaleAndAddToRef(l, i)
- }
- }
- for (u = 0; u < e.additiveAnimations.length; u++) {
- var f;
- 0 !== (f = e.additiveAnimations[u]).weight && (h = I.Vector3[2],
- d = I.Vector3[3],
- p = I.Quaternion[1],
- f.currentValue.decompose(d, p, h),
- d.multiplyToRef(n, d),
- x.LerpToRef(n, d, f.weight, n),
- r.multiplyToRef(p, p),
- C.SlerpToRef(r, p, f.weight, r),
- h.scaleAndAddToRef(f.weight, i))
- }
- var _ = a ? a._animationState.workValue : I.Matrix[0].clone();
- return P.ComposeToRef(n, r, i, _),
- _
- }
- ,
- mn.prototype._processLateAnimationBindingsForQuaternions = function(e, t) {
- if (0 === e.totalWeight && 0 === e.totalAdditiveWeight)
- return t;
- var i = e.animations[0]
- , n = e.originalValue
- , r = t;
- if (0 === e.totalWeight && e.totalAdditiveWeight > 0)
- r.copyFrom(n);
- else if (1 === e.animations.length) {
- if (C.SlerpToRef(n, i.currentValue, Math.min(1, e.totalWeight), r),
- 0 === e.totalAdditiveWeight)
- return r
- } else if (e.animations.length > 1) {
- var o = 1
- , a = void 0
- , s = void 0;
- if (e.totalWeight < 1) {
- var l = 1 - e.totalWeight;
- s = [],
- (a = []).push(n),
- s.push(l)
- } else {
- if (2 === e.animations.length && (C.SlerpToRef(e.animations[0].currentValue, e.animations[1].currentValue, e.animations[1].weight / e.totalWeight, t),
- 0 === e.totalAdditiveWeight))
- return t;
- a = [],
- s = [],
- o = e.totalWeight
- }
- for (var c = 0; c < e.animations.length; c++) {
- var u = e.animations[c];
- a.push(u.currentValue),
- s.push(u.weight / o)
- }
- for (var h = 0, d = 0; d < a.length; )
- d ? (h += s[d],
- C.SlerpToRef(r, a[d], s[d] / h, r),
- d++) : (C.SlerpToRef(a[d], a[d + 1], s[d + 1] / (s[d] + s[d + 1]), t),
- r = t,
- h = s[d] + s[d + 1],
- d += 2)
- }
- for (c = 0; c < e.additiveAnimations.length; c++)
- 0 !== (u = e.additiveAnimations[c]).weight && (r.multiplyToRef(u.currentValue, I.Quaternion[0]),
- C.SlerpToRef(r, I.Quaternion[0], u.weight, r));
- return r
- }
- ,
- mn.prototype._processLateAnimationBindings = function() {
- if (this._registeredForLateAnimationBindings.length) {
- for (var e = 0; e < this._registeredForLateAnimationBindings.length; e++) {
- var t = this._registeredForLateAnimationBindings.data[e];
- for (var i in t._lateAnimationHolders) {
- var n = t._lateAnimationHolders[i]
- , r = n.animations[0]
- , o = n.originalValue
- , a = Qe.AllowMatrixDecomposeForInterpolation && o.m
- , s = t[i];
- if (a)
- s = this._processLateAnimationBindingsForMatrices(n);
- else if (void 0 !== o.w)
- s = this._processLateAnimationBindingsForQuaternions(n, s || C.Identity());
- else {
- var l = 0
- , c = 1;
- n.totalWeight < 1 ? s = r && o.scale ? o.scale(1 - n.totalWeight) : r ? o * (1 - n.totalWeight) : o.clone ? o.clone() : o : r && (c = n.totalWeight,
- s = 1 != (d = r.weight / c) ? r.currentValue.scale ? r.currentValue.scale(d) : r.currentValue * d : r.currentValue,
- l = 1);
- for (var u = l; u < n.animations.length; u++)
- (d = (h = n.animations[u]).weight / c) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d);
- for (u = 0; u < n.additiveAnimations.length; u++) {
- var h, d;
- (d = (h = n.additiveAnimations[u]).weight) && (h.currentValue.scaleAndAddToRef ? h.currentValue.scaleAndAddToRef(d, s) : s += h.currentValue * d)
- }
- }
- t[i] = s
- }
- t._lateAnimationHolders = {}
- }
- this._registeredForLateAnimationBindings.reset()
- }
- }
- ,
- yn.prototype.copyAnimationRange = function(e, t, i, n, r) {
- void 0 === n && (n = !1),
- void 0 === r && (r = null),
- 0 === this.animations.length && (this.animations.push(new Qe(this.name,"_matrix",e.animations[0].framePerSecond,Qe.ANIMATIONTYPE_MATRIX,0)),
- this.animations[0].setKeys([]));
- var o = e.animations[0].getRange(t);
- if (!o)
- return !1;
- for (var a, s, l, c = o.from, u = o.to, h = e.animations[0].getKeys(), d = e.length, p = e.getParent(), f = this.getParent(), _ = n && p && d && this.length && d !== this.length, m = _ && f && p ? f.length / p.length : 1, g = n && !f && r && (1 !== r.x || 1 !== r.y || 1 !== r.z), v = this.animations[0].getKeys(), y = 0, b = h.length; y < b; y++)
- (a = h[y]).frame >= c && a.frame <= u && (n ? (l = a.value.clone(),
- _ ? (s = l.getTranslation(),
- l.setTranslation(s.scaleInPlace(m))) : g && r ? (s = l.getTranslation(),
- l.setTranslation(s.multiplyInPlace(r))) : l = a.value) : l = a.value,
- v.push({
- frame: a.frame + i,
- value: l
- }));
- return this.animations[0].createRange(t, c + i, u + i),
- !0
- }
- ;
- var Tn, En = function() {
- this.enableBlending = !1,
- this.blendingSpeed = .01,
- this.loopMode = Qe.ANIMATIONLOOPMODE_CYCLE
- };
- !function(e) {
- e[e.CW = 0] = "CW",
- e[e.CCW = 1] = "CCW"
- }(Tn || (Tn = {}));
- var Sn = function() {
- function e() {}
- return e.Interpolate = function(e, t, i, n, r) {
- for (var o = 1 - 3 * n + 3 * t, a = 3 * n - 6 * t, s = 3 * t, l = e, c = 0; c < 5; c++) {
- var u = l * l;
- l -= 1 / (3 * o * u + 2 * a * l + s) * (o * (u * l) + a * u + s * l - e),
- l = Math.min(1, Math.max(0, l))
- }
- return 3 * Math.pow(1 - l, 2) * l * i + 3 * (1 - l) * Math.pow(l, 2) * r + Math.pow(l, 3)
- }
- ,
- e
- }()
- , An = function() {
- function e(e) {
- this._radians = e,
- this._radians < 0 && (this._radians += 2 * Math.PI)
- }
- return e.prototype.degrees = function() {
- return 180 * this._radians / Math.PI
- }
- ,
- e.prototype.radians = function() {
- return this._radians
- }
- ,
- e.BetweenTwoPoints = function(t, i) {
- var n = i.subtract(t);
- return new e(Math.atan2(n.y, n.x))
- }
- ,
- e.FromRadians = function(t) {
- return new e(t)
- }
- ,
- e.FromDegrees = function(t) {
- return new e(t * Math.PI / 180)
- }
- ,
- e
- }()
- , xn = function(e, t, i) {
- this.startPoint = e,
- this.midPoint = t,
- this.endPoint = i;
- var n = Math.pow(t.x, 2) + Math.pow(t.y, 2)
- , r = (Math.pow(e.x, 2) + Math.pow(e.y, 2) - n) / 2
- , o = (n - Math.pow(i.x, 2) - Math.pow(i.y, 2)) / 2
- , a = (e.x - t.x) * (t.y - i.y) - (t.x - i.x) * (e.y - t.y);
- this.centerPoint = new A((r * (t.y - i.y) - o * (e.y - t.y)) / a,((e.x - t.x) * o - (t.x - i.x) * r) / a),
- this.radius = this.centerPoint.subtract(this.startPoint).length(),
- this.startAngle = An.BetweenTwoPoints(this.centerPoint, this.startPoint);
- var s = this.startAngle.degrees()
- , l = An.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees()
- , c = An.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
- l - s > 180 && (l -= 360),
- l - s < -180 && (l += 360),
- c - l > 180 && (c -= 360),
- c - l < -180 && (c += 360),
- this.orientation = l - s < 0 ? Tn.CW : Tn.CCW,
- this.angle = An.FromDegrees(this.orientation === Tn.CW ? s - c : c - s)
- }
- , Rn = function() {
- function e(e, t) {
- this._points = new Array,
- this._length = 0,
- this.closed = !1,
- this._points.push(new A(e,t))
- }
- return e.prototype.addLineTo = function(e, t) {
- if (this.closed)
- return this;
- var i = new A(e,t)
- , n = this._points[this._points.length - 1];
- return this._points.push(i),
- this._length += i.subtract(n).length(),
- this
- }
- ,
- e.prototype.addArcTo = function(e, t, i, n, r) {
- if (void 0 === r && (r = 36),
- this.closed)
- return this;
- var o = this._points[this._points.length - 1]
- , a = new A(e,t)
- , s = new A(i,n)
- , l = new xn(o,a,s)
- , c = l.angle.radians() / r;
- l.orientation === Tn.CW && (c *= -1);
- for (var u = l.startAngle.radians() + c, h = 0; h < r; h++) {
- var d = Math.cos(u) * l.radius + l.centerPoint.x
- , p = Math.sin(u) * l.radius + l.centerPoint.y;
- this.addLineTo(d, p),
- u += c
- }
- return this
- }
- ,
- e.prototype.close = function() {
- return this.closed = !0,
- this
- }
- ,
- e.prototype.length = function() {
- var e = this._length;
- if (this.closed) {
- var t = this._points[this._points.length - 1];
- e += this._points[0].subtract(t).length()
- }
- return e
- }
- ,
- e.prototype.getPoints = function() {
- return this._points
- }
- ,
- e.prototype.getPointAtLengthPosition = function(e) {
- if (e < 0 || e > 1)
- return A.Zero();
- for (var t = e * this.length(), i = 0, n = 0; n < this._points.length; n++) {
- var r = (n + 1) % this._points.length
- , o = this._points[n]
- , a = this._points[r].subtract(o)
- , s = a.length() + i;
- if (t >= i && t <= s) {
- var l = a.normalize()
- , c = t - i;
- return new A(o.x + l.x * c,o.y + l.y * c)
- }
- i = s
- }
- return A.Zero()
- }
- ,
- e.StartingAt = function(t, i) {
- return new e(t,i)
- }
- ,
- e
- }()
- , Cn = function() {
- function e(e, t, i, n) {
- void 0 === t && (t = null),
- void 0 === n && (n = !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: x.Zero(),
- previousPointArrayIndex: 0,
- position: 0,
- subPosition: 0,
- interpolateReady: !1,
- interpolationMatrix: P.Identity()
- };
- for (var r = 0; r < e.length; r++)
- this._curve[r] = e[r].clone();
- this._raw = i || !1,
- this._alignTangentsWithPath = n,
- this._compute(t, n)
- }
- return e.prototype.getCurve = function() {
- return this._curve
- }
- ,
- e.prototype.getPoints = function() {
- return this._curve
- }
- ,
- e.prototype.length = function() {
- return this._distances[this._distances.length - 1]
- }
- ,
- e.prototype.getTangents = function() {
- return this._tangents
- }
- ,
- e.prototype.getNormals = function() {
- return this._normals
- }
- ,
- e.prototype.getBinormals = function() {
- return this._binormals
- }
- ,
- e.prototype.getDistances = function() {
- return this._distances
- }
- ,
- e.prototype.getPointAt = function(e) {
- return this._updatePointAtData(e).point
- }
- ,
- e.prototype.getTangentAt = function(e, t) {
- return void 0 === t && (t = !1),
- this._updatePointAtData(e, t),
- t ? x.TransformCoordinates(x.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex]
- }
- ,
- e.prototype.getNormalAt = function(e, t) {
- return void 0 === t && (t = !1),
- this._updatePointAtData(e, t),
- t ? x.TransformCoordinates(x.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex]
- }
- ,
- e.prototype.getBinormalAt = function(e, t) {
- return void 0 === t && (t = !1),
- this._updatePointAtData(e, t),
- t ? x.TransformCoordinates(x.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex]
- }
- ,
- e.prototype.getDistanceAt = function(e) {
- return this.length() * e
- }
- ,
- e.prototype.getPreviousPointIndexAt = function(e) {
- return this._updatePointAtData(e),
- this._pointAtData.previousPointArrayIndex
- }
- ,
- e.prototype.getSubPositionAt = function(e) {
- return this._updatePointAtData(e),
- this._pointAtData.subPosition
- }
- ,
- e.prototype.getClosestPositionTo = function(e) {
- for (var t = Number.MAX_VALUE, i = 0, n = 0; n < this._curve.length - 1; n++) {
- var r = this._curve[n + 0]
- , o = this._curve[n + 1].subtract(r).normalize()
- , a = this._distances[n + 1] - this._distances[n + 0]
- , s = Math.min(Math.max(x.Dot(o, e.subtract(r).normalize()), 0) * x.Distance(r, e) / a, 1)
- , l = x.Distance(r.add(o.scale(s * a)), e);
- l < t && (t = l,
- i = (this._distances[n + 0] + a * s) / this.length())
- }
- return i
- }
- ,
- e.prototype.slice = function(t, i) {
- if (void 0 === t && (t = 0),
- void 0 === i && (i = 1),
- t < 0 && (t = 1 - -1 * t % 1),
- i < 0 && (i = 1 - -1 * i % 1),
- t > i) {
- var n = t;
- t = i,
- i = n
- }
- var r = this.getCurve()
- , o = this.getPointAt(t)
- , a = this.getPreviousPointIndexAt(t)
- , s = this.getPointAt(i)
- , l = this.getPreviousPointIndexAt(i) + 1
- , c = [];
- return 0 !== t && (a++,
- c.push(o)),
- c.push.apply(c, r.slice(a, l)),
- 1 === i && 1 !== t || c.push(s),
- new e(c,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)
- }
- ,
- e.prototype.update = function(e, t, i) {
- void 0 === t && (t = null),
- void 0 === i && (i = !1);
- for (var n = 0; n < e.length; n++)
- this._curve[n].x = e[n].x,
- this._curve[n].y = e[n].y,
- this._curve[n].z = e[n].z;
- return this._compute(t, i),
- this
- }
- ,
- e.prototype._compute = function(e, t) {
- void 0 === t && (t = !1);
- var i = this._curve.length;
- if (!(i < 2)) {
- this._tangents[0] = this._getFirstNonNullVector(0),
- this._raw || this._tangents[0].normalize(),
- this._tangents[i - 1] = this._curve[i - 1].subtract(this._curve[i - 2]),
- this._raw || this._tangents[i - 1].normalize();
- var n, r, o, a, s, l = this._tangents[0], c = this._normalVector(l, e);
- this._normals[0] = c,
- this._raw || this._normals[0].normalize(),
- this._binormals[0] = x.Cross(l, this._normals[0]),
- this._raw || this._binormals[0].normalize(),
- this._distances[0] = 0;
- for (var u = 1; u < i; u++)
- n = this._getLastNonNullVector(u),
- u < i - 1 && (r = this._getFirstNonNullVector(u),
- this._tangents[u] = t ? r : n.add(r),
- this._tangents[u].normalize()),
- this._distances[u] = this._distances[u - 1] + this._curve[u].subtract(this._curve[u - 1]).length(),
- o = this._tangents[u],
- s = this._binormals[u - 1],
- this._normals[u] = x.Cross(s, o),
- this._raw || (0 === this._normals[u].length() ? (a = this._normals[u - 1],
- this._normals[u] = a.clone()) : this._normals[u].normalize()),
- this._binormals[u] = x.Cross(o, this._normals[u]),
- this._raw || this._binormals[u].normalize();
- this._pointAtData.id = NaN
- }
- }
- ,
- e.prototype._getFirstNonNullVector = function(e) {
- for (var t = 1, i = this._curve[e + t].subtract(this._curve[e]); 0 === i.length() && e + t + 1 < this._curve.length; )
- t++,
- i = this._curve[e + t].subtract(this._curve[e]);
- return i
- }
- ,
- e.prototype._getLastNonNullVector = function(e) {
- for (var t = 1, i = this._curve[e].subtract(this._curve[e - t]); 0 === i.length() && e > t + 1; )
- t++,
- i = this._curve[e].subtract(this._curve[e - t]);
- return i
- }
- ,
- e.prototype._normalVector = function(e, t) {
- var i, n = e.length();
- if (0 === n && (n = 1),
- null == t) {
- var r;
- r = d.WithinEpsilon(Math.abs(e.y) / n, 1, m) ? d.WithinEpsilon(Math.abs(e.x) / n, 1, m) ? d.WithinEpsilon(Math.abs(e.z) / n, 1, m) ? x.Zero() : new x(0,0,1) : new x(1,0,0) : new x(0,-1,0),
- i = x.Cross(e, r)
- } else
- i = x.Cross(e, t),
- x.CrossToRef(i, e, i);
- return i.normalize(),
- i
- }
- ,
- e.prototype._updatePointAtData = function(e, t) {
- if (void 0 === t && (t = !1),
- this._pointAtData.id === e)
- return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(),
- this._pointAtData;
- this._pointAtData.id = e;
- var i = this.getPoints();
- if (e <= 0)
- return this._setPointAtData(0, 0, i[0], 0, t);
- if (e >= 1)
- return this._setPointAtData(1, 1, i[i.length - 1], i.length - 1, t);
- for (var n, r = i[0], o = 0, a = e * this.length(), s = 1; s < i.length; s++) {
- n = i[s];
- var l = x.Distance(r, n);
- if ((o += l) === a)
- return this._setPointAtData(e, 1, n, s, t);
- if (o > a) {
- var c = (o - a) / l
- , u = r.subtract(n)
- , h = n.add(u.scaleInPlace(c));
- return this._setPointAtData(e, 1 - c, h, s - 1, t)
- }
- r = n
- }
- return this._pointAtData
- }
- ,
- e.prototype._setPointAtData = function(e, t, i, n, r) {
- return this._pointAtData.point = i,
- this._pointAtData.position = e,
- this._pointAtData.subPosition = t,
- this._pointAtData.previousPointArrayIndex = n,
- this._pointAtData.interpolateReady = r,
- r && this._updateInterpolationMatrix(),
- this._pointAtData
- }
- ,
- e.prototype._updateInterpolationMatrix = function() {
- this._pointAtData.interpolationMatrix = P.Identity();
- var e = this._pointAtData.previousPointArrayIndex;
- if (e !== this._tangents.length - 1) {
- var t = e + 1
- , i = this._tangents[e].clone()
- , n = this._normals[e].clone()
- , r = this._binormals[e].clone()
- , o = this._tangents[t].clone()
- , a = this._normals[t].clone()
- , s = this._binormals[t].clone()
- , l = C.RotationQuaternionFromAxis(n, r, i)
- , c = C.RotationQuaternionFromAxis(a, s, o);
- C.Slerp(l, c, this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)
- }
- }
- ,
- e
- }()
- , Pn = function() {
- function e(e) {
- this._length = 0,
- this._points = e,
- this._length = this._computeLength(e)
- }
- return e.CreateQuadraticBezier = function(t, i, n, r) {
- r = r > 2 ? r : 3;
- for (var o = new Array, a = function(e, t, i, n) {
- return (1 - e) * (1 - e) * t + 2 * e * (1 - e) * i + e * e * n
- }, s = 0; s <= r; s++)
- o.push(new x(a(s / r, t.x, i.x, n.x),a(s / r, t.y, i.y, n.y),a(s / r, t.z, i.z, n.z)));
- return new e(o)
- }
- ,
- e.CreateCubicBezier = function(t, i, n, r, o) {
- o = o > 3 ? o : 4;
- for (var a = new Array, s = function(e, t, i, n, r) {
- return (1 - e) * (1 - e) * (1 - e) * t + 3 * e * (1 - e) * (1 - e) * i + 3 * e * e * (1 - e) * n + e * e * e * r
- }, l = 0; l <= o; l++)
- a.push(new x(s(l / o, t.x, i.x, n.x, r.x),s(l / o, t.y, i.y, n.y, r.y),s(l / o, t.z, i.z, n.z, r.z)));
- return new e(a)
- }
- ,
- e.CreateHermiteSpline = function(t, i, n, r, o) {
- for (var a = new Array, s = 1 / o, l = 0; l <= o; l++)
- a.push(x.Hermite(t, i, n, r, l * s));
- return new e(a)
- }
- ,
- e.CreateCatmullRomSpline = function(t, i, n) {
- var r = new Array
- , o = 1 / i
- , a = 0;
- if (n) {
- for (var s = t.length, l = 0; l < s; l++) {
- a = 0;
- for (var c = 0; c < i; c++)
- r.push(x.CatmullRom(t[l % s], t[(l + 1) % s], t[(l + 2) % s], t[(l + 3) % s], a)),
- a += o
- }
- r.push(r[0])
- } else {
- var u = new Array;
- for (u.push(t[0].clone()),
- Array.prototype.push.apply(u, t),
- u.push(t[t.length - 1].clone()),
- l = 0; l < u.length - 3; l++)
- for (a = 0,
- c = 0; c < i; c++)
- r.push(x.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a)),
- a += o;
- l--,
- r.push(x.CatmullRom(u[l], u[l + 1], u[l + 2], u[l + 3], a))
- }
- return new e(r)
- }
- ,
- e.prototype.getPoints = function() {
- return this._points
- }
- ,
- e.prototype.length = function() {
- return this._length
- }
- ,
- e.prototype.continue = function(t) {
- for (var i = this._points[this._points.length - 1], n = this._points.slice(), r = t.getPoints(), o = 1; o < r.length; o++)
- n.push(r[o].subtract(r[0]).add(i));
- return new e(n)
- }
- ,
- e.prototype._computeLength = function(e) {
- for (var t = 0, i = 1; i < e.length; i++)
- t += e[i].subtract(e[i - 1]).length();
- return t
- }
- ,
- e
- }()
- , Mn = function() {
- function e() {
- this._easingMode = e.EASINGMODE_EASEIN
- }
- return e.prototype.setEasingMode = function(e) {
- var t = Math.min(Math.max(e, 0), 2);
- this._easingMode = t
- }
- ,
- e.prototype.getEasingMode = function() {
- return this._easingMode
- }
- ,
- e.prototype.easeInCore = function(e) {
- throw new Error("You must implement this method")
- }
- ,
- e.prototype.ease = function(t) {
- switch (this._easingMode) {
- case e.EASINGMODE_EASEIN:
- return this.easeInCore(t);
- case e.EASINGMODE_EASEOUT:
- return 1 - this.easeInCore(1 - t)
- }
- return t >= .5 ? .5 * (1 - this.easeInCore(2 * (1 - t))) + .5 : .5 * this.easeInCore(2 * t)
- }
- ,
- e.EASINGMODE_EASEIN = 0,
- e.EASINGMODE_EASEOUT = 1,
- e.EASINGMODE_EASEINOUT = 2,
- e
- }()
- , In = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return e = Math.max(0, Math.min(1, e)),
- 1 - Math.sqrt(1 - e * e)
- }
- ,
- t
- }(Mn)
- , On = function(e) {
- function t(t) {
- void 0 === t && (t = 1);
- var i = e.call(this) || this;
- return i.amplitude = t,
- i
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- var t = Math.max(0, this.amplitude);
- return Math.pow(e, 3) - e * t * Math.sin(3.141592653589793 * e)
- }
- ,
- t
- }(Mn)
- , Dn = function(e) {
- function t(t, i) {
- void 0 === t && (t = 3),
- void 0 === i && (i = 2);
- var n = e.call(this) || this;
- return n.bounces = t,
- n.bounciness = i,
- n
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- var t = Math.max(0, this.bounces)
- , i = this.bounciness;
- i <= 1 && (i = 1.001);
- var n = Math.pow(i, t)
- , r = 1 - i
- , o = (1 - n) / r + .5 * n
- , a = e * o
- , s = Math.log(-a * (1 - i) + 1) / Math.log(i)
- , l = Math.floor(s)
- , c = l + 1
- , u = (1 - Math.pow(i, l)) / (r * o)
- , h = .5 * (u + (1 - Math.pow(i, c)) / (r * o))
- , d = e - h
- , p = h - u;
- return -Math.pow(1 / i, t - l) / (p * p) * (d - p) * (d + p)
- }
- ,
- t
- }(Mn)
- , Nn = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return e * e * e
- }
- ,
- t
- }(Mn)
- , Ln = function(e) {
- function t(t, i) {
- void 0 === t && (t = 3),
- void 0 === i && (i = 3);
- var n = e.call(this) || this;
- return n.oscillations = t,
- n.springiness = i,
- n
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- var t = Math.max(0, this.oscillations)
- , i = Math.max(0, this.springiness);
- return (0 == i ? e : (Math.exp(i * e) - 1) / (Math.exp(i) - 1)) * Math.sin((6.283185307179586 * t + 1.5707963267948966) * e)
- }
- ,
- t
- }(Mn)
- , Fn = function(e) {
- function t(t) {
- void 0 === t && (t = 2);
- var i = e.call(this) || this;
- return i.exponent = t,
- i
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return this.exponent <= 0 ? e : (Math.exp(this.exponent * e) - 1) / (Math.exp(this.exponent) - 1)
- }
- ,
- t
- }(Mn)
- , wn = function(e) {
- function t(t) {
- void 0 === t && (t = 2);
- var i = e.call(this) || this;
- return i.power = t,
- i
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- var t = Math.max(0, this.power);
- return Math.pow(e, t)
- }
- ,
- t
- }(Mn)
- , Bn = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return e * e
- }
- ,
- t
- }(Mn)
- , Un = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return e * e * e * e
- }
- ,
- t
- }(Mn)
- , Vn = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return e * e * e * e * e
- }
- ,
- t
- }(Mn)
- , kn = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return 1 - Math.sin(1.5707963267948966 * (1 - e))
- }
- ,
- t
- }(Mn)
- , Gn = function(e) {
- function t(t, i, n, r) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- void 0 === n && (n = 1),
- void 0 === r && (r = 1);
- var o = e.call(this) || this;
- return o.x1 = t,
- o.y1 = i,
- o.x2 = n,
- o.y2 = r,
- o
- }
- return U(t, e),
- t.prototype.easeInCore = function(e) {
- return Sn.Interpolate(e, this.x1, this.y1, this.x2, this.y2)
- }
- ,
- t
- }(Mn)
- , zn = function() {
- function e(e, t, i) {
- this.frame = e,
- this.action = t,
- this.onlyOnce = i,
- this.isDone = !1
- }
- return e.prototype._clone = function() {
- return new e(this.frame,this.action,this.onlyOnce)
- }
- ,
- e
- }()
- , Wn = function() {
- function e() {}
- return e.prototype.getClassName = function() {
- return "TargetedAnimation"
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.animation = this.animation.serialize(),
- e.targetId = this.target.id,
- e
- }
- ,
- e
- }()
- , Hn = function() {
- function e(e, t) {
- void 0 === t && (t = 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 h,
- this.onAnimationLoopObservable = new h,
- this.onAnimationGroupLoopObservable = new h,
- this.onAnimationGroupEndObservable = new h,
- this.onAnimationGroupPauseObservable = new h,
- this.onAnimationGroupPlayObservable = new h,
- this.metadata = null,
- this._scene = t || E.LastCreatedScene,
- this.uniqueId = this._scene.getUniqueId(),
- this._scene.addAnimationGroup(this)
- }
- return Object.defineProperty(e.prototype, "from", {
- get: function() {
- return this._from
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "to", {
- get: function() {
- return this._to
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isStarted", {
- get: function() {
- return this._isStarted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isPlaying", {
- get: function() {
- return this._isStarted && !this._isPaused
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "speedRatio", {
- get: function() {
- return this._speedRatio
- },
- set: function(e) {
- if (this._speedRatio !== e) {
- this._speedRatio = e;
- for (var t = 0; t < this._animatables.length; t++)
- this._animatables[t].speedRatio = this._speedRatio
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "loopAnimation", {
- get: function() {
- return this._loopAnimation
- },
- set: function(e) {
- if (this._loopAnimation !== e) {
- this._loopAnimation = e;
- for (var t = 0; t < this._animatables.length; t++)
- this._animatables[t].loopAnimation = this._loopAnimation
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isAdditive", {
- get: function() {
- return this._isAdditive
- },
- set: function(e) {
- if (this._isAdditive !== e) {
- this._isAdditive = e;
- for (var t = 0; t < this._animatables.length; t++)
- this._animatables[t].isAdditive = this._isAdditive
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "targetedAnimations", {
- get: function() {
- return this._targetedAnimations
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "animatables", {
- get: function() {
- return this._animatables
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "children", {
- get: function() {
- return this._targetedAnimations
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addTargetedAnimation = function(e, t) {
- var i = new Wn;
- i.animation = e,
- i.target = t;
- var n = e.getKeys();
- return this._from > n[0].frame && (this._from = n[0].frame),
- this._to < n[n.length - 1].frame && (this._to = n[n.length - 1].frame),
- this._targetedAnimations.push(i),
- i
- }
- ,
- e.prototype.normalize = function(e, t) {
- void 0 === e && (e = null),
- void 0 === t && (t = null),
- null == e && (e = this._from),
- null == t && (t = this._to);
- for (var i = 0; i < this._targetedAnimations.length; i++) {
- var n = this._targetedAnimations[i].animation.getKeys()
- , r = n[0]
- , o = n[n.length - 1];
- if (r.frame > e) {
- var a = {
- frame: e,
- value: r.value,
- inTangent: r.inTangent,
- outTangent: r.outTangent,
- interpolation: r.interpolation
- };
- n.splice(0, 0, a)
- }
- o.frame < t && (a = {
- frame: t,
- value: o.value,
- inTangent: o.inTangent,
- outTangent: o.outTangent,
- interpolation: o.interpolation
- },
- n.push(a))
- }
- return this._from = e,
- this._to = t,
- this
- }
- ,
- e.prototype._processLoop = function(e, t, i) {
- var n = this;
- e.onAnimationLoop = function() {
- n.onAnimationLoopObservable.notifyObservers(t),
- n._animationLoopFlags[i] || (n._animationLoopFlags[i] = !0,
- n._animationLoopCount++,
- n._animationLoopCount === n._targetedAnimations.length && (n.onAnimationGroupLoopObservable.notifyObservers(n),
- n._animationLoopCount = 0,
- n._animationLoopFlags = []))
- }
- }
- ,
- e.prototype.start = function(e, t, i, n, r) {
- var o = this;
- if (void 0 === e && (e = !1),
- void 0 === t && (t = 1),
- this._isStarted || 0 === this._targetedAnimations.length)
- return this;
- this._loopAnimation = e,
- this._animationLoopCount = 0,
- this._animationLoopFlags = [];
- for (var a = function(a) {
- var l = s._targetedAnimations[a]
- , c = s._scene.beginDirectAnimation(l.target, [l.animation], void 0 !== i ? i : s._from, void 0 !== n ? n : s._to, e, t, void 0, void 0, void 0 !== r ? r : s._isAdditive);
- c.onAnimationEnd = function() {
- o.onAnimationEndObservable.notifyObservers(l),
- o._checkAnimationGroupEnded(c)
- }
- ,
- s._processLoop(c, l, a),
- s._animatables.push(c)
- }, s = this, l = 0; l < this._targetedAnimations.length; l++)
- a(l);
- return this._speedRatio = t,
- this._isStarted = !0,
- this._isPaused = !1,
- this.onAnimationGroupPlayObservable.notifyObservers(this),
- this
- }
- ,
- e.prototype.pause = function() {
- if (!this._isStarted)
- return this;
- this._isPaused = !0;
- for (var e = 0; e < this._animatables.length; e++)
- this._animatables[e].pause();
- return this.onAnimationGroupPauseObservable.notifyObservers(this),
- this
- }
- ,
- e.prototype.play = function(e) {
- return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (void 0 !== e && (this.loopAnimation = e),
- this.restart()) : (this.stop(),
- this.start(e, this._speedRatio)),
- this._isPaused = !1,
- this
- }
- ,
- e.prototype.reset = function() {
- if (!this._isStarted)
- return this.play(),
- this.goToFrame(0),
- this.stop(),
- this;
- for (var e = 0; e < this._animatables.length; e++)
- this._animatables[e].reset();
- return this
- }
- ,
- e.prototype.restart = function() {
- if (!this._isStarted)
- return this;
- for (var e = 0; e < this._animatables.length; e++)
- this._animatables[e].restart();
- return this.onAnimationGroupPlayObservable.notifyObservers(this),
- this
- }
- ,
- e.prototype.stop = function() {
- if (!this._isStarted)
- return this;
- for (var e = this._animatables.slice(), t = 0; t < e.length; t++)
- e[t].stop();
- return this._isStarted = !1,
- this
- }
- ,
- e.prototype.setWeightForAllAnimatables = function(e) {
- for (var t = 0; t < this._animatables.length; t++)
- this._animatables[t].weight = e;
- return this
- }
- ,
- e.prototype.syncAllAnimationsWith = function(e) {
- for (var t = 0; t < this._animatables.length; t++)
- this._animatables[t].syncWith(e);
- return this
- }
- ,
- e.prototype.goToFrame = function(e) {
- if (!this._isStarted)
- return this;
- for (var t = 0; t < this._animatables.length; t++)
- this._animatables[t].goToFrame(e);
- return this
- }
- ,
- e.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 t = this._parentContainer.animationGroups.indexOf(this);
- t > -1 && this._parentContainer.animationGroups.splice(t, 1),
- this._parentContainer = null
- }
- this.onAnimationEndObservable.clear(),
- this.onAnimationGroupEndObservable.clear(),
- this.onAnimationGroupPauseObservable.clear(),
- this.onAnimationGroupPlayObservable.clear(),
- this.onAnimationLoopObservable.clear(),
- this.onAnimationGroupLoopObservable.clear()
- }
- ,
- e.prototype._checkAnimationGroupEnded = function(e) {
- var t = this._animatables.indexOf(e);
- t > -1 && this._animatables.splice(t, 1),
- 0 === this._animatables.length && (this._isStarted = !1,
- this.onAnimationGroupEndObservable.notifyObservers(this))
- }
- ,
- e.prototype.clone = function(t, i, n) {
- void 0 === n && (n = !1);
- for (var r = new e(t || this.name,this._scene), o = 0, a = this._targetedAnimations; o < a.length; o++) {
- var s = a[o];
- r.addTargetedAnimation(n ? s.animation.clone() : s.animation, i ? i(s.target) : s.target)
- }
- return r
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- e.name = this.name,
- e.from = this.from,
- e.to = this.to,
- e.targetedAnimations = [];
- for (var t = 0; t < this.targetedAnimations.length; t++) {
- var i = this.targetedAnimations[t];
- e.targetedAnimations[t] = i.serialize()
- }
- return ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
- this.metadata && (e.metadata = this.metadata),
- e
- }
- ,
- e.Parse = function(t, i) {
- for (var n = new e(t.name,i), r = 0; r < t.targetedAnimations.length; r++) {
- var o = t.targetedAnimations[r]
- , a = Qe.Parse(o.animation)
- , s = o.targetId;
- if ("influence" === o.animation.property) {
- var l = i.getMorphTargetById(s);
- l && n.addTargetedAnimation(a, l)
- } else {
- var c = i.getNodeById(s);
- null != c && n.addTargetedAnimation(a, c)
- }
- }
- return null !== t.from && null !== t.to && n.normalize(t.from, t.to),
- ye && ye.AddTagsTo(n, t.tags),
- void 0 !== t.metadata && (n.metadata = t.metadata),
- n
- }
- ,
- e.MakeAnimationAdditive = function(e, t, i, n, r) {
- void 0 === t && (t = 0),
- void 0 === n && (n = !1);
- var o = e;
- n && (o = e.clone(r || o.name));
- for (var a = o.targetedAnimations, s = 0; s < a.length; s++) {
- var l = a[s];
- Qe.MakeAnimationAdditive(l.animation, t, i)
- }
- return o.isAdditive = !0,
- o
- }
- ,
- e.prototype.getClassName = function() {
- return "AnimationGroup"
- }
- ,
- e.prototype.toString = function(e) {
- var t = "Name: " + this.name;
- return t += ", type: " + this.getClassName(),
- e && (t += ", from: " + this._from,
- t += ", to: " + this._to,
- t += ", isStarted: " + this._isStarted,
- t += ", speedRatio: " + this._speedRatio,
- t += ", targetedAnimations length: " + this._targetedAnimations.length,
- t += ", animatables length: " + this._animatables),
- t
- }
- ,
- e
- }()
- , Xn = function() {
- function e(e) {
- this._path = e,
- this._onchange = new Array,
- this.value = 0,
- this.animations = new Array
- }
- return e.prototype.getPoint = function() {
- var e = this._path.getPointAtLengthPosition(this.value);
- return new x(e.x,0,e.y)
- }
- ,
- e.prototype.moveAhead = function(e) {
- return void 0 === e && (e = .002),
- this.move(e),
- this
- }
- ,
- e.prototype.moveBack = function(e) {
- return void 0 === e && (e = .002),
- this.move(-e),
- this
- }
- ,
- e.prototype.move = function(e) {
- if (Math.abs(e) > 1)
- throw "step size should be less than 1.";
- return this.value += e,
- this._ensureLimits(),
- this._raiseOnChange(),
- this
- }
- ,
- e.prototype._ensureLimits = function() {
- for (; this.value > 1; )
- this.value -= 1;
- for (; this.value < 0; )
- this.value += 1;
- return this
- }
- ,
- e.prototype._raiseOnChange = function() {
- var e = this;
- return this._onchange.forEach((function(t) {
- return t(e)
- }
- )),
- this
- }
- ,
- e.prototype.onchange = function(e) {
- return this._onchange.push(e),
- this
- }
- ,
- e
- }();
- function jn(e, t, i) {
- try {
- var n = e.next();
- n.done ? t(n) : n.value ? n.value.then((function() {
- n.value = void 0,
- t(n)
- }
- ), i) : t(n)
- } catch (e) {
- i(e)
- }
- }
- function Yn(e) {
- var t;
- return void 0 === e && (e = 25),
- function(i, n, r) {
- var o = performance.now();
- void 0 === t || o - t > e ? (t = o,
- setTimeout((function() {
- jn(i, n, r)
- }
- ), 0)) : jn(i, n, r)
- }
- }
- function Kn(e, t, i, n, r) {
- var o = function() {
- var a, s = function(e) {
- e.done ? i(e.value) : void 0 === a ? a = !0 : o()
- };
- do {
- a = void 0,
- r && r.aborted ? n(new Error("Aborted")) : t(e, s, n),
- void 0 === a && (a = !1)
- } while (a)
- };
- o()
- }
- function Qn(e, t) {
- var i;
- return Kn(e, jn, (function(e) {
- return i = e
- }
- ), (function(e) {
- throw e
- }
- ), t),
- i
- }
- function qn(e, t, i) {
- return new Promise((function(n, r) {
- Kn(e, t, n, r, i)
- }
- ))
- }
- function Zn(e, t) {
- return function() {
- for (var i = [], n = 0; n < arguments.length; n++)
- i[n] = arguments[n];
- return Qn(e.apply(void 0, i), t)
- }
- }
- function Jn(e, t, i) {
- return function() {
- for (var n = [], r = 0; r < arguments.length; r++)
- n[r] = arguments[r];
- return qn(e.apply(void 0, n), t, i)
- }
- }
- var $n = function() {
- function e() {
- this._applyTo = Zn(this._applyToCoroutine.bind(this))
- }
- return e.prototype.set = function(e, t) {
- switch (e.length || K.Warn("Setting vertex data kind '".concat(t, "' with an empty array")),
- t) {
- case Bi.PositionKind:
- this.positions = e;
- break;
- case Bi.NormalKind:
- this.normals = e;
- break;
- case Bi.TangentKind:
- this.tangents = e;
- break;
- case Bi.UVKind:
- this.uvs = e;
- break;
- case Bi.UV2Kind:
- this.uvs2 = e;
- break;
- case Bi.UV3Kind:
- this.uvs3 = e;
- break;
- case Bi.UV4Kind:
- this.uvs4 = e;
- break;
- case Bi.UV5Kind:
- this.uvs5 = e;
- break;
- case Bi.UV6Kind:
- this.uvs6 = e;
- break;
- case Bi.ColorKind:
- this.colors = e;
- break;
- case Bi.MatricesIndicesKind:
- this.matricesIndices = e;
- break;
- case Bi.MatricesWeightsKind:
- this.matricesWeights = e;
- break;
- case Bi.MatricesIndicesExtraKind:
- this.matricesIndicesExtra = e;
- break;
- case Bi.MatricesWeightsExtraKind:
- this.matricesWeightsExtra = e
- }
- }
- ,
- e.prototype.applyToMesh = function(e, t) {
- return this._applyTo(e, t, !1),
- this
- }
- ,
- e.prototype.applyToGeometry = function(e, t) {
- return this._applyTo(e, t, !1),
- this
- }
- ,
- e.prototype.updateMesh = function(e) {
- return this._update(e),
- this
- }
- ,
- e.prototype.updateGeometry = function(e) {
- return this._update(e),
- this
- }
- ,
- e.prototype._applyToCoroutine = function(e, t, i) {
- return void 0 === t && (t = !1),
- z(this, (function(n) {
- switch (n.label) {
- case 0:
- return this.positions ? (e.setVerticesData(Bi.PositionKind, this.positions, t),
- i ? [4] : [3, 2]) : [3, 2];
- case 1:
- n.sent(),
- n.label = 2;
- case 2:
- return this.normals ? (e.setVerticesData(Bi.NormalKind, this.normals, t),
- i ? [4] : [3, 4]) : [3, 4];
- case 3:
- n.sent(),
- n.label = 4;
- case 4:
- return this.tangents ? (e.setVerticesData(Bi.TangentKind, this.tangents, t),
- i ? [4] : [3, 6]) : [3, 6];
- case 5:
- n.sent(),
- n.label = 6;
- case 6:
- return this.uvs ? (e.setVerticesData(Bi.UVKind, this.uvs, t),
- i ? [4] : [3, 8]) : [3, 8];
- case 7:
- n.sent(),
- n.label = 8;
- case 8:
- return this.uvs2 ? (e.setVerticesData(Bi.UV2Kind, this.uvs2, t),
- i ? [4] : [3, 10]) : [3, 10];
- case 9:
- n.sent(),
- n.label = 10;
- case 10:
- return this.uvs3 ? (e.setVerticesData(Bi.UV3Kind, this.uvs3, t),
- i ? [4] : [3, 12]) : [3, 12];
- case 11:
- n.sent(),
- n.label = 12;
- case 12:
- return this.uvs4 ? (e.setVerticesData(Bi.UV4Kind, this.uvs4, t),
- i ? [4] : [3, 14]) : [3, 14];
- case 13:
- n.sent(),
- n.label = 14;
- case 14:
- return this.uvs5 ? (e.setVerticesData(Bi.UV5Kind, this.uvs5, t),
- i ? [4] : [3, 16]) : [3, 16];
- case 15:
- n.sent(),
- n.label = 16;
- case 16:
- return this.uvs6 ? (e.setVerticesData(Bi.UV6Kind, this.uvs6, t),
- i ? [4] : [3, 18]) : [3, 18];
- case 17:
- n.sent(),
- n.label = 18;
- case 18:
- return this.colors ? (e.setVerticesData(Bi.ColorKind, this.colors, t),
- i ? [4] : [3, 20]) : [3, 20];
- case 19:
- n.sent(),
- n.label = 20;
- case 20:
- return this.matricesIndices ? (e.setVerticesData(Bi.MatricesIndicesKind, this.matricesIndices, t),
- i ? [4] : [3, 22]) : [3, 22];
- case 21:
- n.sent(),
- n.label = 22;
- case 22:
- return this.matricesWeights ? (e.setVerticesData(Bi.MatricesWeightsKind, this.matricesWeights, t),
- i ? [4] : [3, 24]) : [3, 24];
- case 23:
- n.sent(),
- n.label = 24;
- case 24:
- return this.matricesIndicesExtra ? (e.setVerticesData(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t),
- i ? [4] : [3, 26]) : [3, 26];
- case 25:
- n.sent(),
- n.label = 26;
- case 26:
- return this.matricesWeightsExtra ? (e.setVerticesData(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t),
- i ? [4] : [3, 28]) : [3, 28];
- case 27:
- n.sent(),
- n.label = 28;
- case 28:
- return this.indices ? (e.setIndices(this.indices, null, t),
- i ? [4] : [3, 30]) : [3, 31];
- case 29:
- n.sent(),
- n.label = 30;
- case 30:
- return [3, 32];
- case 31:
- e.setIndices([], null),
- n.label = 32;
- case 32:
- return [2, this]
- }
- }
- ))
- }
- ,
- e.prototype._update = function(e, t, i) {
- return this.positions && e.updateVerticesData(Bi.PositionKind, this.positions, t, i),
- this.normals && e.updateVerticesData(Bi.NormalKind, this.normals, t, i),
- this.tangents && e.updateVerticesData(Bi.TangentKind, this.tangents, t, i),
- this.uvs && e.updateVerticesData(Bi.UVKind, this.uvs, t, i),
- this.uvs2 && e.updateVerticesData(Bi.UV2Kind, this.uvs2, t, i),
- this.uvs3 && e.updateVerticesData(Bi.UV3Kind, this.uvs3, t, i),
- this.uvs4 && e.updateVerticesData(Bi.UV4Kind, this.uvs4, t, i),
- this.uvs5 && e.updateVerticesData(Bi.UV5Kind, this.uvs5, t, i),
- this.uvs6 && e.updateVerticesData(Bi.UV6Kind, this.uvs6, t, i),
- this.colors && e.updateVerticesData(Bi.ColorKind, this.colors, t, i),
- this.matricesIndices && e.updateVerticesData(Bi.MatricesIndicesKind, this.matricesIndices, t, i),
- this.matricesWeights && e.updateVerticesData(Bi.MatricesWeightsKind, this.matricesWeights, t, i),
- this.matricesIndicesExtra && e.updateVerticesData(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i),
- this.matricesWeightsExtra && e.updateVerticesData(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i),
- this.indices && e.setIndices(this.indices, null),
- this
- }
- ,
- e._TransformVector3Coordinates = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = e.length);
- for (var r = I.Vector3[0], o = I.Vector3[1], a = i; a < i + n; a += 3)
- x.FromArrayToRef(e, a, r),
- x.TransformCoordinatesToRef(r, t, o),
- e[a] = o.x,
- e[a + 1] = o.y,
- e[a + 2] = o.z
- }
- ,
- e._TransformVector3Normals = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = e.length);
- for (var r = I.Vector3[0], o = I.Vector3[1], a = i; a < i + n; a += 3)
- x.FromArrayToRef(e, a, r),
- x.TransformNormalToRef(r, t, o),
- e[a] = o.x,
- e[a + 1] = o.y,
- e[a + 2] = o.z
- }
- ,
- e._TransformVector4Normals = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = e.length);
- for (var r = I.Vector4[0], o = I.Vector4[1], a = i; a < i + n; a += 4)
- R.FromArrayToRef(e, a, r),
- R.TransformNormalToRef(r, t, o),
- e[a] = o.x,
- e[a + 1] = o.y,
- e[a + 2] = o.z,
- e[a + 3] = o.w
- }
- ,
- e._FlipFaces = function(e, t, i) {
- void 0 === t && (t = 0),
- void 0 === i && (i = e.length);
- for (var n = t; n < t + i; n += 3) {
- var r = e[n + 1];
- e[n + 1] = e[n + 2],
- e[n + 2] = r
- }
- }
- ,
- e.prototype.transform = function(t) {
- var i = t.determinant() < 0;
- return this.positions && e._TransformVector3Coordinates(this.positions, t),
- this.normals && e._TransformVector3Normals(this.normals, t),
- this.tangents && e._TransformVector4Normals(this.tangents, t),
- i && this.indices && e._FlipFaces(this.indices),
- this
- }
- ,
- e.prototype.merge = function(e, t, i) {
- void 0 === t && (t = !1),
- void 0 === i && (i = !1);
- var n = Array.isArray(e) ? e.map((function(e) {
- return [e, void 0]
- }
- )) : [[e, void 0]];
- return Qn(this._mergeCoroutine(void 0, n, t, !1, i))
- }
- ,
- e.prototype._mergeCoroutine = function(t, i, n, r, o) {
- var a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x = this;
- return void 0 === n && (n = !1),
- z(this, (function(R) {
- switch (R.label) {
- case 0:
- for (this._validate(),
- a = i.map((function(e) {
- return e[0]
- }
- )),
- s = 0,
- l = a; s < l.length; s++)
- if ((v = l[s])._validate(),
- !this.normals != !v.normals || !this.tangents != !v.tangents || !this.uvs != !v.uvs || !this.uvs2 != !v.uvs2 || !this.uvs3 != !v.uvs3 || !this.uvs4 != !v.uvs4 || !this.uvs5 != !v.uvs5 || !this.uvs6 != !v.uvs6 || !this.colors != !v.colors || !this.matricesIndices != !v.matricesIndices || !this.matricesWeights != !v.matricesWeights || !this.matricesIndicesExtra != !v.matricesIndicesExtra || !this.matricesWeightsExtra != !v.matricesWeightsExtra)
- throw new Error("Cannot merge vertex data that do not have the same set of attributes");
- if (c = a.reduce((function(e, t) {
- var i, n;
- return e + (null !== (n = null === (i = t.indices) || void 0 === i ? void 0 : i.length) && void 0 !== n ? n : 0)
- }
- ), null !== (E = null === (T = this.indices) || void 0 === T ? void 0 : T.length) && void 0 !== E ? E : 0),
- u = o || a.some((function(e) {
- return e.indices === x.indices
- }
- )),
- h = u ? null === (S = this.indices) || void 0 === S ? void 0 : S.slice() : this.indices,
- !(c > 0))
- return [3, 4];
- d = null !== (A = null == h ? void 0 : h.length) && void 0 !== A ? A : 0,
- h || (h = new Array(c)),
- h.length !== c && (Array.isArray(h) ? h.length = c : ((p = n || h instanceof Uint32Array ? new Uint32Array(c) : new Uint16Array(c)).set(h),
- h = p),
- t && t.determinant() < 0 && e._FlipFaces(h, 0, d)),
- f = this.positions ? this.positions.length / 3 : 0,
- _ = 0,
- m = i,
- R.label = 1;
- case 1:
- if (!(_ < m.length))
- return [3, 4];
- if (g = m[_],
- v = g[0],
- y = g[1],
- !v.indices)
- return [3, 3];
- for (b = 0; b < v.indices.length; b++)
- h[d + b] = v.indices[b] + f;
- return y && y.determinant() < 0 && e._FlipFaces(h, d, v.indices.length),
- f += v.positions.length / 3,
- d += v.indices.length,
- r ? [4] : [3, 3];
- case 2:
- R.sent(),
- R.label = 3;
- case 3:
- return _++,
- [3, 1];
- case 4:
- return this.indices = h,
- this.positions = e._MergeElement(Bi.PositionKind, this.positions, t, i.map((function(e) {
- return [e[0].positions, e[1]]
- }
- ))),
- r ? [4] : [3, 6];
- case 5:
- R.sent(),
- R.label = 6;
- case 6:
- return this.normals = e._MergeElement(Bi.NormalKind, this.normals, t, i.map((function(e) {
- return [e[0].normals, e[1]]
- }
- ))),
- r ? [4] : [3, 8];
- case 7:
- R.sent(),
- R.label = 8;
- case 8:
- return this.tangents = e._MergeElement(Bi.TangentKind, this.tangents, t, i.map((function(e) {
- return [e[0].tangents, e[1]]
- }
- ))),
- r ? [4] : [3, 10];
- case 9:
- R.sent(),
- R.label = 10;
- case 10:
- return this.uvs = e._MergeElement(Bi.UVKind, this.uvs, t, i.map((function(e) {
- return [e[0].uvs, e[1]]
- }
- ))),
- r ? [4] : [3, 12];
- case 11:
- R.sent(),
- R.label = 12;
- case 12:
- return this.uvs2 = e._MergeElement(Bi.UV2Kind, this.uvs2, t, i.map((function(e) {
- return [e[0].uvs2, e[1]]
- }
- ))),
- r ? [4] : [3, 14];
- case 13:
- R.sent(),
- R.label = 14;
- case 14:
- return this.uvs3 = e._MergeElement(Bi.UV3Kind, this.uvs3, t, i.map((function(e) {
- return [e[0].uvs3, e[1]]
- }
- ))),
- r ? [4] : [3, 16];
- case 15:
- R.sent(),
- R.label = 16;
- case 16:
- return this.uvs4 = e._MergeElement(Bi.UV4Kind, this.uvs4, t, i.map((function(e) {
- return [e[0].uvs4, e[1]]
- }
- ))),
- r ? [4] : [3, 18];
- case 17:
- R.sent(),
- R.label = 18;
- case 18:
- return this.uvs5 = e._MergeElement(Bi.UV5Kind, this.uvs5, t, i.map((function(e) {
- return [e[0].uvs5, e[1]]
- }
- ))),
- r ? [4] : [3, 20];
- case 19:
- R.sent(),
- R.label = 20;
- case 20:
- return this.uvs6 = e._MergeElement(Bi.UV6Kind, this.uvs6, t, i.map((function(e) {
- return [e[0].uvs6, e[1]]
- }
- ))),
- r ? [4] : [3, 22];
- case 21:
- R.sent(),
- R.label = 22;
- case 22:
- return this.colors = e._MergeElement(Bi.ColorKind, this.colors, t, i.map((function(e) {
- return [e[0].colors, e[1]]
- }
- ))),
- r ? [4] : [3, 24];
- case 23:
- R.sent(),
- R.label = 24;
- case 24:
- return this.matricesIndices = e._MergeElement(Bi.MatricesIndicesKind, this.matricesIndices, t, i.map((function(e) {
- return [e[0].matricesIndices, e[1]]
- }
- ))),
- r ? [4] : [3, 26];
- case 25:
- R.sent(),
- R.label = 26;
- case 26:
- return this.matricesWeights = e._MergeElement(Bi.MatricesWeightsKind, this.matricesWeights, t, i.map((function(e) {
- return [e[0].matricesWeights, e[1]]
- }
- ))),
- r ? [4] : [3, 28];
- case 27:
- R.sent(),
- R.label = 28;
- case 28:
- return this.matricesIndicesExtra = e._MergeElement(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra, t, i.map((function(e) {
- return [e[0].matricesIndicesExtra, e[1]]
- }
- ))),
- r ? [4] : [3, 30];
- case 29:
- R.sent(),
- R.label = 30;
- case 30:
- return this.matricesWeightsExtra = e._MergeElement(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra, t, i.map((function(e) {
- return [e[0].matricesWeightsExtra, e[1]]
- }
- ))),
- [2, this]
- }
- }
- ))
- }
- ,
- e._MergeElement = function(t, i, n, r) {
- var o = r.filter((function(e) {
- return null !== e[0] && void 0 !== e[0]
- }
- ));
- if (0 === o.length)
- return i;
- if (!i)
- return this._MergeElement(t, o[0][0], o[0][1], o.slice(1));
- var a = o.reduce((function(e, t) {
- return e + t[0].length
- }
- ), i.length)
- , s = t === Bi.PositionKind ? e._TransformVector3Coordinates : t === Bi.NormalKind ? e._TransformVector3Normals : t === Bi.TangentKind ? e._TransformVector4Normals : function() {}
- ;
- if (i instanceof Float32Array) {
- var l = new Float32Array(a);
- l.set(i),
- n && s(l, n, 0, i.length);
- for (var c = i.length, u = 0, h = o; u < h.length; u++) {
- var d = h[u]
- , p = d[0]
- , f = d[1];
- l.set(p, c),
- f && s(l, f, c, p.length),
- c += p.length
- }
- return l
- }
- for (var _ = new Array(a), m = 0; m < i.length; m++)
- _[m] = i[m];
- n && s(_, n, 0, i.length),
- c = i.length;
- for (var g = 0, v = o; g < v.length; g++) {
- var y = v[g]
- , b = (p = y[0],
- y[1]);
- for (m = 0; m < p.length; m++)
- _[c + m] = p[m];
- b && s(_, b, c, p.length),
- c += p.length
- }
- return _
- }
- ,
- e.prototype._validate = function() {
- if (!this.positions)
- throw new ft("Positions are required",pt.MeshInvalidPositionsError);
- var e = function(e, t) {
- var i = Bi.DeduceStride(e);
- if (t.length % i != 0)
- throw new Error("The " + e + "s array count must be a multiple of " + i);
- return t.length / i
- }
- , t = e(Bi.PositionKind, this.positions)
- , i = function(i, n) {
- var r = e(i, n);
- if (r !== t)
- throw new Error("The " + i + "s element count (" + r + ") does not match the positions count (" + t + ")")
- };
- this.normals && i(Bi.NormalKind, this.normals),
- this.tangents && i(Bi.TangentKind, this.tangents),
- this.uvs && i(Bi.UVKind, this.uvs),
- this.uvs2 && i(Bi.UV2Kind, this.uvs2),
- this.uvs3 && i(Bi.UV3Kind, this.uvs3),
- this.uvs4 && i(Bi.UV4Kind, this.uvs4),
- this.uvs5 && i(Bi.UV5Kind, this.uvs5),
- this.uvs6 && i(Bi.UV6Kind, this.uvs6),
- this.colors && i(Bi.ColorKind, this.colors),
- this.matricesIndices && i(Bi.MatricesIndicesKind, this.matricesIndices),
- this.matricesWeights && i(Bi.MatricesWeightsKind, this.matricesWeights),
- this.matricesIndicesExtra && i(Bi.MatricesIndicesExtraKind, this.matricesIndicesExtra),
- this.matricesWeightsExtra && i(Bi.MatricesWeightsExtraKind, this.matricesWeightsExtra)
- }
- ,
- e.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
- }
- ,
- e.ExtractFromMesh = function(t, i, n) {
- return e._ExtractFrom(t, i, n)
- }
- ,
- e.ExtractFromGeometry = function(t, i, n) {
- return e._ExtractFrom(t, i, n)
- }
- ,
- e._ExtractFrom = function(t, i, n) {
- var r = new e;
- return t.isVerticesDataPresent(Bi.PositionKind) && (r.positions = t.getVerticesData(Bi.PositionKind, i, n)),
- t.isVerticesDataPresent(Bi.NormalKind) && (r.normals = t.getVerticesData(Bi.NormalKind, i, n)),
- t.isVerticesDataPresent(Bi.TangentKind) && (r.tangents = t.getVerticesData(Bi.TangentKind, i, n)),
- t.isVerticesDataPresent(Bi.UVKind) && (r.uvs = t.getVerticesData(Bi.UVKind, i, n)),
- t.isVerticesDataPresent(Bi.UV2Kind) && (r.uvs2 = t.getVerticesData(Bi.UV2Kind, i, n)),
- t.isVerticesDataPresent(Bi.UV3Kind) && (r.uvs3 = t.getVerticesData(Bi.UV3Kind, i, n)),
- t.isVerticesDataPresent(Bi.UV4Kind) && (r.uvs4 = t.getVerticesData(Bi.UV4Kind, i, n)),
- t.isVerticesDataPresent(Bi.UV5Kind) && (r.uvs5 = t.getVerticesData(Bi.UV5Kind, i, n)),
- t.isVerticesDataPresent(Bi.UV6Kind) && (r.uvs6 = t.getVerticesData(Bi.UV6Kind, i, n)),
- t.isVerticesDataPresent(Bi.ColorKind) && (r.colors = t.getVerticesData(Bi.ColorKind, i, n)),
- t.isVerticesDataPresent(Bi.MatricesIndicesKind) && (r.matricesIndices = t.getVerticesData(Bi.MatricesIndicesKind, i, n)),
- t.isVerticesDataPresent(Bi.MatricesWeightsKind) && (r.matricesWeights = t.getVerticesData(Bi.MatricesWeightsKind, i, n)),
- t.isVerticesDataPresent(Bi.MatricesIndicesExtraKind) && (r.matricesIndicesExtra = t.getVerticesData(Bi.MatricesIndicesExtraKind, i, n)),
- t.isVerticesDataPresent(Bi.MatricesWeightsExtraKind) && (r.matricesWeightsExtra = t.getVerticesData(Bi.MatricesWeightsExtraKind, i, n)),
- r.indices = t.getIndices(i, n),
- r
- }
- ,
- e.CreateRibbon = function(e) {
- throw be("ribbonBuilder")
- }
- ,
- e.CreateBox = function(e) {
- throw be("boxBuilder")
- }
- ,
- e.CreateTiledBox = function(e) {
- throw be("tiledBoxBuilder")
- }
- ,
- e.CreateTiledPlane = function(e) {
- throw be("tiledPlaneBuilder")
- }
- ,
- e.CreateSphere = function(e) {
- throw be("sphereBuilder")
- }
- ,
- e.CreateCylinder = function(e) {
- throw be("cylinderBuilder")
- }
- ,
- e.CreateTorus = function(e) {
- throw be("torusBuilder")
- }
- ,
- e.CreateLineSystem = function(e) {
- throw be("linesBuilder")
- }
- ,
- e.CreateDashedLines = function(e) {
- throw be("linesBuilder")
- }
- ,
- e.CreateGround = function(e) {
- throw be("groundBuilder")
- }
- ,
- e.CreateTiledGround = function(e) {
- throw be("groundBuilder")
- }
- ,
- e.CreateGroundFromHeightMap = function(e) {
- throw be("groundBuilder")
- }
- ,
- e.CreatePlane = function(e) {
- throw be("planeBuilder")
- }
- ,
- e.CreateDisc = function(e) {
- throw be("discBuilder")
- }
- ,
- e.CreatePolygon = function(e, t, i, n, r, o, a) {
- throw be("polygonBuilder")
- }
- ,
- e.CreateIcoSphere = function(e) {
- throw be("icoSphereBuilder")
- }
- ,
- e.CreatePolyhedron = function(e) {
- throw be("polyhedronBuilder")
- }
- ,
- e.CreateCapsule = function(e) {
- throw void 0 === e && (e = {
- orientation: x.Up(),
- subdivisions: 2,
- tessellation: 16,
- height: 1,
- radius: .25,
- capSubdivisions: 6
- }),
- be("capsuleBuilder")
- }
- ,
- e.CreateTorusKnot = function(e) {
- throw be("torusKnotBuilder")
- }
- ,
- e.ComputeNormals = function(e, t, i, n) {
- var r = 0
- , o = 0
- , a = 0
- , s = 0
- , l = 0
- , c = 0
- , u = 0
- , h = 0
- , d = 0
- , p = 0
- , f = 0
- , _ = 0
- , m = 0
- , g = 0
- , v = 0
- , y = 0
- , b = 0
- , T = 0
- , E = 0
- , S = 0
- , A = !1
- , R = !1
- , C = !1
- , P = !1
- , M = 1
- , I = 0
- , O = null;
- n && (A = !!n.facetNormals,
- R = !!n.facetPositions,
- C = !!n.facetPartitioning,
- M = !0 === n.useRightHandedSystem ? -1 : 1,
- I = n.ratio || 0,
- P = !!n.depthSort,
- O = n.distanceTo,
- P && void 0 === O && (O = x.Zero()));
- var D = 0
- , N = 0
- , L = 0
- , F = 0;
- for (C && n && n.bbSize && (D = n.subDiv.X * I / n.bbSize.x,
- N = n.subDiv.Y * I / n.bbSize.y,
- L = n.subDiv.Z * I / n.bbSize.z,
- F = n.subDiv.max * n.subDiv.max,
- n.facetPartitioning.length = 0),
- r = 0; r < e.length; r++)
- i[r] = 0;
- var w = t.length / 3 | 0;
- for (r = 0; r < w; r++) {
- if (m = 1 + (_ = 3 * t[3 * r]),
- g = _ + 2,
- y = 1 + (v = 3 * t[3 * r + 1]),
- b = v + 2,
- E = 1 + (T = 3 * t[3 * r + 2]),
- S = T + 2,
- o = e[_] - e[v],
- a = e[m] - e[y],
- s = e[g] - e[b],
- l = e[T] - e[v],
- c = e[E] - e[y],
- h = M * (a * (u = e[S] - e[b]) - s * c),
- d = M * (s * l - o * u),
- p = M * (o * c - a * l),
- h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f,
- d /= f,
- p /= f,
- A && n && (n.facetNormals[r].x = h,
- n.facetNormals[r].y = d,
- n.facetNormals[r].z = p),
- R && n && (n.facetPositions[r].x = (e[_] + e[v] + e[T]) / 3,
- n.facetPositions[r].y = (e[m] + e[y] + e[E]) / 3,
- n.facetPositions[r].z = (e[g] + e[b] + e[S]) / 3),
- C && n) {
- var B = Math.floor((n.facetPositions[r].x - n.bInfo.minimum.x * I) * D)
- , U = Math.floor((n.facetPositions[r].y - n.bInfo.minimum.y * I) * N)
- , V = Math.floor((n.facetPositions[r].z - n.bInfo.minimum.z * I) * L)
- , k = Math.floor((e[_] - n.bInfo.minimum.x * I) * D)
- , G = Math.floor((e[m] - n.bInfo.minimum.y * I) * N)
- , z = Math.floor((e[g] - n.bInfo.minimum.z * I) * L)
- , W = Math.floor((e[v] - n.bInfo.minimum.x * I) * D)
- , H = Math.floor((e[y] - n.bInfo.minimum.y * I) * N)
- , X = Math.floor((e[b] - n.bInfo.minimum.z * I) * L)
- , j = Math.floor((e[T] - n.bInfo.minimum.x * I) * D)
- , Y = Math.floor((e[E] - n.bInfo.minimum.y * I) * N)
- , K = Math.floor((e[S] - n.bInfo.minimum.z * I) * L)
- , Q = k + n.subDiv.max * G + F * z
- , q = W + n.subDiv.max * H + F * X
- , Z = j + n.subDiv.max * Y + F * K
- , J = B + n.subDiv.max * U + F * V;
- n.facetPartitioning[J] = n.facetPartitioning[J] ? n.facetPartitioning[J] : new Array,
- n.facetPartitioning[Q] = n.facetPartitioning[Q] ? n.facetPartitioning[Q] : new Array,
- n.facetPartitioning[q] = n.facetPartitioning[q] ? n.facetPartitioning[q] : new Array,
- n.facetPartitioning[Z] = n.facetPartitioning[Z] ? n.facetPartitioning[Z] : new Array,
- n.facetPartitioning[Q].push(r),
- q != Q && n.facetPartitioning[q].push(r),
- Z != q && Z != Q && n.facetPartitioning[Z].push(r),
- J != Q && J != q && J != Z && n.facetPartitioning[J].push(r)
- }
- if (P && n && n.facetPositions) {
- var $ = n.depthSortedFacets[r];
- $.ind = 3 * r,
- $.sqDistance = x.DistanceSquared(n.facetPositions[r], O)
- }
- i[_] += h,
- i[m] += d,
- i[g] += p,
- i[v] += h,
- i[y] += d,
- i[b] += p,
- i[T] += h,
- i[E] += d,
- i[S] += p
- }
- for (r = 0; r < i.length / 3; r++)
- h = i[3 * r],
- d = i[3 * r + 1],
- p = i[3 * r + 2],
- h /= f = 0 === (f = Math.sqrt(h * h + d * d + p * p)) ? 1 : f,
- d /= f,
- p /= f,
- i[3 * r] = h,
- i[3 * r + 1] = d,
- i[3 * r + 2] = p
- }
- ,
- e._ComputeSides = function(t, i, n, r, o, a, s) {
- var l, c, u = n.length, h = r.length;
- switch (t = t || e.DEFAULTSIDE) {
- case e.FRONTSIDE:
- break;
- case e.BACKSIDE:
- for (l = 0; l < u; l += 3) {
- var d = n[l];
- n[l] = n[l + 2],
- n[l + 2] = d
- }
- for (c = 0; c < h; c++)
- r[c] = -r[c];
- break;
- case e.DOUBLESIDE:
- for (var p = i.length, f = p / 3, _ = 0; _ < p; _++)
- i[p + _] = i[_];
- for (l = 0; l < u; l += 3)
- n[l + u] = n[l + 2] + f,
- n[l + 1 + u] = n[l + 1] + f,
- n[l + 2 + u] = n[l] + f;
- for (c = 0; c < h; c++)
- r[h + c] = -r[c];
- var m = o.length
- , g = 0;
- for (g = 0; g < m; g++)
- o[g + m] = o[g];
- for (a = a || new R(0,0,1,1),
- s = s || new R(0,0,1,1),
- g = 0,
- l = 0; l < m / 2; l++)
- o[g] = a.x + (a.z - a.x) * o[g],
- o[g + 1] = a.y + (a.w - a.y) * o[g + 1],
- o[g + m] = s.x + (s.z - s.x) * o[g + m],
- o[g + m + 1] = s.y + (s.w - s.y) * o[g + m + 1],
- g += 2
- }
- }
- ,
- e.ImportVertexData = function(t, i) {
- var n = new e
- , r = t.positions;
- r && n.set(r, Bi.PositionKind);
- var o = t.normals;
- o && n.set(o, Bi.NormalKind);
- var a = t.tangents;
- a && n.set(a, Bi.TangentKind);
- var s = t.uvs;
- s && n.set(s, Bi.UVKind);
- var l = t.uv2s;
- l && n.set(l, Bi.UV2Kind);
- var c = t.uv3s;
- c && n.set(c, Bi.UV3Kind);
- var u = t.uv4s;
- u && n.set(u, Bi.UV4Kind);
- var h = t.uv5s;
- h && n.set(h, Bi.UV5Kind);
- var d = t.uv6s;
- d && n.set(d, Bi.UV6Kind);
- var p = t.colors;
- p && n.set(N.CheckColors4(p, r.length / 3), Bi.ColorKind);
- var f = t.matricesIndices;
- f && n.set(f, Bi.MatricesIndicesKind);
- var _ = t.matricesWeights;
- _ && n.set(_, Bi.MatricesWeightsKind);
- var m = t.indices;
- m && (n.indices = m),
- i.setAllVerticesData(n, t.updatable)
- }
- ,
- e.FRONTSIDE = 0,
- e.BACKSIDE = 1,
- e.DOUBLESIDE = 2,
- e.DEFAULTSIDE = 0,
- k([ze.filter((function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- var i = e[0];
- return !Array.isArray(i)
- }
- ))], e, "_TransformVector3Coordinates", null),
- k([ze.filter((function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- var i = e[0];
- return !Array.isArray(i)
- }
- ))], e, "_TransformVector3Normals", null),
- k([ze.filter((function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- var i = e[0];
- return !Array.isArray(i)
- }
- ))], e, "_TransformVector4Normals", null),
- k([ze.filter((function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- var i = e[0];
- return !Array.isArray(i)
- }
- ))], e, "_FlipFaces", null),
- e
- }()
- , er = function(e, t, i) {
- this.bu = e,
- this.bv = t,
- this.distance = i,
- this.faceId = 0,
- this.subMeshId = 0
- }
- , tr = function() {
- function e(e, t, i) {
- this.vectors = g.BuildArray(8, x.Zero),
- this.center = x.Zero(),
- this.centerWorld = x.Zero(),
- this.extendSize = x.Zero(),
- this.extendSizeWorld = x.Zero(),
- this.directions = g.BuildArray(3, x.Zero),
- this.vectorsWorld = g.BuildArray(8, x.Zero),
- this.minimumWorld = x.Zero(),
- this.maximumWorld = x.Zero(),
- this.minimum = x.Zero(),
- this.maximum = x.Zero(),
- this._drawWrapperFront = null,
- this._drawWrapperBack = null,
- this.reConstruct(e, t, i)
- }
- return e.prototype.reConstruct = function(e, t, i) {
- var n = e.x
- , r = e.y
- , o = e.z
- , a = t.x
- , s = t.y
- , l = t.z
- , c = this.vectors;
- this.minimum.copyFromFloats(n, r, o),
- this.maximum.copyFromFloats(a, s, l),
- c[0].copyFromFloats(n, r, o),
- c[1].copyFromFloats(a, s, l),
- c[2].copyFromFloats(a, r, o),
- c[3].copyFromFloats(n, s, o),
- c[4].copyFromFloats(n, r, l),
- c[5].copyFromFloats(a, s, o),
- c[6].copyFromFloats(n, s, l),
- c[7].copyFromFloats(a, r, l),
- t.addToRef(e, this.center).scaleInPlace(.5),
- t.subtractToRef(e, this.extendSize).scaleInPlace(.5),
- this._worldMatrix = i || P.IdentityReadOnly,
- this._update(this._worldMatrix)
- }
- ,
- e.prototype.scale = function(t) {
- var i = e._TmpVector3
- , n = this.maximum.subtractToRef(this.minimum, i[0])
- , r = n.length();
- n.normalizeFromLength(r);
- var o = r * t
- , a = n.scaleInPlace(.5 * o)
- , s = this.center.subtractToRef(a, i[1])
- , l = this.center.addToRef(a, i[2]);
- return this.reConstruct(s, l, this._worldMatrix),
- this
- }
- ,
- e.prototype.getWorldMatrix = function() {
- return this._worldMatrix
- }
- ,
- e.prototype._update = function(e) {
- var t = this.minimumWorld
- , i = this.maximumWorld
- , n = this.directions
- , r = this.vectorsWorld
- , o = this.vectors;
- if (e.isIdentity()) {
- for (t.copyFrom(this.minimum),
- i.copyFrom(this.maximum),
- a = 0; a < 8; ++a)
- r[a].copyFrom(o[a]);
- this.extendSizeWorld.copyFrom(this.extendSize),
- this.centerWorld.copyFrom(this.center)
- } else {
- t.setAll(Number.MAX_VALUE),
- i.setAll(-Number.MAX_VALUE);
- for (var a = 0; a < 8; ++a) {
- var s = r[a];
- x.TransformCoordinatesToRef(o[a], e, s),
- t.minimizeInPlace(s),
- i.maximizeInPlace(s)
- }
- i.subtractToRef(t, this.extendSizeWorld).scaleInPlace(.5),
- i.addToRef(t, this.centerWorld).scaleInPlace(.5)
- }
- x.FromArrayToRef(e.m, 0, n[0]),
- x.FromArrayToRef(e.m, 4, n[1]),
- x.FromArrayToRef(e.m, 8, n[2]),
- this._worldMatrix = e
- }
- ,
- e.prototype.isInFrustum = function(t) {
- return e.IsInFrustum(this.vectorsWorld, t)
- }
- ,
- e.prototype.isCompletelyInFrustum = function(t) {
- return e.IsCompletelyInFrustum(this.vectorsWorld, t)
- }
- ,
- e.prototype.intersectsPoint = function(e) {
- var t = this.minimumWorld
- , i = this.maximumWorld
- , n = t.x
- , r = t.y
- , o = t.z
- , a = i.x
- , s = i.y
- , l = i.z
- , c = e.x
- , u = e.y
- , h = e.z
- , d = -m;
- return !(a - c < d || d > c - n || s - u < d || d > u - r || l - h < d || d > h - o)
- }
- ,
- e.prototype.intersectsSphere = function(t) {
- return e.IntersectsSphere(this.minimumWorld, this.maximumWorld, t.centerWorld, t.radiusWorld)
- }
- ,
- e.prototype.intersectsMinMax = function(e, t) {
- var i = this.minimumWorld
- , n = this.maximumWorld
- , r = i.x
- , o = i.y
- , a = i.z
- , s = n.x
- , l = n.y
- , c = n.z
- , u = e.x
- , h = e.y
- , d = e.z
- , p = t.x
- , f = t.y
- , _ = t.z;
- return !(s < u || r > p || l < h || o > f || c < d || a > _)
- }
- ,
- e.prototype.dispose = function() {
- var e, t;
- null === (e = this._drawWrapperFront) || void 0 === e || e.dispose(),
- null === (t = this._drawWrapperBack) || void 0 === t || t.dispose()
- }
- ,
- e.Intersects = function(e, t) {
- return e.intersectsMinMax(t.minimumWorld, t.maximumWorld)
- }
- ,
- e.IntersectsSphere = function(t, i, n, r) {
- var o = e._TmpVector3[0];
- return x.ClampToRef(n, t, i, o),
- x.DistanceSquared(n, o) <= r * r
- }
- ,
- e.IsCompletelyInFrustum = function(e, t) {
- for (var i = 0; i < 6; ++i)
- for (var n = t[i], r = 0; r < 8; ++r)
- if (n.dotCoordinate(e[r]) < 0)
- return !1;
- return !0
- }
- ,
- e.IsInFrustum = function(e, t) {
- for (var i = 0; i < 6; ++i) {
- for (var n = !0, r = t[i], o = 0; o < 8; ++o)
- if (r.dotCoordinate(e[o]) >= 0) {
- n = !1;
- break
- }
- if (n)
- return !1
- }
- return !0
- }
- ,
- e._TmpVector3 = g.BuildArray(3, x.Zero),
- e
- }()
- , ir = function() {
- function e(e, t, i) {
- this.center = x.Zero(),
- this.centerWorld = x.Zero(),
- this.minimum = x.Zero(),
- this.maximum = x.Zero(),
- this.reConstruct(e, t, i)
- }
- return e.prototype.reConstruct = function(e, t, i) {
- this.minimum.copyFrom(e),
- this.maximum.copyFrom(t);
- var n = x.Distance(e, t);
- t.addToRef(e, this.center).scaleInPlace(.5),
- this.radius = .5 * n,
- this._update(i || P.IdentityReadOnly)
- }
- ,
- e.prototype.scale = function(t) {
- var i = this.radius * t
- , n = e._TmpVector3
- , r = n[0].setAll(i)
- , o = this.center.subtractToRef(r, n[1])
- , a = this.center.addToRef(r, n[2]);
- return this.reConstruct(o, a, this._worldMatrix),
- this
- }
- ,
- e.prototype.getWorldMatrix = function() {
- return this._worldMatrix
- }
- ,
- e.prototype._update = function(t) {
- if (t.isIdentity())
- this.centerWorld.copyFrom(this.center),
- this.radiusWorld = this.radius;
- else {
- x.TransformCoordinatesToRef(this.center, t, this.centerWorld);
- var i = e._TmpVector3[0];
- x.TransformNormalFromFloatsToRef(1, 1, 1, t, i),
- this.radiusWorld = Math.max(Math.abs(i.x), Math.abs(i.y), Math.abs(i.z)) * this.radius
- }
- }
- ,
- e.prototype.isInFrustum = function(e) {
- for (var t = this.centerWorld, i = this.radiusWorld, n = 0; n < 6; n++)
- if (e[n].dotCoordinate(t) <= -i)
- return !1;
- return !0
- }
- ,
- e.prototype.isCenterInFrustum = function(e) {
- for (var t = this.centerWorld, i = 0; i < 6; i++)
- if (e[i].dotCoordinate(t) < 0)
- return !1;
- return !0
- }
- ,
- e.prototype.intersectsPoint = function(e) {
- var t = x.DistanceSquared(this.centerWorld, e);
- return !(this.radiusWorld * this.radiusWorld < t)
- }
- ,
- e.Intersects = function(e, t) {
- var i = x.DistanceSquared(e.centerWorld, t.centerWorld)
- , n = e.radiusWorld + t.radiusWorld;
- return !(n * n < i)
- }
- ,
- e.CreateFromCenterAndRadius = function(t, i, n) {
- this._TmpVector3[0].copyFrom(t),
- this._TmpVector3[1].copyFromFloats(0, 0, i),
- this._TmpVector3[2].copyFrom(t),
- this._TmpVector3[0].addInPlace(this._TmpVector3[1]),
- this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);
- var r = new e(this._TmpVector3[0],this._TmpVector3[2]);
- return r._worldMatrix = n || P.Identity(),
- r
- }
- ,
- e._TmpVector3 = g.BuildArray(3, x.Zero),
- e
- }()
- , nr = {
- min: 0,
- max: 0
- }
- , rr = {
- min: 0,
- max: 0
- }
- , or = function(e, t, i) {
- var n = x.Dot(t.centerWorld, e)
- , r = Math.abs(x.Dot(t.directions[0], e)) * t.extendSize.x + Math.abs(x.Dot(t.directions[1], e)) * t.extendSize.y + Math.abs(x.Dot(t.directions[2], e)) * t.extendSize.z;
- i.min = n - r,
- i.max = n + r
- }
- , ar = function(e, t, i) {
- return or(e, t, nr),
- or(e, i, rr),
- !(nr.min > rr.max || rr.min > nr.max)
- }
- , sr = function() {
- function e(e, t, i) {
- this._isLocked = !1,
- this.boundingBox = new tr(e,t,i),
- this.boundingSphere = new ir(e,t,i)
- }
- return e.prototype.reConstruct = function(e, t, i) {
- this.boundingBox.reConstruct(e, t, i),
- this.boundingSphere.reConstruct(e, t, i)
- }
- ,
- Object.defineProperty(e.prototype, "minimum", {
- get: function() {
- return this.boundingBox.minimum
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "maximum", {
- get: function() {
- return this.boundingBox.maximum
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isLocked", {
- get: function() {
- return this._isLocked
- },
- set: function(e) {
- this._isLocked = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function(e) {
- this._isLocked || (this.boundingBox._update(e),
- this.boundingSphere._update(e))
- }
- ,
- e.prototype.centerOn = function(t, i) {
- var n = e._TmpVector3[0].copyFrom(t).subtractInPlace(i)
- , r = e._TmpVector3[1].copyFrom(t).addInPlace(i);
- return this.boundingBox.reConstruct(n, r, this.boundingBox.getWorldMatrix()),
- this.boundingSphere.reConstruct(n, r, this.boundingBox.getWorldMatrix()),
- this
- }
- ,
- e.prototype.encapsulate = function(e) {
- var t = x.Minimize(this.minimum, e)
- , i = x.Maximize(this.maximum, e);
- return this.reConstruct(t, i, this.boundingBox.getWorldMatrix()),
- this
- }
- ,
- e.prototype.encapsulateBoundingInfo = function(e) {
- return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),
- this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),
- this
- }
- ,
- e.prototype.scale = function(e) {
- return this.boundingBox.scale(e),
- this.boundingSphere.scale(e),
- this
- }
- ,
- e.prototype.isInFrustum = function(e, t) {
- return void 0 === t && (t = a.MESHES_CULLINGSTRATEGY_STANDARD),
- !(t !== a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION && t !== a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY || !this.boundingSphere.isCenterInFrustum(e)) || !!this.boundingSphere.isInFrustum(e) && (!(t !== a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY && t !== a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY) || this.boundingBox.isInFrustum(e))
- }
- ,
- Object.defineProperty(e.prototype, "diagonalLength", {
- get: function() {
- var t = this.boundingBox;
- return t.maximumWorld.subtractToRef(t.minimumWorld, e._TmpVector3[0]).length()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isCompletelyInFrustum = function(e) {
- return this.boundingBox.isCompletelyInFrustum(e)
- }
- ,
- e.prototype._checkCollision = function(e) {
- return e._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld)
- }
- ,
- e.prototype.intersectsPoint = function(e) {
- return !!this.boundingSphere.centerWorld && !!this.boundingSphere.intersectsPoint(e) && !!this.boundingBox.intersectsPoint(e)
- }
- ,
- e.prototype.intersects = function(e, t) {
- if (!ir.Intersects(this.boundingSphere, e.boundingSphere))
- return !1;
- if (!tr.Intersects(this.boundingBox, e.boundingBox))
- return !1;
- if (!t)
- return !0;
- var i = this.boundingBox
- , n = e.boundingBox;
- return !!(ar(i.directions[0], i, n) && ar(i.directions[1], i, n) && ar(i.directions[2], i, n) && ar(n.directions[0], i, n) && ar(n.directions[1], i, n) && ar(n.directions[2], i, n) && ar(x.Cross(i.directions[0], n.directions[0]), i, n) && ar(x.Cross(i.directions[0], n.directions[1]), i, n) && ar(x.Cross(i.directions[0], n.directions[2]), i, n) && ar(x.Cross(i.directions[1], n.directions[0]), i, n) && ar(x.Cross(i.directions[1], n.directions[1]), i, n) && ar(x.Cross(i.directions[1], n.directions[2]), i, n) && ar(x.Cross(i.directions[2], n.directions[0]), i, n) && ar(x.Cross(i.directions[2], n.directions[1]), i, n) && ar(x.Cross(i.directions[2], n.directions[2]), i, n))
- }
- ,
- e._TmpVector3 = g.BuildArray(2, x.Zero),
- e
- }()
- , lr = function() {
- function e() {}
- return e.extractMinAndMaxIndexed = function(e, t, i, n, r, o) {
- for (var a = i; a < i + n; a++) {
- var s = 3 * t[a]
- , l = e[s]
- , c = e[s + 1]
- , u = e[s + 2];
- r.minimizeInPlaceFromFloats(l, c, u),
- o.maximizeInPlaceFromFloats(l, c, u)
- }
- }
- ,
- e.extractMinAndMax = function(e, t, i, n, r, o) {
- for (var a = t, s = t * n; a < t + i; a++,
- s += n) {
- var l = e[s]
- , c = e[s + 1]
- , u = e[s + 2];
- r.minimizeInPlaceFromFloats(l, c, u),
- o.maximizeInPlaceFromFloats(l, c, u)
- }
- }
- ,
- k([ze.filter((function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- var i = e[0]
- , n = e[1];
- return !Array.isArray(i) && !Array.isArray(n)
- }
- ))], e, "extractMinAndMaxIndexed", null),
- k([ze.filter((function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- var i = e[0];
- return !Array.isArray(i)
- }
- ))], e, "extractMinAndMax", null),
- e
- }();
- function cr(e, t, i, n, r) {
- void 0 === r && (r = null);
- var o = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- , a = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- return lr.extractMinAndMaxIndexed(e, t, i, n, o, a),
- r && (o.x -= o.x * r.x + r.y,
- o.y -= o.y * r.x + r.y,
- o.z -= o.z * r.x + r.y,
- a.x += a.x * r.x + r.y,
- a.y += a.y * r.x + r.y,
- a.z += a.z * r.x + r.y),
- {
- minimum: o,
- maximum: a
- }
- }
- function ur(e, t, i, n, r) {
- void 0 === n && (n = null);
- var o = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- , a = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- return r || (r = 3),
- lr.extractMinAndMax(e, t, i, r, o, a),
- n && (o.x -= o.x * n.x + n.y,
- o.y -= o.y * n.x + n.y,
- o.z -= o.z * n.x + n.y,
- a.x += a.x * n.x + n.y,
- a.y += a.y * n.x + n.y,
- a.z += a.z * n.x + n.y),
- {
- minimum: o,
- maximum: a
- }
- }
- var hr = function() {
- function e(e, t, i, n, r, o, a, s, l) {
- void 0 === s && (s = !0),
- void 0 === l && (l = !0),
- this.materialIndex = e,
- this.verticesStart = t,
- this.verticesCount = i,
- this.indexStart = n,
- this.indexCount = r,
- 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 = o,
- this._renderingMesh = a || o,
- l && o.subMeshes.push(this),
- this._engine = this._mesh.getScene().getEngine(),
- this.resetDrawCache(),
- this._trianglePlanes = [],
- this._id = o.subMeshes.length - 1,
- s && (this.refreshBoundingInfo(),
- o.computeWorldMatrix(!0))
- }
- return Object.defineProperty(e.prototype, "materialDefines", {
- get: function() {
- var e;
- return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : null === (e = this._getDrawWrapper()) || void 0 === e ? void 0 : e.defines
- },
- set: function(e) {
- var t;
- (null !== (t = this._mainDrawWrapperOverride) && void 0 !== t ? t : this._getDrawWrapper(void 0, !0)).defines = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getDrawWrapper = function(e, t) {
- void 0 === t && (t = !1),
- e = null != e ? e : this._engine.currentRenderPassId;
- var i = this._drawWrappers[e];
- return !i && t && (this._drawWrappers[e] = i = new Gt(this._mesh.getScene().getEngine())),
- i
- }
- ,
- e.prototype._removeDrawWrapper = function(e, t) {
- var i;
- void 0 === t && (t = !0),
- t && (null === (i = this._drawWrappers[e]) || void 0 === i || i.dispose()),
- this._drawWrappers[e] = void 0
- }
- ,
- Object.defineProperty(e.prototype, "effect", {
- get: function() {
- var e, t;
- return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : null !== (t = null === (e = this._getDrawWrapper()) || void 0 === e ? void 0 : e.effect) && void 0 !== t ? t : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_drawWrapper", {
- get: function() {
- var e;
- return null !== (e = this._mainDrawWrapperOverride) && void 0 !== e ? e : this._getDrawWrapper(void 0, !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_drawWrapperOverride", {
- get: function() {
- return this._mainDrawWrapperOverride
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._setMainDrawWrapperOverride = function(e) {
- this._mainDrawWrapperOverride = e
- }
- ,
- e.prototype.setEffect = function(e, t, i, n) {
- void 0 === t && (t = null),
- void 0 === n && (n = !0);
- var r = this._drawWrapper;
- r.setEffect(e, t, n),
- void 0 !== i && (r.materialContext = i),
- e || (r.defines = null,
- r.materialContext = void 0)
- }
- ,
- e.prototype.resetDrawCache = function(e) {
- if (this._drawWrappers) {
- if (void 0 !== e)
- return void this._removeDrawWrapper(e);
- for (var t = 0, i = this._drawWrappers; t < i.length; t++) {
- var n = i[t];
- null == n || n.dispose()
- }
- }
- this._drawWrappers = []
- }
- ,
- e.AddToMesh = function(t, i, n, r, o, a, s, l) {
- return void 0 === l && (l = !0),
- new e(t,i,n,r,o,a,s,l)
- }
- ,
- Object.defineProperty(e.prototype, "IsGlobal", {
- get: function() {
- return 0 === this.verticesStart && this.verticesCount === this._mesh.getTotalVertices()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getBoundingInfo = function() {
- return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo
- }
- ,
- e.prototype.setBoundingInfo = function(e) {
- return this._boundingInfo = e,
- this
- }
- ,
- e.prototype.getMesh = function() {
- return this._mesh
- }
- ,
- e.prototype.getRenderingMesh = function() {
- return this._renderingMesh
- }
- ,
- e.prototype.getReplacementMesh = function() {
- return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null
- }
- ,
- e.prototype.getEffectiveMesh = function() {
- return (this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null) || this._renderingMesh
- }
- ,
- e.prototype.getMaterial = function() {
- var e, t = null !== (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) && void 0 !== e ? e : this._renderingMesh.material;
- if (null == t)
- return this._mesh.getScene().defaultMaterial;
- if (this._isMultiMaterial(t)) {
- var i = t.getSubMaterial(this.materialIndex);
- return this._currentMaterial !== i && (this._currentMaterial = i,
- this.resetDrawCache()),
- i
- }
- return t
- }
- ,
- e.prototype._isMultiMaterial = function(e) {
- return void 0 !== e.getSubMaterial
- }
- ,
- e.prototype.refreshBoundingInfo = function(e) {
- if (void 0 === e && (e = null),
- this._lastColliderWorldVertices = null,
- this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
- return this;
- if (e || (e = this._renderingMesh.getVerticesData(Bi.PositionKind)),
- !e)
- return this._boundingInfo = this._mesh.getBoundingInfo(),
- this;
- var t, i = this._renderingMesh.getIndices();
- if (0 === this.indexStart && this.indexCount === i.length) {
- var n = this._renderingMesh.getBoundingInfo();
- t = {
- minimum: n.minimum.clone(),
- maximum: n.maximum.clone()
- }
- } else
- t = cr(e, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
- return this._boundingInfo ? this._boundingInfo.reConstruct(t.minimum, t.maximum) : this._boundingInfo = new sr(t.minimum,t.maximum),
- this
- }
- ,
- e.prototype._checkCollision = function(e) {
- return this.getBoundingInfo()._checkCollision(e)
- }
- ,
- e.prototype.updateBoundingInfo = function(e) {
- var t = this.getBoundingInfo();
- return t || (this.refreshBoundingInfo(),
- t = this.getBoundingInfo()),
- t && t.update(e),
- this
- }
- ,
- e.prototype.isInFrustum = function(e) {
- var t = this.getBoundingInfo();
- return !!t && t.isInFrustum(e, this._mesh.cullingStrategy)
- }
- ,
- e.prototype.isCompletelyInFrustum = function(e) {
- var t = this.getBoundingInfo();
- return !!t && t.isCompletelyInFrustum(e)
- }
- ,
- e.prototype.render = function(e) {
- return this._renderingMesh.render(this, e, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0),
- this
- }
- ,
- e.prototype._getLinesIndexBuffer = function(e, t) {
- if (!this._linesIndexBuffer) {
- for (var i = [], n = this.indexStart; n < this.indexStart + this.indexCount; n += 3)
- i.push(e[n], e[n + 1], e[n + 1], e[n + 2], e[n + 2], e[n]);
- this._linesIndexBuffer = t.createIndexBuffer(i),
- this._linesIndexCount = i.length
- }
- return this._linesIndexBuffer
- }
- ,
- e.prototype.canIntersects = function(e) {
- var t = this.getBoundingInfo();
- return !!t && e.intersectsBox(t.boundingBox)
- }
- ,
- e.prototype.intersects = function(e, t, i, n, r) {
- var o = this.getMaterial();
- if (!o)
- return null;
- var s = 3
- , l = !1;
- switch (o.fillMode) {
- case a.MATERIAL_PointListDrawMode:
- case a.MATERIAL_LineLoopDrawMode:
- case a.MATERIAL_LineStripDrawMode:
- case a.MATERIAL_TriangleFanDrawMode:
- return null;
- case a.MATERIAL_TriangleStripDrawMode:
- s = 1,
- l = !0
- }
- return o.fillMode === a.MATERIAL_LineListDrawMode ? i.length ? this._intersectLines(e, t, i, this._mesh.intersectionThreshold, n) : this._intersectUnIndexedLines(e, t, i, this._mesh.intersectionThreshold, n) : !i.length && this._mesh._unIndexed ? this._intersectUnIndexedTriangles(e, t, i, n, r) : this._intersectTriangles(e, t, i, s, l, n, r)
- }
- ,
- e.prototype._intersectLines = function(e, t, i, n, r) {
- for (var o = null, a = this.indexStart; a < this.indexStart + this.indexCount; a += 2) {
- var s = t[i[a]]
- , l = t[i[a + 1]]
- , c = e.intersectionSegment(s, l, n);
- if (!(c < 0) && (r || !o || c < o.distance) && ((o = new er(null,null,c)).faceId = a / 2,
- r))
- break
- }
- return o
- }
- ,
- e.prototype._intersectUnIndexedLines = function(e, t, i, n, r) {
- for (var o = null, a = this.verticesStart; a < this.verticesStart + this.verticesCount; a += 2) {
- var s = t[a]
- , l = t[a + 1]
- , c = e.intersectionSegment(s, l, n);
- if (!(c < 0) && (r || !o || c < o.distance) && ((o = new er(null,null,c)).faceId = a / 2,
- r))
- break
- }
- return o
- }
- ,
- e.prototype._intersectTriangles = function(e, t, i, n, r, o, a) {
- for (var s = null, l = -1, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
- l++;
- var u = i[c]
- , h = i[c + 1]
- , d = i[c + 2];
- if (r && 4294967295 === d)
- c += 2;
- else {
- var p = t[u]
- , f = t[h]
- , _ = t[d];
- if (p && f && _ && (!a || a(p, f, _, e))) {
- var m = e.intersectsTriangle(p, f, _);
- if (m) {
- if (m.distance < 0)
- continue;
- if ((o || !s || m.distance < s.distance) && ((s = m).faceId = l,
- o))
- break
- }
- }
- }
- }
- return s
- }
- ,
- e.prototype._intersectUnIndexedTriangles = function(e, t, i, n, r) {
- for (var o = null, a = this.verticesStart; a < this.verticesStart + this.verticesCount; a += 3) {
- var s = t[a]
- , l = t[a + 1]
- , c = t[a + 2];
- if (!r || r(s, l, c, e)) {
- var u = e.intersectsTriangle(s, l, c);
- if (u) {
- if (u.distance < 0)
- continue;
- if ((n || !o || u.distance < o.distance) && ((o = u).faceId = a / 3,
- n))
- break
- }
- }
- }
- return o
- }
- ,
- e.prototype._rebuild = function() {
- this._linesIndexBuffer && (this._linesIndexBuffer = null)
- }
- ,
- e.prototype.clone = function(t, i) {
- var n = new e(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,i,!1);
- if (!this.IsGlobal) {
- var r = this.getBoundingInfo();
- if (!r)
- return n;
- n._boundingInfo = new sr(r.minimum,r.maximum)
- }
- return n
- }
- ,
- e.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()
- }
- ,
- e.prototype.getClassName = function() {
- return "SubMesh"
- }
- ,
- e.CreateFromIndices = function(t, i, n, r, o, a) {
- void 0 === a && (a = !0);
- for (var s = Number.MAX_VALUE, l = -Number.MAX_VALUE, c = (o || r).getIndices(), u = i; u < i + n; u++) {
- var h = c[u];
- h < s && (s = h),
- h > l && (l = h)
- }
- return new e(t,s,l - s + 1,i,n,r,o,a)
- }
- ,
- e
- }()
- , dr = function() {
- function e() {}
- return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", {
- get: function() {
- return e._ForceFullSceneLoadingForIncremental
- },
- set: function(t) {
- e._ForceFullSceneLoadingForIncremental = t
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ShowLoadingScreen", {
- get: function() {
- return e._ShowLoadingScreen
- },
- set: function(t) {
- e._ShowLoadingScreen = t
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "loggingLevel", {
- get: function() {
- return e._LoggingLevel
- },
- set: function(t) {
- e._LoggingLevel = t
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "CleanBoneMatrixWeights", {
- get: function() {
- return e._CleanBoneMatrixWeights
- },
- set: function(t) {
- e._CleanBoneMatrixWeights = t
- },
- enumerable: !1,
- configurable: !0
- }),
- e._ForceFullSceneLoadingForIncremental = !1,
- e._ShowLoadingScreen = !0,
- e._CleanBoneMatrixWeights = !1,
- e._LoggingLevel = a.SCENELOADER_NO_LOGGING,
- e
- }()
- , pr = function() {
- function e() {}
- return e.UseOpenGLOrientationForUV = !1,
- e
- }()
- , fr = function() {
- function e(e, t, i, n, r) {
- void 0 === n && (n = !1),
- void 0 === r && (r = null),
- this.delayLoadState = a.DELAYLOADSTATE_NONE,
- this._totalVertices = 0,
- this._isDisposed = !1,
- this._indexBufferIsUpdatable = !1,
- this._positionsCache = [],
- this._parentContainer = null,
- this.useBoundingInfoFromGeometry = !1,
- this._scene = t || E.LastCreatedScene,
- this._scene && (this.id = e,
- this.uniqueId = this._scene.getUniqueId(),
- this._engine = this._scene.getEngine(),
- this._meshes = [],
- this._vertexBuffers = {},
- this._indices = [],
- this._updatable = n,
- i ? this.setAllVerticesData(i, n) : (this._totalVertices = 0,
- this._indices = []),
- this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}),
- r && (this.applyToMesh(r),
- r.computeWorldMatrix(!0)))
- }
- return Object.defineProperty(e.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
- }),
- e.CreateGeometryForMesh = function(t) {
- var i = new e(e.RandomId(),t.getScene());
- return i.applyToMesh(t),
- i
- }
- ,
- Object.defineProperty(e.prototype, "meshes", {
- get: function() {
- return this._meshes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "extend", {
- get: function() {
- return this._extend
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype.getEngine = function() {
- return this._engine
- }
- ,
- e.prototype.isReady = function() {
- return this.delayLoadState === a.DELAYLOADSTATE_LOADED || this.delayLoadState === a.DELAYLOADSTATE_NONE
- }
- ,
- Object.defineProperty(e.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
- }),
- e.prototype._rebuild = function() {
- for (var e in this._vertexArrayObjects && (this._vertexArrayObjects = {}),
- 0 !== this._meshes.length && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
- this._vertexBuffers)
- this._vertexBuffers[e]._rebuild()
- }
- ,
- e.prototype.setAllVerticesData = function(e, t) {
- e.applyToGeometry(this, t),
- this._notifyUpdate()
- }
- ,
- e.prototype.setVerticesData = function(e, t, i, n) {
- void 0 === i && (i = !1),
- i && Array.isArray(t) && (t = new Float32Array(t));
- var r = new Bi(this._engine,t,e,i,0 === this._meshes.length,n);
- this.setVerticesBuffer(r)
- }
- ,
- e.prototype.removeVerticesData = function(e) {
- this._vertexBuffers[e] && (this._vertexBuffers[e].dispose(),
- delete this._vertexBuffers[e]),
- this._vertexArrayObjects && this._disposeVertexArrayObjects()
- }
- ,
- e.prototype.setVerticesBuffer = function(e, t, i) {
- void 0 === t && (t = null),
- void 0 === i && (i = !0);
- var n = e.getKind();
- this._vertexBuffers[n] && i && this._vertexBuffers[n].dispose(),
- e._buffer && e._buffer._increaseReferences(),
- this._vertexBuffers[n] = e;
- var r = this._meshes
- , o = r.length;
- if (n === Bi.PositionKind) {
- var a = e.getData();
- null != t ? this._totalVertices = t : null != a && (this._totalVertices = a.length / (e.type === Bi.BYTE ? e.byteStride : e.byteStride / 4)),
- this._updateExtend(a),
- this._resetPointsArrayCache();
- for (var s = 0; s < o; s++) {
- var l = r[s];
- l.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
- l._createGlobalSubMesh(!1),
- l.computeWorldMatrix(!0),
- l.synchronizeInstances()
- }
- }
- this._notifyUpdate(n)
- }
- ,
- e.prototype.updateVerticesDataDirectly = function(e, t, i, n) {
- void 0 === n && (n = !1);
- var r = this.getVertexBuffer(e);
- r && (r.updateDirectly(t, i, n),
- this._notifyUpdate(e))
- }
- ,
- e.prototype.updateVerticesData = function(e, t, i) {
- void 0 === i && (i = !1);
- var n = this.getVertexBuffer(e);
- n && (n.update(t),
- e === Bi.PositionKind && this._updateBoundingInfo(i, t),
- this._notifyUpdate(e))
- }
- ,
- e.prototype._updateBoundingInfo = function(e, t) {
- if (e && this._updateExtend(t),
- this._resetPointsArrayCache(),
- e)
- for (var i = 0, n = this._meshes; i < n.length; i++) {
- var r = n[i];
- r.hasBoundingInfo ? r.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : r.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
- for (var o = 0, a = r.subMeshes; o < a.length; o++)
- a[o].refreshBoundingInfo()
- }
- }
- ,
- e.prototype._bind = function(e, t, i, n) {
- if (e) {
- void 0 === t && (t = this._indexBuffer);
- var r = this.getVertexBuffers();
- if (r)
- if (t == this._indexBuffer && (this._vertexArrayObjects || n)) {
- var o = n || this._vertexArrayObjects;
- o[e.key] || (o[e.key] = this._engine.recordVertexArrayObject(r, t, e, i)),
- this._engine.bindVertexArrayObject(o[e.key], t)
- } else
- this._engine.bindBuffers(r, t, e, i)
- }
- }
- ,
- e.prototype.getTotalVertices = function() {
- return this.isReady() ? this._totalVertices : 0
- }
- ,
- e.prototype.getVerticesData = function(e, t, i) {
- var n = this.getVertexBuffer(e);
- return n ? n.getFloatData(this._totalVertices, i || t && 1 !== this._meshes.length) : null
- }
- ,
- e.prototype.isVertexBufferUpdatable = function(e) {
- var t = this._vertexBuffers[e];
- return !!t && t.isUpdatable()
- }
- ,
- e.prototype.getVertexBuffer = function(e) {
- return this.isReady() ? this._vertexBuffers[e] : null
- }
- ,
- e.prototype.getVertexBuffers = function() {
- return this.isReady() ? this._vertexBuffers : null
- }
- ,
- e.prototype.isVerticesDataPresent = function(e) {
- return this._vertexBuffers ? void 0 !== this._vertexBuffers[e] : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
- }
- ,
- e.prototype.getVerticesDataKinds = function() {
- var e, t = [];
- if (!this._vertexBuffers && this._delayInfo)
- for (e in this._delayInfo)
- t.push(e);
- else
- for (e in this._vertexBuffers)
- t.push(e);
- return t
- }
- ,
- e.prototype.updateIndices = function(e, t, i) {
- if (void 0 === i && (i = !1),
- this._indexBuffer)
- if (this._indexBufferIsUpdatable) {
- var n = e.length !== this._indices.length;
- if (i || (this._indices = e.slice()),
- this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, t),
- n)
- for (var r = 0, o = this._meshes; r < o.length; r++)
- o[r]._createGlobalSubMesh(!0)
- } else
- this.setIndices(e, null, !0)
- }
- ,
- e.prototype.setIndices = function(e, t, i) {
- void 0 === t && (t = null),
- void 0 === i && (i = !1),
- this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
- this._indices = e,
- this._indexBufferIsUpdatable = i,
- 0 !== this._meshes.length && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, i)),
- null != t && (this._totalVertices = t);
- for (var n = 0, r = this._meshes; n < r.length; n++) {
- var o = r[n];
- o._createGlobalSubMesh(!0),
- o.synchronizeInstances()
- }
- this._notifyUpdate()
- }
- ,
- e.prototype.getTotalIndices = function() {
- return this.isReady() ? this._indices.length : 0
- }
- ,
- e.prototype.getIndices = function(e, t) {
- if (!this.isReady())
- return null;
- var i = this._indices;
- return t || e && 1 !== this._meshes.length ? gi.Slice(i) : i
- }
- ,
- e.prototype.getIndexBuffer = function() {
- return this.isReady() ? this._indexBuffer : null
- }
- ,
- e.prototype._releaseVertexArrayObject = function(e) {
- void 0 === e && (e = null),
- e && this._vertexArrayObjects && this._vertexArrayObjects[e.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),
- delete this._vertexArrayObjects[e.key])
- }
- ,
- e.prototype.releaseForMesh = function(e, t) {
- var i = this._meshes
- , n = i.indexOf(e);
- -1 !== n && (i.splice(n, 1),
- this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(),
- e._geometry = null,
- 0 === i.length && t && this.dispose())
- }
- ,
- e.prototype.applyToMesh = function(e) {
- if (e._geometry !== this) {
- var t = e._geometry;
- t && t.releaseForMesh(e),
- this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject();
- var i = this._meshes;
- e._geometry = this,
- e._internalAbstractMeshDataInfo._positions = null,
- this._scene.pushGeometry(this),
- i.push(e),
- this.isReady() ? this._applyToMesh(e) : this._boundingInfo && e.setBoundingInfo(this._boundingInfo)
- }
- }
- ,
- e.prototype._updateExtend = function(e) {
- if (void 0 === e && (e = null),
- this.useBoundingInfoFromGeometry && this._boundingInfo)
- this._extend = {
- minimum: this._boundingInfo.minimum.clone(),
- maximum: this._boundingInfo.maximum.clone()
- };
- else {
- if (!e && !(e = this.getVerticesData(Bi.PositionKind)))
- return;
- this._extend = ur(e, 0, this._totalVertices, this.boundingBias, 3)
- }
- }
- ,
- e.prototype._applyToMesh = function(e) {
- var t = this._meshes.length;
- for (var i in this._vertexBuffers)
- 1 === t && this._vertexBuffers[i].create(),
- i === Bi.PositionKind && (this._extend || this._updateExtend(),
- e.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
- e._createGlobalSubMesh(!1),
- e._updateBoundingInfo());
- 1 === t && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
- e._syncGeometryWithMorphTargetManager(),
- e.synchronizeInstances()
- }
- ,
- e.prototype._notifyUpdate = function(e) {
- this.onGeometryUpdated && this.onGeometryUpdated(this, e),
- this._vertexArrayObjects && this._disposeVertexArrayObjects();
- for (var t = 0, i = this._meshes; t < i.length; t++)
- i[t]._markSubMeshesAsAttributesDirty()
- }
- ,
- e.prototype.load = function(e, t) {
- this.delayLoadState !== a.DELAYLOADSTATE_LOADING && (this.isReady() ? t && t() : (this.delayLoadState = a.DELAYLOADSTATE_LOADING,
- this._queueLoad(e, t)))
- }
- ,
- e.prototype._queueLoad = function(e, t) {
- var i = this;
- this.delayLoadingFile && (e._addPendingData(this),
- e._loadFile(this.delayLoadingFile, (function(n) {
- if (i._delayLoadingFunction) {
- i._delayLoadingFunction(JSON.parse(n), i),
- i.delayLoadState = a.DELAYLOADSTATE_LOADED,
- i._delayInfo = [],
- e._removePendingData(i);
- for (var r = i._meshes, o = r.length, s = 0; s < o; s++)
- i._applyToMesh(r[s]);
- t && t()
- }
- }
- ), void 0, !0))
- }
- ,
- e.prototype.toLeftHanded = function() {
- var e = this.getIndices(!1);
- if (null != e && e.length > 0) {
- for (var t = 0; t < e.length; t += 3) {
- var i = e[t + 0];
- e[t + 0] = e[t + 2],
- e[t + 2] = i
- }
- this.setIndices(e)
- }
- var n = this.getVerticesData(Bi.PositionKind, !1);
- if (null != n && n.length > 0) {
- for (t = 0; t < n.length; t += 3)
- n[t + 2] = -n[t + 2];
- this.setVerticesData(Bi.PositionKind, n, !1)
- }
- var r = this.getVerticesData(Bi.NormalKind, !1);
- if (null != r && r.length > 0) {
- for (t = 0; t < r.length; t += 3)
- r[t + 2] = -r[t + 2];
- this.setVerticesData(Bi.NormalKind, r, !1)
- }
- }
- ,
- e.prototype._resetPointsArrayCache = function() {
- this._positions = null
- }
- ,
- e.prototype._generatePointsArray = function() {
- if (this._positions)
- return !0;
- var e = this.getVerticesData(Bi.PositionKind);
- if (!e || 0 === e.length)
- return !1;
- for (var t = 3 * this._positionsCache.length, i = this._positionsCache.length; t < e.length; t += 3,
- ++i)
- this._positionsCache[i] = x.FromArray(e, t);
- for (t = 0,
- i = 0; t < e.length; t += 3,
- ++i)
- this._positionsCache[i].set(e[0 + t], e[1 + t], e[2 + t]);
- return this._positionsCache.length = e.length / 3,
- this._positions = this._positionsCache,
- !0
- }
- ,
- e.prototype.isDisposed = function() {
- return this._isDisposed
- }
- ,
- e.prototype._disposeVertexArrayObjects = function() {
- if (this._vertexArrayObjects) {
- for (var e in this._vertexArrayObjects)
- this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);
- this._vertexArrayObjects = {};
- for (var t = this._meshes, i = t.length, n = 0; n < i; n++)
- t[n]._invalidateInstanceVertexArrayObject()
- }
- }
- ,
- e.prototype.dispose = function() {
- var e, t = this._meshes, i = t.length;
- for (e = 0; e < i; e++)
- this.releaseForMesh(t[e]);
- for (var n in this._meshes = [],
- this._disposeVertexArrayObjects(),
- this._vertexBuffers)
- this._vertexBuffers[n].dispose();
- if (this._vertexBuffers = {},
- this._totalVertices = 0,
- this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null,
- this._indices = [],
- this.delayLoadState = a.DELAYLOADSTATE_NONE,
- this.delayLoadingFile = null,
- this._delayLoadingFunction = null,
- this._delayInfo = [],
- this._boundingInfo = null,
- this._scene.removeGeometry(this),
- this._parentContainer) {
- var r = this._parentContainer.geometries.indexOf(this);
- r > -1 && this._parentContainer.geometries.splice(r, 1),
- this._parentContainer = null
- }
- this._isDisposed = !0
- }
- ,
- e.prototype.copy = function(t) {
- var i = new $n;
- i.indices = [];
- var n = this.getIndices();
- if (n)
- for (var r = 0; r < n.length; r++)
- i.indices.push(n[r]);
- var o, a = !1, s = !1;
- for (o in this._vertexBuffers) {
- var l = this.getVerticesData(o);
- if (l && (l instanceof Float32Array ? i.set(new Float32Array(l), o) : i.set(l.slice(0), o),
- !s)) {
- var c = this.getVertexBuffer(o);
- c && (s = !(a = c.isUpdatable()))
- }
- }
- var u = new e(t,this._scene,i,a);
- for (o in u.delayLoadState = this.delayLoadState,
- u.delayLoadingFile = this.delayLoadingFile,
- u._delayLoadingFunction = this._delayLoadingFunction,
- this._delayInfo)
- u._delayInfo = u._delayInfo || [],
- u._delayInfo.push(o);
- return u._boundingInfo = new sr(this._extend.minimum,this._extend.maximum),
- u
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.id = this.id,
- e.uniqueId = this.uniqueId,
- e.updatable = this._updatable,
- ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
- e
- }
- ,
- e.prototype._toNumberArray = function(e) {
- return Array.isArray(e) ? e : Array.prototype.slice.call(e)
- }
- ,
- e.prototype.clearCachedData = function() {
- for (var e in this._indices = [],
- this._resetPointsArrayCache(),
- this._vertexBuffers)
- Object.prototype.hasOwnProperty.call(this._vertexBuffers, e) && (this._vertexBuffers[e]._buffer._data = null)
- }
- ,
- e.prototype.serializeVerticeData = function() {
- var e = this.serialize();
- return this.isVerticesDataPresent(Bi.PositionKind) && (e.positions = this._toNumberArray(this.getVerticesData(Bi.PositionKind)),
- this.isVertexBufferUpdatable(Bi.PositionKind) && (e.positions._updatable = !0)),
- this.isVerticesDataPresent(Bi.NormalKind) && (e.normals = this._toNumberArray(this.getVerticesData(Bi.NormalKind)),
- this.isVertexBufferUpdatable(Bi.NormalKind) && (e.normals._updatable = !0)),
- this.isVerticesDataPresent(Bi.TangentKind) && (e.tangents = this._toNumberArray(this.getVerticesData(Bi.TangentKind)),
- this.isVertexBufferUpdatable(Bi.TangentKind) && (e.tangents._updatable = !0)),
- this.isVerticesDataPresent(Bi.UVKind) && (e.uvs = this._toNumberArray(this.getVerticesData(Bi.UVKind)),
- this.isVertexBufferUpdatable(Bi.UVKind) && (e.uvs._updatable = !0)),
- this.isVerticesDataPresent(Bi.UV2Kind) && (e.uv2s = this._toNumberArray(this.getVerticesData(Bi.UV2Kind)),
- this.isVertexBufferUpdatable(Bi.UV2Kind) && (e.uv2s._updatable = !0)),
- this.isVerticesDataPresent(Bi.UV3Kind) && (e.uv3s = this._toNumberArray(this.getVerticesData(Bi.UV3Kind)),
- this.isVertexBufferUpdatable(Bi.UV3Kind) && (e.uv3s._updatable = !0)),
- this.isVerticesDataPresent(Bi.UV4Kind) && (e.uv4s = this._toNumberArray(this.getVerticesData(Bi.UV4Kind)),
- this.isVertexBufferUpdatable(Bi.UV4Kind) && (e.uv4s._updatable = !0)),
- this.isVerticesDataPresent(Bi.UV5Kind) && (e.uv5s = this._toNumberArray(this.getVerticesData(Bi.UV5Kind)),
- this.isVertexBufferUpdatable(Bi.UV5Kind) && (e.uv5s._updatable = !0)),
- this.isVerticesDataPresent(Bi.UV6Kind) && (e.uv6s = this._toNumberArray(this.getVerticesData(Bi.UV6Kind)),
- this.isVertexBufferUpdatable(Bi.UV6Kind) && (e.uv6s._updatable = !0)),
- this.isVerticesDataPresent(Bi.ColorKind) && (e.colors = this._toNumberArray(this.getVerticesData(Bi.ColorKind)),
- this.isVertexBufferUpdatable(Bi.ColorKind) && (e.colors._updatable = !0)),
- this.isVerticesDataPresent(Bi.MatricesIndicesKind) && (e.matricesIndices = this._toNumberArray(this.getVerticesData(Bi.MatricesIndicesKind)),
- e.matricesIndices._isExpanded = !0,
- this.isVertexBufferUpdatable(Bi.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)),
- this.isVerticesDataPresent(Bi.MatricesWeightsKind) && (e.matricesWeights = this._toNumberArray(this.getVerticesData(Bi.MatricesWeightsKind)),
- this.isVertexBufferUpdatable(Bi.MatricesWeightsKind) && (e.matricesWeights._updatable = !0)),
- e.indices = this._toNumberArray(this.getIndices()),
- e
- }
- ,
- e.ExtractFromMesh = function(e, t) {
- var i = e._geometry;
- return i ? i.copy(t) : null
- }
- ,
- e.RandomId = function() {
- return gi.RandomId()
- }
- ,
- e._GetGeometryByLoadedUniqueId = function(e, t) {
- for (var i = 0; i < t.geometries.length; i++)
- if (t.geometries[i]._loadedUniqueId === e)
- return t.geometries[i];
- return null
- }
- ,
- e._ImportGeometry = function(t, i) {
- var n = i.getScene()
- , r = t.geometryUniqueId
- , o = t.geometryId;
- if (r || o) {
- var a = r ? this._GetGeometryByLoadedUniqueId(r, n) : n.getGeometryById(o);
- a && a.applyToMesh(i)
- } else if (t instanceof ArrayBuffer) {
- var s = i._binaryInfo;
- if (s.positionsAttrDesc && s.positionsAttrDesc.count > 0) {
- var l = new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);
- i.setVerticesData(Bi.PositionKind, l, !1)
- }
- if (s.normalsAttrDesc && s.normalsAttrDesc.count > 0) {
- var c = new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);
- i.setVerticesData(Bi.NormalKind, c, !1)
- }
- if (s.tangetsAttrDesc && s.tangetsAttrDesc.count > 0) {
- var u = new Float32Array(t,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);
- i.setVerticesData(Bi.TangentKind, u, !1)
- }
- if (s.uvsAttrDesc && s.uvsAttrDesc.count > 0) {
- var h = new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);
- if (pr.UseOpenGLOrientationForUV)
- for (var d = 1; d < h.length; d += 2)
- h[d] = 1 - h[d];
- i.setVerticesData(Bi.UVKind, h, !1)
- }
- if (s.uvs2AttrDesc && s.uvs2AttrDesc.count > 0) {
- var p = new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);
- if (pr.UseOpenGLOrientationForUV)
- for (d = 1; d < p.length; d += 2)
- p[d] = 1 - p[d];
- i.setVerticesData(Bi.UV2Kind, p, !1)
- }
- if (s.uvs3AttrDesc && s.uvs3AttrDesc.count > 0) {
- var f = new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);
- if (pr.UseOpenGLOrientationForUV)
- for (d = 1; d < f.length; d += 2)
- f[d] = 1 - f[d];
- i.setVerticesData(Bi.UV3Kind, f, !1)
- }
- if (s.uvs4AttrDesc && s.uvs4AttrDesc.count > 0) {
- var _ = new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);
- if (pr.UseOpenGLOrientationForUV)
- for (d = 1; d < _.length; d += 2)
- _[d] = 1 - _[d];
- i.setVerticesData(Bi.UV4Kind, _, !1)
- }
- if (s.uvs5AttrDesc && s.uvs5AttrDesc.count > 0) {
- var m = new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);
- if (pr.UseOpenGLOrientationForUV)
- for (d = 1; d < m.length; d += 2)
- m[d] = 1 - m[d];
- i.setVerticesData(Bi.UV5Kind, m, !1)
- }
- if (s.uvs6AttrDesc && s.uvs6AttrDesc.count > 0) {
- var g = new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);
- if (pr.UseOpenGLOrientationForUV)
- for (d = 1; d < g.length; d += 2)
- g[d] = 1 - g[d];
- i.setVerticesData(Bi.UV6Kind, g, !1)
- }
- if (s.colorsAttrDesc && s.colorsAttrDesc.count > 0) {
- var v = new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);
- i.setVerticesData(Bi.ColorKind, v, !1, s.colorsAttrDesc.stride)
- }
- if (s.matricesIndicesAttrDesc && s.matricesIndicesAttrDesc.count > 0) {
- for (var y = new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count), b = [], T = 0; T < y.length; T++)
- d = y[T],
- b.push(255 & d),
- b.push((65280 & d) >> 8),
- b.push((16711680 & d) >> 16),
- b.push(d >> 24 & 255);
- i.setVerticesData(Bi.MatricesIndicesKind, b, !1)
- }
- if (s.matricesIndicesExtraAttrDesc && s.matricesIndicesExtraAttrDesc.count > 0) {
- for (y = new Int32Array(t,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),
- b = [],
- T = 0; T < y.length; T++)
- d = y[T],
- b.push(255 & d),
- b.push((65280 & d) >> 8),
- b.push((16711680 & d) >> 16),
- b.push(d >> 24 & 255);
- i.setVerticesData(Bi.MatricesIndicesExtraKind, b, !1)
- }
- if (s.matricesWeightsAttrDesc && s.matricesWeightsAttrDesc.count > 0) {
- var E = new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);
- i.setVerticesData(Bi.MatricesWeightsKind, E, !1)
- }
- if (s.indicesAttrDesc && s.indicesAttrDesc.count > 0) {
- var S = new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);
- i.setIndices(S, null)
- }
- if (s.subMeshesAttrDesc && s.subMeshesAttrDesc.count > 0) {
- var A = new Int32Array(t,s.subMeshesAttrDesc.offset,5 * s.subMeshesAttrDesc.count);
- for (i.subMeshes = [],
- T = 0; T < s.subMeshesAttrDesc.count; T++) {
- var x = A[5 * T + 0]
- , R = A[5 * T + 1]
- , C = A[5 * T + 2]
- , P = A[5 * T + 3]
- , M = A[5 * T + 4];
- hr.AddToMesh(x, R, C, P, M, i)
- }
- }
- } else if (t.positions && t.normals && t.indices) {
- if (i.setVerticesData(Bi.PositionKind, t.positions, t.positions._updatable),
- i.setVerticesData(Bi.NormalKind, t.normals, t.normals._updatable),
- t.tangents && i.setVerticesData(Bi.TangentKind, t.tangents, t.tangents._updatable),
- t.uvs && i.setVerticesData(Bi.UVKind, t.uvs, t.uvs._updatable),
- t.uvs2 && i.setVerticesData(Bi.UV2Kind, t.uvs2, t.uvs2._updatable),
- t.uvs3 && i.setVerticesData(Bi.UV3Kind, t.uvs3, t.uvs3._updatable),
- t.uvs4 && i.setVerticesData(Bi.UV4Kind, t.uvs4, t.uvs4._updatable),
- t.uvs5 && i.setVerticesData(Bi.UV5Kind, t.uvs5, t.uvs5._updatable),
- t.uvs6 && i.setVerticesData(Bi.UV6Kind, t.uvs6, t.uvs6._updatable),
- t.colors && i.setVerticesData(Bi.ColorKind, N.CheckColors4(t.colors, t.positions.length / 3), t.colors._updatable),
- t.matricesIndices)
- if (t.matricesIndices._isExpanded)
- delete t.matricesIndices._isExpanded,
- i.setVerticesData(Bi.MatricesIndicesKind, t.matricesIndices, t.matricesIndices._updatable);
- else {
- for (b = [],
- T = 0; T < t.matricesIndices.length; T++) {
- var I = t.matricesIndices[T];
- b.push(255 & I),
- b.push((65280 & I) >> 8),
- b.push((16711680 & I) >> 16),
- b.push(I >> 24 & 255)
- }
- i.setVerticesData(Bi.MatricesIndicesKind, b, t.matricesIndices._updatable)
- }
- if (t.matricesIndicesExtra)
- if (t.matricesIndicesExtra._isExpanded)
- delete t.matricesIndices._isExpanded,
- i.setVerticesData(Bi.MatricesIndicesExtraKind, t.matricesIndicesExtra, t.matricesIndicesExtra._updatable);
- else {
- for (b = [],
- T = 0; T < t.matricesIndicesExtra.length; T++)
- I = t.matricesIndicesExtra[T],
- b.push(255 & I),
- b.push((65280 & I) >> 8),
- b.push((16711680 & I) >> 16),
- b.push(I >> 24 & 255);
- i.setVerticesData(Bi.MatricesIndicesExtraKind, b, t.matricesIndicesExtra._updatable)
- }
- t.matricesWeights && (e._CleanMatricesWeights(t, i),
- i.setVerticesData(Bi.MatricesWeightsKind, t.matricesWeights, t.matricesWeights._updatable)),
- t.matricesWeightsExtra && i.setVerticesData(Bi.MatricesWeightsExtraKind, t.matricesWeightsExtra, t.matricesWeights._updatable),
- i.setIndices(t.indices, null)
- }
- if (t.subMeshes) {
- i.subMeshes = [];
- for (var O = 0; O < t.subMeshes.length; O++) {
- var D = t.subMeshes[O];
- hr.AddToMesh(D.materialIndex, D.verticesStart, D.verticesCount, D.indexStart, D.indexCount, i)
- }
- }
- i._shouldGenerateFlatShading && (i.convertToFlatShadedMesh(),
- i._shouldGenerateFlatShading = !1),
- i.computeWorldMatrix(!0),
- n.onMeshImportedObservable.notifyObservers(i)
- }
- ,
- e._CleanMatricesWeights = function(e, t) {
- var i = .001;
- if (dr.CleanBoneMatrixWeights) {
- var n = 0;
- if (e.skeletonId > -1) {
- var r = t.getScene().getLastSkeletonById(e.skeletonId);
- if (r) {
- n = r.bones.length;
- for (var o = t.getVerticesData(Bi.MatricesIndicesKind), a = t.getVerticesData(Bi.MatricesIndicesExtraKind), s = e.matricesWeights, l = e.matricesWeightsExtra, c = e.numBoneInfluencer, u = s.length, h = 0; h < u; h += 4) {
- for (var d = 0, p = -1, f = 0; f < 4; f++)
- d += _ = s[h + f],
- _ < i && p < 0 && (p = f);
- if (l)
- for (f = 0; f < 4; f++) {
- var _;
- d += _ = l[h + f],
- _ < i && p < 0 && (p = f + 4)
- }
- if ((p < 0 || p > c - 1) && (p = c - 1),
- d > i) {
- var m = 1 / d;
- for (f = 0; f < 4; f++)
- s[h + f] *= m;
- if (l)
- for (f = 0; f < 4; f++)
- l[h + f] *= m
- } else
- p >= 4 ? (l[h + p - 4] = 1 - d,
- a[h + p - 4] = n) : (s[h + p] = 1 - d,
- o[h + p] = n)
- }
- t.setVerticesData(Bi.MatricesIndicesKind, o),
- e.matricesWeightsExtra && t.setVerticesData(Bi.MatricesIndicesExtraKind, a)
- }
- }
- }
- }
- ,
- e.Parse = function(t, i, n) {
- var r = new e(t.id,i,void 0,t.updatable);
- return r._loadedUniqueId = t.uniqueId,
- ye && ye.AddTagsTo(r, t.tags),
- t.delayLoadingFile ? (r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
- r.delayLoadingFile = n + t.delayLoadingFile,
- r._boundingInfo = new sr(x.FromArray(t.boundingBoxMinimum),x.FromArray(t.boundingBoxMaximum)),
- r._delayInfo = [],
- t.hasUVs && r._delayInfo.push(Bi.UVKind),
- t.hasUVs2 && r._delayInfo.push(Bi.UV2Kind),
- t.hasUVs3 && r._delayInfo.push(Bi.UV3Kind),
- t.hasUVs4 && r._delayInfo.push(Bi.UV4Kind),
- t.hasUVs5 && r._delayInfo.push(Bi.UV5Kind),
- t.hasUVs6 && r._delayInfo.push(Bi.UV6Kind),
- t.hasColors && r._delayInfo.push(Bi.ColorKind),
- t.hasMatricesIndices && r._delayInfo.push(Bi.MatricesIndicesKind),
- t.hasMatricesWeights && r._delayInfo.push(Bi.MatricesWeightsKind),
- r._delayLoadingFunction = $n.ImportVertexData) : $n.ImportVertexData(t, r),
- i.pushGeometry(r, !0),
- r
- }
- ,
- e
- }()
- , _r = function() {
- function e(e) {
- void 0 === e && (e = 30),
- this._enabled = !0,
- this._rollingFrameTime = new mr(e)
- }
- return e.prototype.sampleFrame = function(e) {
- if (void 0 === e && (e = ct.Now),
- this._enabled) {
- if (null != this._lastFrameTimeMs) {
- var t = e - this._lastFrameTimeMs;
- this._rollingFrameTime.add(t)
- }
- this._lastFrameTimeMs = e
- }
- }
- ,
- Object.defineProperty(e.prototype, "averageFrameTime", {
- get: function() {
- return this._rollingFrameTime.average
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "averageFrameTimeVariance", {
- get: function() {
- return this._rollingFrameTime.variance
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "instantaneousFrameTime", {
- get: function() {
- return this._rollingFrameTime.history(0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "averageFPS", {
- get: function() {
- return 1e3 / this._rollingFrameTime.average
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "instantaneousFPS", {
- get: function() {
- var e = this._rollingFrameTime.history(0);
- return 0 === e ? 0 : 1e3 / e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isSaturated", {
- get: function() {
- return this._rollingFrameTime.isSaturated()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.enable = function() {
- this._enabled = !0
- }
- ,
- e.prototype.disable = function() {
- this._enabled = !1,
- this._lastFrameTimeMs = null
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reset = function() {
- this._lastFrameTimeMs = null,
- this._rollingFrameTime.reset()
- }
- ,
- e
- }()
- , mr = function() {
- function e(e) {
- this._samples = new Array(e),
- this.reset()
- }
- return e.prototype.add = function(e) {
- var t;
- if (this.isSaturated()) {
- var i = this._samples[this._pos];
- t = i - this.average,
- this.average -= t / (this._sampleCount - 1),
- this._m2 -= t * (i - this.average)
- } else
- this._sampleCount++;
- t = e - this.average,
- this.average += t / this._sampleCount,
- this._m2 += t * (e - this.average),
- this.variance = this._m2 / (this._sampleCount - 1),
- this._samples[this._pos] = e,
- this._pos++,
- this._pos %= this._samples.length
- }
- ,
- e.prototype.history = function(e) {
- if (e >= this._sampleCount || e >= this._samples.length)
- return 0;
- var t = this._wrapPosition(this._pos - 1);
- return this._samples[this._wrapPosition(t - e)]
- }
- ,
- e.prototype.isSaturated = function() {
- return this._sampleCount >= this._samples.length
- }
- ,
- e.prototype.reset = function() {
- this.average = 0,
- this.variance = 0,
- this._sampleCount = 0,
- this._pos = 0,
- this._m2 = 0
- }
- ,
- e.prototype._wrapPosition = function(e) {
- var t = this._samples.length;
- return (e % t + t) % t
- }
- ,
- e
- }();
- function gr(e, t, i, n) {
- switch (void 0 === i && (i = !1),
- e) {
- case a.TEXTURETYPE_BYTE:
- var r = (ArrayBuffer,
- new Int8Array(t));
- return n && r.set(new Int8Array(n)),
- r;
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- var o = (ArrayBuffer,
- new Uint8Array(t));
- return n && o.set(new Uint8Array(n)),
- o;
- case a.TEXTURETYPE_SHORT:
- var s = t instanceof ArrayBuffer ? new Int16Array(t) : new Int16Array(i ? t / 2 : t);
- return n && s.set(new Int16Array(n)),
- s;
- case a.TEXTURETYPE_UNSIGNED_SHORT:
- case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
- case a.TEXTURETYPE_HALF_FLOAT:
- var l = t instanceof ArrayBuffer ? new Uint16Array(t) : new Uint16Array(i ? t / 2 : t);
- return n && l.set(new Uint16Array(n)),
- l;
- case a.TEXTURETYPE_INT:
- var c = t instanceof ArrayBuffer ? new Int32Array(t) : new Int32Array(i ? t / 4 : t);
- return n && c.set(new Int32Array(n)),
- c;
- case a.TEXTURETYPE_UNSIGNED_INTEGER:
- case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
- case a.TEXTURETYPE_UNSIGNED_INT_24_8:
- case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
- case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
- case a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
- var u = t instanceof ArrayBuffer ? new Uint32Array(t) : new Uint32Array(i ? t / 4 : t);
- return n && u.set(new Uint32Array(n)),
- u;
- case a.TEXTURETYPE_FLOAT:
- var h = t instanceof ArrayBuffer ? new Float32Array(t) : new Float32Array(i ? t / 4 : t);
- return n && h.set(new Float32Array(n)),
- h
- }
- var d = (ArrayBuffer,
- new Uint8Array(t));
- return n && d.set(new Uint8Array(n)),
- d
- }
- Ht.prototype.setAlphaConstants = function(e, t, i, n) {
- this._alphaState.setAlphaBlendConstants(e, t, i, n)
- }
- ,
- Ht.prototype.setAlphaMode = function(e, t) {
- if (void 0 === t && (t = !1),
- this._alphaMode !== e) {
- switch (e) {
- case a.ALPHA_DISABLE:
- this._alphaState.alphaBlend = !1;
- break;
- case a.ALPHA_PREMULTIPLIED:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_PREMULTIPLIED_PORTERDUFF:
- 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 a.ALPHA_COMBINE:
- 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 a.ALPHA_ONEONE:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ADD:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_SUBTRACT:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_MULTIPLY:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_MAXIMIZED:
- 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 a.ALPHA_INTERPOLATE:
- 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 a.ALPHA_SCREENMODE:
- 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 a.ALPHA_ONEONE_ONEONE:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ALPHATOCOLOR:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_REVERSEONEMINUS:
- 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 a.ALPHA_SRC_DSTONEMINUSSRCALPHA:
- 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 a.ALPHA_ONEONE_ONEZERO:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_EXCLUSION:
- 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 a.ALPHA_LAYER_ACCUMULATE:
- 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
- }
- t || (this.depthCullingState.depthMask = e === a.ALPHA_DISABLE),
- this._alphaMode = e
- }
- }
- ,
- Ht.prototype.getAlphaMode = function() {
- return this._alphaMode
- }
- ,
- Ht.prototype.setAlphaEquation = function(e) {
- if (this._alphaEquation !== e) {
- switch (e) {
- case a.ALPHA_EQUATION_ADD:
- this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_ADD, a.GL_ALPHA_EQUATION_ADD);
- break;
- case a.ALPHA_EQUATION_SUBSTRACT:
- this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_SUBTRACT, a.GL_ALPHA_EQUATION_SUBTRACT);
- break;
- case a.ALPHA_EQUATION_REVERSE_SUBTRACT:
- this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT, a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT);
- break;
- case a.ALPHA_EQUATION_MAX:
- this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MAX, a.GL_ALPHA_EQUATION_MAX);
- break;
- case a.ALPHA_EQUATION_MIN:
- this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MIN, a.GL_ALPHA_EQUATION_MIN);
- break;
- case a.ALPHA_EQUATION_DARKEN:
- this._alphaState.setAlphaEquationParameters(a.GL_ALPHA_EQUATION_MIN, a.GL_ALPHA_EQUATION_ADD)
- }
- this._alphaEquation = e
- }
- }
- ,
- Ht.prototype.getAlphaEquation = function() {
- return this._alphaEquation
- }
- ,
- Ht.prototype._readTexturePixelsSync = function(e, t, i, n, r, o, a, s) {
- var l, c;
- void 0 === n && (n = -1),
- void 0 === r && (r = 0),
- void 0 === o && (o = null),
- void 0 === a && (a = !0),
- void 0 === s && (s = !1);
- var u = this._gl;
- if (!u)
- throw new Error("Engine does not have gl rendering context.");
- if (!this._dummyFramebuffer) {
- var h = u.createFramebuffer();
- if (!h)
- throw new Error("Unable to create dummy framebuffer");
- this._dummyFramebuffer = h
- }
- u.bindFramebuffer(u.FRAMEBUFFER, this._dummyFramebuffer),
- n > -1 ? u.framebufferTexture2D(u.FRAMEBUFFER, u.COLOR_ATTACHMENT0, u.TEXTURE_CUBE_MAP_POSITIVE_X + n, null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource, r) : u.framebufferTexture2D(u.FRAMEBUFFER, u.COLOR_ATTACHMENT0, u.TEXTURE_2D, null === (c = e._hardwareTexture) || void 0 === c ? void 0 : c.underlyingResource, r);
- var d = void 0 !== e.type ? this._getWebGLTextureType(e.type) : u.UNSIGNED_BYTE;
- return s ? o || (o = gr(e.type, 4 * t * i)) : d === u.UNSIGNED_BYTE ? (o || (o = new Uint8Array(4 * t * i)),
- d = u.UNSIGNED_BYTE) : (o || (o = new Float32Array(4 * t * i)),
- d = u.FLOAT),
- a && this.flushFramebuffer(),
- u.readPixels(0, 0, t, i, u.RGBA, d, o),
- u.bindFramebuffer(u.FRAMEBUFFER, this._currentFramebuffer),
- o
- }
- ,
- Ht.prototype._readTexturePixels = function(e, t, i, n, r, o, a, s) {
- return void 0 === n && (n = -1),
- void 0 === r && (r = 0),
- void 0 === o && (o = null),
- void 0 === a && (a = !0),
- void 0 === s && (s = !1),
- Promise.resolve(this._readTexturePixelsSync(e, t, i, n, r, o, a, s))
- }
- ,
- Ht.prototype.updateDynamicIndexBuffer = function(e, t, i) {
- var n;
- void 0 === i && (i = 0),
- this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null,
- this.bindIndexBuffer(e),
- n = t instanceof Uint16Array || t instanceof Uint32Array ? t : e.is32Bits ? new Uint32Array(t) : new Uint16Array(t),
- this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, n, this._gl.DYNAMIC_DRAW),
- this._resetIndexBufferBinding()
- }
- ,
- Ht.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
- this.bindArrayBuffer(e),
- void 0 === i && (i = 0);
- var r = t.length || t.byteLength;
- void 0 === n || n >= r && 0 === i ? t instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, i, new Float32Array(t)) : this._gl.bufferSubData(this._gl.ARRAY_BUFFER, i, t) : t instanceof Array ? this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(t).subarray(i, i + n)) : (t = t instanceof ArrayBuffer ? new Uint8Array(t,i,n) : new Uint8Array(t.buffer,t.byteOffset + i,n),
- this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, t)),
- this._resetVertexBufferBinding()
- }
- ;
- var vr = function(e) {
- function t(i, n, r, o) {
- void 0 === o && (o = !1);
- var s = e.call(this, i, n, r, o) || this;
- if (s.enableOfflineSupport = !1,
- s.disableManifestCheck = !1,
- s.scenes = new Array,
- s._virtualScenes = new Array,
- s.onNewSceneAddedObservable = new h,
- s.postProcesses = new Array,
- s.isPointerLock = !1,
- s.onResizeObservable = new h,
- s.onCanvasBlurObservable = new h,
- s.onCanvasFocusObservable = new h,
- s.onCanvasPointerOutObservable = new h,
- s.onBeginFrameObservable = new h,
- s.customAnimationFrameRequester = null,
- s.onEndFrameObservable = new h,
- s.onBeforeShaderCompilationObservable = new h,
- s.onAfterShaderCompilationObservable = new h,
- s._deterministicLockstep = !1,
- s._lockstepMaxSteps = 4,
- s._timeStep = 1 / 60,
- s._fps = 60,
- s._deltaTime = 0,
- s._drawCalls = new un,
- s.canvasTabIndex = 1,
- s.disablePerformanceMonitorInBackground = !1,
- s._performanceMonitor = new _r,
- s._compatibilityMode = !0,
- s.currentRenderPassId = a.RENDERPASS_MAIN,
- s._renderPassNames = ["main"],
- t.Instances.push(s),
- !i)
- return s;
- if (s._features.supportRenderPasses = !0,
- r = s._creationOptions,
- i.getContext) {
- var l = i;
- if (s._sharedInit(l, !!r.doNotHandleTouchAction, r.audioEngine),
- nt()) {
- var c = document;
- s._onFullscreenChange = function() {
- void 0 !== c.fullscreen ? s.isFullscreen = c.fullscreen : void 0 !== c.mozFullScreen ? s.isFullscreen = c.mozFullScreen : void 0 !== c.webkitIsFullScreen ? s.isFullscreen = c.webkitIsFullScreen : void 0 !== c.msIsFullScreen && (s.isFullscreen = c.msIsFullScreen),
- s.isFullscreen && s._pointerLockRequested && l && t._RequestPointerlock(l)
- }
- ,
- document.addEventListener("fullscreenchange", s._onFullscreenChange, !1),
- document.addEventListener("mozfullscreenchange", s._onFullscreenChange, !1),
- document.addEventListener("webkitfullscreenchange", s._onFullscreenChange, !1),
- document.addEventListener("msfullscreenchange", s._onFullscreenChange, !1),
- s._onPointerLockChange = function() {
- s.isPointerLock = c.mozPointerLockElement === l || c.webkitPointerLockElement === l || c.msPointerLockElement === l || c.pointerLockElement === l
- }
- ,
- document.addEventListener("pointerlockchange", s._onPointerLockChange, !1),
- document.addEventListener("mspointerlockchange", s._onPointerLockChange, !1),
- document.addEventListener("mozpointerlockchange", s._onPointerLockChange, !1),
- document.addEventListener("webkitpointerlockchange", s._onPointerLockChange, !1),
- !t.audioEngine && r.audioEngine && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(s.getRenderingCanvas(), s.getAudioContext(), s.getAudioDestination()))
- }
- s._connectVREvents(),
- s.enableOfflineSupport = void 0 !== t.OfflineProviderFactory,
- s._deterministicLockstep = !!r.deterministicLockstep,
- s._lockstepMaxSteps = r.lockstepMaxSteps || 0,
- s._timeStep = r.timeStep || 1 / 60
- }
- return s._prepareVRComponent(),
- r.autoEnableWebVR && s.initWebVR(),
- s
- }
- return U(t, e),
- Object.defineProperty(t, "NpmPackage", {
- get: function() {
- return Ht.NpmPackage
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "Version", {
- get: function() {
- return Ht.Version
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "Instances", {
- get: function() {
- return E.Instances
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "LastCreatedEngine", {
- get: function() {
- return E.LastCreatedEngine
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "LastCreatedScene", {
- get: function() {
- return E.LastCreatedScene
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.createImageBitmapFromSource = function(e, t) {
- var i = this;
- return new Promise((function(n, r) {
- var o = new Image;
- o.onload = function() {
- o.decode().then((function() {
- i.createImageBitmap(o, t).then((function(e) {
- n(e)
- }
- ))
- }
- ))
- }
- ,
- o.onerror = function() {
- r("Error loading image ".concat(o.src))
- }
- ,
- o.src = e
- }
- ))
- }
- ,
- t.prototype.createImageBitmap = function(e, t) {
- return createImageBitmap(e, t)
- }
- ,
- t.prototype.resizeImageBitmap = function(e, t, i) {
- var n = this.createCanvas(t, i).getContext("2d");
- if (!n)
- throw new Error("Unable to get 2d context for resizeImageBitmap");
- return n.drawImage(e, 0, 0),
- n.getImageData(0, 0, t, i).data
- }
- ,
- t.MarkAllMaterialsAsDirty = function(e, i) {
- for (var n = 0; n < t.Instances.length; n++)
- for (var r = t.Instances[n], o = 0; o < r.scenes.length; o++)
- r.scenes[o].markAllMaterialsAsDirty(e, i)
- }
- ,
- t.DefaultLoadingScreenFactory = function(e) {
- throw be("LoadingScreen")
- }
- ,
- Object.defineProperty(t.prototype, "_supportsHardwareTextureRescaling", {
- get: function() {
- return !!t._RescalePostProcessFactory
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "performanceMonitor", {
- get: function() {
- return this._performanceMonitor
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "compatibilityMode", {
- get: function() {
- return this._compatibilityMode
- },
- set: function(e) {
- this._compatibilityMode = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getInputElement = function() {
- return this._renderingCanvas
- }
- ,
- t.prototype._sharedInit = function(i, n, r) {
- var o = this;
- if (e.prototype._sharedInit.call(this, i, n, r),
- this._onCanvasFocus = function() {
- o.onCanvasFocusObservable.notifyObservers(o)
- }
- ,
- this._onCanvasBlur = function() {
- o.onCanvasBlurObservable.notifyObservers(o)
- }
- ,
- i.addEventListener("focus", this._onCanvasFocus),
- i.addEventListener("blur", this._onCanvasBlur),
- this._onBlur = function() {
- o.disablePerformanceMonitorInBackground && o._performanceMonitor.disable(),
- o._windowIsBackground = !0
- }
- ,
- this._onFocus = function() {
- o.disablePerformanceMonitorInBackground && o._performanceMonitor.enable(),
- o._windowIsBackground = !1
- }
- ,
- this._onCanvasPointerOut = function(e) {
- document.elementFromPoint(e.clientX, e.clientY) !== i && o.onCanvasPointerOutObservable.notifyObservers(e)
- }
- ,
- nt()) {
- var a = this.getHostWindow();
- a && (a.addEventListener("blur", this._onBlur),
- a.addEventListener("focus", this._onFocus))
- }
- i.addEventListener("pointerout", this._onCanvasPointerOut),
- n || this._disableTouchAction(),
- !t.audioEngine && r && t.AudioEngineFactory && (t.audioEngine = t.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination()))
- }
- ,
- t.prototype.getAspectRatio = function(e, t) {
- void 0 === t && (t = !1);
- var i = e.viewport;
- return this.getRenderWidth(t) * i.width / (this.getRenderHeight(t) * i.height)
- }
- ,
- t.prototype.getScreenAspectRatio = function() {
- return this.getRenderWidth(!0) / this.getRenderHeight(!0)
- }
- ,
- t.prototype.getRenderingCanvasClientRect = function() {
- return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null
- }
- ,
- t.prototype.getInputElementClientRect = function() {
- return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null
- }
- ,
- t.prototype.isDeterministicLockStep = function() {
- return this._deterministicLockstep
- }
- ,
- t.prototype.getLockstepMaxSteps = function() {
- return this._lockstepMaxSteps
- }
- ,
- t.prototype.getTimeStep = function() {
- return 1e3 * this._timeStep
- }
- ,
- t.prototype.generateMipMapsForCubemap = function(e, t) {
- if (void 0 === t && (t = !0),
- e.generateMipMaps) {
- var i = this._gl;
- this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, e, !0),
- i.generateMipmap(i.TEXTURE_CUBE_MAP),
- t && this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null)
- }
- }
- ,
- t.prototype.getDepthBuffer = function() {
- return this._depthCullingState.depthTest
- }
- ,
- t.prototype.setDepthBuffer = function(e) {
- this._depthCullingState.depthTest = e
- }
- ,
- t.prototype.getDepthWrite = function() {
- return this._depthCullingState.depthMask
- }
- ,
- t.prototype.setDepthWrite = function(e) {
- this._depthCullingState.depthMask = e
- }
- ,
- t.prototype.getStencilBuffer = function() {
- return this._stencilState.stencilTest
- }
- ,
- t.prototype.setStencilBuffer = function(e) {
- this._stencilState.stencilTest = e
- }
- ,
- t.prototype.getStencilMask = function() {
- return this._stencilState.stencilMask
- }
- ,
- t.prototype.setStencilMask = function(e) {
- this._stencilState.stencilMask = e
- }
- ,
- t.prototype.getStencilFunction = function() {
- return this._stencilState.stencilFunc
- }
- ,
- t.prototype.getStencilFunctionReference = function() {
- return this._stencilState.stencilFuncRef
- }
- ,
- t.prototype.getStencilFunctionMask = function() {
- return this._stencilState.stencilFuncMask
- }
- ,
- t.prototype.setStencilFunction = function(e) {
- this._stencilState.stencilFunc = e
- }
- ,
- t.prototype.setStencilFunctionReference = function(e) {
- this._stencilState.stencilFuncRef = e
- }
- ,
- t.prototype.setStencilFunctionMask = function(e) {
- this._stencilState.stencilFuncMask = e
- }
- ,
- t.prototype.getStencilOperationFail = function() {
- return this._stencilState.stencilOpStencilFail
- }
- ,
- t.prototype.getStencilOperationDepthFail = function() {
- return this._stencilState.stencilOpDepthFail
- }
- ,
- t.prototype.getStencilOperationPass = function() {
- return this._stencilState.stencilOpStencilDepthPass
- }
- ,
- t.prototype.setStencilOperationFail = function(e) {
- this._stencilState.stencilOpStencilFail = e
- }
- ,
- t.prototype.setStencilOperationDepthFail = function(e) {
- this._stencilState.stencilOpDepthFail = e
- }
- ,
- t.prototype.setStencilOperationPass = function(e) {
- this._stencilState.stencilOpStencilDepthPass = e
- }
- ,
- t.prototype.setDitheringState = function(e) {
- e ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER)
- }
- ,
- t.prototype.setRasterizerState = function(e) {
- e ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD)
- }
- ,
- t.prototype.getDepthFunction = function() {
- return this._depthCullingState.depthFunc
- }
- ,
- t.prototype.setDepthFunction = function(e) {
- this._depthCullingState.depthFunc = e
- }
- ,
- t.prototype.setDepthFunctionToGreater = function() {
- this.setDepthFunction(a.GREATER)
- }
- ,
- t.prototype.setDepthFunctionToGreaterOrEqual = function() {
- this.setDepthFunction(a.GEQUAL)
- }
- ,
- t.prototype.setDepthFunctionToLess = function() {
- this.setDepthFunction(a.LESS)
- }
- ,
- t.prototype.setDepthFunctionToLessOrEqual = function() {
- this.setDepthFunction(a.LEQUAL)
- }
- ,
- t.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()
- }
- ,
- t.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)
- }
- ,
- t.prototype.setDirectViewport = function(e, t, i, n) {
- var r = this._cachedViewport;
- return this._cachedViewport = null,
- this._viewport(e, t, i, n),
- r
- }
- ,
- t.prototype.scissorClear = function(e, t, i, n, r) {
- this.enableScissor(e, t, i, n),
- this.clear(r, !0, !0, !0),
- this.disableScissor()
- }
- ,
- t.prototype.enableScissor = function(e, t, i, n) {
- var r = this._gl;
- r.enable(r.SCISSOR_TEST),
- r.scissor(e, t, i, n)
- }
- ,
- t.prototype.disableScissor = function() {
- var e = this._gl;
- e.disable(e.SCISSOR_TEST)
- }
- ,
- t.prototype._reportDrawCall = function(e) {
- void 0 === e && (e = 1),
- this._drawCalls.addCount(e, !1)
- }
- ,
- t.prototype.initWebVR = function() {
- throw be("WebVRCamera")
- }
- ,
- t.prototype._prepareVRComponent = function() {}
- ,
- t.prototype._connectVREvents = function(e, t) {}
- ,
- t.prototype._submitVRFrame = function() {}
- ,
- t.prototype.disableVR = function() {}
- ,
- t.prototype.isVRPresenting = function() {
- return !1
- }
- ,
- t.prototype._requestVRFrame = function() {}
- ,
- t.prototype._loadFileAsync = function(e, t, i) {
- var n = this;
- return new Promise((function(r, o) {
- n._loadFile(e, (function(e) {
- r(e)
- }
- ), void 0, t, i, (function(e, t) {
- o(t)
- }
- ))
- }
- ))
- }
- ,
- t.prototype.getVertexShaderSource = function(e) {
- var t = this._gl.getAttachedShaders(e);
- return t ? this._gl.getShaderSource(t[0]) : null
- }
- ,
- t.prototype.getFragmentShaderSource = function(e) {
- var t = this._gl.getAttachedShaders(e);
- return t ? this._gl.getShaderSource(t[1]) : null
- }
- ,
- t.prototype.setDepthStencilTexture = function(e, t, i, n) {
- void 0 !== e && (t && (this._boundUniforms[e] = t),
- i && i.depthStencilTexture ? this._setTexture(e, i, !1, !0, n) : this._setTexture(e, null, void 0, void 0, n))
- }
- ,
- t.prototype.setTextureFromPostProcess = function(e, t, i) {
- var n, r = null;
- t && (t._textures.data[t._currentRenderTextureInd] ? r = t._textures.data[t._currentRenderTextureInd] : t._forcedOutputTexture && (r = t._forcedOutputTexture)),
- this._bindTexture(e, null !== (n = null == r ? void 0 : r.texture) && void 0 !== n ? n : null, i)
- }
- ,
- t.prototype.setTextureFromPostProcessOutput = function(e, t, i) {
- var n, r;
- this._bindTexture(e, null !== (r = null === (n = null == t ? void 0 : t._outputTexture) || void 0 === n ? void 0 : n.texture) && void 0 !== r ? r : null, i)
- }
- ,
- t.prototype._rebuildBuffers = function() {
- for (var t = 0, i = this.scenes; t < i.length; t++)
- (o = i[t]).resetCachedMaterial(),
- o._rebuildGeometries(),
- o._rebuildTextures();
- for (var n = 0, r = this._virtualScenes; n < r.length; n++) {
- var o;
- (o = r[n]).resetCachedMaterial(),
- o._rebuildGeometries(),
- o._rebuildTextures()
- }
- e.prototype._rebuildBuffers.call(this)
- }
- ,
- t.prototype._renderFrame = function() {
- for (var e = 0; e < this._activeRenderLoops.length; e++)
- (0,
- this._activeRenderLoops[e])()
- }
- ,
- t.prototype._renderLoop = function() {
- if (!this._contextWasLost) {
- var e = !0;
- !this.renderEvenInBackground && this._windowIsBackground && (e = !1),
- e && (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
- }
- ,
- t.prototype._renderViews = function() {
- return !1
- }
- ,
- t.prototype.switchFullscreen = function(e) {
- this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(e)
- }
- ,
- t.prototype.enterFullscreen = function(e) {
- this.isFullscreen || (this._pointerLockRequested = e,
- this._renderingCanvas && t._RequestFullscreen(this._renderingCanvas))
- }
- ,
- t.prototype.exitFullscreen = function() {
- this.isFullscreen && t._ExitFullscreen()
- }
- ,
- t.prototype.enterPointerlock = function() {
- this._renderingCanvas && t._RequestPointerlock(this._renderingCanvas)
- }
- ,
- t.prototype.exitPointerlock = function() {
- t._ExitPointerlock()
- }
- ,
- t.prototype.beginFrame = function() {
- this._measureFps(),
- this.onBeginFrameObservable.notifyObservers(this),
- e.prototype.beginFrame.call(this)
- }
- ,
- t.prototype.endFrame = function() {
- e.prototype.endFrame.call(this),
- this._submitVRFrame(),
- this.onEndFrameObservable.notifyObservers(this)
- }
- ,
- t.prototype.resize = function(t) {
- void 0 === t && (t = !1),
- this.isVRPresenting() || e.prototype.resize.call(this, t)
- }
- ,
- t.prototype.setSize = function(t, i, n) {
- if (void 0 === n && (n = !1),
- !this._renderingCanvas)
- return !1;
- if (!e.prototype.setSize.call(this, t, i, n))
- return !1;
- if (this.scenes) {
- for (var r = 0; r < this.scenes.length; r++)
- for (var o = this.scenes[r], a = 0; a < o.cameras.length; a++)
- o.cameras[a]._currentRenderId = 0;
- this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this)
- }
- return !0
- }
- ,
- t.prototype._deletePipelineContext = function(t) {
- var i = t;
- i && i.program && i.transformFeedback && (this.deleteTransformFeedback(i.transformFeedback),
- i.transformFeedback = null),
- e.prototype._deletePipelineContext.call(this, t)
- }
- ,
- t.prototype.createShaderProgram = function(t, i, n, r, o, a) {
- void 0 === a && (a = null),
- o = o || this._gl,
- this.onBeforeShaderCompilationObservable.notifyObservers(this);
- var s = e.prototype.createShaderProgram.call(this, t, i, n, r, o, a);
- return this.onAfterShaderCompilationObservable.notifyObservers(this),
- s
- }
- ,
- t.prototype._createShaderProgram = function(e, t, i, n, r) {
- void 0 === r && (r = null);
- var o = n.createProgram();
- if (e.program = o,
- !o)
- throw new Error("Unable to create program");
- if (n.attachShader(o, t),
- n.attachShader(o, i),
- this.webGLVersion > 1 && r) {
- var a = this.createTransformFeedback();
- this.bindTransformFeedback(a),
- this.setTranformFeedbackVaryings(o, r),
- e.transformFeedback = a
- }
- return n.linkProgram(o),
- this.webGLVersion > 1 && r && this.bindTransformFeedback(null),
- e.context = n,
- e.vertexShader = t,
- e.fragmentShader = i,
- e.isParallelCompiled || this._finalizePipelineContext(e),
- o
- }
- ,
- t.prototype._releaseTexture = function(t) {
- e.prototype._releaseTexture.call(this, t)
- }
- ,
- t.prototype._releaseRenderTargetWrapper = function(t) {
- e.prototype._releaseRenderTargetWrapper.call(this, t),
- this.scenes.forEach((function(e) {
- e.postProcesses.forEach((function(e) {
- e._outputTexture === t && (e._outputTexture = null)
- }
- )),
- e.cameras.forEach((function(e) {
- e._postProcesses.forEach((function(e) {
- e && e._outputTexture === t && (e._outputTexture = null)
- }
- ))
- }
- ))
- }
- ))
- }
- ,
- t.prototype.getRenderPassNames = function() {
- return this._renderPassNames
- }
- ,
- t.prototype.getCurrentRenderPassName = function() {
- return this._renderPassNames[this.currentRenderPassId]
- }
- ,
- t.prototype.createRenderPassId = function(e) {
- var i = ++t._RenderPassIdCounter;
- return this._renderPassNames[i] = null != e ? e : "NONAME",
- i
- }
- ,
- t.prototype.releaseRenderPassId = function(e) {
- this._renderPassNames[e] = void 0;
- for (var t = 0; t < this.scenes.length; ++t)
- for (var i = this.scenes[t], n = 0; n < i.meshes.length; ++n) {
- var r = i.meshes[n];
- if (r.subMeshes)
- for (var o = 0; o < r.subMeshes.length; ++o)
- r.subMeshes[o]._removeDrawWrapper(e)
- }
- }
- ,
- t.prototype._rescaleTexture = function(e, i, n, r, o) {
- var s = 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 l = this.createRenderTargetTexture({
- width: i.width,
- height: i.height
- }, {
- generateMipMaps: !1,
- type: a.TEXTURETYPE_UNSIGNED_INT,
- samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1
- });
- !this._rescalePostProcess && t._RescalePostProcessFactory && (this._rescalePostProcess = t._RescalePostProcessFactory(this)),
- this._rescalePostProcess.externalTextureSamplerBinding = !0,
- this._rescalePostProcess.getEffect().executeWhenCompiled((function() {
- s._rescalePostProcess.onApply = function(t) {
- t._bindTexture("textureSampler", e)
- }
- ;
- var t = n;
- t || (t = s.scenes[s.scenes.length - 1]),
- t.postProcessManager.directRender([s._rescalePostProcess], l, !0),
- s._bindTextureDirectly(s._gl.TEXTURE_2D, i, !0),
- s._gl.copyTexImage2D(s._gl.TEXTURE_2D, 0, r, 0, 0, i.width, i.height, 0),
- s.unBindFramebuffer(l),
- l.dispose(),
- o && o()
- }
- ))
- }
- ,
- t.prototype.getFps = function() {
- return this._fps
- }
- ,
- t.prototype.getDeltaTime = function() {
- return this._deltaTime
- }
- ,
- t.prototype._measureFps = function() {
- this._performanceMonitor.sampleFrame(),
- this._fps = this._performanceMonitor.averageFPS,
- this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0
- }
- ,
- t.prototype._uploadImageToTexture = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0);
- var r = this._gl
- , o = this._getWebGLTextureType(e.type)
- , a = this._getInternalFormat(e.format)
- , s = this._getRGBABufferInternalSizedFormat(e.type, a)
- , l = e.isCube ? r.TEXTURE_CUBE_MAP : r.TEXTURE_2D;
- this._bindTextureDirectly(l, e, !0),
- this._unpackFlipY(e.invertY);
- var c = r.TEXTURE_2D;
- e.isCube && (c = r.TEXTURE_CUBE_MAP_POSITIVE_X + i),
- r.texImage2D(c, n, s, a, o, t),
- this._bindTextureDirectly(l, null, !0)
- }
- ,
- t.prototype.updateTextureComparisonFunction = function(e, t) {
- if (1 !== this.webGLVersion) {
- var i = this._gl;
- e.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, e, !0),
- 0 === t ? (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_FUNC, a.LEQUAL),
- i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_MODE, i.NONE)) : (i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_FUNC, t),
- i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE)),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
- 0 === t ? (i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_FUNC, a.LEQUAL),
- i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_MODE, i.NONE)) : (i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_FUNC, t),
- i.texParameteri(i.TEXTURE_2D, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE)),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null)),
- e._comparisonFunction = t
- } else
- K.Error("WebGL 1 does not support texture comparison.")
- }
- ,
- t.prototype.createInstancesBuffer = function(e) {
- var t = this._gl.createBuffer();
- if (!t)
- throw new Error("Unable to create instance buffer");
- var i = new Ut(t);
- return i.capacity = e,
- this.bindArrayBuffer(i),
- this._gl.bufferData(this._gl.ARRAY_BUFFER, e, this._gl.DYNAMIC_DRAW),
- i.references = 1,
- i
- }
- ,
- t.prototype.deleteInstancesBuffer = function(e) {
- this._gl.deleteBuffer(e)
- }
- ,
- t.prototype._clientWaitAsync = function(e, t, i) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 10);
- var n = this._gl;
- return new Promise((function(r, o) {
- var a = function() {
- var s = n.clientWaitSync(e, t, 0);
- s != n.WAIT_FAILED ? s != n.TIMEOUT_EXPIRED ? r() : setTimeout(a, i) : o()
- };
- a()
- }
- ))
- }
- ,
- t.prototype._readPixelsAsync = function(e, t, i, n, r, o, a) {
- if (this._webGLVersion < 2)
- throw new Error("_readPixelsAsync only work on WebGL2+");
- var s = this._gl
- , l = s.createBuffer();
- s.bindBuffer(s.PIXEL_PACK_BUFFER, l),
- s.bufferData(s.PIXEL_PACK_BUFFER, a.byteLength, s.STREAM_READ),
- s.readPixels(e, t, i, n, r, o, 0),
- s.bindBuffer(s.PIXEL_PACK_BUFFER, null);
- var c = s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE, 0);
- return c ? (s.flush(),
- this._clientWaitAsync(c, 0, 10).then((function() {
- return s.deleteSync(c),
- s.bindBuffer(s.PIXEL_PACK_BUFFER, l),
- s.getBufferSubData(s.PIXEL_PACK_BUFFER, 0, a),
- s.bindBuffer(s.PIXEL_PACK_BUFFER, null),
- s.deleteBuffer(l),
- a
- }
- ))) : null
- }
- ,
- t.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();
- 1 === t.Instances.length && t.audioEngine && (t.audioEngine.dispose(),
- t.audioEngine = null),
- this.disableVR(),
- nt() && (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)),
- ot() && (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))),
- e.prototype.dispose.call(this);
- var i = t.Instances.indexOf(this);
- i >= 0 && t.Instances.splice(i, 1),
- this.onResizeObservable.clear(),
- this.onCanvasBlurObservable.clear(),
- this.onCanvasFocusObservable.clear(),
- this.onCanvasPointerOutObservable.clear(),
- this.onBeginFrameObservable.clear(),
- this.onEndFrameObservable.clear()
- }
- ,
- t.prototype._disableTouchAction = function() {
- this._renderingCanvas && this._renderingCanvas.setAttribute && (this._renderingCanvas.setAttribute("touch-action", "none"),
- this._renderingCanvas.style.touchAction = "none",
- this._renderingCanvas.style.msTouchAction = "none")
- }
- ,
- t.prototype.displayLoadingUI = function() {
- if (nt()) {
- var e = this.loadingScreen;
- e && e.displayLoadingUI()
- }
- }
- ,
- t.prototype.hideLoadingUI = function() {
- if (nt()) {
- var e = this._loadingScreen;
- e && e.hideLoadingUI()
- }
- }
- ,
- Object.defineProperty(t.prototype, "loadingScreen", {
- get: function() {
- return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = t.DefaultLoadingScreenFactory(this._renderingCanvas)),
- this._loadingScreen
- },
- set: function(e) {
- this._loadingScreen = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "loadingUIText", {
- set: function(e) {
- this.loadingScreen.loadingUIText = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "loadingUIBackgroundColor", {
- set: function(e) {
- this.loadingScreen.loadingUIBackgroundColor = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.createVideoElement = function(e) {
- return document.createElement("video")
- }
- ,
- t._RequestPointerlock = function(e) {
- e.requestPointerLock = e.requestPointerLock || e.msRequestPointerLock || e.mozRequestPointerLock || e.webkitRequestPointerLock,
- e.requestPointerLock && e.requestPointerLock()
- }
- ,
- t._ExitPointerlock = function() {
- var e = document;
- document.exitPointerLock = document.exitPointerLock || e.msExitPointerLock || e.mozExitPointerLock || e.webkitExitPointerLock,
- document.exitPointerLock && document.exitPointerLock()
- }
- ,
- t._RequestFullscreen = function(e) {
- var t = e.requestFullscreen || e.msRequestFullscreen || e.webkitRequestFullscreen || e.mozRequestFullScreen;
- t && t.call(e)
- }
- ,
- t._ExitFullscreen = function() {
- var e = document;
- document.exitFullscreen ? document.exitFullscreen() : e.mozCancelFullScreen ? e.mozCancelFullScreen() : e.webkitCancelFullScreen ? e.webkitCancelFullScreen() : e.msCancelFullScreen && e.msCancelFullScreen()
- }
- ,
- t.prototype.getFontOffset = function(e) {
- var t = document.createElement("span");
- t.innerHTML = "Hg",
- t.setAttribute("style", "font: ".concat(e, " !important"));
- var i = document.createElement("div");
- i.style.display = "inline-block",
- i.style.width = "1px",
- i.style.height = "0px",
- i.style.verticalAlign = "bottom";
- var n = document.createElement("div");
- n.style.whiteSpace = "nowrap",
- n.appendChild(t),
- n.appendChild(i),
- document.body.appendChild(n);
- var r = 0
- , o = 0;
- try {
- o = i.getBoundingClientRect().top - t.getBoundingClientRect().top,
- i.style.verticalAlign = "baseline",
- r = i.getBoundingClientRect().top - t.getBoundingClientRect().top
- } finally {
- document.body.removeChild(n)
- }
- return {
- ascent: r,
- height: o,
- descent: o - r
- }
- }
- ,
- t.ALPHA_DISABLE = a.ALPHA_DISABLE,
- t.ALPHA_ADD = a.ALPHA_ADD,
- t.ALPHA_COMBINE = a.ALPHA_COMBINE,
- t.ALPHA_SUBTRACT = a.ALPHA_SUBTRACT,
- t.ALPHA_MULTIPLY = a.ALPHA_MULTIPLY,
- t.ALPHA_MAXIMIZED = a.ALPHA_MAXIMIZED,
- t.ALPHA_ONEONE = a.ALPHA_ONEONE,
- t.ALPHA_PREMULTIPLIED = a.ALPHA_PREMULTIPLIED,
- t.ALPHA_PREMULTIPLIED_PORTERDUFF = a.ALPHA_PREMULTIPLIED_PORTERDUFF,
- t.ALPHA_INTERPOLATE = a.ALPHA_INTERPOLATE,
- t.ALPHA_SCREENMODE = a.ALPHA_SCREENMODE,
- t.DELAYLOADSTATE_NONE = a.DELAYLOADSTATE_NONE,
- t.DELAYLOADSTATE_LOADED = a.DELAYLOADSTATE_LOADED,
- t.DELAYLOADSTATE_LOADING = a.DELAYLOADSTATE_LOADING,
- t.DELAYLOADSTATE_NOTLOADED = a.DELAYLOADSTATE_NOTLOADED,
- t.NEVER = a.NEVER,
- t.ALWAYS = a.ALWAYS,
- t.LESS = a.LESS,
- t.EQUAL = a.EQUAL,
- t.LEQUAL = a.LEQUAL,
- t.GREATER = a.GREATER,
- t.GEQUAL = a.GEQUAL,
- t.NOTEQUAL = a.NOTEQUAL,
- t.KEEP = a.KEEP,
- t.REPLACE = a.REPLACE,
- t.INCR = a.INCR,
- t.DECR = a.DECR,
- t.INVERT = a.INVERT,
- t.INCR_WRAP = a.INCR_WRAP,
- t.DECR_WRAP = a.DECR_WRAP,
- t.TEXTURE_CLAMP_ADDRESSMODE = a.TEXTURE_CLAMP_ADDRESSMODE,
- t.TEXTURE_WRAP_ADDRESSMODE = a.TEXTURE_WRAP_ADDRESSMODE,
- t.TEXTURE_MIRROR_ADDRESSMODE = a.TEXTURE_MIRROR_ADDRESSMODE,
- t.TEXTUREFORMAT_ALPHA = a.TEXTUREFORMAT_ALPHA,
- t.TEXTUREFORMAT_LUMINANCE = a.TEXTUREFORMAT_LUMINANCE,
- t.TEXTUREFORMAT_LUMINANCE_ALPHA = a.TEXTUREFORMAT_LUMINANCE_ALPHA,
- t.TEXTUREFORMAT_RGB = a.TEXTUREFORMAT_RGB,
- t.TEXTUREFORMAT_RGBA = a.TEXTUREFORMAT_RGBA,
- t.TEXTUREFORMAT_RED = a.TEXTUREFORMAT_RED,
- t.TEXTUREFORMAT_R = a.TEXTUREFORMAT_R,
- t.TEXTUREFORMAT_RG = a.TEXTUREFORMAT_RG,
- t.TEXTUREFORMAT_RED_INTEGER = a.TEXTUREFORMAT_RED_INTEGER,
- t.TEXTUREFORMAT_R_INTEGER = a.TEXTUREFORMAT_R_INTEGER,
- t.TEXTUREFORMAT_RG_INTEGER = a.TEXTUREFORMAT_RG_INTEGER,
- t.TEXTUREFORMAT_RGB_INTEGER = a.TEXTUREFORMAT_RGB_INTEGER,
- t.TEXTUREFORMAT_RGBA_INTEGER = a.TEXTUREFORMAT_RGBA_INTEGER,
- t.TEXTURETYPE_UNSIGNED_BYTE = a.TEXTURETYPE_UNSIGNED_BYTE,
- t.TEXTURETYPE_UNSIGNED_INT = a.TEXTURETYPE_UNSIGNED_INT,
- t.TEXTURETYPE_FLOAT = a.TEXTURETYPE_FLOAT,
- t.TEXTURETYPE_HALF_FLOAT = a.TEXTURETYPE_HALF_FLOAT,
- t.TEXTURETYPE_BYTE = a.TEXTURETYPE_BYTE,
- t.TEXTURETYPE_SHORT = a.TEXTURETYPE_SHORT,
- t.TEXTURETYPE_UNSIGNED_SHORT = a.TEXTURETYPE_UNSIGNED_SHORT,
- t.TEXTURETYPE_INT = a.TEXTURETYPE_INT,
- t.TEXTURETYPE_UNSIGNED_INTEGER = a.TEXTURETYPE_UNSIGNED_INTEGER,
- t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,
- t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,
- t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
- t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,
- t.TEXTURETYPE_UNSIGNED_INT_24_8 = a.TEXTURETYPE_UNSIGNED_INT_24_8,
- t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,
- t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,
- t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,
- t.TEXTURE_NEAREST_SAMPLINGMODE = a.TEXTURE_NEAREST_SAMPLINGMODE,
- t.TEXTURE_BILINEAR_SAMPLINGMODE = a.TEXTURE_BILINEAR_SAMPLINGMODE,
- t.TEXTURE_TRILINEAR_SAMPLINGMODE = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- t.TEXTURE_NEAREST_NEAREST_MIPLINEAR = a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,
- t.TEXTURE_LINEAR_LINEAR_MIPNEAREST = a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,
- t.TEXTURE_LINEAR_LINEAR_MIPLINEAR = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,
- t.TEXTURE_NEAREST_NEAREST_MIPNEAREST = a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,
- t.TEXTURE_NEAREST_LINEAR_MIPNEAREST = a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,
- t.TEXTURE_NEAREST_LINEAR_MIPLINEAR = a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,
- t.TEXTURE_NEAREST_LINEAR = a.TEXTURE_NEAREST_LINEAR,
- t.TEXTURE_NEAREST_NEAREST = a.TEXTURE_NEAREST_NEAREST,
- t.TEXTURE_LINEAR_NEAREST_MIPNEAREST = a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,
- t.TEXTURE_LINEAR_NEAREST_MIPLINEAR = a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,
- t.TEXTURE_LINEAR_LINEAR = a.TEXTURE_LINEAR_LINEAR,
- t.TEXTURE_LINEAR_NEAREST = a.TEXTURE_LINEAR_NEAREST,
- t.TEXTURE_EXPLICIT_MODE = a.TEXTURE_EXPLICIT_MODE,
- t.TEXTURE_SPHERICAL_MODE = a.TEXTURE_SPHERICAL_MODE,
- t.TEXTURE_PLANAR_MODE = a.TEXTURE_PLANAR_MODE,
- t.TEXTURE_CUBIC_MODE = a.TEXTURE_CUBIC_MODE,
- t.TEXTURE_PROJECTION_MODE = a.TEXTURE_PROJECTION_MODE,
- t.TEXTURE_SKYBOX_MODE = a.TEXTURE_SKYBOX_MODE,
- t.TEXTURE_INVCUBIC_MODE = a.TEXTURE_INVCUBIC_MODE,
- t.TEXTURE_EQUIRECTANGULAR_MODE = a.TEXTURE_EQUIRECTANGULAR_MODE,
- t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,
- t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
- t.SCALEMODE_FLOOR = a.SCALEMODE_FLOOR,
- t.SCALEMODE_NEAREST = a.SCALEMODE_NEAREST,
- t.SCALEMODE_CEILING = a.SCALEMODE_CEILING,
- t._RescalePostProcessFactory = null,
- t._RenderPassIdCounter = 0,
- t
- }(Ht)
- , yr = function(e) {
- function t(i, n, r) {
- void 0 === n && (n = null),
- void 0 === r && (r = !0);
- var o = e.call(this, i, n) || this;
- return o._forward = new x(0,0,1),
- o._up = new x(0,1,0),
- o._right = new x(1,0,0),
- o._position = x.Zero(),
- o._rotation = x.Zero(),
- o._rotationQuaternion = null,
- o._scaling = x.One(),
- o._transformToBoneReferal = null,
- o._isAbsoluteSynced = !1,
- o._billboardMode = t.BILLBOARDMODE_NONE,
- o._preserveParentRotationForBillboard = !1,
- o.scalingDeterminant = 1,
- o._infiniteDistance = !1,
- o.ignoreNonUniformScaling = !1,
- o.reIntegrateRotationIntoRotationQuaternion = !1,
- o._poseMatrix = null,
- o._localMatrix = P.Zero(),
- o._usePivotMatrix = !1,
- o._absolutePosition = x.Zero(),
- o._absoluteScaling = x.Zero(),
- o._absoluteRotationQuaternion = C.Identity(),
- o._pivotMatrix = P.Identity(),
- o._postMultiplyPivotMatrix = !1,
- o._isWorldMatrixFrozen = !1,
- o._indexInSceneTransformNodesArray = -1,
- o.onAfterWorldMatrixUpdateObservable = new h,
- o._nonUniformScaling = !1,
- r && o.getScene().addTransformNode(o),
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "billboardMode", {
- get: function() {
- return this._billboardMode
- },
- set: function(e) {
- this._billboardMode !== e && (this._billboardMode = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "preserveParentRotationForBillboard", {
- get: function() {
- return this._preserveParentRotationForBillboard
- },
- set: function(e) {
- e !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "infiniteDistance", {
- get: function() {
- return this._infiniteDistance
- },
- set: function(e) {
- this._infiniteDistance !== e && (this._infiniteDistance = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "TransformNode"
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(e) {
- this._position = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.isUsingPivotMatrix = function() {
- return this._usePivotMatrix
- }
- ,
- Object.defineProperty(t.prototype, "rotation", {
- get: function() {
- return this._rotation
- },
- set: function(e) {
- this._rotation = e,
- this._rotationQuaternion = null,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scaling", {
- get: function() {
- return this._scaling
- },
- set: function(e) {
- this._scaling = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationQuaternion", {
- get: function() {
- return this._rotationQuaternion
- },
- set: function(e) {
- this._rotationQuaternion = e,
- e && this._rotation.setAll(0),
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "forward", {
- get: function() {
- return x.TransformNormalFromFloatsToRef(0, 0, this.getScene().useRightHandedSystem ? -1 : 1, this.getWorldMatrix(), this._forward),
- this._forward.normalize()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "up", {
- get: function() {
- return x.TransformNormalFromFloatsToRef(0, 1, 0, this.getWorldMatrix(), this._up),
- this._up.normalize()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return x.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem ? -1 : 1, 0, 0, this.getWorldMatrix(), this._right),
- this._right.normalize()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.updatePoseMatrix = function(e) {
- return this._poseMatrix ? (this._poseMatrix.copyFrom(e),
- this) : (this._poseMatrix = e.clone(),
- this)
- }
- ,
- t.prototype.getPoseMatrix = function() {
- return this._poseMatrix || (this._poseMatrix = P.Identity()),
- this._poseMatrix
- }
- ,
- t.prototype._isSynchronized = function() {
- var e = this._cache;
- return !(this.billboardMode !== e.billboardMode || this.billboardMode !== t.BILLBOARDMODE_NONE || e.pivotMatrixUpdated || this.infiniteDistance || this.position._isDirty || this.scaling._isDirty || this._rotationQuaternion && this._rotationQuaternion._isDirty || this.rotation._isDirty)
- }
- ,
- t.prototype._initCache = function() {
- e.prototype._initCache.call(this);
- var t = this._cache;
- t.localMatrixUpdated = !1,
- t.billboardMode = -1,
- t.infiniteDistance = !1
- }
- ,
- Object.defineProperty(t.prototype, "absolutePosition", {
- get: function() {
- return this.getAbsolutePosition()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "absoluteScaling", {
- get: function() {
- return this._syncAbsoluteScalingAndRotation(),
- this._absoluteScaling
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "absoluteRotationQuaternion", {
- get: function() {
- return this._syncAbsoluteScalingAndRotation(),
- this._absoluteRotationQuaternion
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setPreTransformMatrix = function(e) {
- return this.setPivotMatrix(e, !1)
- }
- ,
- t.prototype.setPivotMatrix = function(e, t) {
- return void 0 === t && (t = !0),
- this._pivotMatrix.copyFrom(e),
- this._usePivotMatrix = !this._pivotMatrix.isIdentity(),
- this._cache.pivotMatrixUpdated = !0,
- this._postMultiplyPivotMatrix = t,
- this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = P.Invert(this._pivotMatrix)),
- this
- }
- ,
- t.prototype.getPivotMatrix = function() {
- return this._pivotMatrix
- }
- ,
- t.prototype.instantiateHierarchy = function(e, t, i) {
- void 0 === e && (e = null);
- var n = this.clone("Clone of " + (this.name || this.id), e || this.parent, !0);
- n && i && i(this, n);
- for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++)
- o[r].instantiateHierarchy(n, t, i);
- return n
- }
- ,
- t.prototype.freezeWorldMatrix = function(e, t) {
- return void 0 === e && (e = null),
- void 0 === t && (t = !1),
- e ? t ? (this._rotation.setAll(0),
- this._rotationQuaternion = this._rotationQuaternion || C.Identity(),
- e.decompose(this._scaling, this._rotationQuaternion, this._position),
- this.computeWorldMatrix(!0)) : (this._worldMatrix = e,
- 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
- }
- ,
- t.prototype.unfreezeWorldMatrix = function() {
- return this._isWorldMatrixFrozen = !1,
- this.computeWorldMatrix(!0),
- this
- }
- ,
- Object.defineProperty(t.prototype, "isWorldMatrixFrozen", {
- get: function() {
- return this._isWorldMatrixFrozen
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getAbsolutePosition = function() {
- return this.computeWorldMatrix(),
- this._absolutePosition
- }
- ,
- t.prototype.setAbsolutePosition = function(e) {
- if (!e)
- return this;
- var t, i, n;
- if (void 0 === e.x) {
- if (arguments.length < 3)
- return this;
- t = arguments[0],
- i = arguments[1],
- n = arguments[2]
- } else
- t = e.x,
- i = e.y,
- n = e.z;
- if (this.parent) {
- var r = I.Matrix[0];
- this.parent.getWorldMatrix().invertToRef(r),
- x.TransformCoordinatesFromFloatsToRef(t, i, n, r, this.position)
- } else
- this.position.x = t,
- this.position.y = i,
- this.position.z = n;
- return this._absolutePosition.copyFrom(e),
- this
- }
- ,
- t.prototype.setPositionWithLocalVector = function(e) {
- return this.computeWorldMatrix(),
- this.position = x.TransformNormal(e, this._localMatrix),
- this
- }
- ,
- t.prototype.getPositionExpressedInLocalSpace = function() {
- this.computeWorldMatrix();
- var e = I.Matrix[0];
- return this._localMatrix.invertToRef(e),
- x.TransformNormal(this.position, e)
- }
- ,
- t.prototype.locallyTranslate = function(e) {
- return this.computeWorldMatrix(!0),
- this.position = x.TransformCoordinates(e, this._localMatrix),
- this
- }
- ,
- t.prototype.lookAt = function(e, i, n, r, o) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- void 0 === r && (r = 0),
- void 0 === o && (o = Ji.LOCAL);
- var a = t._LookAtVectorCache
- , s = o === Ji.LOCAL ? this.position : this.getAbsolutePosition();
- if (e.subtractToRef(s, a),
- this.setDirection(a, i, n, r),
- o === Ji.WORLD && this.parent)
- if (this.rotationQuaternion) {
- var l = I.Matrix[0];
- this.rotationQuaternion.toRotationMatrix(l);
- var c = I.Matrix[1];
- this.parent.getWorldMatrix().getRotationMatrixToRef(c),
- c.invert(),
- l.multiplyToRef(c, l),
- this.rotationQuaternion.fromRotationMatrix(l)
- } else {
- var u = I.Quaternion[0];
- C.FromEulerVectorToRef(this.rotation, u),
- l = I.Matrix[0],
- u.toRotationMatrix(l),
- c = I.Matrix[1],
- this.parent.getWorldMatrix().getRotationMatrixToRef(c),
- c.invert(),
- l.multiplyToRef(c, l),
- u.fromRotationMatrix(l),
- u.toEulerAnglesToRef(this.rotation)
- }
- return this
- }
- ,
- t.prototype.getDirection = function(e) {
- var t = x.Zero();
- return this.getDirectionToRef(e, t),
- t
- }
- ,
- t.prototype.getDirectionToRef = function(e, t) {
- return x.TransformNormalToRef(e, this.getWorldMatrix(), t),
- this
- }
- ,
- t.prototype.setDirection = function(e, t, i, n) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- void 0 === n && (n = 0);
- var r = -Math.atan2(e.z, e.x) + Math.PI / 2
- , o = Math.sqrt(e.x * e.x + e.z * e.z)
- , a = -Math.atan2(e.y, o);
- return this.rotationQuaternion ? C.RotationYawPitchRollToRef(r + t, a + i, n, this.rotationQuaternion) : (this.rotation.x = a + i,
- this.rotation.y = r + t,
- this.rotation.z = n),
- this
- }
- ,
- t.prototype.setPivotPoint = function(e, t) {
- void 0 === t && (t = Ji.LOCAL),
- 0 == this.getScene().getRenderId() && this.computeWorldMatrix(!0);
- var i = this.getWorldMatrix();
- if (t == Ji.WORLD) {
- var n = I.Matrix[0];
- i.invertToRef(n),
- e = x.TransformCoordinates(e, n)
- }
- return this.setPivotMatrix(P.Translation(-e.x, -e.y, -e.z), !0)
- }
- ,
- t.prototype.getPivotPoint = function() {
- var e = x.Zero();
- return this.getPivotPointToRef(e),
- e
- }
- ,
- t.prototype.getPivotPointToRef = function(e) {
- return e.x = -this._pivotMatrix.m[12],
- e.y = -this._pivotMatrix.m[13],
- e.z = -this._pivotMatrix.m[14],
- this
- }
- ,
- t.prototype.getAbsolutePivotPoint = function() {
- var e = x.Zero();
- return this.getAbsolutePivotPointToRef(e),
- e
- }
- ,
- t.prototype.getAbsolutePivotPointToRef = function(e) {
- return this.getPivotPointToRef(e),
- x.TransformCoordinatesToRef(e, this.getWorldMatrix(), e),
- this
- }
- ,
- t.prototype.markAsDirty = function(t) {
- if (this._children)
- for (var i = 0, n = this._children; i < n.length; i++)
- n[i].markAsDirty(t);
- return e.prototype.markAsDirty.call(this, t)
- }
- ,
- t.prototype.setParent = function(e, i) {
- if (void 0 === i && (i = !1),
- !e && !this.parent)
- return this;
- var n = I.Quaternion[0]
- , r = I.Vector3[0]
- , o = I.Vector3[1]
- , a = I.Matrix[1];
- P.IdentityToRef(a);
- var s = I.Matrix[0];
- this.computeWorldMatrix(!0);
- var l = this.rotationQuaternion;
- return l || (l = t._TmpRotation,
- C.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, l)),
- P.ComposeToRef(this.scaling, l, this.position, s),
- this.parent && s.multiplyToRef(this.parent.computeWorldMatrix(!0), s),
- e && (e.computeWorldMatrix(!0).invertToRef(a),
- s.multiplyToRef(a, s)),
- s.decompose(o, n, r, i ? this : void 0),
- this.rotationQuaternion ? this.rotationQuaternion.copyFrom(n) : n.toEulerAnglesToRef(this.rotation),
- this.scaling.copyFrom(o),
- this.position.copyFrom(r),
- this.parent = e,
- this
- }
- ,
- Object.defineProperty(t.prototype, "nonUniformScaling", {
- get: function() {
- return this._nonUniformScaling
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._updateNonUniformScalingState = function(e) {
- return this._nonUniformScaling !== e && (this._nonUniformScaling = e,
- !0)
- }
- ,
- t.prototype.attachToBone = function(e, t) {
- return this._currentParentWhenAttachingToBone = this.parent,
- this._transformToBoneReferal = t,
- this.parent = e,
- e.getSkeleton().prepare(),
- e.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
- this
- }
- ,
- t.prototype.detachFromBone = function(e) {
- return void 0 === e && (e = !1),
- this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
- this._transformToBoneReferal = null,
- this.parent = e ? this._currentParentWhenAttachingToBone : null,
- this) : (e && (this.parent = this._currentParentWhenAttachingToBone),
- this)
- }
- ,
- t.prototype.rotate = function(e, i, n) {
- var r;
- if (e.normalize(),
- this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(),
- this.rotation.setAll(0)),
- n && n !== Ji.LOCAL) {
- if (this.parent) {
- var o = I.Matrix[0];
- this.parent.getWorldMatrix().invertToRef(o),
- e = x.TransformNormal(e, o)
- }
- (r = C.RotationAxisToRef(e, i, t._RotationAxisCache)).multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
- } else
- r = C.RotationAxisToRef(e, i, t._RotationAxisCache),
- this.rotationQuaternion.multiplyToRef(r, this.rotationQuaternion);
- return this
- }
- ,
- t.prototype.rotateAround = function(e, t, i) {
- t.normalize(),
- this.rotationQuaternion || (this.rotationQuaternion = C.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z),
- this.rotation.setAll(0));
- var n = I.Vector3[0]
- , r = I.Vector3[1]
- , o = I.Vector3[2]
- , a = I.Quaternion[0]
- , s = I.Matrix[0]
- , l = I.Matrix[1]
- , c = I.Matrix[2]
- , u = I.Matrix[3];
- return e.subtractToRef(this.position, n),
- P.TranslationToRef(n.x, n.y, n.z, s),
- P.TranslationToRef(-n.x, -n.y, -n.z, l),
- P.RotationAxisToRef(t, i, c),
- l.multiplyToRef(c, u),
- u.multiplyToRef(s, u),
- u.decompose(r, a, o),
- this.position.addInPlace(o),
- a.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion),
- this
- }
- ,
- t.prototype.translate = function(e, t, i) {
- var n = e.scale(t);
- if (i && i !== Ji.LOCAL)
- this.setAbsolutePosition(this.getAbsolutePosition().add(n));
- else {
- var r = this.getPositionExpressedInLocalSpace().add(n);
- this.setPositionWithLocalVector(r)
- }
- return this
- }
- ,
- t.prototype.addRotation = function(e, t, i) {
- var n;
- this.rotationQuaternion ? n = this.rotationQuaternion : (n = I.Quaternion[1],
- C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, n));
- var r = I.Quaternion[0];
- return C.RotationYawPitchRollToRef(t, e, i, r),
- n.multiplyInPlace(r),
- this.rotationQuaternion || n.toEulerAnglesToRef(this.rotation),
- this
- }
- ,
- t.prototype._getEffectiveParent = function() {
- return this.parent
- }
- ,
- t.prototype.computeWorldMatrix = function(e) {
- if (this._isWorldMatrixFrozen && !this._isDirty)
- return this._worldMatrix;
- var i = this.getScene().getRenderId();
- if (!this._isDirty && !e && this.isSynchronized())
- return this._currentRenderId = i,
- this._worldMatrix;
- var n = this.getScene().activeCamera
- , r = 0 != (this._billboardMode & t.BILLBOARDMODE_USE_POSITION)
- , o = this._billboardMode !== t.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
- this._updateCache();
- var a = this._cache;
- a.pivotMatrixUpdated = !1,
- a.billboardMode = this.billboardMode,
- a.infiniteDistance = this.infiniteDistance,
- this._currentRenderId = i,
- this._childUpdateId += 1,
- this._isDirty = !1,
- this._position._isDirty = !1,
- this._rotation._isDirty = !1,
- this._scaling._isDirty = !1;
- var s, l = this._getEffectiveParent(), c = t._TmpScaling, u = this._position;
- if (this._infiniteDistance && !this.parent && n) {
- var h = n.getWorldMatrix()
- , d = new x(h.m[12],h.m[13],h.m[14]);
- (u = t._TmpTranslation).copyFromFloats(this._position.x + d.x, this._position.y + d.y, this._position.z + d.z)
- }
- if (c.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant),
- this._rotationQuaternion ? (this._rotationQuaternion._isDirty = !1,
- s = this._rotationQuaternion,
- this.reIntegrateRotationIntoRotationQuaternion && (E = this.rotation.lengthSquared()) && (this._rotationQuaternion.multiplyInPlace(C.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)),
- this._rotation.copyFromFloats(0, 0, 0))) : (s = t._TmpRotation,
- C.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, s)),
- this._usePivotMatrix) {
- var p = I.Matrix[1];
- P.ScalingToRef(c.x, c.y, c.z, p);
- var f = I.Matrix[0];
- s.toRotationMatrix(f),
- this._pivotMatrix.multiplyToRef(p, I.Matrix[4]),
- I.Matrix[4].multiplyToRef(f, this._localMatrix),
- this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix),
- this._localMatrix.addTranslationFromFloats(u.x, u.y, u.z)
- } else
- P.ComposeToRef(c, s, u, this._localMatrix);
- if (l && l.getWorldMatrix) {
- if (e && l.computeWorldMatrix(e),
- o) {
- this._transformToBoneReferal ? l.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), I.Matrix[7]) : I.Matrix[7].copyFrom(l.getWorldMatrix());
- var _ = I.Vector3[5]
- , m = I.Vector3[6];
- I.Matrix[7].decompose(m, void 0, _),
- P.ScalingToRef(m.x, m.y, m.z, I.Matrix[7]),
- I.Matrix[7].setTranslation(_),
- this._localMatrix.multiplyToRef(I.Matrix[7], this._worldMatrix)
- } else
- this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(l.getWorldMatrix(), I.Matrix[6]),
- I.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(l.getWorldMatrix(), this._worldMatrix);
- this._markSyncedWithParent()
- } else
- this._worldMatrix.copyFrom(this._localMatrix);
- if (o && n && this.billboardMode && !r) {
- var g = I.Vector3[0];
- if (this._worldMatrix.getTranslationToRef(g),
- I.Matrix[1].copyFrom(n.getViewMatrix()),
- I.Matrix[1].setTranslationFromFloats(0, 0, 0),
- I.Matrix[1].invertToRef(I.Matrix[0]),
- (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL) {
- I.Matrix[0].decompose(void 0, I.Quaternion[0], void 0);
- var v = I.Vector3[1];
- I.Quaternion[0].toEulerAnglesToRef(v),
- (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (v.x = 0),
- (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (v.y = 0),
- (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (v.z = 0),
- P.RotationYawPitchRollToRef(v.y, v.x, v.z, I.Matrix[0])
- }
- this._worldMatrix.setTranslationFromFloats(0, 0, 0),
- this._worldMatrix.multiplyToRef(I.Matrix[0], this._worldMatrix),
- this._worldMatrix.setTranslation(I.Vector3[0])
- } else if (o && n && this.billboardMode && r) {
- g = I.Vector3[0],
- this._worldMatrix.getTranslationToRef(g);
- var y = n.globalPosition;
- this._worldMatrix.invertToRef(I.Matrix[1]);
- var b = I.Vector3[1];
- x.TransformCoordinatesToRef(y, I.Matrix[1], b),
- b.normalize();
- var T = -Math.atan2(b.z, b.x) + Math.PI / 2
- , E = Math.sqrt(b.x * b.x + b.z * b.z)
- , S = -Math.atan2(b.y, E);
- C.RotationYawPitchRollToRef(T, S, 0, I.Quaternion[0]),
- (this.billboardMode & t.BILLBOARDMODE_ALL) !== t.BILLBOARDMODE_ALL ? (v = I.Vector3[1],
- I.Quaternion[0].toEulerAnglesToRef(v),
- (this.billboardMode & t.BILLBOARDMODE_X) !== t.BILLBOARDMODE_X && (v.x = 0),
- (this.billboardMode & t.BILLBOARDMODE_Y) !== t.BILLBOARDMODE_Y && (v.y = 0),
- (this.billboardMode & t.BILLBOARDMODE_Z) !== t.BILLBOARDMODE_Z && (v.z = 0),
- P.RotationYawPitchRollToRef(v.y, v.x, v.z, I.Matrix[0])) : P.FromQuaternionToRef(I.Quaternion[0], I.Matrix[0]),
- this._worldMatrix.setTranslationFromFloats(0, 0, 0),
- this._worldMatrix.multiplyToRef(I.Matrix[0], this._worldMatrix),
- this._worldMatrix.setTranslation(I.Vector3[0])
- }
- return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : l && l._nonUniformScaling ? this._updateNonUniformScalingState(l._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 = P.Invert(this._worldMatrix)),
- this._worldMatrixDeterminantIsDirty = !0,
- this._worldMatrix
- }
- ,
- t.prototype.resetLocalMatrix = function(e) {
- if (void 0 === e && (e = !0),
- this.computeWorldMatrix(),
- e)
- for (var t = this.getChildren(), i = 0; i < t.length; ++i) {
- var n = t[i];
- if (n) {
- n.computeWorldMatrix();
- var r = I.Matrix[0];
- n._localMatrix.multiplyToRef(this._localMatrix, r);
- var o = I.Quaternion[0];
- r.decompose(n.scaling, o, n.position),
- n.rotationQuaternion ? n.rotationQuaternion.copyFrom(o) : o.toEulerAnglesToRef(n.rotation)
- }
- }
- this.scaling.copyFromFloats(1, 1, 1),
- this.position.copyFromFloats(0, 0, 0),
- this.rotation.copyFromFloats(0, 0, 0),
- this.rotationQuaternion && (this.rotationQuaternion = C.Identity()),
- this._worldMatrix = P.Identity()
- }
- ,
- t.prototype._afterComputeWorldMatrix = function() {}
- ,
- t.prototype.registerAfterWorldMatrixUpdate = function(e) {
- return this.onAfterWorldMatrixUpdateObservable.add(e),
- this
- }
- ,
- t.prototype.unregisterAfterWorldMatrixUpdate = function(e) {
- return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),
- this
- }
- ,
- t.prototype.getPositionInCameraSpace = function(e) {
- return void 0 === e && (e = null),
- e || (e = this.getScene().activeCamera),
- x.TransformCoordinates(this.getAbsolutePosition(), e.getViewMatrix())
- }
- ,
- t.prototype.getDistanceToCamera = function(e) {
- return void 0 === e && (e = null),
- e || (e = this.getScene().activeCamera),
- this.getAbsolutePosition().subtract(e.globalPosition).length()
- }
- ,
- t.prototype.clone = function(e, i, n) {
- var r = this
- , o = Ge.Clone((function() {
- return new t(e,r.getScene())
- }
- ), this);
- if (o.name = e,
- o.id = e,
- i && (o.parent = i),
- !n)
- for (var a = this.getDescendants(!0), s = 0; s < a.length; s++) {
- var l = a[s];
- l.clone && l.clone(e + "." + l.name, o)
- }
- return o
- }
- ,
- t.prototype.serialize = function(e) {
- var t = Ge.Serialize(this, e);
- return t.type = this.getClassName(),
- t.uniqueId = this.uniqueId,
- this.parent && (t.parentId = this.parent.uniqueId),
- t.localMatrix = this.getPivotMatrix().asArray(),
- t.isEnabled = this.isEnabled(),
- this.parent && (t.parentId = this.parent.uniqueId),
- t
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n);
- return e.localMatrix ? r.setPreTransformMatrix(P.FromArray(e.localMatrix)) : e.pivotMatrix && r.setPivotMatrix(P.FromArray(e.pivotMatrix)),
- r.setEnabled(e.isEnabled),
- void 0 !== e.parentId && (r._waitingParentId = e.parentId),
- r
- }
- ,
- t.prototype.getChildTransformNodes = function(e, i) {
- var n = [];
- return this._getDescendants(n, e, (function(e) {
- return (!i || i(e)) && e instanceof t
- }
- )),
- n
- }
- ,
- t.prototype.dispose = function(t, i) {
- if (void 0 === i && (i = !1),
- this.getScene().stopAnimation(this),
- this.getScene().removeTransformNode(this),
- this._parentContainer) {
- var n = this._parentContainer.transformNodes.indexOf(this);
- n > -1 && this._parentContainer.transformNodes.splice(n, 1),
- this._parentContainer = null
- }
- if (this.onAfterWorldMatrixUpdateObservable.clear(),
- t)
- for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++) {
- var a = o[r];
- a.parent = null,
- a.computeWorldMatrix(!0)
- }
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.prototype.normalizeToUnitCube = function(e, t, i) {
- void 0 === e && (e = !0),
- void 0 === t && (t = !1);
- var n = null
- , r = null;
- t && (this.rotationQuaternion ? (r = this.rotationQuaternion.clone(),
- this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (n = this.rotation.clone(),
- this.rotation.copyFromFloats(0, 0, 0)));
- var o = this.getHierarchyBoundingVectors(e, i)
- , a = o.max.subtract(o.min)
- , s = Math.max(a.x, a.y, a.z);
- if (0 === s)
- return this;
- var l = 1 / s;
- return this.scaling.scaleInPlace(l),
- t && (this.rotationQuaternion && r ? this.rotationQuaternion.copyFrom(r) : this.rotation && n && this.rotation.copyFrom(n)),
- this
- }
- ,
- t.prototype._syncAbsoluteScalingAndRotation = function() {
- this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion),
- this._isAbsoluteSynced = !0)
- }
- ,
- t.BILLBOARDMODE_NONE = 0,
- t.BILLBOARDMODE_X = 1,
- t.BILLBOARDMODE_Y = 2,
- t.BILLBOARDMODE_Z = 4,
- t.BILLBOARDMODE_ALL = 7,
- t.BILLBOARDMODE_USE_POSITION = 128,
- t._TmpRotation = C.Zero(),
- t._TmpScaling = x.Zero(),
- t._TmpTranslation = x.Zero(),
- t._LookAtVectorCache = new x(0,0,0),
- t._RotationAxisCache = new C,
- k([De("position")], t.prototype, "_position", void 0),
- k([De("rotation")], t.prototype, "_rotation", void 0),
- k([Be("rotationQuaternion")], t.prototype, "_rotationQuaternion", void 0),
- k([De("scaling")], t.prototype, "_scaling", void 0),
- k([Ce("billboardMode")], t.prototype, "_billboardMode", void 0),
- k([Ce()], t.prototype, "scalingDeterminant", void 0),
- k([Ce("infiniteDistance")], t.prototype, "_infiniteDistance", void 0),
- k([Ce()], t.prototype, "ignoreNonUniformScaling", void 0),
- k([Ce()], t.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0),
- t
- }(Xe)
- , br = function() {
- this._checkCollisions = !1,
- this._collisionMask = -1,
- this._collisionGroup = -1,
- this._surroundingMeshes = null,
- this._collider = null,
- this._oldPositionForCollisions = new x(0,0,0),
- this._diffPositionForCollisions = new x(0,0,0),
- this._collisionResponse = !0
- }
- , Tr = function() {
- this.facetNb = 0,
- this.partitioningSubdivisions = 10,
- this.partitioningBBoxRatio = 1.01,
- this.facetDataEnabled = !1,
- this.facetParameters = {},
- this.bbSize = x.Zero(),
- this.subDiv = {
- max: 1,
- X: 1,
- Y: 1,
- Z: 1
- },
- this.facetDepthSort = !1,
- this.facetDepthSortEnabled = !1
- }
- , Er = function() {
- this._hasVertexAlpha = !1,
- this._useVertexColors = !0,
- this._numBoneInfluencers = 4,
- this._applyFog = !0,
- this._receiveShadows = !1,
- this._facetData = new Tr,
- 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 br,
- this._enableDistantPicking = !1
- }
- , Sr = function(e) {
- function t(i, n) {
- void 0 === n && (n = null);
- var r = e.call(this, i, n, !1) || this;
- return r._internalAbstractMeshDataInfo = new Er,
- r._waitingMaterialId = null,
- r.cullingStrategy = t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
- r.onCollideObservable = new h,
- r.onCollisionPositionChangeObservable = new h,
- r.onMaterialChangedObservable = new h,
- r.definedFacingForward = !0,
- r._occlusionQuery = null,
- r._renderingGroup = null,
- r.alphaIndex = Number.MAX_VALUE,
- r.isVisible = !0,
- r.isPickable = !0,
- r.isNearPickable = !1,
- r.isNearGrabbable = !1,
- r.showSubMeshesBoundingBox = !1,
- r.isBlocker = !1,
- r.enablePointerMoveEvents = !1,
- r.outlineColor = D.Red(),
- r.outlineWidth = .02,
- r.overlayColor = D.Red(),
- r.overlayAlpha = .5,
- r.useOctreeForRenderingSelection = !0,
- r.useOctreeForPicking = !0,
- r.useOctreeForCollisions = !0,
- r.alwaysSelectAsActiveMesh = !1,
- r.doNotSyncBoundingInfo = !1,
- r.actionManager = null,
- r.ellipsoid = new x(.5,1,.5),
- r.ellipsoidOffset = new x(0,0,0),
- r.edgesWidth = 1,
- r.edgesColor = new N(1,0,0,1),
- r._edgesRenderer = null,
- r._masterMesh = null,
- r._boundingInfo = null,
- r._boundingInfoIsDirty = !0,
- r._renderId = 0,
- r._intersectionsInProgress = new Array,
- r._unIndexed = !1,
- r._lightSources = new Array,
- r._waitingData = {
- lods: null,
- actions: null,
- freezeWorldMatrix: null
- },
- r._bonesTransformMatrices = null,
- r._transformMatrixTexture = null,
- r.onRebuildObservable = new h,
- r._onCollisionPositionChange = function(e, t, i) {
- void 0 === i && (i = null),
- t.subtractToRef(r._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
- r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > vr.CollisionsEpsilon && r.position.addInPlace(r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
- i && r.onCollideObservable.notifyObservers(i),
- r.onCollisionPositionChangeObservable.notifyObservers(r.position)
- }
- ,
- r.getScene().addMesh(r),
- r._resyncLightSources(),
- r._uniformBuffer = new Fi(r.getScene().getEngine(),void 0,void 0,i,!r.getScene().getEngine().isWebGPU),
- r._buildUniformLayout(),
- r
- }
- return U(t, e),
- Object.defineProperty(t, "BILLBOARDMODE_NONE", {
- get: function() {
- return yr.BILLBOARDMODE_NONE
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "BILLBOARDMODE_X", {
- get: function() {
- return yr.BILLBOARDMODE_X
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "BILLBOARDMODE_Y", {
- get: function() {
- return yr.BILLBOARDMODE_Y
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "BILLBOARDMODE_Z", {
- get: function() {
- return yr.BILLBOARDMODE_Z
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "BILLBOARDMODE_ALL", {
- get: function() {
- return yr.BILLBOARDMODE_ALL
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "BILLBOARDMODE_USE_POSITION", {
- get: function() {
- return yr.BILLBOARDMODE_USE_POSITION
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "facetNb", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetNb
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "partitioningSubdivisions", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "partitioningBBoxRatio", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "mustDepthSortFacets", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetDepthSort
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._facetData.facetDepthSort = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "facetDepthSortFrom", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "collisionRetryCount", {
- get: function() {
- return this._internalAbstractMeshDataInfo._collisionRetryCount
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._collisionRetryCount = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isFacetDataEnabled", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "morphTargetManager", {
- get: function() {
- return this._internalAbstractMeshDataInfo._morphTargetManager
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._morphTargetManager !== e && (this._internalAbstractMeshDataInfo._morphTargetManager = e,
- this._syncGeometryWithMorphTargetManager())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bakedVertexAnimationManager", {
- get: function() {
- return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._bakedVertexAnimationManager !== e && (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = e,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._syncGeometryWithMorphTargetManager = function() {}
- ,
- t.prototype._updateNonUniformScalingState = function(t) {
- return !!e.prototype._updateNonUniformScalingState.call(this, t) && (this._markSubMeshesAsMiscDirty(),
- !0)
- }
- ,
- Object.defineProperty(t.prototype, "onCollide", {
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onCollisionPositionChange", {
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "visibility", {
- get: function() {
- return this._internalAbstractMeshDataInfo._visibility
- },
- set: function(e) {
- if (this._internalAbstractMeshDataInfo._visibility !== e) {
- var t = this._internalAbstractMeshDataInfo._visibility;
- this._internalAbstractMeshDataInfo._visibility = e,
- (1 === t && 1 !== e || 1 !== t && 1 === e) && this._markSubMeshesAsMiscDirty()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "renderingGroupId", {
- get: function() {
- return this._internalAbstractMeshDataInfo._renderingGroupId
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._renderingGroupId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "material", {
- get: function() {
- return this._internalAbstractMeshDataInfo._material
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._material !== e && (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
- this._internalAbstractMeshDataInfo._material = e,
- e && e.meshMap && (e.meshMap[this.uniqueId] = this),
- this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this),
- this.subMeshes && (this.resetDrawCache(),
- this._unBindEffect()))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getMaterialForRenderPass = function(e) {
- var t;
- return null === (t = this._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === t ? void 0 : t[e]
- }
- ,
- t.prototype.setMaterialForRenderPass = function(e, t) {
- this._internalAbstractMeshDataInfo._materialForRenderPass || (this._internalAbstractMeshDataInfo._materialForRenderPass = []),
- this._internalAbstractMeshDataInfo._materialForRenderPass[e] = t
- }
- ,
- Object.defineProperty(t.prototype, "receiveShadows", {
- get: function() {
- return this._internalAbstractMeshDataInfo._receiveShadows
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._receiveShadows !== e && (this._internalAbstractMeshDataInfo._receiveShadows = e,
- this._markSubMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasVertexAlpha", {
- get: function() {
- return this._internalAbstractMeshDataInfo._hasVertexAlpha
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._hasVertexAlpha !== e && (this._internalAbstractMeshDataInfo._hasVertexAlpha = e,
- this._markSubMeshesAsAttributesDirty(),
- this._markSubMeshesAsMiscDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useVertexColors", {
- get: function() {
- return this._internalAbstractMeshDataInfo._useVertexColors
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._useVertexColors !== e && (this._internalAbstractMeshDataInfo._useVertexColors = e,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "computeBonesUsingShaders", {
- get: function() {
- return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "numBoneInfluencers", {
- get: function() {
- return this._internalAbstractMeshDataInfo._numBoneInfluencers
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._numBoneInfluencers !== e && (this._internalAbstractMeshDataInfo._numBoneInfluencers = e,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "applyFog", {
- get: function() {
- return this._internalAbstractMeshDataInfo._applyFog
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._applyFog !== e && (this._internalAbstractMeshDataInfo._applyFog = e,
- this._markSubMeshesAsMiscDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "enableDistantPicking", {
- get: function() {
- return this._internalAbstractMeshDataInfo._enableDistantPicking
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._enableDistantPicking = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "layerMask", {
- get: function() {
- return this._internalAbstractMeshDataInfo._layerMask
- },
- set: function(e) {
- e !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = e,
- this._resyncLightSources())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "collisionMask", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = isNaN(e) ? -1 : e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "collisionResponse", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "collisionGroup", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = isNaN(e) ? -1 : e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "surroundingMeshes", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lightSources", {
- get: function() {
- return this._lightSources
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_positions", {
- get: function() {
- return null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "skeleton", {
- get: function() {
- return this._internalAbstractMeshDataInfo._skeleton
- },
- set: function(e) {
- var t = this._internalAbstractMeshDataInfo._skeleton;
- t && t.needInitialSkinMatrix && t._unregisterMeshWithPoseMatrix(this),
- e && e.needInitialSkinMatrix && e._registerMeshWithPoseMatrix(this),
- this._internalAbstractMeshDataInfo._skeleton = e,
- this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null),
- this._markSubMeshesAsAttributesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildUniformLayout = function() {
- this._uniformBuffer.addUniform("world", 16),
- this._uniformBuffer.addUniform("visibility", 1),
- this._uniformBuffer.create()
- }
- ,
- t.prototype.transferToEffect = function(e) {
- var t = this._uniformBuffer;
- t.updateMatrix("world", e),
- t.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility),
- t.update()
- }
- ,
- t.prototype.getMeshUniformBuffer = function() {
- return this._uniformBuffer
- }
- ,
- t.prototype.getClassName = function() {
- return "AbstractMesh"
- }
- ,
- t.prototype.toString = function(e) {
- var t = "Name: " + this.name + ", isInstance: " + ("InstancedMesh" !== this.getClassName() ? "YES" : "NO");
- t += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
- var i = this._internalAbstractMeshDataInfo._skeleton;
- return i && (t += ", skeleton: " + i.name),
- e && (t += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode],
- t += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")),
- t
- }
- ,
- t.prototype._getEffectiveParent = function() {
- return this._masterMesh && this.billboardMode !== yr.BILLBOARDMODE_NONE ? this._masterMesh : e.prototype._getEffectiveParent.call(this)
- }
- ,
- t.prototype._getActionManagerForTrigger = function(e, t) {
- if (void 0 === t && (t = !0),
- this.actionManager && (t || this.actionManager.isRecursive)) {
- if (!e)
- return this.actionManager;
- if (this.actionManager.hasSpecificTrigger(e))
- return this.actionManager
- }
- return this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
- }
- ,
- t.prototype._rebuild = function(e) {
- if (void 0 === e && (e = !1),
- this.onRebuildObservable.notifyObservers(this),
- null !== this._occlusionQuery && (this._occlusionQuery = null),
- this.subMeshes)
- for (var t = 0, i = this.subMeshes; t < i.length; t++)
- i[t]._rebuild()
- }
- ,
- t.prototype._resyncLightSources = function() {
- this._lightSources.length = 0;
- for (var e = 0, t = this.getScene().lights; e < t.length; e++) {
- var i = t[e];
- i.isEnabled() && i.canAffectMesh(this) && this._lightSources.push(i)
- }
- this._markSubMeshesAsLightDirty()
- }
- ,
- t.prototype._resyncLightSource = function(e) {
- var t = e.isEnabled() && e.canAffectMesh(this)
- , i = this._lightSources.indexOf(e)
- , n = !1;
- if (-1 === i) {
- if (!t)
- return;
- this._lightSources.push(e)
- } else {
- if (t)
- return;
- n = !0,
- this._lightSources.splice(i, 1)
- }
- this._markSubMeshesAsLightDirty(n)
- }
- ,
- t.prototype._unBindEffect = function() {
- for (var e = 0, t = this.subMeshes; e < t.length; e++)
- t[e].setEffect(null)
- }
- ,
- t.prototype._removeLightSource = function(e, t) {
- var i = this._lightSources.indexOf(e);
- -1 !== i && (this._lightSources.splice(i, 1),
- this._markSubMeshesAsLightDirty(t))
- }
- ,
- t.prototype._markSubMeshesAsDirty = function(e) {
- if (this.subMeshes)
- for (var t = 0, i = this.subMeshes; t < i.length; t++)
- for (var n = i[t], r = 0; r < n._drawWrappers.length; ++r) {
- var o = n._drawWrappers[r];
- o && o.defines && o.defines.markAllAsDirty && e(o.defines)
- }
- }
- ,
- t.prototype._markSubMeshesAsLightDirty = function(e) {
- void 0 === e && (e = !1),
- this._markSubMeshesAsDirty((function(t) {
- return t.markAsLightDirty(e)
- }
- ))
- }
- ,
- t.prototype._markSubMeshesAsAttributesDirty = function() {
- this._markSubMeshesAsDirty((function(e) {
- return e.markAsAttributesDirty()
- }
- ))
- }
- ,
- t.prototype._markSubMeshesAsMiscDirty = function() {
- this._markSubMeshesAsDirty((function(e) {
- return e.markAsMiscDirty()
- }
- ))
- }
- ,
- t.prototype.markAsDirty = function(e) {
- return this._currentRenderId = Number.MAX_VALUE,
- this._isDirty = !0,
- this
- }
- ,
- t.prototype.resetDrawCache = function(e) {
- if (this.subMeshes)
- for (var t = 0, i = this.subMeshes; t < i.length; t++)
- i[t].resetDrawCache(e)
- }
- ,
- Object.defineProperty(t.prototype, "scaling", {
- get: function() {
- return this._scaling
- },
- set: function(e) {
- this._scaling = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isBlocked", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getLOD = function(e) {
- return this
- }
- ,
- t.prototype.getTotalVertices = function() {
- return 0
- }
- ,
- t.prototype.getTotalIndices = function() {
- return 0
- }
- ,
- t.prototype.getIndices = function() {
- return null
- }
- ,
- t.prototype.getVerticesData = function(e) {
- return null
- }
- ,
- t.prototype.setVerticesData = function(e, t, i, n) {
- return this
- }
- ,
- t.prototype.updateVerticesData = function(e, t, i, n) {
- return this
- }
- ,
- t.prototype.setIndices = function(e, t) {
- return this
- }
- ,
- t.prototype.isVerticesDataPresent = function(e) {
- return !1
- }
- ,
- t.prototype.getBoundingInfo = function() {
- return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1,
- this._updateBoundingInfo()),
- this._boundingInfo)
- }
- ,
- t.prototype.setBoundingInfo = function(e) {
- return this._boundingInfo = e,
- this
- }
- ,
- Object.defineProperty(t.prototype, "hasBoundingInfo", {
- get: function() {
- return null !== this._boundingInfo
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.buildBoundingInfo = function(e, t, i) {
- return this._boundingInfo = new sr(e,t,i),
- this._boundingInfo
- }
- ,
- t.prototype.normalizeToUnitCube = function(t, i, n) {
- return void 0 === t && (t = !0),
- void 0 === i && (i = !1),
- e.prototype.normalizeToUnitCube.call(this, t, i, n)
- }
- ,
- Object.defineProperty(t.prototype, "useBones", {
- get: function() {
- return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(Bi.MatricesIndicesKind) && this.isVerticesDataPresent(Bi.MatricesWeightsKind)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._preActivate = function() {}
- ,
- t.prototype._preActivateForIntermediateRendering = function(e) {}
- ,
- t.prototype._activate = function(e, t) {
- return this._renderId = e,
- !0
- }
- ,
- t.prototype._postActivate = function() {}
- ,
- t.prototype._freeze = function() {}
- ,
- t.prototype._unFreeze = function() {}
- ,
- t.prototype.getWorldMatrix = function() {
- return this._masterMesh && this.billboardMode === yr.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : e.prototype.getWorldMatrix.call(this)
- }
- ,
- t.prototype._getWorldMatrixDeterminant = function() {
- return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : e.prototype._getWorldMatrixDeterminant.call(this)
- }
- ,
- Object.defineProperty(t.prototype, "isAnInstance", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasInstances", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasThinInstances", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.movePOV = function(e, t, i) {
- return this.position.addInPlace(this.calcMovePOV(e, t, i)),
- this
- }
- ,
- t.prototype.calcMovePOV = function(e, t, i) {
- var n = new P;
- (this.rotationQuaternion ? this.rotationQuaternion : C.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z)).toRotationMatrix(n);
- var r = x.Zero()
- , o = this.definedFacingForward ? -1 : 1;
- return x.TransformCoordinatesFromFloatsToRef(e * o, t, i * o, n, r),
- r
- }
- ,
- t.prototype.rotatePOV = function(e, t, i) {
- return this.rotation.addInPlace(this.calcRotatePOV(e, t, i)),
- this
- }
- ,
- t.prototype.calcRotatePOV = function(e, t, i) {
- var n = this.definedFacingForward ? 1 : -1;
- return new x(e * n,t,i * n)
- }
- ,
- t.prototype.refreshBoundingInfo = function(e, t) {
- return void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- this._boundingInfo && this._boundingInfo.isLocked || this._refreshBoundingInfo(this._getPositionData(e, t), null),
- this
- }
- ,
- t.prototype._refreshBoundingInfo = function(e, t) {
- if (e) {
- var i = ur(e, 0, this.getTotalVertices(), t);
- this._boundingInfo ? this._boundingInfo.reConstruct(i.minimum, i.maximum) : this._boundingInfo = new sr(i.minimum,i.maximum)
- }
- if (this.subMeshes)
- for (var n = 0; n < this.subMeshes.length; n++)
- this.subMeshes[n].refreshBoundingInfo(e);
- this._updateBoundingInfo()
- }
- ,
- t.prototype.getPositionData = function(e, t, i) {
- if ((i = null != i ? i : this.getVerticesData(Bi.PositionKind)) && t && this.morphTargetManager)
- for (var n = 0, r = 0, o = 0; o < i.length; o++) {
- for (var a = 0; a < this.morphTargetManager.numTargets; a++) {
- var s = this.morphTargetManager.getTarget(a)
- , l = s.influence;
- if (l > 0) {
- var c = s.getPositions();
- c && (i[o] += (c[o] - i[o]) * l)
- }
- }
- if (n++,
- this._positions && 3 === n) {
- n = 0;
- var u = 3 * r;
- this._positions[r++].copyFromFloats(i[u], i[u + 1], i[u + 2])
- }
- }
- if (i && e && this.skeleton) {
- var h = this.getVerticesData(Bi.MatricesIndicesKind)
- , d = this.getVerticesData(Bi.MatricesWeightsKind);
- if (d && h) {
- var p = this.numBoneInfluencers > 4
- , f = p ? this.getVerticesData(Bi.MatricesIndicesExtraKind) : null
- , _ = p ? this.getVerticesData(Bi.MatricesWeightsExtraKind) : null
- , m = this.skeleton.getTransformMatrices(this)
- , g = I.Vector3[0]
- , v = I.Matrix[0]
- , y = I.Matrix[1]
- , b = 0;
- for (u = 0; u < i.length; u += 3,
- b += 4) {
- v.reset();
- var T = void 0
- , E = void 0;
- for (T = 0; T < 4; T++)
- (E = d[b + T]) > 0 && (P.FromFloat32ArrayToRefScaled(m, Math.floor(16 * h[b + T]), E, y),
- v.addToSelf(y));
- if (p)
- for (T = 0; T < 4; T++)
- (E = _[b + T]) > 0 && (P.FromFloat32ArrayToRefScaled(m, Math.floor(16 * f[b + T]), E, y),
- v.addToSelf(y));
- x.TransformCoordinatesFromFloatsToRef(i[u], i[u + 1], i[u + 2], v, g),
- g.toArray(i, u),
- this._positions && this._positions[u / 3].copyFrom(g)
- }
- }
- }
- return i
- }
- ,
- t.prototype._getPositionData = function(e, t) {
- var i, n = this.getVerticesData(Bi.PositionKind);
- if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null),
- n && (e && this.skeleton || t && this.morphTargetManager) && (n = gi.Slice(n),
- this._generatePointsArray(),
- this._positions)) {
- var r = this._positions;
- this._internalAbstractMeshDataInfo._positions = new Array(r.length);
- for (var o = 0; o < r.length; o++)
- this._internalAbstractMeshDataInfo._positions[o] = (null === (i = r[o]) || void 0 === i ? void 0 : i.clone()) || new x
- }
- return this.getPositionData(e, t, n)
- }
- ,
- t.prototype._updateBoundingInfo = function() {
- return this._boundingInfo ? this._boundingInfo.update(this.worldMatrixFromCache) : this._boundingInfo = new sr(this.position,this.position,this.worldMatrixFromCache),
- this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),
- this
- }
- ,
- t.prototype._updateSubMeshesBoundingInfo = function(e) {
- if (!this.subMeshes)
- return this;
- for (var t = this.subMeshes.length, i = 0; i < t; i++) {
- var n = this.subMeshes[i];
- (t > 1 || !n.IsGlobal) && n.updateBoundingInfo(e)
- }
- return this
- }
- ,
- t.prototype._afterComputeWorldMatrix = function() {
- this.doNotSyncBoundingInfo || (this._boundingInfoIsDirty = !0)
- }
- ,
- t.prototype.isInFrustum = function(e) {
- return this.getBoundingInfo().isInFrustum(e, this.cullingStrategy)
- }
- ,
- t.prototype.isCompletelyInFrustum = function(e) {
- return this.getBoundingInfo().isCompletelyInFrustum(e)
- }
- ,
- t.prototype.intersectsMesh = function(e, t, i) {
- void 0 === t && (t = !1);
- var n = this.getBoundingInfo()
- , r = e.getBoundingInfo();
- if (n.intersects(r, t))
- return !0;
- if (i)
- for (var o = 0, a = this.getChildMeshes(); o < a.length; o++)
- if (a[o].intersectsMesh(e, t, !0))
- return !0;
- return !1
- }
- ,
- t.prototype.intersectsPoint = function(e) {
- return this.getBoundingInfo().intersectsPoint(e)
- }
- ,
- Object.defineProperty(t.prototype, "checkCollisions", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "collider", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collider
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.moveWithCollisions = function(e) {
- this.getAbsolutePosition().addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
- var t = this.getScene().collisionCoordinator;
- return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = t.createCollider()),
- this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid,
- t.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, e, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId),
- this
- }
- ,
- t.prototype._collideForSubMesh = function(e, t, i) {
- var n;
- if (this._generatePointsArray(),
- !this._positions)
- return this;
- if (!e._lastColliderWorldVertices || !e._lastColliderTransformMatrix.equals(t)) {
- e._lastColliderTransformMatrix = t.clone(),
- e._lastColliderWorldVertices = [],
- e._trianglePlanes = [];
- for (var r = e.verticesStart, o = e.verticesStart + e.verticesCount, s = r; s < o; s++)
- e._lastColliderWorldVertices.push(x.TransformCoordinates(this._positions[s], t))
- }
- return i._collide(e._trianglePlanes, e._lastColliderWorldVertices, this.getIndices(), e.indexStart, e.indexStart + e.indexCount, e.verticesStart, !!e.getMaterial(), this, this._shouldConvertRHS(), (null === (n = e.getMaterial()) || void 0 === n ? void 0 : n.fillMode) === a.MATERIAL_TriangleStripDrawMode),
- this
- }
- ,
- t.prototype._processCollisionsForSubMeshes = function(e, t) {
- for (var i = this._scene.getCollidingSubMeshCandidates(this, e), n = i.length, r = 0; r < n; r++) {
- var o = i.data[r];
- n > 1 && !o._checkCollision(e) || this._collideForSubMesh(o, t, e)
- }
- return this
- }
- ,
- t.prototype._shouldConvertRHS = function() {
- return !1
- }
- ,
- t.prototype._checkCollision = function(e) {
- if (!this.getBoundingInfo()._checkCollision(e))
- return this;
- var t = I.Matrix[0]
- , i = I.Matrix[1];
- return P.ScalingToRef(1 / e._radius.x, 1 / e._radius.y, 1 / e._radius.z, t),
- this.worldMatrixFromCache.multiplyToRef(t, i),
- this._processCollisionsForSubMeshes(e, i),
- this
- }
- ,
- t.prototype._generatePointsArray = function() {
- return !1
- }
- ,
- t.prototype.intersects = function(e, t, i, n, r, o) {
- void 0 === n && (n = !1),
- void 0 === o && (o = !1);
- var s = new Ui
- , l = "InstancedLinesMesh" === this.getClassName() || "LinesMesh" === this.getClassName() ? this.intersectionThreshold : 0
- , c = this.getBoundingInfo();
- if (!this.subMeshes)
- return s;
- if (!(o || e.intersectsSphere(c.boundingSphere, l) && e.intersectsBox(c.boundingBox, l)))
- return s;
- if (n)
- return s.hit = !o,
- s.pickedMesh = o ? null : this,
- s.distance = o ? 0 : x.Distance(e.origin, c.boundingSphere.center),
- s.subMeshId = 0,
- s;
- if (!this._generatePointsArray())
- return s;
- for (var u = null, h = this._scene.getIntersectingSubMeshCandidates(this, e), d = h.length, p = !1, f = 0; f < d; f++) {
- var _ = (m = h.data[f]).getMaterial();
- if (_ && (_.fillMode == a.MATERIAL_TriangleStripDrawMode || _.fillMode == a.MATERIAL_TriangleFillMode || _.fillMode == a.MATERIAL_WireFrameFillMode || _.fillMode == a.MATERIAL_PointFillMode || _.fillMode == a.MATERIAL_LineListDrawMode)) {
- p = !0;
- break
- }
- }
- if (!p)
- return s.hit = !0,
- s.pickedMesh = this,
- s.distance = x.Distance(e.origin, c.boundingSphere.center),
- s.subMeshId = -1,
- s;
- for (f = 0; f < d; f++) {
- var m = h.data[f];
- if (!(d > 1) || m.canIntersects(e)) {
- var g = m.intersects(e, this._positions, this.getIndices(), t, i);
- if (g && (t || !u || g.distance < u.distance) && ((u = g).subMeshId = f,
- t))
- break
- }
- }
- if (u) {
- var v = null != r ? r : this.getWorldMatrix()
- , y = I.Vector3[0]
- , b = I.Vector3[1];
- x.TransformCoordinatesToRef(e.origin, v, y),
- e.direction.scaleToRef(u.distance, b);
- var T = x.TransformNormal(b, v).addInPlace(y);
- return s.hit = !0,
- s.distance = x.Distance(y, T),
- s.pickedPoint = T,
- s.pickedMesh = this,
- s.bu = u.bu || 0,
- s.bv = u.bv || 0,
- s.subMeshFaceId = u.faceId,
- s.faceId = u.faceId + h.data[u.subMeshId].indexStart / (-1 !== this.getClassName().indexOf("LinesMesh") ? 2 : 3),
- s.subMeshId = u.subMeshId,
- s
- }
- return s
- }
- ,
- t.prototype.clone = function(e, t, i) {
- return null
- }
- ,
- t.prototype.releaseSubMeshes = function() {
- if (this.subMeshes)
- for (; this.subMeshes.length; )
- this.subMeshes[0].dispose();
- else
- this.subMeshes = new Array;
- return this
- }
- ,
- t.prototype.dispose = function(t, i) {
- var n, r = this;
- for (void 0 === i && (i = !1),
- this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
- this.getScene().freeActiveMeshes(),
- this.getScene().freeRenderingGroups(),
- void 0 !== this.actionManager && null !== this.actionManager && (this.actionManager.dispose(),
- this.actionManager = null),
- this._internalAbstractMeshDataInfo._skeleton = null,
- this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
- this._transformMatrixTexture = null),
- n = 0; n < this._intersectionsInProgress.length; n++) {
- var o = this._intersectionsInProgress[n]
- , a = o._intersectionsInProgress.indexOf(this);
- o._intersectionsInProgress.splice(a, 1)
- }
- this._intersectionsInProgress = [],
- this.getScene().lights.forEach((function(e) {
- var t = e.includedOnlyMeshes.indexOf(r);
- -1 !== t && e.includedOnlyMeshes.splice(t, 1),
- -1 !== (t = e.excludedMeshes.indexOf(r)) && e.excludedMeshes.splice(t, 1);
- var i = e.getShadowGenerator();
- if (i) {
- var n = i.getShadowMap();
- n && n.renderList && -1 !== (t = n.renderList.indexOf(r)) && n.renderList.splice(t, 1)
- }
- }
- )),
- "InstancedMesh" === this.getClassName() && "InstancedLinesMesh" === this.getClassName() || this.releaseSubMeshes();
- var s = this.getScene().getEngine();
- if (null !== this._occlusionQuery && (this.isOcclusionQueryInProgress = !1,
- s.deleteQuery(this._occlusionQuery),
- this._occlusionQuery = null),
- s.wipeCaches(),
- this.getScene().removeMesh(this),
- this._parentContainer) {
- var l = this._parentContainer.meshes.indexOf(this);
- l > -1 && this._parentContainer.meshes.splice(l, 1),
- this._parentContainer = null
- }
- if (i && this.material && ("MultiMaterial" === this.material.getClassName() ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)),
- !t)
- for (n = 0; n < this.getScene().particleSystems.length; n++)
- this.getScene().particleSystems[n].emitter === this && (this.getScene().particleSystems[n].dispose(),
- n--);
- this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(),
- this._uniformBuffer.dispose(),
- this.onAfterWorldMatrixUpdateObservable.clear(),
- this.onCollideObservable.clear(),
- this.onCollisionPositionChangeObservable.clear(),
- this.onRebuildObservable.clear(),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.prototype.addChild = function(e, t) {
- return void 0 === t && (t = !1),
- e.setParent(this, t),
- this
- }
- ,
- t.prototype.removeChild = function(e, t) {
- return void 0 === t && (t = !1),
- e.setParent(null, t),
- this
- }
- ,
- t.prototype._initFacetData = function() {
- var e = this._internalAbstractMeshDataInfo._facetData;
- e.facetNormals || (e.facetNormals = new Array),
- e.facetPositions || (e.facetPositions = new Array),
- e.facetPartitioning || (e.facetPartitioning = new Array),
- e.facetNb = this.getIndices().length / 3 | 0,
- e.partitioningSubdivisions = e.partitioningSubdivisions ? e.partitioningSubdivisions : 10,
- e.partitioningBBoxRatio = e.partitioningBBoxRatio ? e.partitioningBBoxRatio : 1.01;
- for (var t = 0; t < e.facetNb; t++)
- e.facetNormals[t] = x.Zero(),
- e.facetPositions[t] = x.Zero();
- return e.facetDataEnabled = !0,
- this
- }
- ,
- t.prototype.updateFacetData = function() {
- var e = this._internalAbstractMeshDataInfo._facetData;
- e.facetDataEnabled || this._initFacetData();
- var t = this.getVerticesData(Bi.PositionKind)
- , i = this.getIndices()
- , n = this.getVerticesData(Bi.NormalKind)
- , r = this.getBoundingInfo();
- if (e.facetDepthSort && !e.facetDepthSortEnabled) {
- if (e.facetDepthSortEnabled = !0,
- i instanceof Uint16Array)
- e.depthSortedIndices = new Uint16Array(i);
- else if (i instanceof Uint32Array)
- e.depthSortedIndices = new Uint32Array(i);
- else {
- for (var o = !1, a = 0; a < i.length; a++)
- if (i[a] > 65535) {
- o = !0;
- break
- }
- e.depthSortedIndices = o ? new Uint32Array(i) : new Uint16Array(i)
- }
- if (e.facetDepthSortFunction = function(e, t) {
- return t.sqDistance - e.sqDistance
- }
- ,
- !e.facetDepthSortFrom) {
- var s = this.getScene().activeCamera;
- e.facetDepthSortFrom = s ? s.position : x.Zero()
- }
- e.depthSortedFacets = [];
- for (var l = 0; l < e.facetNb; l++) {
- var c = {
- ind: 3 * l,
- sqDistance: 0
- };
- e.depthSortedFacets.push(c)
- }
- e.invertedMatrix = P.Identity(),
- e.facetDepthSortOrigin = x.Zero()
- }
- e.bbSize.x = r.maximum.x - r.minimum.x > m ? r.maximum.x - r.minimum.x : m,
- e.bbSize.y = r.maximum.y - r.minimum.y > m ? r.maximum.y - r.minimum.y : m,
- e.bbSize.z = r.maximum.z - r.minimum.z > m ? r.maximum.z - r.minimum.z : m;
- var u = e.bbSize.x > e.bbSize.y ? e.bbSize.x : e.bbSize.y;
- if (u = u > e.bbSize.z ? u : e.bbSize.z,
- e.subDiv.max = e.partitioningSubdivisions,
- e.subDiv.X = Math.floor(e.subDiv.max * e.bbSize.x / u),
- e.subDiv.Y = Math.floor(e.subDiv.max * e.bbSize.y / u),
- e.subDiv.Z = Math.floor(e.subDiv.max * e.bbSize.z / u),
- e.subDiv.X = e.subDiv.X < 1 ? 1 : e.subDiv.X,
- e.subDiv.Y = e.subDiv.Y < 1 ? 1 : e.subDiv.Y,
- e.subDiv.Z = e.subDiv.Z < 1 ? 1 : e.subDiv.Z,
- e.facetParameters.facetNormals = this.getFacetLocalNormals(),
- e.facetParameters.facetPositions = this.getFacetLocalPositions(),
- e.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(),
- e.facetParameters.bInfo = r,
- e.facetParameters.bbSize = e.bbSize,
- e.facetParameters.subDiv = e.subDiv,
- e.facetParameters.ratio = this.partitioningBBoxRatio,
- e.facetParameters.depthSort = e.facetDepthSort,
- e.facetDepthSort && e.facetDepthSortEnabled && (this.computeWorldMatrix(!0),
- this._worldMatrix.invertToRef(e.invertedMatrix),
- x.TransformCoordinatesToRef(e.facetDepthSortFrom, e.invertedMatrix, e.facetDepthSortOrigin),
- e.facetParameters.distanceTo = e.facetDepthSortOrigin),
- e.facetParameters.depthSortedFacets = e.depthSortedFacets,
- n && $n.ComputeNormals(t, i, n, e.facetParameters),
- e.facetDepthSort && e.facetDepthSortEnabled) {
- e.depthSortedFacets.sort(e.facetDepthSortFunction);
- var h = e.depthSortedIndices.length / 3 | 0;
- for (l = 0; l < h; l++) {
- var d = e.depthSortedFacets[l].ind;
- e.depthSortedIndices[3 * l] = i[d],
- e.depthSortedIndices[3 * l + 1] = i[d + 1],
- e.depthSortedIndices[3 * l + 2] = i[d + 2]
- }
- this.updateIndices(e.depthSortedIndices, void 0, !0)
- }
- return this
- }
- ,
- t.prototype.getFacetLocalNormals = function() {
- var e = this._internalAbstractMeshDataInfo._facetData;
- return e.facetNormals || this.updateFacetData(),
- e.facetNormals
- }
- ,
- t.prototype.getFacetLocalPositions = function() {
- var e = this._internalAbstractMeshDataInfo._facetData;
- return e.facetPositions || this.updateFacetData(),
- e.facetPositions
- }
- ,
- t.prototype.getFacetLocalPartitioning = function() {
- var e = this._internalAbstractMeshDataInfo._facetData;
- return e.facetPartitioning || this.updateFacetData(),
- e.facetPartitioning
- }
- ,
- t.prototype.getFacetPosition = function(e) {
- var t = x.Zero();
- return this.getFacetPositionToRef(e, t),
- t
- }
- ,
- t.prototype.getFacetPositionToRef = function(e, t) {
- var i = this.getFacetLocalPositions()[e]
- , n = this.getWorldMatrix();
- return x.TransformCoordinatesToRef(i, n, t),
- this
- }
- ,
- t.prototype.getFacetNormal = function(e) {
- var t = x.Zero();
- return this.getFacetNormalToRef(e, t),
- t
- }
- ,
- t.prototype.getFacetNormalToRef = function(e, t) {
- var i = this.getFacetLocalNormals()[e];
- return x.TransformNormalToRef(i, this.getWorldMatrix(), t),
- this
- }
- ,
- t.prototype.getFacetsAtLocalCoordinates = function(e, t, i) {
- var n = this.getBoundingInfo()
- , r = this._internalAbstractMeshDataInfo._facetData
- , o = Math.floor((e - n.minimum.x * r.partitioningBBoxRatio) * r.subDiv.X * r.partitioningBBoxRatio / r.bbSize.x)
- , a = Math.floor((t - n.minimum.y * r.partitioningBBoxRatio) * r.subDiv.Y * r.partitioningBBoxRatio / r.bbSize.y)
- , s = Math.floor((i - n.minimum.z * r.partitioningBBoxRatio) * r.subDiv.Z * r.partitioningBBoxRatio / r.bbSize.z);
- return o < 0 || o > r.subDiv.max || a < 0 || a > r.subDiv.max || s < 0 || s > r.subDiv.max ? null : r.facetPartitioning[o + r.subDiv.max * a + r.subDiv.max * r.subDiv.max * s]
- }
- ,
- t.prototype.getClosestFacetAtCoordinates = function(e, t, i, n, r, o) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !0);
- var a = this.getWorldMatrix()
- , s = I.Matrix[5];
- a.invertToRef(s);
- var l = I.Vector3[8];
- x.TransformCoordinatesFromFloatsToRef(e, t, i, s, l);
- var c = this.getClosestFacetAtLocalCoordinates(l.x, l.y, l.z, n, r, o);
- return n && x.TransformCoordinatesFromFloatsToRef(n.x, n.y, n.z, a, n),
- c
- }
- ,
- t.prototype.getClosestFacetAtLocalCoordinates = function(e, t, i, n, r, o) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !0);
- var a = null
- , s = 0
- , l = 0
- , c = 0
- , u = 0
- , h = 0
- , d = 0
- , p = 0
- , f = 0
- , _ = this.getFacetLocalPositions()
- , m = this.getFacetLocalNormals()
- , g = this.getFacetsAtLocalCoordinates(e, t, i);
- if (!g)
- return null;
- for (var v, y, b, T = Number.MAX_VALUE, E = T, S = 0; S < g.length; S++)
- y = m[v = g[S]],
- u = (e - (b = _[v]).x) * y.x + (t - b.y) * y.y + (i - b.z) * y.z,
- (!r || r && o && u >= 0 || r && !o && u <= 0) && (u = y.x * b.x + y.y * b.y + y.z * b.z,
- h = -(y.x * e + y.y * t + y.z * i - u) / (y.x * y.x + y.y * y.y + y.z * y.z),
- (E = (s = (d = e + y.x * h) - e) * s + (l = (p = t + y.y * h) - t) * l + (c = (f = i + y.z * h) - i) * c) < T && (T = E,
- a = v,
- n && (n.x = d,
- n.y = p,
- n.z = f)));
- return a
- }
- ,
- t.prototype.getFacetDataParameters = function() {
- return this._internalAbstractMeshDataInfo._facetData.facetParameters
- }
- ,
- t.prototype.disableFacetData = function() {
- var e = this._internalAbstractMeshDataInfo._facetData;
- return e.facetDataEnabled && (e.facetDataEnabled = !1,
- e.facetPositions = new Array,
- e.facetNormals = new Array,
- e.facetPartitioning = new Array,
- e.facetParameters = null,
- e.depthSortedIndices = new Uint32Array(0)),
- this
- }
- ,
- t.prototype.updateIndices = function(e, t, i) {
- return void 0 === i && (i = !1),
- this
- }
- ,
- t.prototype.createNormals = function(e) {
- var t, i = this.getVerticesData(Bi.PositionKind), n = this.getIndices();
- return t = this.isVerticesDataPresent(Bi.NormalKind) ? this.getVerticesData(Bi.NormalKind) : [],
- $n.ComputeNormals(i, n, t, {
- useRightHandedSystem: this.getScene().useRightHandedSystem
- }),
- this.setVerticesData(Bi.NormalKind, t, e),
- this
- }
- ,
- t.prototype.alignWithNormal = function(e, t) {
- t || (t = vn.Y);
- var i = I.Vector3[0]
- , n = I.Vector3[1];
- return x.CrossToRef(t, e, n),
- x.CrossToRef(e, n, i),
- this.rotationQuaternion ? C.RotationQuaternionFromAxisToRef(i, e, n, this.rotationQuaternion) : x.RotationFromAxisToRef(i, e, n, this.rotation),
- this
- }
- ,
- t.prototype._checkOcclusionQuery = function() {
- return !1
- }
- ,
- t.prototype.disableEdgesRendering = function() {
- throw be("EdgesRenderer")
- }
- ,
- t.prototype.enableEdgesRendering = function(e, t, i) {
- throw be("EdgesRenderer")
- }
- ,
- t.prototype.getConnectedParticleSystems = function() {
- var e = this;
- return this._scene.particleSystems.filter((function(t) {
- return t.emitter === e
- }
- ))
- }
- ,
- t.OCCLUSION_TYPE_NONE = 0,
- t.OCCLUSION_TYPE_OPTIMISTIC = 1,
- t.OCCLUSION_TYPE_STRICT = 2,
- t.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0,
- t.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1,
- t.CULLINGSTRATEGY_STANDARD = a.MESHES_CULLINGSTRATEGY_STANDARD,
- t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
- t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION,
- t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY,
- t
- }(yr);
- y("BABYLON.AbstractMesh", Sr);
- var Ar, xr = function() {
- function e(e, t, i, n) {
- this.x = e,
- this.y = t,
- this.width = i,
- this.height = n
- }
- return e.prototype.toGlobal = function(t, i) {
- return new e(this.x * t,this.y * i,this.width * t,this.height * i)
- }
- ,
- e.prototype.toGlobalToRef = function(e, t, i) {
- return i.x = this.x * e,
- i.y = this.y * t,
- i.width = this.width * e,
- i.height = this.height * t,
- this
- }
- ,
- e.prototype.clone = function() {
- return new e(this.x,this.y,this.width,this.height)
- }
- ,
- e
- }(), Rr = function(e) {
- function t(i, n, r, o) {
- void 0 === o && (o = !0);
- var a = e.call(this, i, r) || this;
- return a._position = x.Zero(),
- a._upVector = x.Up(),
- a.orthoLeft = null,
- a.orthoRight = null,
- a.orthoBottom = null,
- a.orthoTop = null,
- a.fov = .8,
- a.projectionPlaneTilt = 0,
- a.minZ = 1,
- a.maxZ = 1e4,
- a.inertia = .9,
- a.mode = t.PERSPECTIVE_CAMERA,
- a.isIntermediate = !1,
- a.viewport = new xr(0,0,1,1),
- a.layerMask = 268435455,
- a.fovMode = t.FOVMODE_VERTICAL_FIXED,
- a.cameraRigMode = t.RIG_MODE_NONE,
- a.customRenderTargets = new Array,
- a.outputRenderTarget = null,
- a.onViewMatrixChangedObservable = new h,
- a.onProjectionMatrixChangedObservable = new h,
- a.onAfterCheckInputsObservable = new h,
- a.onRestoreStateObservable = new h,
- a.isRigCamera = !1,
- a._rigCameras = new Array,
- a._webvrViewMatrix = P.Identity(),
- a._skipRendering = !1,
- a._projectionMatrix = new P,
- a._postProcesses = new Array,
- a._activeMeshes = new bi(256),
- a._globalPosition = x.Zero(),
- a._computedViewMatrix = P.Identity(),
- a._doNotComputeProjectionMatrix = !1,
- a._transformMatrix = P.Zero(),
- a._refreshFrustumPlanes = !0,
- a._absoluteRotation = C.Identity(),
- a._isCamera = !0,
- a._isLeftCamera = !1,
- a._isRightCamera = !1,
- a.getScene().addCamera(a),
- o && !a.getScene().activeCamera && (a.getScene().activeCamera = a),
- a.position = n,
- a.renderPassId = a.getScene().getEngine().createRenderPassId("Camera ".concat(i)),
- a
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(e) {
- this._position = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "upVector", {
- get: function() {
- return this._upVector
- },
- set: function(e) {
- this._upVector = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "screenArea", {
- get: function() {
- var e, i, n, r, o = 0, a = 0;
- if (this.mode === t.PERSPECTIVE_CAMERA)
- this.fovMode === t.FOVMODE_VERTICAL_FIXED ? (a = 2 * this.minZ * Math.tan(this.fov / 2),
- o = this.getEngine().getAspectRatio(this) * a) : a = (o = 2 * this.minZ * Math.tan(this.fov / 2)) / this.getEngine().getAspectRatio(this);
- else {
- var s = this.getEngine().getRenderWidth() / 2
- , l = this.getEngine().getRenderHeight() / 2;
- o = (null !== (e = this.orthoRight) && void 0 !== e ? e : s) - (null !== (i = this.orthoLeft) && void 0 !== i ? i : -s),
- a = (null !== (n = this.orthoTop) && void 0 !== n ? n : l) - (null !== (r = this.orthoBottom) && void 0 !== r ? r : -l)
- }
- return o * a
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.storeState = function() {
- return this._stateStored = !0,
- this._storedFov = this.fov,
- this
- }
- ,
- t.prototype._restoreStateValues = function() {
- return !!this._stateStored && (this.fov = this._storedFov,
- !0)
- }
- ,
- t.prototype.restoreState = function() {
- return !!this._restoreStateValues() && (this.onRestoreStateObservable.notifyObservers(this),
- !0)
- }
- ,
- t.prototype.getClassName = function() {
- return "Camera"
- }
- ,
- t.prototype.toString = function(e) {
- var t = "Name: " + this.name;
- if (t += ", type: " + this.getClassName(),
- this.animations)
- for (var i = 0; i < this.animations.length; i++)
- t += ", animation[0]: " + this.animations[i].toString(e);
- return t
- }
- ,
- t.prototype.applyVerticalCorrection = function() {
- var e = this.absoluteRotation.toEulerAngles();
- this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -e.x : e.x
- }
- ,
- Object.defineProperty(t.prototype, "globalPosition", {
- get: function() {
- return this._globalPosition
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getActiveMeshes = function() {
- return this._activeMeshes
- }
- ,
- t.prototype.isActiveMesh = function(e) {
- return -1 !== this._activeMeshes.indexOf(e)
- }
- ,
- t.prototype.isReady = function(t) {
- if (void 0 === t && (t = !1),
- t)
- for (var i = 0, n = this._postProcesses; i < n.length; i++) {
- var r = n[i];
- if (r && !r.isReady())
- return !1
- }
- return e.prototype.isReady.call(this, t)
- }
- ,
- t.prototype._initCache = function() {
- e.prototype._initCache.call(this),
- this._cache.position = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.upVector = new x(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
- }
- ,
- t.prototype._updateCache = function(t) {
- t || e.prototype._updateCache.call(this),
- this._cache.position.copyFrom(this.position),
- this._cache.upVector.copyFrom(this.upVector)
- }
- ,
- t.prototype._isSynchronized = function() {
- return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix()
- }
- ,
- t.prototype._isSynchronizedViewMatrix = function() {
- return !!e.prototype._isSynchronized.call(this) && this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent()
- }
- ,
- t.prototype._isSynchronizedProjectionMatrix = function() {
- var e = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
- if (!e)
- return !1;
- var i = this.getEngine();
- return this.mode === t.PERSPECTIVE_CAMERA ? this._cache.fov === this.fov && this._cache.fovMode === this.fovMode && this._cache.aspectRatio === i.getAspectRatio(this) && this._cache.projectionPlaneTilt === this.projectionPlaneTilt : this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === i.getRenderWidth() && this._cache.renderHeight === i.getRenderHeight()
- }
- ,
- t.prototype.attachControl = function(e, t) {}
- ,
- t.prototype.detachControl = function(e) {}
- ,
- t.prototype.update = function() {
- this._checkInputs(),
- this.cameraRigMode !== t.RIG_MODE_NONE && this._updateRigCameras()
- }
- ,
- t.prototype._checkInputs = function() {
- this.onAfterCheckInputsObservable.notifyObservers(this)
- }
- ,
- Object.defineProperty(t.prototype, "rigCameras", {
- get: function() {
- return this._rigCameras
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rigPostProcess", {
- get: function() {
- return this._rigPostProcess
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._getFirstPostProcess = function() {
- for (var e = 0; e < this._postProcesses.length; e++)
- if (null !== this._postProcesses[e])
- return this._postProcesses[e];
- return null
- }
- ,
- t.prototype._cascadePostProcessesToRigCams = function() {
- var e = this._getFirstPostProcess();
- e && e.markTextureDirty();
- for (var t = 0, i = this._rigCameras.length; t < i; t++) {
- var n = this._rigCameras[t]
- , r = n._rigPostProcess;
- r ? ("pass" === r.getEffectName() && (n.isIntermediate = 0 === this._postProcesses.length),
- n._postProcesses = this._postProcesses.slice(0).concat(r),
- r.markTextureDirty()) : n._postProcesses = this._postProcesses.slice(0)
- }
- }
- ,
- t.prototype.attachPostProcess = function(e, t) {
- return void 0 === t && (t = null),
- !e.isReusable() && this._postProcesses.indexOf(e) > -1 ? (K.Error("You're trying to reuse a post process not defined as reusable."),
- 0) : (null == t || t < 0 ? this._postProcesses.push(e) : null === this._postProcesses[t] ? this._postProcesses[t] = e : this._postProcesses.splice(t, 0, e),
- this._cascadePostProcessesToRigCams(),
- this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
- this._postProcesses.indexOf(e))
- }
- ,
- t.prototype.detachPostProcess = function(e) {
- var t = this._postProcesses.indexOf(e);
- -1 !== t && (this._postProcesses[t] = null),
- this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
- this._cascadePostProcessesToRigCams()
- }
- ,
- t.prototype.getWorldMatrix = function() {
- return this._isSynchronizedViewMatrix() || this.getViewMatrix(),
- this._worldMatrix
- }
- ,
- t.prototype._getViewMatrix = function() {
- return P.Identity()
- }
- ,
- t.prototype.getViewMatrix = function(e) {
- return !e && this._isSynchronizedViewMatrix() || (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
- }
- ,
- t.prototype.freezeProjectionMatrix = function(e) {
- this._doNotComputeProjectionMatrix = !0,
- void 0 !== e && (this._projectionMatrix = e)
- }
- ,
- t.prototype.unfreezeProjectionMatrix = function() {
- this._doNotComputeProjectionMatrix = !1
- }
- ,
- t.prototype.getProjectionMatrix = function(e) {
- var i, n, r, o, a, s, l, c;
- if (this._doNotComputeProjectionMatrix || !e && this._isSynchronizedProjectionMatrix())
- return this._projectionMatrix;
- this._cache.mode = this.mode,
- this._cache.minZ = this.minZ,
- this._cache.maxZ = this.maxZ,
- this._refreshFrustumPlanes = !0;
- var u = this.getEngine()
- , h = this.getScene();
- if (this.mode === t.PERSPECTIVE_CAMERA) {
- this._cache.fov = this.fov,
- this._cache.fovMode = this.fovMode,
- this._cache.aspectRatio = u.getAspectRatio(this),
- this._cache.projectionPlaneTilt = this.projectionPlaneTilt,
- this.minZ <= 0 && (this.minZ = .1);
- var d = u.useReverseDepthBuffer;
- (h.useRightHandedSystem ? P.PerspectiveFovRHToRef : P.PerspectiveFovLHToRef)(this.fov, u.getAspectRatio(this), d ? this.maxZ : this.minZ, d ? this.minZ : this.maxZ, this._projectionMatrix, this.fovMode === t.FOVMODE_VERTICAL_FIXED, u.isNDCHalfZRange, this.projectionPlaneTilt, u.useReverseDepthBuffer)
- } else {
- var p = u.getRenderWidth() / 2
- , f = u.getRenderHeight() / 2;
- h.useRightHandedSystem ? P.OrthoOffCenterRHToRef(null !== (i = this.orthoLeft) && void 0 !== i ? i : -p, null !== (n = this.orthoRight) && void 0 !== n ? n : p, null !== (r = this.orthoBottom) && void 0 !== r ? r : -f, null !== (o = this.orthoTop) && void 0 !== o ? o : f, this.minZ, this.maxZ, this._projectionMatrix, u.isNDCHalfZRange) : P.OrthoOffCenterLHToRef(null !== (a = this.orthoLeft) && void 0 !== a ? a : -p, null !== (s = this.orthoRight) && void 0 !== s ? s : p, null !== (l = this.orthoBottom) && void 0 !== l ? l : -f, null !== (c = this.orthoTop) && void 0 !== c ? c : f, this.minZ, this.maxZ, this._projectionMatrix, u.isNDCHalfZRange),
- this._cache.orthoLeft = this.orthoLeft,
- this._cache.orthoRight = this.orthoRight,
- this._cache.orthoBottom = this.orthoBottom,
- this._cache.orthoTop = this.orthoTop,
- this._cache.renderWidth = u.getRenderWidth(),
- this._cache.renderHeight = u.getRenderHeight()
- }
- return this.onProjectionMatrixChangedObservable.notifyObservers(this),
- this._projectionMatrix
- }
- ,
- t.prototype.getTransformationMatrix = function() {
- return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
- this._transformMatrix
- }
- ,
- t.prototype._updateFrustumPlanes = function() {
- this._refreshFrustumPlanes && (this.getTransformationMatrix(),
- this._frustumPlanes ? dn.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = dn.GetPlanes(this._transformMatrix),
- this._refreshFrustumPlanes = !1)
- }
- ,
- t.prototype.isInFrustum = function(e, t) {
- if (void 0 === t && (t = !1),
- this._updateFrustumPlanes(),
- t && this.rigCameras.length > 0) {
- var i = !1;
- return this.rigCameras.forEach((function(t) {
- t._updateFrustumPlanes(),
- i = i || e.isInFrustum(t._frustumPlanes)
- }
- )),
- i
- }
- return e.isInFrustum(this._frustumPlanes)
- }
- ,
- t.prototype.isCompletelyInFrustum = function(e) {
- return this._updateFrustumPlanes(),
- e.isCompletelyInFrustum(this._frustumPlanes)
- }
- ,
- t.prototype.getForwardRay = function(e, t, i) {
- throw void 0 === e && (e = 100),
- be("Ray")
- }
- ,
- t.prototype.getForwardRayToRef = function(e, t, i, n) {
- throw void 0 === t && (t = 100),
- be("Ray")
- }
- ,
- t.prototype.dispose = function(i, n) {
- for (void 0 === n && (n = !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 r = this._rigCameras.pop();
- r && r.dispose()
- }
- if (this._parentContainer) {
- var o = this._parentContainer.cameras.indexOf(this);
- o > -1 && this._parentContainer.cameras.splice(o, 1),
- this._parentContainer = null
- }
- if (this._rigPostProcess)
- this._rigPostProcess.dispose(this),
- this._rigPostProcess = null,
- this._postProcesses = [];
- else if (this.cameraRigMode !== t.RIG_MODE_NONE)
- this._rigPostProcess = null,
- this._postProcesses = [];
- else
- for (var a = this._postProcesses.length; --a >= 0; ) {
- var s = this._postProcesses[a];
- s && s.dispose(this)
- }
- for (var l = this.customRenderTargets.length; --l >= 0; )
- this.customRenderTargets[l].dispose();
- this.customRenderTargets = [],
- this._activeMeshes.dispose(),
- this.getScene().getEngine().releaseRenderPassId(this.renderPassId),
- e.prototype.dispose.call(this, i, n)
- }
- ,
- Object.defineProperty(t.prototype, "isLeftCamera", {
- get: function() {
- return this._isLeftCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isRightCamera", {
- get: function() {
- return this._isRightCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "leftCamera", {
- get: function() {
- return this._rigCameras.length < 1 ? null : this._rigCameras[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rightCamera", {
- get: function() {
- return this._rigCameras.length < 2 ? null : this._rigCameras[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getLeftTarget = function() {
- return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget()
- }
- ,
- t.prototype.getRightTarget = function() {
- return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget()
- }
- ,
- t.prototype.setCameraRigMode = function(e, i) {
- if (this.cameraRigMode !== e) {
- for (; this._rigCameras.length > 0; ) {
- var n = this._rigCameras.pop();
- n && n.dispose()
- }
- if (this.cameraRigMode = e,
- this._cameraRigParams = {},
- this._cameraRigParams.interaxialDistance = i.interaxialDistance || .0637,
- this._cameraRigParams.stereoHalfAngle = gi.ToRadians(this._cameraRigParams.interaxialDistance / .0637),
- this.cameraRigMode !== t.RIG_MODE_NONE) {
- var r = this.createRigCamera(this.name + "_L", 0);
- r && (r._isLeftCamera = !0);
- var o = this.createRigCamera(this.name + "_R", 1);
- o && (o._isRightCamera = !0),
- r && o && (this._rigCameras.push(r),
- this._rigCameras.push(o))
- }
- this._setRigMode(i),
- this._cascadePostProcessesToRigCams(),
- this.update()
- }
- }
- ,
- t.prototype._setRigMode = function(e) {}
- ,
- t.prototype._getVRProjectionMatrix = function() {
- return P.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
- }
- ,
- t.prototype._updateCameraRotationMatrix = function() {}
- ,
- t.prototype._updateWebVRCameraRotationMatrix = function() {}
- ,
- t.prototype._getWebVRProjectionMatrix = function() {
- return P.Identity()
- }
- ,
- t.prototype._getWebVRViewMatrix = function() {
- return P.Identity()
- }
- ,
- t.prototype.setCameraRigParameter = function(e, t) {
- this._cameraRigParams || (this._cameraRigParams = {}),
- this._cameraRigParams[e] = t,
- "interaxialDistance" === e && (this._cameraRigParams.stereoHalfAngle = gi.ToRadians(t / .0637))
- }
- ,
- t.prototype.createRigCamera = function(e, t) {
- return null
- }
- ,
- t.prototype._updateRigCameras = function() {
- for (var e = 0; e < this._rigCameras.length; e++)
- this._rigCameras[e].minZ = this.minZ,
- this._rigCameras[e].maxZ = this.maxZ,
- this._rigCameras[e].fov = this.fov,
- this._rigCameras[e].upVector.copyFrom(this.upVector);
- this.cameraRigMode === t.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport)
- }
- ,
- t.prototype._setupInputs = function() {}
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.uniqueId = this.uniqueId,
- e.type = this.getClassName(),
- this.parent && (e.parentId = this.parent.uniqueId),
- this.inputs && this.inputs.serialize(e),
- Ge.AppendSerializedAnimations(this, e),
- e.ranges = this.serializeAnimationRanges(),
- e.isEnabled = this.isEnabled(),
- e
- }
- ,
- t.prototype.clone = function(e) {
- var i = Ge.Clone(t.GetConstructorFromName(this.getClassName(), e, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
- return i.name = e,
- this.onClonedObservable.notifyObservers(i),
- i
- }
- ,
- t.prototype.getDirection = function(e) {
- var t = x.Zero();
- return this.getDirectionToRef(e, t),
- t
- }
- ,
- Object.defineProperty(t.prototype, "absoluteRotation", {
- get: function() {
- return this.getWorldMatrix().decompose(void 0, this._absoluteRotation),
- this._absoluteRotation
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getDirectionToRef = function(e, t) {
- x.TransformNormalToRef(e, this.getWorldMatrix(), t)
- }
- ,
- t.GetConstructorFromName = function(e, i, n, r, o) {
- return void 0 === r && (r = 0),
- void 0 === o && (o = !0),
- Xe.Construct(e, i, n, {
- interaxial_distance: r,
- isStereoscopicSideBySide: o
- }) || function() {
- return t._CreateDefaultParsedCamera(i, n)
- }
- }
- ,
- t.prototype.computeWorldMatrix = function() {
- return this.getWorldMatrix()
- }
- ,
- t.Parse = function(e, i) {
- var n = e.type
- , r = t.GetConstructorFromName(n, e.name, i, e.interaxial_distance, e.isStereoscopicSideBySide)
- , o = Ge.Parse(r, e, i);
- if (void 0 !== e.parentId && (o._waitingParentId = e.parentId),
- o.inputs && (o.inputs.parse(e),
- o._setupInputs()),
- e.upVector && (o.upVector = x.FromArray(e.upVector)),
- o.setPosition && (o.position.copyFromFloats(0, 0, 0),
- o.setPosition(x.FromArray(e.position))),
- e.target && o.setTarget && o.setTarget(x.FromArray(e.target)),
- e.cameraRigMode) {
- var a = e.interaxial_distance ? {
- interaxialDistance: e.interaxial_distance
- } : {};
- o.setCameraRigMode(e.cameraRigMode, a)
- }
- if (e.animations) {
- for (var s = 0; s < e.animations.length; s++) {
- var l = e.animations[s]
- , c = b("BABYLON.Animation");
- c && o.animations.push(c.Parse(l))
- }
- Xe.ParseAnimationRanges(o, e, i)
- }
- return e.autoAnimate && i.beginAnimation(o, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
- void 0 !== e.isEnabled && o.setEnabled(e.isEnabled),
- o
- }
- ,
- t._CreateDefaultParsedCamera = function(e, t) {
- throw be("UniversalCamera")
- }
- ,
- t.PERSPECTIVE_CAMERA = a.PERSPECTIVE_CAMERA,
- t.ORTHOGRAPHIC_CAMERA = a.ORTHOGRAPHIC_CAMERA,
- t.FOVMODE_VERTICAL_FIXED = a.FOVMODE_VERTICAL_FIXED,
- t.FOVMODE_HORIZONTAL_FIXED = a.FOVMODE_HORIZONTAL_FIXED,
- t.RIG_MODE_NONE = a.RIG_MODE_NONE,
- t.RIG_MODE_STEREOSCOPIC_ANAGLYPH = a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,
- t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,
- t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,
- t.RIG_MODE_STEREOSCOPIC_OVERUNDER = a.RIG_MODE_STEREOSCOPIC_OVERUNDER,
- t.RIG_MODE_STEREOSCOPIC_INTERLACED = a.RIG_MODE_STEREOSCOPIC_INTERLACED,
- t.RIG_MODE_VR = a.RIG_MODE_VR,
- t.RIG_MODE_WEBVR = a.RIG_MODE_WEBVR,
- t.RIG_MODE_CUSTOM = a.RIG_MODE_CUSTOM,
- t.ForceAttachControlToAlwaysPreventDefault = !1,
- k([De("position")], t.prototype, "_position", void 0),
- k([De("upVector")], t.prototype, "_upVector", void 0),
- k([Ce()], t.prototype, "orthoLeft", void 0),
- k([Ce()], t.prototype, "orthoRight", void 0),
- k([Ce()], t.prototype, "orthoBottom", void 0),
- k([Ce()], t.prototype, "orthoTop", void 0),
- k([Ce()], t.prototype, "fov", void 0),
- k([Ce()], t.prototype, "projectionPlaneTilt", void 0),
- k([Ce()], t.prototype, "minZ", void 0),
- k([Ce()], t.prototype, "maxZ", void 0),
- k([Ce()], t.prototype, "inertia", void 0),
- k([Ce()], t.prototype, "mode", void 0),
- k([Ce()], t.prototype, "layerMask", void 0),
- k([Ce()], t.prototype, "fovMode", void 0),
- k([Ce()], t.prototype, "cameraRigMode", void 0),
- k([Ce()], t.prototype, "interaxialDistance", void 0),
- k([Ce()], t.prototype, "isStereoscopicSideBySide", void 0),
- t
- }(Xe), Cr = function(e) {
- function t(i, n) {
- var r = e.call(this, i, n) || this;
- return r.diffuse = new D(1,1,1),
- r.specular = new D(1,1,1),
- r.falloffType = t.FALLOFF_DEFAULT,
- r.intensity = 1,
- r._range = Number.MAX_VALUE,
- r._inverseSquaredRange = 0,
- r._photometricScale = 1,
- r._intensityMode = t.INTENSITYMODE_AUTOMATIC,
- r._radius = 1e-5,
- r.renderPriority = 0,
- r._shadowEnabled = !0,
- r._excludeWithLayerMask = 0,
- r._includeOnlyWithLayerMask = 0,
- r._lightmapMode = 0,
- r._excludedMeshesIds = new Array,
- r._includedOnlyMeshesIds = new Array,
- r._isLight = !0,
- r.getScene().addLight(r),
- r._uniformBuffer = new Fi(r.getScene().getEngine(),void 0,void 0,i),
- r._buildUniformLayout(),
- r.includedOnlyMeshes = new Array,
- r.excludedMeshes = new Array,
- r._resyncMeshes(),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "range", {
- get: function() {
- return this._range
- },
- set: function(e) {
- this._range = e,
- this._inverseSquaredRange = 1 / (this.range * this.range)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "intensityMode", {
- get: function() {
- return this._intensityMode
- },
- set: function(e) {
- this._intensityMode = e,
- this._computePhotometricScale()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "radius", {
- get: function() {
- return this._radius
- },
- set: function(e) {
- this._radius = e,
- this._computePhotometricScale()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadowEnabled", {
- get: function() {
- return this._shadowEnabled
- },
- set: function(e) {
- this._shadowEnabled !== e && (this._shadowEnabled = e,
- this._markMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "includedOnlyMeshes", {
- get: function() {
- return this._includedOnlyMeshes
- },
- set: function(e) {
- this._includedOnlyMeshes = e,
- this._hookArrayForIncludedOnly(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "excludedMeshes", {
- get: function() {
- return this._excludedMeshes
- },
- set: function(e) {
- this._excludedMeshes = e,
- this._hookArrayForExcluded(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "excludeWithLayerMask", {
- get: function() {
- return this._excludeWithLayerMask
- },
- set: function(e) {
- this._excludeWithLayerMask = e,
- this._resyncMeshes()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "includeOnlyWithLayerMask", {
- get: function() {
- return this._includeOnlyWithLayerMask
- },
- set: function(e) {
- this._includeOnlyWithLayerMask = e,
- this._resyncMeshes()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lightmapMode", {
- get: function() {
- return this._lightmapMode
- },
- set: function(e) {
- this._lightmapMode !== e && (this._lightmapMode = e,
- this._markMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.transferTexturesToEffect = function(e, t) {
- return this
- }
- ,
- t.prototype._bindLight = function(e, t, i, n, r) {
- void 0 === r && (r = !0);
- var o = e.toString()
- , a = !1;
- if (this._uniformBuffer.bindToEffect(i, "Light" + o),
- this._renderId !== t.getRenderId() || this._lastUseSpecular !== n || !this._uniformBuffer.useUbo) {
- this._renderId = t.getRenderId(),
- this._lastUseSpecular = n;
- var s = this.getScaledIntensity();
- this.transferToEffect(i, o),
- this.diffuse.scaleToRef(s, L.Color3[0]),
- this._uniformBuffer.updateColor4("vLightDiffuse", L.Color3[0], this.range, o),
- n && (this.specular.scaleToRef(s, L.Color3[1]),
- this._uniformBuffer.updateColor4("vLightSpecular", L.Color3[1], this.radius, o)),
- a = !0
- }
- if (this.transferTexturesToEffect(i, o),
- t.shadowsEnabled && this.shadowEnabled && r) {
- var l = this.getShadowGenerator();
- l && (l.bindShadowLight(o, i),
- a = !0)
- }
- a ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer()
- }
- ,
- t.prototype.getClassName = function() {
- return "Light"
- }
- ,
- t.prototype.toString = function(e) {
- var t = "Name: " + this.name;
- if (t += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()],
- this.animations)
- for (var i = 0; i < this.animations.length; i++)
- t += ", animation[0]: " + this.animations[i].toString(e);
- return t
- }
- ,
- t.prototype._syncParentEnabledState = function() {
- e.prototype._syncParentEnabledState.call(this),
- this.isDisposed() || this._resyncMeshes()
- }
- ,
- t.prototype.setEnabled = function(t) {
- e.prototype.setEnabled.call(this, t),
- this._resyncMeshes()
- }
- ,
- t.prototype.getShadowGenerator = function() {
- return this._shadowGenerator
- }
- ,
- t.prototype.getAbsolutePosition = function() {
- return x.Zero()
- }
- ,
- t.prototype.canAffectMesh = function(e) {
- return !(e && (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && -1 === this.includedOnlyMeshes.indexOf(e) || this.excludedMeshes && this.excludedMeshes.length > 0 && -1 !== this.excludedMeshes.indexOf(e) || 0 !== this.includeOnlyWithLayerMask && 0 == (this.includeOnlyWithLayerMask & e.layerMask) || 0 !== this.excludeWithLayerMask && this.excludeWithLayerMask & e.layerMask))
- }
- ,
- t.prototype.dispose = function(t, i) {
- if (void 0 === i && (i = !1),
- this._shadowGenerator && (this._shadowGenerator.dispose(),
- this._shadowGenerator = null),
- this.getScene().stopAnimation(this),
- this._parentContainer) {
- var n = this._parentContainer.lights.indexOf(this);
- n > -1 && this._parentContainer.lights.splice(n, 1),
- this._parentContainer = null
- }
- for (var r = 0, o = this.getScene().meshes; r < o.length; r++)
- o[r]._removeLightSource(this, !0);
- this._uniformBuffer.dispose(),
- this.getScene().removeLight(this),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.prototype.getTypeID = function() {
- return 0
- }
- ,
- t.prototype.getScaledIntensity = function() {
- return this._photometricScale * this.intensity
- }
- ,
- t.prototype.clone = function(e, i) {
- void 0 === i && (i = null);
- var n = t.GetConstructorFromName(this.getTypeID(), e, this.getScene());
- if (!n)
- return null;
- var r = Ge.Clone(n, this);
- return e && (r.name = e),
- i && (r.parent = i),
- r.setEnabled(this.isEnabled()),
- this.onClonedObservable.notifyObservers(r),
- r
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.uniqueId = this.uniqueId,
- e.type = this.getTypeID(),
- this.parent && (e.parentId = this.parent.uniqueId),
- this.excludedMeshes.length > 0 && (e.excludedMeshesIds = [],
- this.excludedMeshes.forEach((function(t) {
- e.excludedMeshesIds.push(t.id)
- }
- ))),
- this.includedOnlyMeshes.length > 0 && (e.includedOnlyMeshesIds = [],
- this.includedOnlyMeshes.forEach((function(t) {
- e.includedOnlyMeshesIds.push(t.id)
- }
- ))),
- Ge.AppendSerializedAnimations(this, e),
- e.ranges = this.serializeAnimationRanges(),
- e.isEnabled = this.isEnabled(),
- e
- }
- ,
- t.GetConstructorFromName = function(e, t, i) {
- return Xe.Construct("Light_Type_" + e, t, i) || null
- }
- ,
- t.Parse = function(e, i) {
- var n = t.GetConstructorFromName(e.type, e.name, i);
- if (!n)
- return null;
- var r = Ge.Parse(n, e, i);
- if (e.excludedMeshesIds && (r._excludedMeshesIds = e.excludedMeshesIds),
- e.includedOnlyMeshesIds && (r._includedOnlyMeshesIds = e.includedOnlyMeshesIds),
- void 0 !== e.parentId && (r._waitingParentId = e.parentId),
- void 0 !== e.falloffType && (r.falloffType = e.falloffType),
- void 0 !== e.lightmapMode && (r.lightmapMode = e.lightmapMode),
- e.animations) {
- for (var o = 0; o < e.animations.length; o++) {
- var a = e.animations[o]
- , s = b("BABYLON.Animation");
- s && r.animations.push(s.Parse(a))
- }
- Xe.ParseAnimationRanges(r, e, i)
- }
- return e.autoAnimate && i.beginAnimation(r, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
- void 0 !== e.isEnabled && r.setEnabled(e.isEnabled),
- r
- }
- ,
- t.prototype._hookArrayForExcluded = function(e) {
- var t = this
- , i = e.push;
- e.push = function() {
- for (var n = [], r = 0; r < arguments.length; r++)
- n[r] = arguments[r];
- for (var o = i.apply(e, n), a = 0, s = n; a < s.length; a++) {
- var l = s[a];
- l._resyncLightSource(t)
- }
- return o
- }
- ;
- var n = e.splice;
- e.splice = function(i, r) {
- for (var o = n.apply(e, [i, r]), a = 0, s = o; a < s.length; a++)
- s[a]._resyncLightSource(t);
- return o
- }
- ;
- for (var r = 0, o = e; r < o.length; r++)
- o[r]._resyncLightSource(this)
- }
- ,
- t.prototype._hookArrayForIncludedOnly = function(e) {
- var t = this
- , i = e.push;
- e.push = function() {
- for (var n = [], r = 0; r < arguments.length; r++)
- n[r] = arguments[r];
- var o = i.apply(e, n);
- return t._resyncMeshes(),
- o
- }
- ;
- var n = e.splice;
- e.splice = function(i, r) {
- var o = n.apply(e, [i, r]);
- return t._resyncMeshes(),
- o
- }
- ,
- this._resyncMeshes()
- }
- ,
- t.prototype._resyncMeshes = function() {
- for (var e = 0, t = this.getScene().meshes; e < t.length; e++)
- t[e]._resyncLightSource(this)
- }
- ,
- t.prototype._markMeshesAsLightDirty = function() {
- for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
- var i = t[e];
- -1 !== i.lightSources.indexOf(this) && i._markSubMeshesAsLightDirty()
- }
- }
- ,
- t.prototype._computePhotometricScale = function() {
- this._photometricScale = this._getPhotometricScale(),
- this.getScene().resetCachedMaterial()
- }
- ,
- t.prototype._getPhotometricScale = function() {
- var e = 0
- , i = this.getTypeID()
- , n = this.intensityMode;
- switch (n === t.INTENSITYMODE_AUTOMATIC && (n = i === t.LIGHTTYPEID_DIRECTIONALLIGHT ? t.INTENSITYMODE_ILLUMINANCE : t.INTENSITYMODE_LUMINOUSINTENSITY),
- i) {
- case t.LIGHTTYPEID_POINTLIGHT:
- case t.LIGHTTYPEID_SPOTLIGHT:
- switch (n) {
- case t.INTENSITYMODE_LUMINOUSPOWER:
- e = 1 / (4 * Math.PI);
- break;
- case t.INTENSITYMODE_LUMINOUSINTENSITY:
- e = 1;
- break;
- case t.INTENSITYMODE_LUMINANCE:
- e = this.radius * this.radius
- }
- break;
- case t.LIGHTTYPEID_DIRECTIONALLIGHT:
- switch (n) {
- case t.INTENSITYMODE_ILLUMINANCE:
- e = 1;
- break;
- case t.INTENSITYMODE_LUMINANCE:
- var r = this.radius;
- r = Math.max(r, .001),
- e = 2 * Math.PI * (1 - Math.cos(r))
- }
- break;
- case t.LIGHTTYPEID_HEMISPHERICLIGHT:
- e = 1
- }
- return e
- }
- ,
- t.prototype._reorderLightsInScene = function() {
- var e = this.getScene();
- 0 != this._renderPriority && (e.requireLightSorting = !0),
- this.getScene().sortLightsByPriority()
- }
- ,
- t.FALLOFF_DEFAULT = fn.FALLOFF_DEFAULT,
- t.FALLOFF_PHYSICAL = fn.FALLOFF_PHYSICAL,
- t.FALLOFF_GLTF = fn.FALLOFF_GLTF,
- t.FALLOFF_STANDARD = fn.FALLOFF_STANDARD,
- t.LIGHTMAP_DEFAULT = fn.LIGHTMAP_DEFAULT,
- t.LIGHTMAP_SPECULAR = fn.LIGHTMAP_SPECULAR,
- t.LIGHTMAP_SHADOWSONLY = fn.LIGHTMAP_SHADOWSONLY,
- t.INTENSITYMODE_AUTOMATIC = fn.INTENSITYMODE_AUTOMATIC,
- t.INTENSITYMODE_LUMINOUSPOWER = fn.INTENSITYMODE_LUMINOUSPOWER,
- t.INTENSITYMODE_LUMINOUSINTENSITY = fn.INTENSITYMODE_LUMINOUSINTENSITY,
- t.INTENSITYMODE_ILLUMINANCE = fn.INTENSITYMODE_ILLUMINANCE,
- t.INTENSITYMODE_LUMINANCE = fn.INTENSITYMODE_LUMINANCE,
- t.LIGHTTYPEID_POINTLIGHT = fn.LIGHTTYPEID_POINTLIGHT,
- t.LIGHTTYPEID_DIRECTIONALLIGHT = fn.LIGHTTYPEID_DIRECTIONALLIGHT,
- t.LIGHTTYPEID_SPOTLIGHT = fn.LIGHTTYPEID_SPOTLIGHT,
- t.LIGHTTYPEID_HEMISPHERICLIGHT = fn.LIGHTTYPEID_HEMISPHERICLIGHT,
- k([Me()], t.prototype, "diffuse", void 0),
- k([Me()], t.prototype, "specular", void 0),
- k([Ce()], t.prototype, "falloffType", void 0),
- k([Ce()], t.prototype, "intensity", void 0),
- k([Ce()], t.prototype, "range", null),
- k([Ce()], t.prototype, "intensityMode", null),
- k([Ce()], t.prototype, "radius", null),
- k([Ce()], t.prototype, "_renderPriority", void 0),
- k([Re("_reorderLightsInScene")], t.prototype, "renderPriority", void 0),
- k([Ce("shadowEnabled")], t.prototype, "_shadowEnabled", void 0),
- k([Ce("excludeWithLayerMask")], t.prototype, "_excludeWithLayerMask", void 0),
- k([Ce("includeOnlyWithLayerMask")], t.prototype, "_includeOnlyWithLayerMask", void 0),
- k([Ce("lightmapMode")], t.prototype, "_lightmapMode", void 0),
- t
- }(Xe), Pr = function() {
- function e() {}
- return e.BindClipPlane = function(e, t) {
- if (t.clipPlane) {
- var i = t.clipPlane;
- e.setFloat4("vClipPlane", i.normal.x, i.normal.y, i.normal.z, i.d)
- }
- t.clipPlane2 && (i = t.clipPlane2,
- e.setFloat4("vClipPlane2", i.normal.x, i.normal.y, i.normal.z, i.d)),
- t.clipPlane3 && (i = t.clipPlane3,
- e.setFloat4("vClipPlane3", i.normal.x, i.normal.y, i.normal.z, i.d)),
- t.clipPlane4 && (i = t.clipPlane4,
- e.setFloat4("vClipPlane4", i.normal.x, i.normal.y, i.normal.z, i.d)),
- t.clipPlane5 && (i = t.clipPlane5,
- e.setFloat4("vClipPlane5", i.normal.x, i.normal.y, i.normal.z, i.d)),
- t.clipPlane6 && (i = t.clipPlane6,
- e.setFloat4("vClipPlane6", i.normal.x, i.normal.y, i.normal.z, i.d))
- }
- ,
- e
- }(), Mr = function() {
- function e() {}
- return e.BindSceneUniformBuffer = function(e, t) {
- t.bindToEffect(e, "Scene")
- }
- ,
- e.PrepareDefinesForMergedUV = function(e, t, i) {
- t._needUVs = !0,
- t[i] = !0,
- e.getTextureMatrix().isIdentityAs3x2() ? (t[i + "DIRECTUV"] = e.coordinatesIndex + 1,
- t["MAINUV" + (e.coordinatesIndex + 1)] = !0) : t[i + "DIRECTUV"] = 0
- }
- ,
- e.BindTextureMatrix = function(e, t, i) {
- var n = e.getTextureMatrix();
- t.updateMatrix(i + "Matrix", n)
- }
- ,
- e.GetFogState = function(e, t) {
- return t.fogEnabled && e.applyFog && t.fogMode !== mn.FOGMODE_NONE
- }
- ,
- e.PrepareDefinesForMisc = function(e, t, i, n, r, o, a) {
- a._areMiscDirty && (a.LOGARITHMICDEPTH = i,
- a.POINTSIZE = n,
- a.FOG = r && this.GetFogState(e, t),
- a.NONUNIFORMSCALING = e.nonUniformScaling,
- a.ALPHATEST = o)
- }
- ,
- e.PrepareDefinesForFrameBoundValues = function(e, t, i, n, r, o) {
- void 0 === r && (r = null),
- void 0 === o && (o = !1);
- var a, s, l, c, u, h, d = !1;
- a = null == r ? void 0 !== e.clipPlane && null !== e.clipPlane : r,
- s = null == r ? void 0 !== e.clipPlane2 && null !== e.clipPlane2 : r,
- l = null == r ? void 0 !== e.clipPlane3 && null !== e.clipPlane3 : r,
- c = null == r ? void 0 !== e.clipPlane4 && null !== e.clipPlane4 : r,
- u = null == r ? void 0 !== e.clipPlane5 && null !== e.clipPlane5 : r,
- h = null == r ? void 0 !== e.clipPlane6 && null !== e.clipPlane6 : r,
- i.CLIPPLANE !== a && (i.CLIPPLANE = a,
- d = !0),
- i.CLIPPLANE2 !== s && (i.CLIPPLANE2 = s,
- d = !0),
- i.CLIPPLANE3 !== l && (i.CLIPPLANE3 = l,
- d = !0),
- i.CLIPPLANE4 !== c && (i.CLIPPLANE4 = c,
- d = !0),
- i.CLIPPLANE5 !== u && (i.CLIPPLANE5 = u,
- d = !0),
- i.CLIPPLANE6 !== h && (i.CLIPPLANE6 = h,
- d = !0),
- i.DEPTHPREPASS !== !t.getColorWrite() && (i.DEPTHPREPASS = !i.DEPTHPREPASS,
- d = !0),
- i.INSTANCES !== n && (i.INSTANCES = n,
- d = !0),
- i.INSTANCESCOLOR && !i.INSTANCES && (i.INSTANCESCOLOR = !1,
- d = !0),
- i.THIN_INSTANCES !== o && (i.THIN_INSTANCES = o,
- d = !0),
- d && i.markAsUnprocessed()
- }
- ,
- e.PrepareDefinesForBones = function(e, t) {
- if (e.useBones && e.computeBonesUsingShaders && e.skeleton) {
- t.NUM_BONE_INFLUENCERS = e.numBoneInfluencers;
- var i = void 0 !== t.BONETEXTURE;
- if (e.skeleton.isUsingTextureForMatrices && i)
- t.BONETEXTURE = !0;
- else {
- t.BonesPerMesh = e.skeleton.bones.length + 1,
- t.BONETEXTURE = !i && void 0;
- var n = e.getScene().prePassRenderer;
- if (n && n.enabled) {
- var r = -1 === n.excludedSkinnedMesh.indexOf(e);
- t.BONES_VELOCITY_ENABLED = r
- }
- }
- } else
- t.NUM_BONE_INFLUENCERS = 0,
- t.BonesPerMesh = 0
- }
- ,
- e.PrepareDefinesForMorphTargets = function(e, t) {
- var i = e.morphTargetManager;
- i ? (t.MORPHTARGETS_UV = i.supportsUVs && t.UV1,
- t.MORPHTARGETS_TANGENT = i.supportsTangents && t.TANGENT,
- t.MORPHTARGETS_NORMAL = i.supportsNormals && t.NORMAL,
- t.MORPHTARGETS = i.numInfluencers > 0,
- t.NUM_MORPH_INFLUENCERS = i.numInfluencers,
- t.MORPHTARGETS_TEXTURE = i.isUsingTextureForTargets) : (t.MORPHTARGETS_UV = !1,
- t.MORPHTARGETS_TANGENT = !1,
- t.MORPHTARGETS_NORMAL = !1,
- t.MORPHTARGETS = !1,
- t.NUM_MORPH_INFLUENCERS = 0)
- }
- ,
- e.PrepareDefinesForBakedVertexAnimation = function(e, t) {
- var i = e.bakedVertexAnimationManager;
- t.BAKED_VERTEX_ANIMATION_TEXTURE = !(!i || !i.isEnabled)
- }
- ,
- e.PrepareDefinesForAttributes = function(e, t, i, n, r, o, s) {
- if (void 0 === r && (r = !1),
- void 0 === o && (o = !0),
- void 0 === s && (s = !0),
- !t._areAttributesDirty && t._needNormals === t._normals && t._needUVs === t._uvs)
- return !1;
- t._normals = t._needNormals,
- t._uvs = t._needUVs,
- t.NORMAL = t._needNormals && e.isVerticesDataPresent(Bi.NormalKind),
- t._needNormals && e.isVerticesDataPresent(Bi.TangentKind) && (t.TANGENT = !0);
- for (var l = 1; l <= a.MAX_SUPPORTED_UV_SETS; ++l)
- t["UV" + l] = !!t._needUVs && e.isVerticesDataPresent("uv".concat(1 === l ? "" : l));
- if (i) {
- var c = e.useVertexColors && e.isVerticesDataPresent(Bi.ColorKind);
- t.VERTEXCOLOR = c,
- t.VERTEXALPHA = e.hasVertexAlpha && c && o
- }
- return e.isVerticesDataPresent(Bi.ColorInstanceKind) && (t.INSTANCESCOLOR = !0),
- n && this.PrepareDefinesForBones(e, t),
- r && this.PrepareDefinesForMorphTargets(e, t),
- s && this.PrepareDefinesForBakedVertexAnimation(e, t),
- !0
- }
- ,
- e.PrepareDefinesForMultiview = function(e, t) {
- if (e.activeCamera) {
- var i = t.MULTIVIEW;
- t.MULTIVIEW = null !== e.activeCamera.outputRenderTarget && e.activeCamera.outputRenderTarget.getViewCount() > 1,
- t.MULTIVIEW != i && t.markAsUnprocessed()
- }
- }
- ,
- e.PrepareDefinesForOIT = function(e, t, i) {
- var n = t.ORDER_INDEPENDENT_TRANSPARENCY
- , r = t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
- t.ORDER_INDEPENDENT_TRANSPARENCY = e.useOrderIndependentTransparency && i,
- t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !e.getEngine().getCaps().textureFloatLinearFiltering,
- n === t.ORDER_INDEPENDENT_TRANSPARENCY && r === t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS || t.markAsUnprocessed()
- }
- ,
- e.PrepareDefinesForPrePass = function(e, t, i) {
- var n = t.PREPASS;
- if (t._arePrePassDirty) {
- var r = [{
- type: a.PREPASS_POSITION_TEXTURE_TYPE,
- define: "PREPASS_POSITION",
- index: "PREPASS_POSITION_INDEX"
- }, {
- type: a.PREPASS_VELOCITY_TEXTURE_TYPE,
- define: "PREPASS_VELOCITY",
- index: "PREPASS_VELOCITY_INDEX"
- }, {
- type: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
- define: "PREPASS_REFLECTIVITY",
- index: "PREPASS_REFLECTIVITY_INDEX"
- }, {
- type: a.PREPASS_IRRADIANCE_TEXTURE_TYPE,
- define: "PREPASS_IRRADIANCE",
- index: "PREPASS_IRRADIANCE_INDEX"
- }, {
- type: a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,
- define: "PREPASS_ALBEDO_SQRT",
- index: "PREPASS_ALBEDO_SQRT_INDEX"
- }, {
- type: a.PREPASS_DEPTH_TEXTURE_TYPE,
- define: "PREPASS_DEPTH",
- index: "PREPASS_DEPTH_INDEX"
- }, {
- type: a.PREPASS_NORMAL_TEXTURE_TYPE,
- define: "PREPASS_NORMAL",
- index: "PREPASS_NORMAL_INDEX"
- }];
- if (e.prePassRenderer && e.prePassRenderer.enabled && i) {
- t.PREPASS = !0,
- t.SCENE_MRT_COUNT = e.prePassRenderer.mrtCount;
- for (var o = 0; o < r.length; o++) {
- var s = e.prePassRenderer.getIndex(r[o].type);
- -1 !== s ? (t[r[o].define] = !0,
- t[r[o].index] = s) : t[r[o].define] = !1
- }
- } else
- for (t.PREPASS = !1,
- o = 0; o < r.length; o++)
- t[r[o].define] = !1;
- t.PREPASS != n && (t.markAsUnprocessed(),
- t.markAsImageProcessingDirty())
- }
- }
- ,
- e.PrepareDefinesForLight = function(e, t, i, n, r, o, a) {
- switch (a.needNormals = !0,
- void 0 === r["LIGHT" + n] && (a.needRebuild = !0),
- r["LIGHT" + n] = !0,
- r["SPOTLIGHT" + n] = !1,
- r["HEMILIGHT" + n] = !1,
- r["POINTLIGHT" + n] = !1,
- r["DIRLIGHT" + n] = !1,
- i.prepareLightSpecificDefines(r, n),
- r["LIGHT_FALLOFF_PHYSICAL" + n] = !1,
- r["LIGHT_FALLOFF_GLTF" + n] = !1,
- r["LIGHT_FALLOFF_STANDARD" + n] = !1,
- i.falloffType) {
- case Cr.FALLOFF_GLTF:
- r["LIGHT_FALLOFF_GLTF" + n] = !0;
- break;
- case Cr.FALLOFF_PHYSICAL:
- r["LIGHT_FALLOFF_PHYSICAL" + n] = !0;
- break;
- case Cr.FALLOFF_STANDARD:
- r["LIGHT_FALLOFF_STANDARD" + n] = !0
- }
- if (o && !i.specular.equalsFloats(0, 0, 0) && (a.specularEnabled = !0),
- r["SHADOW" + n] = !1,
- r["SHADOWCSM" + n] = !1,
- r["SHADOWCSMDEBUG" + n] = !1,
- r["SHADOWCSMNUM_CASCADES" + n] = !1,
- r["SHADOWCSMUSESHADOWMAXZ" + n] = !1,
- r["SHADOWCSMNOBLEND" + n] = !1,
- r["SHADOWCSM_RIGHTHANDED" + n] = !1,
- r["SHADOWPCF" + n] = !1,
- r["SHADOWPCSS" + n] = !1,
- r["SHADOWPOISSON" + n] = !1,
- r["SHADOWESM" + n] = !1,
- r["SHADOWCLOSEESM" + n] = !1,
- r["SHADOWCUBE" + n] = !1,
- r["SHADOWLOWQUALITY" + n] = !1,
- r["SHADOWMEDIUMQUALITY" + n] = !1,
- t && t.receiveShadows && e.shadowsEnabled && i.shadowEnabled) {
- var s = i.getShadowGenerator();
- if (s) {
- var l = s.getShadowMap();
- l && l.renderList && l.renderList.length > 0 && (a.shadowEnabled = !0,
- s.prepareDefines(r, n))
- }
- }
- i.lightmapMode != Cr.LIGHTMAP_DEFAULT ? (a.lightmapMode = !0,
- r["LIGHTMAPEXCLUDED" + n] = !0,
- r["LIGHTMAPNOSPECULAR" + n] = i.lightmapMode == Cr.LIGHTMAP_SHADOWSONLY) : (r["LIGHTMAPEXCLUDED" + n] = !1,
- r["LIGHTMAPNOSPECULAR" + n] = !1)
- }
- ,
- e.PrepareDefinesForLights = function(e, t, i, n, r, o) {
- if (void 0 === r && (r = 4),
- void 0 === o && (o = !1),
- !i._areLightsDirty)
- return i._needNormals;
- var a = 0
- , s = {
- needNormals: !1,
- needRebuild: !1,
- lightmapMode: !1,
- shadowEnabled: !1,
- specularEnabled: !1
- };
- if (e.lightsEnabled && !o)
- for (var l = 0, c = t.lightSources; l < c.length; l++) {
- var u = c[l];
- if (this.PrepareDefinesForLight(e, t, u, a, i, n, s),
- ++a === r)
- break
- }
- i.SPECULARTERM = s.specularEnabled,
- i.SHADOWS = s.shadowEnabled;
- for (var h = a; h < r; h++)
- void 0 !== i["LIGHT" + h] && (i["LIGHT" + h] = !1,
- i["HEMILIGHT" + h] = !1,
- i["POINTLIGHT" + h] = !1,
- i["DIRLIGHT" + h] = !1,
- i["SPOTLIGHT" + h] = !1,
- i["SHADOW" + h] = !1,
- i["SHADOWCSM" + h] = !1,
- i["SHADOWCSMDEBUG" + h] = !1,
- i["SHADOWCSMNUM_CASCADES" + h] = !1,
- i["SHADOWCSMUSESHADOWMAXZ" + h] = !1,
- i["SHADOWCSMNOBLEND" + h] = !1,
- i["SHADOWCSM_RIGHTHANDED" + h] = !1,
- i["SHADOWPCF" + h] = !1,
- i["SHADOWPCSS" + h] = !1,
- i["SHADOWPOISSON" + h] = !1,
- i["SHADOWESM" + h] = !1,
- i["SHADOWCLOSEESM" + h] = !1,
- i["SHADOWCUBE" + h] = !1,
- i["SHADOWLOWQUALITY" + h] = !1,
- i["SHADOWMEDIUMQUALITY" + h] = !1);
- var d = e.getEngine().getCaps();
- return void 0 === i.SHADOWFLOAT && (s.needRebuild = !0),
- i.SHADOWFLOAT = s.shadowEnabled && (d.textureFloatRender && d.textureFloatLinearFiltering || d.textureHalfFloatRender && d.textureHalfFloatLinearFiltering),
- i.LIGHTMAPEXCLUDED = s.lightmapMode,
- s.needRebuild && i.rebuild(),
- s.needNormals
- }
- ,
- e.PrepareUniformsAndSamplersForLight = function(e, t, i, n, r, o) {
- void 0 === r && (r = null),
- void 0 === o && (o = !1),
- r && r.push("Light" + e),
- o || (t.push("vLightData" + e, "vLightDiffuse" + e, "vLightSpecular" + e, "vLightDirection" + e, "vLightFalloff" + e, "vLightGround" + e, "lightMatrix" + e, "shadowsInfo" + e, "depthValues" + e),
- i.push("shadowSampler" + e),
- i.push("depthSampler" + e),
- t.push("viewFrustumZ" + e, "cascadeBlendFactor" + e, "lightSizeUVCorrection" + e, "depthCorrection" + e, "penumbraDarkness" + e, "frustumLengths" + e),
- n && (i.push("projectionLightSampler" + e),
- t.push("textureProjectionMatrix" + e)))
- }
- ,
- e.PrepareUniformsAndSamplersList = function(e, t, i, n) {
- var r;
- void 0 === n && (n = 4);
- var o = null;
- if (e.uniformsNames) {
- var a = e;
- r = a.uniformsNames,
- o = a.uniformBuffersNames,
- t = a.samplers,
- i = a.defines,
- n = a.maxSimultaneousLights || 0
- } else
- r = e,
- t || (t = []);
- for (var s = 0; s < n && i["LIGHT" + s]; s++)
- this.PrepareUniformsAndSamplersForLight(s, r, t, i["PROJECTEDLIGHTTEXTURE" + s], o);
- i.NUM_MORPH_INFLUENCERS && r.push("morphTargetInfluences"),
- i.BAKED_VERTEX_ANIMATION_TEXTURE && (r.push("bakedVertexAnimationSettings"),
- r.push("bakedVertexAnimationTextureSizeInverted"),
- r.push("bakedVertexAnimationTime"),
- t.push("bakedVertexAnimationTexture"))
- }
- ,
- e.HandleFallbacksForShadows = function(e, t, i, n) {
- void 0 === i && (i = 4),
- void 0 === n && (n = 0);
- for (var r = 0, o = 0; o < i && e["LIGHT" + o]; o++)
- o > 0 && (r = n + o,
- t.addFallback(r, "LIGHT" + o)),
- e.SHADOWS || (e["SHADOW" + o] && t.addFallback(n, "SHADOW" + o),
- e["SHADOWPCF" + o] && t.addFallback(n, "SHADOWPCF" + o),
- e["SHADOWPCSS" + o] && t.addFallback(n, "SHADOWPCSS" + o),
- e["SHADOWPOISSON" + o] && t.addFallback(n, "SHADOWPOISSON" + o),
- e["SHADOWESM" + o] && t.addFallback(n, "SHADOWESM" + o),
- e["SHADOWCLOSEESM" + o] && t.addFallback(n, "SHADOWCLOSEESM" + o));
- return r++
- }
- ,
- e.PrepareAttributesForMorphTargetsInfluencers = function(e, t, i) {
- this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = i,
- this.PrepareAttributesForMorphTargets(e, t, this._TmpMorphInfluencers)
- }
- ,
- e.PrepareAttributesForMorphTargets = function(e, t, i) {
- var n = i.NUM_MORPH_INFLUENCERS;
- if (n > 0 && E.LastCreatedEngine) {
- var r = E.LastCreatedEngine.getCaps().maxVertexAttribs
- , o = t.morphTargetManager;
- if (null == o ? void 0 : o.isUsingTextureForTargets)
- return;
- for (var a = o && o.supportsNormals && i.NORMAL, s = o && o.supportsTangents && i.TANGENT, l = o && o.supportsUVs && i.UV1, c = 0; c < n; c++)
- e.push(Bi.PositionKind + c),
- a && e.push(Bi.NormalKind + c),
- s && e.push(Bi.TangentKind + c),
- l && e.push(Bi.UVKind + "_" + c),
- e.length > r && K.Error("Cannot add more vertex attributes for mesh " + t.name)
- }
- }
- ,
- e.PrepareAttributesForBakedVertexAnimation = function(e, t, i) {
- i.BAKED_VERTEX_ANIMATION_TEXTURE && i.INSTANCES && e.push("bakedVertexAnimationSettingsInstanced")
- }
- ,
- e.PrepareAttributesForBones = function(e, t, i, n) {
- i.NUM_BONE_INFLUENCERS > 0 && (n.addCPUSkinningFallback(0, t),
- e.push(Bi.MatricesIndicesKind),
- e.push(Bi.MatricesWeightsKind),
- i.NUM_BONE_INFLUENCERS > 4 && (e.push(Bi.MatricesIndicesExtraKind),
- e.push(Bi.MatricesWeightsExtraKind)))
- }
- ,
- e.PrepareAttributesForInstances = function(e, t) {
- (t.INSTANCES || t.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!t.PREPASS_VELOCITY)
- }
- ,
- e.PushAttributesForInstances = function(e, t) {
- void 0 === t && (t = !1),
- e.push("world0"),
- e.push("world1"),
- e.push("world2"),
- e.push("world3"),
- t && (e.push("previousWorld0"),
- e.push("previousWorld1"),
- e.push("previousWorld2"),
- e.push("previousWorld3"))
- }
- ,
- e.BindLightProperties = function(e, t, i) {
- e.transferToEffect(t, i + "")
- }
- ,
- e.BindLight = function(e, t, i, n, r, o) {
- void 0 === o && (o = !0),
- e._bindLight(t, i, n, r, o)
- }
- ,
- e.BindLights = function(e, t, i, n, r) {
- void 0 === r && (r = 4);
- for (var o = Math.min(t.lightSources.length, r), a = 0; a < o; a++) {
- var s = t.lightSources[a];
- this.BindLight(s, a, e, i, "boolean" == typeof n ? n : n.SPECULARTERM, t.receiveShadows)
- }
- }
- ,
- e.BindFogParameters = function(e, t, i, n) {
- void 0 === n && (n = !1),
- e.fogEnabled && t.applyFog && e.fogMode !== mn.FOGMODE_NONE && (i.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity),
- n ? (e.fogColor.toLinearSpaceToRef(this._TempFogColor),
- i.setColor3("vFogColor", this._TempFogColor)) : i.setColor3("vFogColor", e.fogColor))
- }
- ,
- e.BindBonesParameters = function(t, i, n) {
- if (i && t && (t.computeBonesUsingShaders && i._bonesComputationForcedToCPU && (t.computeBonesUsingShaders = !1),
- t.useBones && t.computeBonesUsingShaders && t.skeleton)) {
- var r = t.skeleton;
- if (r.isUsingTextureForMatrices && i.getUniformIndex("boneTextureWidth") > -1) {
- var o = r.getTransformMatrixTexture(t);
- i.setTexture("boneSampler", o),
- i.setFloat("boneTextureWidth", 4 * (r.bones.length + 1))
- } else {
- var s = r.getTransformMatrices(t);
- s && (i.setMatrices("mBones", s),
- n && t.getScene().prePassRenderer && t.getScene().prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE) && (n.previousBones[t.uniqueId] || (n.previousBones[t.uniqueId] = s.slice()),
- i.setMatrices("mPreviousBones", n.previousBones[t.uniqueId]),
- e._CopyBonesTransformationMatrices(s, n.previousBones[t.uniqueId])))
- }
- }
- }
- ,
- e._CopyBonesTransformationMatrices = function(e, t) {
- return t.set(e),
- t
- }
- ,
- e.BindMorphTargetParameters = function(e, t) {
- var i = e.morphTargetManager;
- e && i && t.setFloatArray("morphTargetInfluences", i.influences)
- }
- ,
- e.BindLogDepth = function(e, t, i) {
- if (!e || e.LOGARITHMICDEPTH) {
- var n = i.activeCamera;
- n.mode === Rr.ORTHOGRAPHIC_CAMERA && K.Error("Logarithmic depth is not compatible with orthographic cameras!", 20),
- t.setFloat("logarithmicDepthConstant", 2 / (Math.log(n.maxZ + 1) / Math.LN2))
- }
- }
- ,
- e.BindClipPlane = function(e, t) {
- Pr.BindClipPlane(e, t)
- }
- ,
- e._TmpMorphInfluencers = {
- NUM_MORPH_INFLUENCERS: 0
- },
- e._TempFogColor = D.Black(),
- e
- }(), Ir = function() {
- function e() {
- this.reset()
- }
- return e.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(e.prototype, "func", {
- get: function() {
- return this._func
- },
- set: function(e) {
- this._func = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "funcRef", {
- get: function() {
- return this._funcRef
- },
- set: function(e) {
- this._funcRef = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "funcMask", {
- get: function() {
- return this._funcMask
- },
- set: function(e) {
- this._funcMask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opStencilFail", {
- get: function() {
- return this._opStencilFail
- },
- set: function(e) {
- this._opStencilFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opDepthFail", {
- get: function() {
- return this._opDepthFail
- },
- set: function(e) {
- this._opDepthFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opStencilDepthPass", {
- get: function() {
- return this._opStencilDepthPass
- },
- set: function(e) {
- this._opStencilDepthPass = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mask", {
- get: function() {
- return this._mask
- },
- set: function(e) {
- this._mask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "MaterialStencilState"
- }
- ,
- e.prototype.copyTo = function(e) {
- Ge.Clone((function() {
- return e
- }
- ), this)
- }
- ,
- e.prototype.serialize = function() {
- return Ge.Serialize(this)
- }
- ,
- e.prototype.parse = function(e, t, i) {
- var n = this;
- Ge.Parse((function() {
- return n
- }
- ), e, t, i)
- }
- ,
- k([Ce()], e.prototype, "func", null),
- k([Ce()], e.prototype, "funcRef", null),
- k([Ce()], e.prototype, "funcMask", null),
- k([Ce()], e.prototype, "opStencilFail", null),
- k([Ce()], e.prototype, "opDepthFail", null),
- k([Ce()], e.prototype, "opStencilDepthPass", null),
- k([Ce()], e.prototype, "mask", null),
- k([Ce()], e.prototype, "enabled", null),
- e
- }();
- !function(e) {
- e[e.Created = 1] = "Created",
- e[e.Disposed = 2] = "Disposed",
- e[e.GetDefineNames = 4] = "GetDefineNames",
- e[e.PrepareUniformBuffer = 8] = "PrepareUniformBuffer",
- e[e.IsReadyForSubMesh = 16] = "IsReadyForSubMesh",
- e[e.PrepareDefines = 32] = "PrepareDefines",
- e[e.BindForSubMesh = 64] = "BindForSubMesh",
- e[e.PrepareEffect = 128] = "PrepareEffect",
- e[e.GetAnimatables = 256] = "GetAnimatables",
- e[e.GetActiveTextures = 512] = "GetActiveTextures",
- e[e.HasTexture = 1024] = "HasTexture",
- e[e.FillRenderTargetTextures = 2048] = "FillRenderTargetTextures",
- e[e.HasRenderTargetTextures = 4096] = "HasRenderTargetTextures",
- e[e.HardBindForSubMesh = 8192] = "HardBindForSubMesh"
- }(Ar || (Ar = {}));
- var Or = function() {
- function e(t, i, n) {
- 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 h,
- this._onDisposeObserver = null,
- this._onUnBindObservable = null,
- this._onBindObserver = null,
- this._alphaMode = a.ALPHA_COMBINE,
- 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 Ir,
- this._useUBO = !1,
- this._fillMode = e.TriangleFillMode,
- this._cachedDepthWriteState = !1,
- this._cachedColorWriteState = !1,
- this._cachedDepthFunctionState = 0,
- this._indexInSceneMaterialArray = -1,
- this.meshMap = null,
- this._parentContainer = null,
- this._uniformBufferLayoutBuilt = !1,
- this._eventInfo = {},
- this._callbackPluginEventGeneric = function() {}
- ,
- this._callbackPluginEventIsReadyForSubMesh = function() {}
- ,
- this._callbackPluginEventPrepareDefines = function() {}
- ,
- this._callbackPluginEventHardBindForSubMesh = function() {}
- ,
- this._callbackPluginEventBindForSubMesh = function() {}
- ,
- this._callbackPluginEventHasRenderTargetTextures = function() {}
- ,
- this._callbackPluginEventFillRenderTargetTextures = function() {}
- ,
- this._forceAlphaTest = !1,
- this._transparencyMode = null,
- this.name = t;
- var r = i || E.LastCreatedScene;
- r && (this._scene = r,
- this._dirtyCallbacks = {},
- this._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag] = this._markAllSubMeshesAsTexturesDirty.bind(this),
- this._dirtyCallbacks[a.MATERIAL_LightDirtyFlag] = this._markAllSubMeshesAsLightsDirty.bind(this),
- this._dirtyCallbacks[a.MATERIAL_FresnelDirtyFlag] = this._markAllSubMeshesAsFresnelDirty.bind(this),
- this._dirtyCallbacks[a.MATERIAL_AttributesDirtyFlag] = this._markAllSubMeshesAsAttributesDirty.bind(this),
- this._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag] = this._markAllSubMeshesAsMiscDirty.bind(this),
- this._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag] = this._markAllSubMeshesAsPrePassDirty.bind(this),
- this._dirtyCallbacks[a.MATERIAL_AllDirtyFlag] = this._markAllSubMeshesAsAllDirty.bind(this),
- this.id = t || gi.RandomId(),
- this.uniqueId = this._scene.getUniqueId(),
- this._materialContext = this._scene.getEngine().createMaterialContext(),
- this._drawWrapper = new Gt(this._scene.getEngine(),!1),
- this._drawWrapper.materialContext = this._materialContext,
- this._scene.useRightHandedSystem ? this.sideOrientation = e.ClockWiseSideOrientation : this.sideOrientation = e.CounterClockWiseSideOrientation,
- this._uniformBuffer = new Fi(this._scene.getEngine(),void 0,void 0,t),
- this._useUBO = this.getScene().getEngine().supportsUniformBuffers,
- n || this._scene.addMaterial(this),
- this._scene.useMaterialMeshMap && (this.meshMap = {}),
- e.OnEventObservable.notifyObservers(this, Ar.Created))
- }
- return Object.defineProperty(e.prototype, "canRenderToMRT", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alpha", {
- get: function() {
- return this._alpha
- },
- set: function(t) {
- this._alpha !== t && (this._alpha = t,
- this.markAsDirty(e.MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "backFaceCulling", {
- get: function() {
- return this._backFaceCulling
- },
- set: function(t) {
- this._backFaceCulling !== t && (this._backFaceCulling = t,
- this.markAsDirty(e.TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cullBackFaces", {
- get: function() {
- return this._cullBackFaces
- },
- set: function(t) {
- this._cullBackFaces !== t && (this._cullBackFaces = t,
- this.markAsDirty(e.TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
- get: function() {
- return this._eventInfo.hasRenderTargetTextures = !1,
- this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
- this._eventInfo.hasRenderTargetTextures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBindObservable", {
- get: function() {
- return this._onBindObservable || (this._onBindObservable = new h),
- this._onBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBind", {
- set: function(e) {
- this._onBindObserver && this.onBindObservable.remove(this._onBindObserver),
- this._onBindObserver = this.onBindObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onUnBindObservable", {
- get: function() {
- return this._onUnBindObservable || (this._onUnBindObservable = new h),
- this._onUnBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onEffectCreatedObservable", {
- get: function() {
- return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new h),
- this._onEffectCreatedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alphaMode", {
- get: function() {
- return this._alphaMode
- },
- set: function(t) {
- this._alphaMode !== t && (this._alphaMode = t,
- this.markAsDirty(e.TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.prototype, "isPrePassCapable", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fogEnabled", {
- get: function() {
- return this._fogEnabled
- },
- set: function(t) {
- this._fogEnabled !== t && (this._fogEnabled = t,
- this.markAsDirty(e.MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wireframe", {
- get: function() {
- switch (this._fillMode) {
- case e.WireFrameFillMode:
- case e.LineListDrawMode:
- case e.LineLoopDrawMode:
- case e.LineStripDrawMode:
- return !0
- }
- return this._scene.forceWireframe
- },
- set: function(t) {
- this.fillMode = t ? e.WireFrameFillMode : e.TriangleFillMode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pointsCloud", {
- get: function() {
- switch (this._fillMode) {
- case e.PointFillMode:
- case e.PointListDrawMode:
- return !0
- }
- return this._scene.forcePointsCloud
- },
- set: function(t) {
- this.fillMode = t ? e.PointFillMode : e.TriangleFillMode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fillMode", {
- get: function() {
- return this._fillMode
- },
- set: function(t) {
- this._fillMode !== t && (this._fillMode = t,
- this.markAsDirty(e.MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getDrawWrapper = function() {
- return this._drawWrapper
- }
- ,
- e.prototype._setDrawWrapper = function(e) {
- this._drawWrapper = e
- }
- ,
- e.prototype.toString = function(e) {
- return "Name: " + this.name
- }
- ,
- e.prototype.getClassName = function() {
- return "Material"
- }
- ,
- Object.defineProperty(e.prototype, "isFrozen", {
- get: function() {
- return this.checkReadyOnlyOnce
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.freeze = function() {
- this.markDirty(),
- this.checkReadyOnlyOnce = !0
- }
- ,
- e.prototype.unfreeze = function() {
- this.markDirty(),
- this.checkReadyOnlyOnce = !1
- }
- ,
- e.prototype.isReady = function(e, t) {
- return !0
- }
- ,
- e.prototype.isReadyForSubMesh = function(e, t, i) {
- var n = t.materialDefines;
- return !!n && (this._eventInfo.isReadyForSubMesh = !0,
- this._eventInfo.defines = n,
- this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
- this._eventInfo.isReadyForSubMesh)
- }
- ,
- e.prototype.getEffect = function() {
- return this._drawWrapper.effect
- }
- ,
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- Object.defineProperty(e.prototype, "transparencyMode", {
- get: function() {
- return this._transparencyMode
- },
- set: function(t) {
- this._transparencyMode !== t && (this._transparencyMode = t,
- this._forceAlphaTest = t === e.MATERIAL_ALPHATESTANDBLEND,
- this._markAllSubMeshesAsTexturesAndMiscDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_disableAlphaBlending", {
- get: function() {
- return this._transparencyMode === e.MATERIAL_OPAQUE || this._transparencyMode === e.MATERIAL_ALPHATEST
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.needAlphaBlending = function() {
- return !this._disableAlphaBlending && this.alpha < 1
- }
- ,
- e.prototype.needAlphaBlendingForMesh = function(e) {
- return !(this._disableAlphaBlending && e.visibility >= 1) && (this.needAlphaBlending() || e.visibility < 1 || e.hasVertexAlpha)
- }
- ,
- e.prototype.needAlphaTesting = function() {
- return !!this._forceAlphaTest
- }
- ,
- e.prototype._shouldTurnAlphaTestOn = function(e) {
- return !this.needAlphaBlendingForMesh(e) && this.needAlphaTesting()
- }
- ,
- e.prototype.getAlphaTestTexture = function() {
- return null
- }
- ,
- e.prototype.markDirty = function() {
- for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
- var i = t[e];
- if (i.subMeshes)
- for (var n = 0, r = i.subMeshes; n < r.length; n++) {
- var o = r[n];
- o.getMaterial() === this && o.effect && (o.effect._wasPreviouslyReady = !1)
- }
- }
- }
- ,
- e.prototype._preBind = function(t, i) {
- void 0 === i && (i = null);
- var n = this._scene.getEngine()
- , r = (null == i ? this.sideOrientation : i) === e.ClockWiseSideOrientation;
- return n.enableEffect(t || this._getDrawWrapper()),
- n.setState(this.backFaceCulling, this.zOffset, !1, r, this.cullBackFaces, this.stencil, this.zOffsetUnits),
- r
- }
- ,
- e.prototype.bind = function(e, t) {}
- ,
- e.prototype.buildUniformLayout = function() {
- var e = this._uniformBuffer;
- this._eventInfo.ubo = e,
- this._callbackPluginEventGeneric(Ar.PrepareUniformBuffer, this._eventInfo),
- e.create(),
- this._uniformBufferLayoutBuilt = !0
- }
- ,
- e.prototype.bindForSubMesh = function(e, t, i) {
- i.effect && (this._eventInfo.subMesh = i,
- this._callbackPluginEventBindForSubMesh(this._eventInfo))
- }
- ,
- e.prototype.bindOnlyWorldMatrix = function(e) {}
- ,
- e.prototype.bindView = function(e) {
- this._useUBO ? this._needToBindSceneUbo = !0 : e.setMatrix("view", this.getScene().getViewMatrix())
- }
- ,
- e.prototype.bindViewProjection = function(e) {
- this._useUBO ? this._needToBindSceneUbo = !0 : (e.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
- e.setMatrix("projection", this.getScene().getProjectionMatrix()))
- }
- ,
- e.prototype.bindEyePosition = function(e, t) {
- this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(e, t)
- }
- ,
- e.prototype._afterBind = function(e, t) {
- if (void 0 === t && (t = null),
- this._scene._cachedMaterial = this,
- this._needToBindSceneUbo && t && (this._needToBindSceneUbo = !1,
- Mr.BindSceneUniformBuffer(t, this.getScene().getSceneUniformBuffer()),
- this._scene.finalizeSceneUbo()),
- this._scene._cachedVisibility = e ? e.visibility : 1,
- this._onBindObservable && e && this._onBindObservable.notifyObservers(e),
- this.disableDepthWrite) {
- var i = this._scene.getEngine();
- this._cachedDepthWriteState = i.getDepthWrite(),
- i.setDepthWrite(!1)
- }
- this.disableColorWrite && (i = this._scene.getEngine(),
- this._cachedColorWriteState = i.getColorWrite(),
- i.setColorWrite(!1)),
- 0 !== this.depthFunction && (i = this._scene.getEngine(),
- this._cachedDepthFunctionState = i.getDepthFunction() || 0,
- i.setDepthFunction(this.depthFunction))
- }
- ,
- e.prototype.unbind = function() {
- this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this),
- 0 !== this.depthFunction && this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),
- this.disableDepthWrite && this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),
- this.disableColorWrite && this._scene.getEngine().setColorWrite(this._cachedColorWriteState)
- }
- ,
- e.prototype.getAnimatables = function() {
- return this._eventInfo.animatables = [],
- this._callbackPluginEventGeneric(Ar.GetAnimatables, this._eventInfo),
- this._eventInfo.animatables
- }
- ,
- e.prototype.getActiveTextures = function() {
- return this._eventInfo.activeTextures = [],
- this._callbackPluginEventGeneric(Ar.GetActiveTextures, this._eventInfo),
- this._eventInfo.activeTextures
- }
- ,
- e.prototype.hasTexture = function(e) {
- return this._eventInfo.hasTexture = !1,
- this._eventInfo.texture = e,
- this._callbackPluginEventGeneric(Ar.HasTexture, this._eventInfo),
- this._eventInfo.hasTexture
- }
- ,
- e.prototype.clone = function(e) {
- return null
- }
- ,
- e.prototype.getBindedMeshes = function() {
- var e = this;
- if (this.meshMap) {
- var t = new Array;
- for (var i in this.meshMap) {
- var n = this.meshMap[i];
- n && t.push(n)
- }
- return t
- }
- return this._scene.meshes.filter((function(t) {
- return t.material === e
- }
- ))
- }
- ,
- e.prototype.forceCompilation = function(e, t, i, n) {
- var r = this
- , o = V({
- clipPlane: !1,
- useInstances: !1
- }, i)
- , a = this.getScene()
- , s = this.allowShaderHotSwapping;
- this.allowShaderHotSwapping = !1;
- var l = function() {
- if (r._scene && r._scene.getEngine()) {
- var i = a.clipPlane;
- if (o.clipPlane && (a.clipPlane = new hn(0,0,0,1)),
- r._storeEffectOnSubMeshes) {
- var c = !0
- , u = null;
- if (e.subMeshes) {
- var h = new hr(0,0,0,0,0,e,void 0,!1,!1);
- h.materialDefines && (h.materialDefines._renderId = -1),
- r.isReadyForSubMesh(e, h, o.useInstances) || (h.effect && h.effect.getCompilationError() && h.effect.allFallbacksProcessed() ? u = h.effect.getCompilationError() : (c = !1,
- setTimeout(l, 16)))
- }
- c && (r.allowShaderHotSwapping = s,
- u && n && n(u),
- t && t(r))
- } else
- r.isReady() ? (r.allowShaderHotSwapping = s,
- t && t(r)) : setTimeout(l, 16);
- o.clipPlane && (a.clipPlane = i)
- }
- };
- l()
- }
- ,
- e.prototype.forceCompilationAsync = function(e, t) {
- var i = this;
- return new Promise((function(n, r) {
- i.forceCompilation(e, (function() {
- n()
- }
- ), t, (function(e) {
- r(e)
- }
- ))
- }
- ))
- }
- ,
- e.prototype.markAsDirty = function(t) {
- this.getScene().blockMaterialDirtyMechanism || (e._DirtyCallbackArray.length = 0,
- t & e.TextureDirtyFlag && e._DirtyCallbackArray.push(e._TextureDirtyCallBack),
- t & e.LightDirtyFlag && e._DirtyCallbackArray.push(e._LightsDirtyCallBack),
- t & e.FresnelDirtyFlag && e._DirtyCallbackArray.push(e._FresnelDirtyCallBack),
- t & e.AttributesDirtyFlag && e._DirtyCallbackArray.push(e._AttributeDirtyCallBack),
- t & e.MiscDirtyFlag && e._DirtyCallbackArray.push(e._MiscDirtyCallBack),
- t & e.PrePassDirtyFlag && e._DirtyCallbackArray.push(e._PrePassDirtyCallBack),
- e._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(e._RunDirtyCallBacks),
- this.getScene().resetCachedMaterial())
- }
- ,
- e.prototype.resetDrawCache = function() {
- for (var e = 0, t = this.getScene().meshes; e < t.length; e++) {
- var i = t[e];
- if (i.subMeshes)
- for (var n = 0, r = i.subMeshes; n < r.length; n++) {
- var o = r[n];
- o.getMaterial() === this && o.resetDrawCache()
- }
- }
- }
- ,
- e.prototype._markAllSubMeshesAsDirty = function(e) {
- if (!this.getScene().blockMaterialDirtyMechanism)
- for (var t = 0, i = this.getScene().meshes; t < i.length; t++) {
- var n = i[t];
- if (n.subMeshes)
- for (var r = 0, o = n.subMeshes; r < o.length; r++) {
- var a = o[r];
- if (0 !== n._renderId && a.getMaterial() === this)
- for (var s = 0, l = a._drawWrappers; s < l.length; s++) {
- var c = l[s];
- c && c.defines && c.defines.markAllAsDirty && this._materialContext === c.materialContext && e(c.defines)
- }
- }
- }
- }
- ,
- e.prototype._markScenePrePassDirty = function() {
- if (!this.getScene().blockMaterialDirtyMechanism) {
- var e = this.getScene().enablePrePassRenderer();
- e && e.markAsDirty()
- }
- }
- ,
- e.prototype._markAllSubMeshesAsAllDirty = function() {
- this._markAllSubMeshesAsDirty(e._AllDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
- this._markAllSubMeshesAsDirty(e._ImageProcessingDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._markAllSubMeshesAsDirty(e._TextureDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsFresnelDirty = function() {
- this._markAllSubMeshesAsDirty(e._FresnelDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
- this._markAllSubMeshesAsDirty(e._FresnelAndMiscDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsLightsDirty = function() {
- this._markAllSubMeshesAsDirty(e._LightsDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsAttributesDirty = function() {
- this._markAllSubMeshesAsDirty(e._AttributeDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsMiscDirty = function() {
- this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsPrePassDirty = function() {
- this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)
- }
- ,
- e.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
- this._markAllSubMeshesAsDirty(e._TextureAndMiscDirtyCallBack)
- }
- ,
- e.prototype.setPrePassRenderer = function(e) {
- return !1
- }
- ,
- e.prototype.dispose = function(e, t, i) {
- var n = this.getScene();
- if (n.stopAnimation(this),
- n.freeProcessedMaterials(),
- n.removeMaterial(this),
- this._eventInfo.forceDisposeTextures = t,
- this._callbackPluginEventGeneric(Ar.Disposed, this._eventInfo),
- this._parentContainer) {
- var r = this._parentContainer.materials.indexOf(this);
- r > -1 && this._parentContainer.materials.splice(r, 1),
- this._parentContainer = null
- }
- if (!0 !== i)
- if (this.meshMap)
- for (var o in this.meshMap)
- (l = this.meshMap[o]) && (l.material = null,
- this.releaseVertexArrayObject(l, e));
- else
- for (var a = 0, s = n.meshes; a < s.length; a++) {
- var l;
- (l = s[a]).material !== this || l.sourceMesh || (l.material = null,
- this.releaseVertexArrayObject(l, 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()
- }
- ,
- e.prototype.releaseVertexArrayObject = function(e, t) {
- if (e.geometry) {
- var i = e.geometry;
- if (this._storeEffectOnSubMeshes)
- for (var n = 0, r = e.subMeshes; n < r.length; n++) {
- var o = r[n];
- i._releaseVertexArrayObject(o.effect),
- t && o.effect && o.effect.dispose()
- }
- else
- i._releaseVertexArrayObject(this._drawWrapper.effect)
- }
- }
- ,
- e.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.stencil = this.stencil.serialize(),
- e.uniqueId = this.uniqueId,
- e
- }
- ,
- e.Parse = function(e, t, i) {
- if (e.customType) {
- if ("BABYLON.PBRMaterial" === e.customType && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial",
- !BABYLON.LegacyPBRMaterial))
- return K.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),
- null
- } else
- e.customType = "BABYLON.StandardMaterial";
- var n = gi.Instantiate(e.customType).Parse(e, t, i);
- return n._loadedUniqueId = e.uniqueId,
- n
- }
- ,
- e.TriangleFillMode = a.MATERIAL_TriangleFillMode,
- e.WireFrameFillMode = a.MATERIAL_WireFrameFillMode,
- e.PointFillMode = a.MATERIAL_PointFillMode,
- e.PointListDrawMode = a.MATERIAL_PointListDrawMode,
- e.LineListDrawMode = a.MATERIAL_LineListDrawMode,
- e.LineLoopDrawMode = a.MATERIAL_LineLoopDrawMode,
- e.LineStripDrawMode = a.MATERIAL_LineStripDrawMode,
- e.TriangleStripDrawMode = a.MATERIAL_TriangleStripDrawMode,
- e.TriangleFanDrawMode = a.MATERIAL_TriangleFanDrawMode,
- e.ClockWiseSideOrientation = a.MATERIAL_ClockWiseSideOrientation,
- e.CounterClockWiseSideOrientation = a.MATERIAL_CounterClockWiseSideOrientation,
- e.TextureDirtyFlag = a.MATERIAL_TextureDirtyFlag,
- e.LightDirtyFlag = a.MATERIAL_LightDirtyFlag,
- e.FresnelDirtyFlag = a.MATERIAL_FresnelDirtyFlag,
- e.AttributesDirtyFlag = a.MATERIAL_AttributesDirtyFlag,
- e.MiscDirtyFlag = a.MATERIAL_MiscDirtyFlag,
- e.PrePassDirtyFlag = a.MATERIAL_PrePassDirtyFlag,
- e.AllDirtyFlag = a.MATERIAL_AllDirtyFlag,
- e.MATERIAL_OPAQUE = 0,
- e.MATERIAL_ALPHATEST = 1,
- e.MATERIAL_ALPHABLEND = 2,
- e.MATERIAL_ALPHATESTANDBLEND = 3,
- e.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0,
- e.MATERIAL_NORMALBLENDMETHOD_RNM = 1,
- e.OnEventObservable = new h,
- e._AllDirtyCallBack = function(e) {
- return e.markAllAsDirty()
- }
- ,
- e._ImageProcessingDirtyCallBack = function(e) {
- return e.markAsImageProcessingDirty()
- }
- ,
- e._TextureDirtyCallBack = function(e) {
- return e.markAsTexturesDirty()
- }
- ,
- e._FresnelDirtyCallBack = function(e) {
- return e.markAsFresnelDirty()
- }
- ,
- e._MiscDirtyCallBack = function(e) {
- return e.markAsMiscDirty()
- }
- ,
- e._PrePassDirtyCallBack = function(e) {
- return e.markAsPrePassDirty()
- }
- ,
- e._LightsDirtyCallBack = function(e) {
- return e.markAsLightDirty()
- }
- ,
- e._AttributeDirtyCallBack = function(e) {
- return e.markAsAttributesDirty()
- }
- ,
- e._FresnelAndMiscDirtyCallBack = function(t) {
- e._FresnelDirtyCallBack(t),
- e._MiscDirtyCallBack(t)
- }
- ,
- e._TextureAndMiscDirtyCallBack = function(t) {
- e._TextureDirtyCallBack(t),
- e._MiscDirtyCallBack(t)
- }
- ,
- e._DirtyCallbackArray = [],
- e._RunDirtyCallBacks = function(t) {
- for (var i = 0, n = e._DirtyCallbackArray; i < n.length; i++)
- (0,
- n[i])(t)
- }
- ,
- k([Ce()], e.prototype, "id", void 0),
- k([Ce()], e.prototype, "uniqueId", void 0),
- k([Ce()], e.prototype, "name", void 0),
- k([Ce()], e.prototype, "metadata", void 0),
- k([Ce()], e.prototype, "checkReadyOnEveryCall", void 0),
- k([Ce()], e.prototype, "checkReadyOnlyOnce", void 0),
- k([Ce()], e.prototype, "state", void 0),
- k([Ce("alpha")], e.prototype, "_alpha", void 0),
- k([Ce("backFaceCulling")], e.prototype, "_backFaceCulling", void 0),
- k([Ce("cullBackFaces")], e.prototype, "_cullBackFaces", void 0),
- k([Ce()], e.prototype, "sideOrientation", void 0),
- k([Ce("alphaMode")], e.prototype, "_alphaMode", void 0),
- k([Ce()], e.prototype, "_needDepthPrePass", void 0),
- k([Ce()], e.prototype, "disableDepthWrite", void 0),
- k([Ce()], e.prototype, "disableColorWrite", void 0),
- k([Ce()], e.prototype, "forceDepthWrite", void 0),
- k([Ce()], e.prototype, "depthFunction", void 0),
- k([Ce()], e.prototype, "separateCullingPass", void 0),
- k([Ce("fogEnabled")], e.prototype, "_fogEnabled", void 0),
- k([Ce()], e.prototype, "pointSize", void 0),
- k([Ce()], e.prototype, "zOffset", void 0),
- k([Ce()], e.prototype, "zOffsetUnits", void 0),
- k([Ce()], e.prototype, "pointsCloud", null),
- k([Ce()], e.prototype, "fillMode", null),
- k([Ce()], e.prototype, "transparencyMode", null),
- e
- }()
- , Dr = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i, !0) || this;
- return n._waitingSubMaterialsUniqueIds = [],
- n.getScene().multiMaterials.push(n),
- n.subMaterials = new Array,
- n._storeEffectOnSubMeshes = !0,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "subMaterials", {
- get: function() {
- return this._subMaterials
- },
- set: function(e) {
- this._subMaterials = e,
- this._hookArray(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getChildren = function() {
- return this.subMaterials
- }
- ,
- t.prototype._hookArray = function(e) {
- var t = this
- , i = e.push;
- e.push = function() {
- for (var n = [], r = 0; r < arguments.length; r++)
- n[r] = arguments[r];
- var o = i.apply(e, n);
- return t._markAllSubMeshesAsTexturesDirty(),
- o
- }
- ;
- var n = e.splice;
- e.splice = function(i, r) {
- var o = n.apply(e, [i, r]);
- return t._markAllSubMeshesAsTexturesDirty(),
- o
- }
- }
- ,
- t.prototype.getSubMaterial = function(e) {
- return e < 0 || e >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[e]
- }
- ,
- t.prototype.getActiveTextures = function() {
- var t;
- return (t = e.prototype.getActiveTextures.call(this)).concat.apply(t, this.subMaterials.map((function(e) {
- return e ? e.getActiveTextures() : []
- }
- )))
- }
- ,
- t.prototype.hasTexture = function(t) {
- var i;
- if (e.prototype.hasTexture.call(this, t))
- return !0;
- for (var n = 0; n < this.subMaterials.length; n++)
- if (null === (i = this.subMaterials[n]) || void 0 === i ? void 0 : i.hasTexture(t))
- return !0;
- return !1
- }
- ,
- t.prototype.getClassName = function() {
- return "MultiMaterial"
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- for (var n = 0; n < this.subMaterials.length; n++) {
- var r = this.subMaterials[n];
- if (r) {
- if (r._storeEffectOnSubMeshes) {
- if (!r.isReadyForSubMesh(e, t, i))
- return !1;
- continue
- }
- if (!r.isReady(e))
- return !1
- }
- }
- return !0
- }
- ,
- t.prototype.clone = function(e, i) {
- for (var n = new t(e,this.getScene()), r = 0; r < this.subMaterials.length; r++) {
- var o, a = this.subMaterials[r];
- o = i && a ? a.clone(e + "-" + a.name) : this.subMaterials[r],
- n.subMaterials.push(o)
- }
- return n
- }
- ,
- t.prototype.serialize = function() {
- var e = {};
- e.name = this.name,
- e.id = this.id,
- e.uniqueId = this.uniqueId,
- ye && (e.tags = ye.GetTags(this)),
- e.materialsUniqueIds = [],
- e.materials = [];
- for (var t = 0; t < this.subMaterials.length; t++) {
- var i = this.subMaterials[t];
- i ? (e.materialsUniqueIds.push(i.uniqueId),
- e.materials.push(i.id)) : (e.materialsUniqueIds.push(null),
- e.materials.push(null))
- }
- return e
- }
- ,
- t.prototype.dispose = function(t, i, n) {
- var r = this.getScene();
- if (r) {
- if (n)
- for (var o = 0; o < this.subMaterials.length; o++) {
- var a = this.subMaterials[o];
- a && a.dispose(t, i)
- }
- var s = r.multiMaterials.indexOf(this);
- s >= 0 && r.multiMaterials.splice(s, 1),
- e.prototype.dispose.call(this, t, i)
- }
- }
- ,
- t.ParseMultiMaterial = function(e, i) {
- var n = new t(e.name,i);
- return n.id = e.id,
- n._loadedUniqueId = e.uniqueId,
- ye && ye.AddTagsTo(n, e.tags),
- e.materialsUniqueIds ? n._waitingSubMaterialsUniqueIds = e.materialsUniqueIds : e.materials.forEach((function(e) {
- return n.subMaterials.push(i.getLastMaterialById(e))
- }
- )),
- n
- }
- ,
- t
- }(Or);
- y("BABYLON.MultiMaterial", Dr);
- var Nr = function(e, t) {
- this.distanceOrScreenCoverage = e,
- this.mesh = t
- }
- , Lr = function() {}
- , Fr = function() {
- this.visibleInstances = {},
- this.batchCache = new wr,
- this.batchCacheReplacementModeInFrozenMode = new wr,
- this.instancesBufferSize = 2048
- }
- , wr = function() {
- this.mustReturn = !1,
- this.visibleInstances = new Array,
- this.renderSelf = new Array,
- this.hardwareInstancedRendering = new Array
- }
- , Br = function() {
- this.instancesCount = 0,
- this.matrixBuffer = null,
- this.previousMatrixBuffer = null,
- this.matrixBufferSize = 512,
- this.matrixData = null,
- this.boundingVectors = [],
- this.worldMatrices = null
- }
- , Ur = function() {
- 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
- }
- , Vr = function(e) {
- function t(i, n, r, o, s, l) {
- void 0 === n && (n = null),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === l && (l = !0);
- var c = e.call(this, i, n) || this;
- if (c._internalMeshDataInfo = new Ur,
- c.delayLoadState = a.DELAYLOADSTATE_NONE,
- c.instances = new Array,
- c._creationDataStorage = null,
- c._geometry = null,
- c._instanceDataStorage = new Fr,
- c._thinInstanceDataStorage = new Br,
- c._shouldGenerateFlatShading = !1,
- c._originalBuilderSideOrientation = t.DEFAULTSIDE,
- c.overrideMaterialSideOrientation = null,
- c.ignoreCameraMaxZ = !1,
- n = c.getScene(),
- c._onBeforeDraw = function(e, t, i) {
- e && i && (c._uniformBuffer ? c.transferToEffect(t) : i.bindOnlyWorldMatrix(t))
- }
- ,
- o) {
- if (o._geometry && o._geometry.applyToMesh(c),
- fe.DeepCopy(o, c, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata", "morphTargetManager", "hasInstances", "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"]),
- c._internalMeshDataInfo._source = o,
- n.useClonedMeshMap && (o._internalMeshDataInfo.meshMap || (o._internalMeshDataInfo.meshMap = {}),
- o._internalMeshDataInfo.meshMap[c.uniqueId] = c),
- c._originalBuilderSideOrientation = o._originalBuilderSideOrientation,
- c._creationDataStorage = o._creationDataStorage,
- o._ranges) {
- var u = o._ranges;
- for (var d in u)
- Object.prototype.hasOwnProperty.call(u, d) && u[d] && c.createAnimationRange(d, u[d].from, u[d].to)
- }
- if (o.metadata && o.metadata.clone ? c.metadata = o.metadata.clone() : c.metadata = o.metadata,
- ye && ye.HasTags(o) && ye.AddTagsTo(c, ye.GetTags(o, !0)),
- c.setEnabled(o.isEnabled()),
- c.parent = o.parent,
- c.setPivotMatrix(o.getPivotMatrix()),
- c.id = i + "." + o.id,
- c.material = o.material,
- !s)
- for (var p = o.getDescendants(!0), f = 0; f < p.length; f++) {
- var _ = p[f];
- _.clone && _.clone(i + "." + _.name, c)
- }
- if (o.morphTargetManager && (c.morphTargetManager = o.morphTargetManager),
- n.getPhysicsEngine) {
- var m = n.getPhysicsEngine();
- if (l && m) {
- var g = m.getImpostorForPhysicsObject(o);
- g && (c.physicsImpostor = g.clone(c))
- }
- }
- for (f = 0; f < n.particleSystems.length; f++) {
- var v = n.particleSystems[f];
- v.emitter === o && v.clone(v.name, c)
- }
- c.skeleton = o.skeleton,
- c.refreshBoundingInfo(!0, !0),
- c.computeWorldMatrix(!0)
- }
- return null !== r && (c.parent = r),
- c._instanceDataStorage.hardwareInstancedRendering = c.getEngine().getCaps().instancedArrays,
- c._internalMeshDataInfo._onMeshReadyObserverAdded = function(e) {
- e.unregisterOnNextCall = !0,
- c.isReady(!0) ? c.onMeshReadyObservable.notifyObservers(c) : c._internalMeshDataInfo._checkReadinessObserver || (c._internalMeshDataInfo._checkReadinessObserver = c._scene.onBeforeRenderObservable.add((function() {
- c.isReady(!0) && (c._scene.onBeforeRenderObservable.remove(c._internalMeshDataInfo._checkReadinessObserver),
- c._internalMeshDataInfo._checkReadinessObserver = null,
- c.onMeshReadyObservable.notifyObservers(c))
- }
- )))
- }
- ,
- c.onMeshReadyObservable = new h(c._internalMeshDataInfo._onMeshReadyObserverAdded),
- o && o.onClonedObservable.notifyObservers(c),
- c
- }
- return U(t, e),
- t._GetDefaultSideOrientation = function(e) {
- return e || t.FRONTSIDE
- }
- ,
- Object.defineProperty(t.prototype, "useLODScreenCoverage", {
- get: function() {
- return this._internalMeshDataInfo._useLODScreenCoverage
- },
- set: function(e) {
- this._internalMeshDataInfo._useLODScreenCoverage = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "computeBonesUsingShaders", {
- get: function() {
- return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
- },
- set: function(e) {
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== e && (e && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(Bi.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0),
- this._internalMeshDataInfo._sourceNormals && this.setVerticesData(Bi.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)),
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders = e,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBeforeRenderObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new h),
- this._internalMeshDataInfo._onBeforeRenderObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBeforeBindObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new h),
- this._internalMeshDataInfo._onBeforeBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onAfterRenderObservable", {
- get: function() {
- return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new h),
- this._internalMeshDataInfo._onAfterRenderObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBetweenPassObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new h),
- this._internalMeshDataInfo._onBetweenPassObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBeforeDrawObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new h),
- this._internalMeshDataInfo._onBeforeDrawObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBeforeDraw", {
- set: function(e) {
- this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),
- this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasInstances", {
- get: function() {
- return this.instances.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasThinInstances", {
- get: function() {
- var e;
- return (null !== (e = this._thinInstanceDataStorage.instancesCount) && void 0 !== e ? e : 0) > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "forcedInstanceCount", {
- get: function() {
- return this._internalMeshDataInfo._forcedInstanceCount
- },
- set: function(e) {
- this._internalMeshDataInfo._forcedInstanceCount = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "source", {
- get: function() {
- return this._internalMeshDataInfo._source
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cloneMeshMap", {
- get: function() {
- return this._internalMeshDataInfo.meshMap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isUnIndexed", {
- get: function() {
- return this._unIndexed
- },
- set: function(e) {
- this._unIndexed !== e && (this._unIndexed = e,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.instancesData
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "previousWorldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.instancesPreviousData
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.manualUpdate
- },
- set: function(e) {
- this._instanceDataStorage.manualUpdate = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "manualUpdateOfPreviousWorldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.previousManualUpdate
- },
- set: function(e) {
- this._instanceDataStorage.previousManualUpdate = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.instantiateHierarchy = function(e, t, i) {
- void 0 === e && (e = null);
- var n = !(this.getTotalVertices() > 0) || t && t.doNotInstantiate ? this.clone("Clone of " + (this.name || this.id), e || this.parent, !0) : this.createInstance("instance of " + (this.name || this.id));
- n.parent = e || this.parent,
- n.position = this.position.clone(),
- n.scaling = this.scaling.clone(),
- this.rotationQuaternion ? n.rotationQuaternion = this.rotationQuaternion.clone() : n.rotation = this.rotation.clone(),
- i && i(this, n);
- for (var r = 0, o = this.getChildTransformNodes(!0); r < o.length; r++)
- o[r].instantiateHierarchy(n, t, i);
- return n
- }
- ,
- t.prototype.getClassName = function() {
- return "Mesh"
- }
- ,
- Object.defineProperty(t.prototype, "_isMesh", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.toString = function(t) {
- var i = e.prototype.toString.call(this, t);
- if (i += ", n vertices: " + this.getTotalVertices(),
- i += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"),
- this.animations)
- for (var n = 0; n < this.animations.length; n++)
- i += ", animation[0]: " + this.animations[n].toString(t);
- if (t)
- if (this._geometry) {
- var r = this.getIndices()
- , o = this.getVerticesData(Bi.PositionKind);
- o && r && (i += ", flat shading: " + (o.length / 3 === r.length ? "YES" : "NO"))
- } else
- i += ", flat shading: UNKNOWN";
- return i
- }
- ,
- t.prototype._unBindEffect = function() {
- e.prototype._unBindEffect.call(this);
- for (var t = 0, i = this.instances; t < i.length; t++)
- i[t]._unBindEffect()
- }
- ,
- Object.defineProperty(t.prototype, "hasLODLevels", {
- get: function() {
- return this._internalMeshDataInfo._LODLevels.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getLODLevels = function() {
- return this._internalMeshDataInfo._LODLevels
- }
- ,
- t.prototype._sortLODLevels = function() {
- var e = this._internalMeshDataInfo._useLODScreenCoverage ? -1 : 1;
- this._internalMeshDataInfo._LODLevels.sort((function(t, i) {
- return t.distanceOrScreenCoverage < i.distanceOrScreenCoverage ? e : t.distanceOrScreenCoverage > i.distanceOrScreenCoverage ? -e : 0
- }
- ))
- }
- ,
- t.prototype.addLODLevel = function(e, t) {
- if (t && t._masterMesh)
- return K.Warn("You cannot use a mesh as LOD level twice"),
- this;
- var i = new Nr(e,t);
- return this._internalMeshDataInfo._LODLevels.push(i),
- t && (t._masterMesh = this),
- this._sortLODLevels(),
- this
- }
- ,
- t.prototype.getLODLevelAtDistance = function(e) {
- for (var t = this._internalMeshDataInfo, i = 0; i < t._LODLevels.length; i++) {
- var n = t._LODLevels[i];
- if (n.distanceOrScreenCoverage === e)
- return n.mesh
- }
- return null
- }
- ,
- t.prototype.removeLODLevel = function(e) {
- for (var t = this._internalMeshDataInfo, i = 0; i < t._LODLevels.length; i++)
- t._LODLevels[i].mesh === e && (t._LODLevels.splice(i, 1),
- e && (e._masterMesh = null));
- return this._sortLODLevels(),
- this
- }
- ,
- t.prototype.getLOD = function(e, t) {
- var i, n = this._internalMeshDataInfo;
- if (!n._LODLevels || 0 === n._LODLevels.length)
- return this;
- var r = (i = t || this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length()
- , o = r
- , s = 1;
- if (n._useLODScreenCoverage) {
- var l = e.screenArea
- , c = i.radiusWorld * e.minZ / r;
- o = (c = c * c * Math.PI) / l,
- s = -1
- }
- if (s * n._LODLevels[n._LODLevels.length - 1].distanceOrScreenCoverage > s * o)
- return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this),
- this;
- for (var u = 0; u < n._LODLevels.length; u++) {
- var h = n._LODLevels[u];
- if (s * h.distanceOrScreenCoverage < s * o) {
- if (h.mesh) {
- if (h.mesh.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
- return h.mesh._checkDelayState(),
- this;
- if (h.mesh.delayLoadState === a.DELAYLOADSTATE_LOADING)
- return this;
- h.mesh._preActivate(),
- h.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)
- }
- return this.onLODLevelSelection && this.onLODLevelSelection(o, this, h.mesh),
- h.mesh
- }
- }
- return this.onLODLevelSelection && this.onLODLevelSelection(o, this, this),
- this
- }
- ,
- Object.defineProperty(t.prototype, "geometry", {
- get: function() {
- return this._geometry
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getTotalVertices = function() {
- return null === this._geometry || void 0 === this._geometry ? 0 : this._geometry.getTotalVertices()
- }
- ,
- t.prototype.getVerticesData = function(e, t, i) {
- var n, r;
- if (!this._geometry)
- return null;
- var o = null === (r = null === (n = this._userInstancedBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) || void 0 === r ? void 0 : r.getFloatData(this._geometry.getTotalVertices(), i || t && 1 !== this._geometry.meshes.length);
- return o || (o = this._geometry.getVerticesData(e, t, i)),
- o
- }
- ,
- t.prototype.getVertexBuffer = function(e) {
- var t, i;
- return this._geometry ? null !== (i = null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) && void 0 !== i ? i : this._geometry.getVertexBuffer(e) : null
- }
- ,
- t.prototype.isVerticesDataPresent = function(e) {
- var t;
- return this._geometry ? void 0 !== (null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) || this._geometry.isVerticesDataPresent(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
- }
- ,
- t.prototype.isVertexBufferUpdatable = function(e) {
- var t, i;
- return this._geometry ? (null === (i = null === (t = this._userInstancedBuffersStorage) || void 0 === t ? void 0 : t.vertexBuffers[e]) || void 0 === i ? void 0 : i.isUpdatable()) || this._geometry.isVertexBufferUpdatable(e) : !!this._delayInfo && -1 !== this._delayInfo.indexOf(e)
- }
- ,
- t.prototype.getVerticesDataKinds = function() {
- if (!this._geometry) {
- var e = new Array;
- return this._delayInfo && this._delayInfo.forEach((function(t) {
- e.push(t)
- }
- )),
- e
- }
- var t = this._geometry.getVerticesDataKinds();
- if (this._userInstancedBuffersStorage)
- for (var i in this._userInstancedBuffersStorage.vertexBuffers)
- t.push(i);
- return t
- }
- ,
- t.prototype.getTotalIndices = function() {
- return this._geometry ? this._geometry.getTotalIndices() : 0
- }
- ,
- t.prototype.getIndices = function(e, t) {
- return this._geometry ? this._geometry.getIndices(e, t) : []
- }
- ,
- Object.defineProperty(t.prototype, "isBlocked", {
- get: function() {
- return null !== this._masterMesh && void 0 !== this._masterMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.isReady = function(t, i) {
- var n, r, o, s, l, c;
- if (void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- this.delayLoadState === a.DELAYLOADSTATE_LOADING)
- return !1;
- if (!e.prototype.isReady.call(this, t))
- return !1;
- if (!this.subMeshes || 0 === this.subMeshes.length)
- return !0;
- if (!t)
- return !0;
- var u = this.getEngine()
- , h = this.getScene()
- , d = i || u.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
- this.computeWorldMatrix();
- var p = this.material || h.defaultMaterial;
- if (p)
- if (p._storeEffectOnSubMeshes)
- for (var f = 0, _ = this.subMeshes; f < _.length; f++) {
- var m = (S = _[f]).getMaterial();
- if (m)
- if (m._storeEffectOnSubMeshes) {
- if (!m.isReadyForSubMesh(this, S, d))
- return !1
- } else if (!m.isReady(this, d))
- return !1
- }
- else if (!p.isReady(this, d))
- return !1;
- for (var g = u.currentRenderPassId, v = 0, y = this.lightSources; v < y.length; v++) {
- var b = y[v].getShadowGenerator();
- if (b && (!(null === (n = b.getShadowMap()) || void 0 === n ? void 0 : n.renderList) || (null === (r = b.getShadowMap()) || void 0 === r ? void 0 : r.renderList) && -1 !== (null === (s = null === (o = b.getShadowMap()) || void 0 === o ? void 0 : o.renderList) || void 0 === s ? void 0 : s.indexOf(this)))) {
- b.getShadowMap() && (u.currentRenderPassId = b.getShadowMap().renderPassId);
- for (var T = 0, E = this.subMeshes; T < E.length; T++) {
- var S = E[T];
- if (!b.isReady(S, d, null !== (c = null === (l = S.getMaterial()) || void 0 === l ? void 0 : l.needAlphaBlendingForMesh(this)) && void 0 !== c && c))
- return u.currentRenderPassId = g,
- !1
- }
- u.currentRenderPassId = g
- }
- }
- for (var A = 0, x = this._internalMeshDataInfo._LODLevels; A < x.length; A++) {
- var R = x[A];
- if (R.mesh && !R.mesh.isReady(d))
- return !1
- }
- return !0
- }
- ,
- Object.defineProperty(t.prototype, "areNormalsFrozen", {
- get: function() {
- return this._internalMeshDataInfo._areNormalsFrozen
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.freezeNormals = function() {
- return this._internalMeshDataInfo._areNormalsFrozen = !0,
- this
- }
- ,
- t.prototype.unfreezeNormals = function() {
- return this._internalMeshDataInfo._areNormalsFrozen = !1,
- this
- }
- ,
- Object.defineProperty(t.prototype, "overridenInstanceCount", {
- set: function(e) {
- this._instanceDataStorage.overridenInstanceCount = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._preActivate = function() {
- var e = this._internalMeshDataInfo
- , t = this.getScene().getRenderId();
- return e._preActivateId === t || (e._preActivateId = t,
- this._instanceDataStorage.visibleInstances = null),
- this
- }
- ,
- t.prototype._preActivateForIntermediateRendering = function(e) {
- return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = e),
- this
- }
- ,
- t.prototype._registerInstanceForRenderId = function(e, t) {
- return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = {
- defaultRenderId: t,
- selfDefaultRenderId: this._renderId
- }),
- this._instanceDataStorage.visibleInstances[t] || (void 0 !== this._instanceDataStorage.previousRenderId && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null),
- this._instanceDataStorage.previousRenderId = t,
- this._instanceDataStorage.visibleInstances[t] = new Array),
- this._instanceDataStorage.visibleInstances[t].push(e),
- this
- }
- ,
- t.prototype._afterComputeWorldMatrix = function() {
- e.prototype._afterComputeWorldMatrix.call(this),
- this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1))
- }
- ,
- t.prototype._postActivate = function() {
- this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),
- this.edgesRenderer.customInstances.push(this.getWorldMatrix()))
- }
- ,
- t.prototype.refreshBoundingInfo = function(e, t) {
- if (void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- this.hasBoundingInfo && this.getBoundingInfo().isLocked)
- return this;
- var i = this.geometry ? this.geometry.boundingBias : null;
- return this._refreshBoundingInfo(this._getPositionData(e, t), i),
- this
- }
- ,
- t.prototype._createGlobalSubMesh = function(e) {
- var t = this.getTotalVertices();
- if (!t || !this.getIndices())
- return null;
- if (this.subMeshes && this.subMeshes.length > 0) {
- var i = this.getIndices();
- if (!i)
- return null;
- var n = i.length
- , r = !1;
- if (e)
- r = !0;
- else
- for (var o = 0, a = this.subMeshes; o < a.length; o++) {
- var s = a[o];
- if (s.indexStart + s.indexCount > n) {
- r = !0;
- break
- }
- if (s.verticesStart + s.verticesCount > t) {
- r = !0;
- break
- }
- }
- if (!r)
- return this.subMeshes[0]
- }
- return this.releaseSubMeshes(),
- new hr(0,0,t,0,this.getTotalIndices(),this)
- }
- ,
- t.prototype.subdivide = function(e) {
- if (!(e < 1)) {
- for (var t = this.getTotalIndices(), i = t / e | 0, n = 0; i % 3 != 0; )
- i++;
- this.releaseSubMeshes();
- for (var r = 0; r < e && !(n >= t); r++)
- hr.CreateFromIndices(0, n, r === e - 1 ? t - n : i, this),
- n += i;
- this.synchronizeInstances()
- }
- }
- ,
- t.prototype.setVerticesData = function(e, t, i, n) {
- if (void 0 === i && (i = !1),
- this._geometry)
- this._geometry.setVerticesData(e, t, i, n);
- else {
- var r = new $n;
- r.set(t, e);
- var o = this.getScene();
- new fr(fr.RandomId(),o,r,i,this)
- }
- return this
- }
- ,
- t.prototype.removeVerticesData = function(e) {
- this._geometry && this._geometry.removeVerticesData(e)
- }
- ,
- t.prototype.markVerticesDataAsUpdatable = function(e, t) {
- void 0 === t && (t = !0);
- var i = this.getVertexBuffer(e);
- i && i.isUpdatable() !== t && this.setVerticesData(e, this.getVerticesData(e), t)
- }
- ,
- t.prototype.setVerticesBuffer = function(e, t) {
- return void 0 === t && (t = !0),
- this._geometry || (this._geometry = fr.CreateGeometryForMesh(this)),
- this._geometry.setVerticesBuffer(e, null, t),
- this
- }
- ,
- t.prototype.updateVerticesData = function(e, t, i, n) {
- return this._geometry ? (n ? (this.makeGeometryUnique(),
- this.updateVerticesData(e, t, i, !1)) : this._geometry.updateVerticesData(e, t, i),
- this) : this
- }
- ,
- t.prototype.updateMeshPositions = function(e, t) {
- void 0 === t && (t = !0);
- var i = this.getVerticesData(Bi.PositionKind);
- if (!i)
- return this;
- if (e(i),
- this.updateVerticesData(Bi.PositionKind, i, !1, !1),
- t) {
- var n = this.getIndices()
- , r = this.getVerticesData(Bi.NormalKind);
- if (!r)
- return this;
- $n.ComputeNormals(i, n, r),
- this.updateVerticesData(Bi.NormalKind, r, !1, !1)
- }
- return this
- }
- ,
- t.prototype.makeGeometryUnique = function() {
- if (!this._geometry)
- return this;
- if (1 === this._geometry.meshes.length)
- return this;
- var e = this._geometry
- , t = this._geometry.copy(fr.RandomId());
- return e.releaseForMesh(this, !0),
- t.applyToMesh(this),
- this
- }
- ,
- t.prototype.setIndices = function(e, t, i) {
- if (void 0 === t && (t = null),
- void 0 === i && (i = !1),
- this._geometry)
- this._geometry.setIndices(e, t, i);
- else {
- var n = new $n;
- n.indices = e;
- var r = this.getScene();
- new fr(fr.RandomId(),r,n,i,this)
- }
- return this
- }
- ,
- t.prototype.updateIndices = function(e, t, i) {
- return void 0 === i && (i = !1),
- this._geometry ? (this._geometry.updateIndices(e, t, i),
- this) : this
- }
- ,
- t.prototype.toLeftHanded = function() {
- return this._geometry ? (this._geometry.toLeftHanded(),
- this) : this
- }
- ,
- t.prototype._bind = function(e, t, i) {
- if (!this._geometry)
- return this;
- var n, r = this.getScene().getEngine();
- if (this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(t),
- this._unIndexed)
- n = null;
- else
- switch (i) {
- case Or.PointFillMode:
- n = null;
- break;
- case Or.WireFrameFillMode:
- n = e._getLinesIndexBuffer(this.getIndices(), r);
- break;
- default:
- case Or.TriangleFillMode:
- n = this._geometry.getIndexBuffer()
- }
- return !this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(t, n) : this._geometry._bind(t, n, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects),
- this
- }
- ,
- t.prototype._draw = function(e, t, i) {
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
- return this;
- this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
- var n = this.getScene().getEngine();
- return this._unIndexed || t == Or.PointFillMode ? n.drawArraysType(t, e.verticesStart, e.verticesCount, this.forcedInstanceCount || i) : t == Or.WireFrameFillMode ? n.drawElementsType(t, 0, e._linesIndexCount, this.forcedInstanceCount || i) : n.drawElementsType(t, e.indexStart, e.indexCount, this.forcedInstanceCount || i),
- this
- }
- ,
- t.prototype.registerBeforeRender = function(e) {
- return this.onBeforeRenderObservable.add(e),
- this
- }
- ,
- t.prototype.unregisterBeforeRender = function(e) {
- return this.onBeforeRenderObservable.removeCallback(e),
- this
- }
- ,
- t.prototype.registerAfterRender = function(e) {
- return this.onAfterRenderObservable.add(e),
- this
- }
- ,
- t.prototype.unregisterAfterRender = function(e) {
- return this.onAfterRenderObservable.removeCallback(e),
- this
- }
- ,
- t.prototype._getInstancesRenderList = function(e, t) {
- if (void 0 === t && (t = !1),
- this._instanceDataStorage.isFrozen) {
- if (t)
- return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e] = !1,
- this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e] = !0,
- this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;
- if (this._instanceDataStorage.previousBatch)
- return this._instanceDataStorage.previousBatch
- }
- var i = this.getScene()
- , n = i._isInIntermediateRendering()
- , r = n ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances
- , o = this._instanceDataStorage.batchCache;
- if (o.mustReturn = !1,
- o.renderSelf[e] = t || !r && this.isEnabled() && this.isVisible,
- o.visibleInstances[e] = null,
- this._instanceDataStorage.visibleInstances && !t) {
- var a = this._instanceDataStorage.visibleInstances
- , s = i.getRenderId()
- , l = n ? a.intermediateDefaultRenderId : a.defaultRenderId;
- o.visibleInstances[e] = a[s],
- !o.visibleInstances[e] && l && (o.visibleInstances[e] = a[l])
- }
- return o.hardwareInstancedRendering[e] = !t && this._instanceDataStorage.hardwareInstancedRendering && null !== o.visibleInstances[e] && void 0 !== o.visibleInstances[e],
- this._instanceDataStorage.previousBatch = o,
- o
- }
- ,
- t.prototype._renderWithInstances = function(e, i, n, r, o) {
- var a, s = n.visibleInstances[e._id];
- if (!s)
- return this;
- for (var l = this._instanceDataStorage, c = l.instancesBufferSize, u = l.instancesBuffer, h = l.instancesPreviousBuffer, d = 16 * (s.length + 1) * 4; l.instancesBufferSize < d; )
- l.instancesBufferSize *= 2;
- l.instancesData && c == l.instancesBufferSize || (l.instancesData = new Float32Array(l.instancesBufferSize / 4)),
- (this._scene.needsPreviousWorldMatrices && !l.instancesPreviousData || c != l.instancesBufferSize) && (l.instancesPreviousData = new Float32Array(l.instancesBufferSize / 4));
- var p = 0
- , f = 0
- , _ = n.renderSelf[e._id]
- , m = !u || c !== l.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !l.instancesPreviousBuffer;
- if (this._instanceDataStorage.manualUpdate || l.isFrozen && !m)
- f = (_ ? 1 : 0) + s.length;
- else {
- var g = this.getWorldMatrix();
- if (_ && (this._scene.needsPreviousWorldMatrices && (l.masterMeshPreviousWorldMatrix ? (l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData, p),
- l.masterMeshPreviousWorldMatrix.copyFrom(g)) : (l.masterMeshPreviousWorldMatrix = g.clone(),
- l.masterMeshPreviousWorldMatrix.copyToArray(l.instancesPreviousData, p))),
- g.copyToArray(l.instancesData, p),
- p += 16,
- f++),
- s) {
- if (t.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && (null === (a = e.getMaterial()) || void 0 === a ? void 0 : a.needAlphaBlendingForMesh(e.getRenderingMesh()))) {
- for (var v = this._scene.activeCamera.globalPosition, y = 0; y < s.length; y++) {
- var b = s[y];
- b._distanceToCamera = x.Distance(b.getBoundingInfo().boundingSphere.centerWorld, v)
- }
- s.sort((function(e, t) {
- return e._distanceToCamera > t._distanceToCamera ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : 0
- }
- ))
- }
- for (y = 0; y < s.length; y++) {
- var T = s[y]
- , E = T.getWorldMatrix();
- E.copyToArray(l.instancesData, p),
- this._scene.needsPreviousWorldMatrices && (T._previousWorldMatrix ? (T._previousWorldMatrix.copyToArray(l.instancesPreviousData, p),
- T._previousWorldMatrix.copyFrom(E)) : (T._previousWorldMatrix = E.clone(),
- T._previousWorldMatrix.copyToArray(l.instancesPreviousData, p))),
- p += 16,
- f++
- }
- }
- }
- return m ? (u && u.dispose(),
- h && h.dispose(),
- u = new wi(o,l.instancesData,!0,16,!1,!0),
- l.instancesBuffer = u,
- this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = {
- data: {},
- vertexBuffers: {},
- strides: {},
- sizes: {},
- vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
- }),
- this._userInstancedBuffersStorage.vertexBuffers.world0 = u.createVertexBuffer("world0", 0, 4),
- this._userInstancedBuffersStorage.vertexBuffers.world1 = u.createVertexBuffer("world1", 4, 4),
- this._userInstancedBuffersStorage.vertexBuffers.world2 = u.createVertexBuffer("world2", 8, 4),
- this._userInstancedBuffersStorage.vertexBuffers.world3 = u.createVertexBuffer("world3", 12, 4),
- this._scene.needsPreviousWorldMatrices && (h = new wi(o,l.instancesPreviousData,!0,16,!1,!0),
- l.instancesPreviousBuffer = h,
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = h.createVertexBuffer("previousWorld0", 0, 4),
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = h.createVertexBuffer("previousWorld1", 4, 4),
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = h.createVertexBuffer("previousWorld2", 8, 4),
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = h.createVertexBuffer("previousWorld3", 12, 4)),
- this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen || (u.updateDirectly(l.instancesData, 0, f),
- !this._scene.needsPreviousWorldMatrices || this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.previousManualUpdate || h.updateDirectly(l.instancesPreviousData, 0, f)),
- this._processInstancedBuffers(s, _),
- this.getScene()._activeIndices.addCount(e.indexCount * f, !1),
- o._currentDrawContext && (o._currentDrawContext.useInstancing = !0),
- this._bind(e, r, i),
- this._draw(e, i, f),
- !this._scene.needsPreviousWorldMatrices || m || !this._instanceDataStorage.manualUpdate || this._instanceDataStorage.isFrozen || this._instanceDataStorage.previousManualUpdate || h.updateDirectly(l.instancesData, 0, f),
- o.unbindInstanceAttributes(),
- this
- }
- ,
- t.prototype._renderWithThinInstances = function(e, t, i, n) {
- var r, o, a = null !== (o = null === (r = this._thinInstanceDataStorage) || void 0 === r ? void 0 : r.instancesCount) && void 0 !== o ? o : 0;
- this.getScene()._activeIndices.addCount(e.indexCount * a, !1),
- n._currentDrawContext && (n._currentDrawContext.useInstancing = !0),
- this._bind(e, i, t),
- this._draw(e, t, a),
- this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && this._thinInstanceDataStorage.matrixData && (this._thinInstanceDataStorage.previousMatrixBuffer ? this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, a) : this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", this._thinInstanceDataStorage.matrixData, !1)),
- n.unbindInstanceAttributes()
- }
- ,
- t.prototype._processInstancedBuffers = function(e, t) {}
- ,
- t.prototype._processRendering = function(e, t, i, n, r, o, a, s) {
- var l = this.getScene()
- , c = l.getEngine();
- if (o && t.getRenderingMesh().hasThinInstances)
- return this._renderWithThinInstances(t, n, i, c),
- this;
- if (o)
- this._renderWithInstances(t, n, r, i, c);
- else {
- c._currentDrawContext && (c._currentDrawContext.useInstancing = !1);
- var u = 0;
- r.renderSelf[t._id] && (a && a(!1, e.getWorldMatrix(), s),
- u++,
- this._draw(t, n, this._instanceDataStorage.overridenInstanceCount));
- var h = r.visibleInstances[t._id];
- if (h) {
- var d = h.length;
- u += d;
- for (var p = 0; p < d; p++) {
- var f = h[p].getWorldMatrix();
- a && a(!0, f, s),
- this._draw(t, n)
- }
- }
- l._activeIndices.addCount(t.indexCount * u, !1)
- }
- return this
- }
- ,
- t.prototype._rebuild = function(t) {
- if (void 0 === t && (t = !1),
- this._instanceDataStorage.instancesBuffer && (t && this._instanceDataStorage.instancesBuffer.dispose(),
- this._instanceDataStorage.instancesBuffer = null),
- this._userInstancedBuffersStorage) {
- for (var i in this._userInstancedBuffersStorage.vertexBuffers) {
- var n = this._userInstancedBuffersStorage.vertexBuffers[i];
- n && (t && n.dispose(),
- this._userInstancedBuffersStorage.vertexBuffers[i] = null)
- }
- this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {})
- }
- this._internalMeshDataInfo._effectiveMaterial = null,
- e.prototype._rebuild.call(this, t)
- }
- ,
- t.prototype._freeze = function() {
- if (this.subMeshes) {
- for (var e = 0; e < this.subMeshes.length; e++)
- this._getInstancesRenderList(e);
- this._internalMeshDataInfo._effectiveMaterial = null,
- this._instanceDataStorage.isFrozen = !0
- }
- }
- ,
- t.prototype._unFreeze = function() {
- this._instanceDataStorage.isFrozen = !1,
- this._instanceDataStorage.previousBatch = null
- }
- ,
- t.prototype.render = function(e, t, i) {
- var n, r, o, a = this.getScene();
- if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1,
- this._checkOcclusionQuery() && !this._occlusionDataStorage.forceRenderingWhenOccluded)
- return this;
- var s = this._getInstancesRenderList(e._id, !!i);
- if (s.mustReturn)
- return this;
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
- return this;
- var l = a.getEngine()
- , c = 0
- , u = null;
- this.ignoreCameraMaxZ && a.activeCamera && !a._isInIntermediateRendering() && (c = a.activeCamera.maxZ,
- u = a.activeCamera,
- a.activeCamera.maxZ = 0,
- a.updateTransformMatrix(!0)),
- this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
- var h, d = s.hardwareInstancedRendering[e._id] || e.getRenderingMesh().hasThinInstances, p = this._instanceDataStorage, f = e.getMaterial();
- if (!f)
- return u && (u.maxZ = c,
- a.updateTransformMatrix(!0)),
- this;
- if (p.isFrozen && this._internalMeshDataInfo._effectiveMaterial && this._internalMeshDataInfo._effectiveMaterial === f) {
- if (f._storeEffectOnSubMeshes && !(null === (n = e.effect) || void 0 === n ? void 0 : n._wasPreviouslyReady) || !f._storeEffectOnSubMeshes && !(null === (r = f.getEffect()) || void 0 === r ? void 0 : r._wasPreviouslyReady))
- return u && (u.maxZ = c,
- a.updateTransformMatrix(!0)),
- this
- } else {
- if (f._storeEffectOnSubMeshes) {
- if (!f.isReadyForSubMesh(this, e, d))
- return u && (u.maxZ = c,
- a.updateTransformMatrix(!0)),
- this
- } else if (!f.isReady(this, d))
- return u && (u.maxZ = c,
- a.updateTransformMatrix(!0)),
- this;
- this._internalMeshDataInfo._effectiveMaterial = f
- }
- t && l.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
- for (var _ = null !== (o = null == (h = this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? e._drawWrapper : this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper()) ? void 0 : h.effect) && void 0 !== o ? o : null, m = 0, g = a._beforeRenderingMeshStage; m < g.length; m++)
- g[m].action(this, e, s, _);
- if (!h || !_)
- return u && (u.maxZ = c,
- a.updateTransformMatrix(!0)),
- this;
- var v, y = i || this;
- if (p.isFrozen || !this._internalMeshDataInfo._effectiveMaterial.backFaceCulling && null === this.overrideMaterialSideOrientation)
- v = p.sideOrientation;
- else {
- var b = y._getWorldMatrixDeterminant();
- null == (v = this.overrideMaterialSideOrientation) && (v = this._internalMeshDataInfo._effectiveMaterial.sideOrientation),
- b < 0 && (v = v === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation),
- p.sideOrientation = v
- }
- var T = this._internalMeshDataInfo._effectiveMaterial._preBind(h, v);
- this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && l.setDepthWrite(!0);
- var E = a.forcePointsCloud ? Or.PointFillMode : a.forceWireframe ? Or.WireFrameFillMode : this._internalMeshDataInfo._effectiveMaterial.fillMode;
- this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),
- d || this._bind(e, _, E);
- var S = this._internalMeshDataInfo._effectiveMaterial
- , A = y.getWorldMatrix();
- S._storeEffectOnSubMeshes ? S.bindForSubMesh(A, this, e) : S.bind(A, this),
- !S.backFaceCulling && S.separateCullingPass && (l.setState(!0, S.zOffset, !1, !T, S.cullBackFaces, S.stencil, S.zOffsetUnits),
- this._processRendering(this, e, _, E, s, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
- l.setState(!0, S.zOffset, !1, T, S.cullBackFaces, S.stencil, S.zOffsetUnits),
- this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),
- this._processRendering(this, e, _, E, s, d, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
- this._internalMeshDataInfo._effectiveMaterial.unbind();
- for (var x = 0, R = a._afterRenderingMeshStage; x < R.length; x++)
- R[x].action(this, e, s, _);
- return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),
- u && (u.maxZ = c,
- a.updateTransformMatrix(!0)),
- this
- }
- ,
- t.prototype.cleanMatrixWeights = function() {
- this.isVerticesDataPresent(Bi.MatricesWeightsKind) && (this.isVerticesDataPresent(Bi.MatricesWeightsExtraKind) ? this._normalizeSkinWeightsAndExtra() : this._normalizeSkinFourWeights())
- }
- ,
- t.prototype._normalizeSkinFourWeights = function() {
- for (var e = this.getVerticesData(Bi.MatricesWeightsKind), t = e.length, i = 0; i < t; i += 4) {
- var n = e[i] + e[i + 1] + e[i + 2] + e[i + 3];
- if (0 === n)
- e[i] = 1;
- else {
- var r = 1 / n;
- e[i] *= r,
- e[i + 1] *= r,
- e[i + 2] *= r,
- e[i + 3] *= r
- }
- }
- this.setVerticesData(Bi.MatricesWeightsKind, e)
- }
- ,
- t.prototype._normalizeSkinWeightsAndExtra = function() {
- for (var e = this.getVerticesData(Bi.MatricesWeightsExtraKind), t = this.getVerticesData(Bi.MatricesWeightsKind), i = t.length, n = 0; n < i; n += 4) {
- var r = t[n] + t[n + 1] + t[n + 2] + t[n + 3];
- if (0 === (r += e[n] + e[n + 1] + e[n + 2] + e[n + 3]))
- t[n] = 1;
- else {
- var o = 1 / r;
- t[n] *= o,
- t[n + 1] *= o,
- t[n + 2] *= o,
- t[n + 3] *= o,
- e[n] *= o,
- e[n + 1] *= o,
- e[n + 2] *= o,
- e[n + 3] *= o
- }
- }
- this.setVerticesData(Bi.MatricesWeightsKind, t),
- this.setVerticesData(Bi.MatricesWeightsKind, e)
- }
- ,
- t.prototype.validateSkinning = function() {
- var e = this.getVerticesData(Bi.MatricesWeightsExtraKind)
- , t = this.getVerticesData(Bi.MatricesWeightsKind);
- if (null === t || null == this.skeleton)
- return {
- skinned: !1,
- valid: !0,
- report: "not skinned"
- };
- for (var i = t.length, n = 0, r = 0, o = 0, a = 0, s = null === e ? 4 : 8, l = new Array, c = 0; c <= s; c++)
- l[c] = 0;
- for (c = 0; c < i; c += 4) {
- for (var u = t[c], h = u, d = 0 === h ? 0 : 1, p = 1; p < s; p++) {
- var f = p < 4 ? t[c + p] : e[c + p - 4];
- f > u && n++,
- 0 !== f && d++,
- h += f,
- u = f
- }
- if (l[d]++,
- d > o && (o = d),
- 0 === h)
- r++;
- else {
- var _ = 1 / h
- , m = 0;
- for (p = 0; p < s; p++)
- m += p < 4 ? Math.abs(t[c + p] - t[c + p] * _) : Math.abs(e[c + p - 4] - e[c + p - 4] * _);
- m > .001 && a++
- }
- }
- var g = this.skeleton.bones.length
- , v = this.getVerticesData(Bi.MatricesIndicesKind)
- , y = this.getVerticesData(Bi.MatricesIndicesExtraKind)
- , b = 0;
- for (c = 0; c < i; c += 4)
- for (p = 0; p < s; p++) {
- var T = p < 4 ? v[c + p] : y[c + p - 4];
- (T >= g || T < 0) && b++
- }
- return {
- skinned: !0,
- valid: 0 === r && 0 === a && 0 === b,
- report: "Number of Weights = " + i / 4 + "\nMaximum influences = " + o + "\nMissing Weights = " + r + "\nNot Sorted = " + n + "\nNot Normalized = " + a + "\nWeightCounts = [" + l + "]\nNumber of bones = " + g + "\nBad Bone Indices = " + b
- }
- }
- ,
- t.prototype._checkDelayState = function() {
- var e = this.getScene();
- return this._geometry ? this._geometry.load(e) : this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = a.DELAYLOADSTATE_LOADING,
- this._queueLoad(e)),
- this
- }
- ,
- t.prototype._queueLoad = function(e) {
- var t = this;
- e._addPendingData(this);
- var i = -1 !== this.delayLoadingFile.indexOf(".babylonbinarymeshdata");
- return gi.LoadFile(this.delayLoadingFile, (function(i) {
- i instanceof ArrayBuffer ? t._delayLoadingFunction(i, t) : t._delayLoadingFunction(JSON.parse(i), t),
- t.instances.forEach((function(e) {
- e.refreshBoundingInfo(),
- e._syncSubMeshes()
- }
- )),
- t.delayLoadState = a.DELAYLOADSTATE_LOADED,
- e._removePendingData(t)
- }
- ), (function() {}
- ), e.offlineProvider, i),
- this
- }
- ,
- t.prototype.isInFrustum = function(t) {
- return this.delayLoadState !== a.DELAYLOADSTATE_LOADING && !!e.prototype.isInFrustum.call(this, t) && (this._checkDelayState(),
- !0)
- }
- ,
- t.prototype.setMaterialById = function(e) {
- var t, i = this.getScene().materials;
- for (t = i.length - 1; t > -1; t--)
- if (i[t].id === e)
- return this.material = i[t],
- this;
- var n = this.getScene().multiMaterials;
- for (t = n.length - 1; t > -1; t--)
- if (n[t].id === e)
- return this.material = n[t],
- this;
- return this
- }
- ,
- t.prototype.getAnimatables = function() {
- var e = new Array;
- return this.material && e.push(this.material),
- this.skeleton && e.push(this.skeleton),
- e
- }
- ,
- t.prototype.bakeTransformIntoVertices = function(e) {
- if (!this.isVerticesDataPresent(Bi.PositionKind))
- return this;
- var t = this.subMeshes.splice(0);
- this._resetPointsArrayCache();
- var i, n = this.getVerticesData(Bi.PositionKind), r = new Array;
- for (i = 0; i < n.length; i += 3)
- x.TransformCoordinates(x.FromArray(n, i), e).toArray(r, i);
- if (this.setVerticesData(Bi.PositionKind, r, this.getVertexBuffer(Bi.PositionKind).isUpdatable()),
- this.isVerticesDataPresent(Bi.NormalKind)) {
- for (n = this.getVerticesData(Bi.NormalKind),
- r = [],
- i = 0; i < n.length; i += 3)
- x.TransformNormal(x.FromArray(n, i), e).normalize().toArray(r, i);
- this.setVerticesData(Bi.NormalKind, r, this.getVertexBuffer(Bi.NormalKind).isUpdatable())
- }
- return e.determinant() < 0 && this.flipFaces(),
- this.releaseSubMeshes(),
- this.subMeshes = t,
- this
- }
- ,
- t.prototype.bakeCurrentTransformIntoVertices = function(e) {
- return void 0 === e && (e = !0),
- this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),
- this.resetLocalMatrix(e),
- this
- }
- ,
- Object.defineProperty(t.prototype, "_positions", {
- get: function() {
- return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._resetPointsArrayCache = function() {
- return this._geometry && this._geometry._resetPointsArrayCache(),
- this
- }
- ,
- t.prototype._generatePointsArray = function() {
- return !!this._geometry && this._geometry._generatePointsArray()
- }
- ,
- t.prototype.clone = function(e, i, n, r) {
- return void 0 === e && (e = ""),
- void 0 === i && (i = null),
- void 0 === r && (r = !0),
- new t(e,this.getScene(),i,this,n,r)
- }
- ,
- t.prototype.dispose = function(t, i) {
- void 0 === i && (i = !1),
- this.morphTargetManager = null,
- this._geometry && this._geometry.releaseForMesh(this, !0);
- var n = this._internalMeshDataInfo;
- if (n._onBeforeDrawObservable && n._onBeforeDrawObservable.clear(),
- n._onBeforeBindObservable && n._onBeforeBindObservable.clear(),
- n._onBeforeRenderObservable && n._onBeforeRenderObservable.clear(),
- n._onAfterRenderObservable && n._onAfterRenderObservable.clear(),
- n._onBetweenPassObservable && n._onBetweenPassObservable.clear(),
- this._scene.useClonedMeshMap) {
- if (n.meshMap)
- for (var r in n.meshMap)
- (s = n.meshMap[r]) && (s._internalMeshDataInfo._source = null,
- n.meshMap[r] = void 0);
- n._source && n._source._internalMeshDataInfo.meshMap && (n._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0)
- } else
- for (var o = 0, a = this.getScene().meshes; o < a.length; o++) {
- var s;
- (s = a[o])._internalMeshDataInfo && s._internalMeshDataInfo._source && s._internalMeshDataInfo._source === this && (s._internalMeshDataInfo._source = null)
- }
- n._source = null,
- this._disposeInstanceSpecificData(),
- this._disposeThinInstanceSpecificData(),
- this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.prototype._disposeInstanceSpecificData = function() {}
- ,
- t.prototype._disposeThinInstanceSpecificData = function() {}
- ,
- t.prototype._invalidateInstanceVertexArrayObject = function() {}
- ,
- t.prototype.applyDisplacementMap = function(e, t, i, n, r, o, a) {
- var s = this;
- void 0 === a && (a = !1);
- var l = this.getScene();
- return gi.LoadImage(e, (function(e) {
- var l = e.width
- , c = e.height
- , u = s.getEngine().createCanvas(l, c).getContext("2d");
- u.drawImage(e, 0, 0);
- var h = u.getImageData(0, 0, l, c).data;
- s.applyDisplacementMapFromBuffer(h, l, c, t, i, r, o, a),
- n && n(s)
- }
- ), (function() {}
- ), l.offlineProvider),
- this
- }
- ,
- t.prototype.applyDisplacementMapFromBuffer = function(e, t, i, n, r, o, a, s) {
- if (void 0 === s && (s = !1),
- !this.isVerticesDataPresent(Bi.PositionKind) || !this.isVerticesDataPresent(Bi.NormalKind) || !this.isVerticesDataPresent(Bi.UVKind))
- return K.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),
- this;
- var l = this.getVerticesData(Bi.PositionKind, !0, !0)
- , c = this.getVerticesData(Bi.NormalKind)
- , u = this.getVerticesData(Bi.UVKind)
- , h = x.Zero()
- , d = x.Zero()
- , p = A.Zero();
- o = o || A.Zero(),
- a = a || new A(1,1);
- for (var f = 0; f < l.length; f += 3) {
- x.FromArrayToRef(l, f, h),
- x.FromArrayToRef(c, f, d),
- A.FromArrayToRef(u, f / 3 * 2, p);
- var _ = 4 * ((Math.abs(p.x * a.x + o.x % 1) * (t - 1) % t | 0) + (Math.abs(p.y * a.y + o.y % 1) * (i - 1) % i | 0) * t)
- , m = e[_] / 255 * .3 + e[_ + 1] / 255 * .59 + e[_ + 2] / 255 * .11;
- d.normalize(),
- d.scaleInPlace(n + (r - n) * m),
- (h = h.add(d)).toArray(l, f)
- }
- return $n.ComputeNormals(l, this.getIndices(), c),
- s ? (this.setVerticesData(Bi.PositionKind, l),
- this.setVerticesData(Bi.NormalKind, c),
- this.setVerticesData(Bi.UVKind, u)) : (this.updateVerticesData(Bi.PositionKind, l),
- this.updateVerticesData(Bi.NormalKind, c)),
- this
- }
- ,
- t.prototype.convertToFlatShadedMesh = function() {
- var e, t, i = this.getVerticesDataKinds(), n = {}, r = {}, o = {}, s = !1;
- for (e = 0; e < i.length; e++) {
- t = i[e];
- var l = this.getVertexBuffer(t)
- , c = l.getData();
- (c instanceof Array || c instanceof Float32Array) && 0 === c.length || (t !== Bi.NormalKind ? (n[t] = l,
- r[t] = this.getVerticesData(t),
- o[t] = []) : (s = l.isUpdatable(),
- i.splice(e, 1),
- e--))
- }
- var u, h = this.subMeshes.slice(0), d = this.getIndices(), p = this.getTotalIndices();
- for (u = 0; u < p; u++) {
- var f = d[u];
- for (e = 0; e < i.length; e++)
- if (n[t = i[e]])
- for (var _ = n[t].getStrideSize(), m = 0; m < _; m++)
- o[t].push(r[t][f * _ + m])
- }
- var g, v = [], y = o[Bi.PositionKind];
- for (g = this.getScene().useRightHandedSystem ? this.overrideMaterialSideOrientation === a.MATERIAL_CounterClockWiseSideOrientation : this.overrideMaterialSideOrientation === a.MATERIAL_ClockWiseSideOrientation,
- u = 0; u < p; u += 3) {
- d[u] = u,
- d[u + 1] = u + 1,
- d[u + 2] = u + 2;
- var b = x.FromArray(y, 3 * u)
- , T = x.FromArray(y, 3 * (u + 1))
- , E = x.FromArray(y, 3 * (u + 2))
- , S = b.subtract(T)
- , A = E.subtract(T)
- , R = x.Normalize(x.Cross(S, A));
- g && R.scaleInPlace(-1);
- for (var C = 0; C < 3; C++)
- v.push(R.x),
- v.push(R.y),
- v.push(R.z)
- }
- for (this.setIndices(d),
- this.setVerticesData(Bi.NormalKind, v, s),
- e = 0; e < i.length; e++)
- o[t = i[e]] && this.setVerticesData(t, o[t], n[t].isUpdatable());
- this.releaseSubMeshes();
- for (var P = 0; P < h.length; P++) {
- var M = h[P];
- hr.AddToMesh(M.materialIndex, M.indexStart, M.indexCount, M.indexStart, M.indexCount, this)
- }
- return this.synchronizeInstances(),
- this
- }
- ,
- t.prototype.convertToUnIndexedMesh = function() {
- var e, t, i = this.getVerticesDataKinds(), n = {}, r = {}, o = {};
- for (e = 0; e < i.length; e++) {
- t = i[e];
- var a = this.getVertexBuffer(t);
- n[t] = a,
- r[t] = n[t].getData(),
- o[t] = []
- }
- var s, l = this.subMeshes.slice(0), c = this.getIndices(), u = this.getTotalIndices();
- for (s = 0; s < u; s++) {
- var h = c[s];
- for (e = 0; e < i.length; e++)
- for (var d = n[t = i[e]].getStrideSize(), p = 0; p < d; p++)
- o[t].push(r[t][h * d + p])
- }
- for (s = 0; s < u; s += 3)
- c[s] = s,
- c[s + 1] = s + 1,
- c[s + 2] = s + 2;
- for (this.setIndices(c),
- e = 0; e < i.length; e++)
- t = i[e],
- this.setVerticesData(t, o[t], n[t].isUpdatable());
- this.releaseSubMeshes();
- for (var f = 0; f < l.length; f++) {
- var _ = l[f];
- hr.AddToMesh(_.materialIndex, _.indexStart, _.indexCount, _.indexStart, _.indexCount, this)
- }
- return this._unIndexed = !0,
- this.synchronizeInstances(),
- this
- }
- ,
- t.prototype.flipFaces = function(e) {
- void 0 === e && (e = !1);
- var t, i = $n.ExtractFromMesh(this);
- if (e && this.isVerticesDataPresent(Bi.NormalKind) && i.normals)
- for (t = 0; t < i.normals.length; t++)
- i.normals[t] *= -1;
- if (i.indices) {
- var n = void 0;
- for (t = 0; t < i.indices.length; t += 3)
- n = i.indices[t + 1],
- i.indices[t + 1] = i.indices[t + 2],
- i.indices[t + 2] = n
- }
- return i.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind)),
- this
- }
- ,
- t.prototype.increaseVertices = function(e) {
- var t = $n.ExtractFromMesh(this)
- , i = t.uvs && !Array.isArray(t.uvs) && Array.from ? Array.from(t.uvs) : t.uvs
- , n = t.indices && !Array.isArray(t.indices) && Array.from ? Array.from(t.indices) : t.indices
- , r = t.positions && !Array.isArray(t.positions) && Array.from ? Array.from(t.positions) : t.positions
- , o = t.normals && !Array.isArray(t.normals) && Array.from ? Array.from(t.normals) : t.normals;
- if (n && r && o && i) {
- t.indices = n,
- t.positions = r,
- t.normals = o,
- t.uvs = i;
- for (var a = e + 1, s = new Array, l = 0; l < a + 1; l++)
- s[l] = new Array;
- var c = void 0
- , u = void 0
- , h = new x(0,0,0)
- , d = new x(0,0,0)
- , p = new A(0,0)
- , f = new Array
- , _ = new Array
- , m = new Array
- , g = void 0
- , v = r.length
- , y = i.length;
- for (l = 0; l < n.length; l += 3) {
- _[0] = n[l],
- _[1] = n[l + 1],
- _[2] = n[l + 2];
- for (var b = 0; b < 3; b++)
- if (c = _[b],
- u = _[(b + 1) % 3],
- void 0 === m[c] && void 0 === m[u] ? (m[c] = new Array,
- m[u] = new Array) : (void 0 === m[c] && (m[c] = new Array),
- void 0 === m[u] && (m[u] = new Array)),
- void 0 === m[c][u] && void 0 === m[u][c]) {
- m[c][u] = [],
- h.x = (r[3 * u] - r[3 * c]) / a,
- h.y = (r[3 * u + 1] - r[3 * c + 1]) / a,
- h.z = (r[3 * u + 2] - r[3 * c + 2]) / a,
- d.x = (o[3 * u] - o[3 * c]) / a,
- d.y = (o[3 * u + 1] - o[3 * c + 1]) / a,
- d.z = (o[3 * u + 2] - o[3 * c + 2]) / a,
- p.x = (i[2 * u] - i[2 * c]) / a,
- p.y = (i[2 * u + 1] - i[2 * c + 1]) / a,
- m[c][u].push(c);
- for (var T = 1; T < a; T++)
- m[c][u].push(r.length / 3),
- r[v] = r[3 * c] + T * h.x,
- o[v++] = o[3 * c] + T * d.x,
- r[v] = r[3 * c + 1] + T * h.y,
- o[v++] = o[3 * c + 1] + T * d.y,
- r[v] = r[3 * c + 2] + T * h.z,
- o[v++] = o[3 * c + 2] + T * d.z,
- i[y++] = i[2 * c] + T * p.x,
- i[y++] = i[2 * c + 1] + T * p.y;
- m[c][u].push(u),
- m[u][c] = new Array,
- g = m[c][u].length;
- for (var E = 0; E < g; E++)
- m[u][c][E] = m[c][u][g - 1 - E]
- }
- for (s[0][0] = n[l],
- s[1][0] = m[n[l]][n[l + 1]][1],
- s[1][1] = m[n[l]][n[l + 2]][1],
- T = 2; T < a; T++)
- for (s[T][0] = m[n[l]][n[l + 1]][T],
- s[T][T] = m[n[l]][n[l + 2]][T],
- h.x = (r[3 * s[T][T]] - r[3 * s[T][0]]) / T,
- h.y = (r[3 * s[T][T] + 1] - r[3 * s[T][0] + 1]) / T,
- h.z = (r[3 * s[T][T] + 2] - r[3 * s[T][0] + 2]) / T,
- d.x = (o[3 * s[T][T]] - o[3 * s[T][0]]) / T,
- d.y = (o[3 * s[T][T] + 1] - o[3 * s[T][0] + 1]) / T,
- d.z = (o[3 * s[T][T] + 2] - o[3 * s[T][0] + 2]) / T,
- p.x = (i[2 * s[T][T]] - i[2 * s[T][0]]) / T,
- p.y = (i[2 * s[T][T] + 1] - i[2 * s[T][0] + 1]) / T,
- b = 1; b < T; b++)
- s[T][b] = r.length / 3,
- r[v] = r[3 * s[T][0]] + b * h.x,
- o[v++] = o[3 * s[T][0]] + b * d.x,
- r[v] = r[3 * s[T][0] + 1] + b * h.y,
- o[v++] = o[3 * s[T][0] + 1] + b * d.y,
- r[v] = r[3 * s[T][0] + 2] + b * h.z,
- o[v++] = o[3 * s[T][0] + 2] + b * d.z,
- i[y++] = i[2 * s[T][0]] + b * p.x,
- i[y++] = i[2 * s[T][0] + 1] + b * p.y;
- for (s[a] = m[n[l + 1]][n[l + 2]],
- f.push(s[0][0], s[1][0], s[1][1]),
- T = 1; T < a; T++) {
- for (b = void 0,
- b = 0; b < T; b++)
- f.push(s[T][b], s[T + 1][b], s[T + 1][b + 1]),
- f.push(s[T][b], s[T + 1][b + 1], s[T][b + 1]);
- f.push(s[T][b], s[T + 1][b], s[T + 1][b + 1])
- }
- }
- t.indices = f,
- t.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind))
- } else
- K.Warn("VertexData contains null entries")
- }
- ,
- t.prototype.forceSharedVertices = function() {
- var e = $n.ExtractFromMesh(this)
- , t = e.uvs
- , i = e.indices
- , n = e.positions
- , r = e.colors;
- if (void 0 === i || void 0 === n || null === i || null === n)
- K.Warn("VertexData contains empty entries");
- else {
- for (var o = new Array, a = new Array, s = new Array, l = new Array, c = new Array, u = 0, h = {}, d = void 0, p = void 0, f = 0; f < i.length; f += 3) {
- p = [i[f], i[f + 1], i[f + 2]],
- c = new Array;
- for (var _ = 0; _ < 3; _++) {
- c[_] = "";
- for (var m = 0; m < 3; m++)
- Math.abs(n[3 * p[_] + m]) < 1e-8 && (n[3 * p[_] + m] = 0),
- c[_] += n[3 * p[_] + m] + "|"
- }
- if (c[0] != c[1] && c[0] != c[2] && c[1] != c[2])
- for (_ = 0; _ < 3; _++) {
- if (void 0 === (d = h[c[_]])) {
- for (h[c[_]] = u,
- d = u++,
- m = 0; m < 3; m++)
- o.push(n[3 * p[_] + m]);
- if (null != r)
- for (m = 0; m < 4; m++)
- l.push(r[4 * p[_] + m]);
- if (null != t)
- for (m = 0; m < 2; m++)
- s.push(t[2 * p[_] + m])
- }
- a.push(d)
- }
- }
- var g = new Array;
- $n.ComputeNormals(o, a, g),
- e.positions = o,
- e.indices = a,
- e.normals = g,
- null != t && (e.uvs = s),
- null != r && (e.colors = l),
- e.applyToMesh(this, this.isVertexBufferUpdatable(Bi.PositionKind))
- }
- }
- ,
- t._instancedMeshFactory = function(e, t) {
- throw be("InstancedMesh")
- }
- ,
- t._PhysicsImpostorParser = function(e, t, i) {
- throw be("PhysicsImpostor")
- }
- ,
- t.prototype.createInstance = function(e) {
- return t._instancedMeshFactory(e, this)
- }
- ,
- t.prototype.synchronizeInstances = function() {
- for (var e = 0; e < this.instances.length; e++)
- this.instances[e]._syncSubMeshes();
- return this
- }
- ,
- t.prototype.optimizeIndices = function(e) {
- var t = this
- , i = this.getIndices()
- , n = this.getVerticesData(Bi.PositionKind);
- if (!n || !i)
- return this;
- for (var r = new Array, o = 0; o < n.length; o += 3)
- r.push(x.FromArray(n, o));
- var a = new Array;
- return yi.SyncAsyncForLoop(r.length, 40, (function(e) {
- for (var t = r.length - 1 - e, i = r[t], n = 0; n < t; ++n) {
- var o = r[n];
- if (i.equals(o)) {
- a[t] = n;
- break
- }
- }
- }
- ), (function() {
- for (var n = 0; n < i.length; ++n)
- i[n] = a[i[n]] || i[n];
- var r = t.subMeshes.slice(0);
- t.setIndices(i),
- t.subMeshes = r,
- e && e(t)
- }
- )),
- this
- }
- ,
- t.prototype.serialize = function(e) {
- e.name = this.name,
- e.id = this.id,
- e.uniqueId = this.uniqueId,
- e.type = this.getClassName(),
- ye && ye.HasTags(this) && (e.tags = ye.GetTags(this)),
- e.position = this.position.asArray(),
- this.rotationQuaternion ? e.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (e.rotation = this.rotation.asArray()),
- e.scaling = this.scaling.asArray(),
- this._postMultiplyPivotMatrix ? e.pivotMatrix = this.getPivotMatrix().asArray() : e.localMatrix = this.getPivotMatrix().asArray(),
- e.isEnabled = this.isEnabled(!1),
- e.isVisible = this.isVisible,
- e.infiniteDistance = this.infiniteDistance,
- e.pickable = this.isPickable,
- e.receiveShadows = this.receiveShadows,
- e.billboardMode = this.billboardMode,
- e.visibility = this.visibility,
- e.checkCollisions = this.checkCollisions,
- e.isBlocker = this.isBlocker,
- e.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation,
- this.parent && (e.parentId = this.parent.uniqueId),
- e.isUnIndexed = this.isUnIndexed;
- var t = this._geometry;
- if (t && this.subMeshes) {
- e.geometryUniqueId = t.uniqueId,
- e.geometryId = t.id,
- e.subMeshes = [];
- for (var i = 0; i < this.subMeshes.length; i++) {
- var n = this.subMeshes[i];
- e.subMeshes.push({
- materialIndex: n.materialIndex,
- verticesStart: n.verticesStart,
- verticesCount: n.verticesCount,
- indexStart: n.indexStart,
- indexCount: n.indexCount
- })
- }
- }
- this.material ? this.material.doNotSerialize || (e.materialUniqueId = this.material.uniqueId,
- e.materialId = this.material.id) : (this.material = null,
- e.materialUniqueId = this._scene.defaultMaterial.uniqueId,
- e.materialId = this._scene.defaultMaterial.id),
- this.morphTargetManager && (e.morphTargetManagerId = this.morphTargetManager.uniqueId),
- this.skeleton && (e.skeletonId = this.skeleton.id,
- e.numBoneInfluencers = this.numBoneInfluencers),
- this.getScene()._getComponent(Wi.NAME_PHYSICSENGINE) && (a = this.getPhysicsImpostor()) && (e.physicsMass = a.getParam("mass"),
- e.physicsFriction = a.getParam("friction"),
- e.physicsRestitution = a.getParam("mass"),
- e.physicsImpostor = a.type),
- this.metadata && (e.metadata = this.metadata),
- e.instances = [];
- for (var r = 0; r < this.instances.length; r++) {
- var o = this.instances[r];
- if (!o.doNotSerialize) {
- var a, s = {
- name: o.name,
- id: o.id,
- isEnabled: o.isEnabled(!1),
- isVisible: o.isVisible,
- isPickable: o.isPickable,
- checkCollisions: o.checkCollisions,
- position: o.position.asArray(),
- scaling: o.scaling.asArray()
- };
- o.parent && (s.parentId = o.parent.uniqueId),
- o.rotationQuaternion ? s.rotationQuaternion = o.rotationQuaternion.asArray() : o.rotation && (s.rotation = o.rotation.asArray()),
- this.getScene()._getComponent(Wi.NAME_PHYSICSENGINE) && (a = o.getPhysicsImpostor()) && (s.physicsMass = a.getParam("mass"),
- s.physicsFriction = a.getParam("friction"),
- s.physicsRestitution = a.getParam("mass"),
- s.physicsImpostor = a.type),
- o.metadata && (s.metadata = o.metadata),
- e.instances.push(s),
- Ge.AppendSerializedAnimations(o, s),
- s.ranges = o.serializeAnimationRanges()
- }
- }
- if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (e.thinInstances = {
- instancesCount: this._thinInstanceDataStorage.instancesCount,
- matrixData: gi.SliceToArray(this._thinInstanceDataStorage.matrixData),
- matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize,
- enablePicking: this.thinInstanceEnablePicking
- },
- this._userThinInstanceBuffersStorage)) {
- var l = {
- data: {},
- sizes: {},
- strides: {}
- };
- for (var c in this._userThinInstanceBuffersStorage.data)
- l.data[c] = gi.SliceToArray(this._userThinInstanceBuffersStorage.data[c]),
- l.sizes[c] = this._userThinInstanceBuffersStorage.sizes[c],
- l.strides[c] = this._userThinInstanceBuffersStorage.strides[c];
- e.thinInstances.userThinInstance = l
- }
- Ge.AppendSerializedAnimations(this, e),
- e.ranges = this.serializeAnimationRanges(),
- e.layerMask = this.layerMask,
- e.alphaIndex = this.alphaIndex,
- e.hasVertexAlpha = this.hasVertexAlpha,
- e.overlayAlpha = this.overlayAlpha,
- e.overlayColor = this.overlayColor.asArray(),
- e.renderOverlay = this.renderOverlay,
- e.applyFog = this.applyFog,
- this.actionManager && (e.actions = this.actionManager.serialize(this.name))
- }
- ,
- t.prototype._syncGeometryWithMorphTargetManager = function() {
- if (this.geometry) {
- this._markSubMeshesAsAttributesDirty();
- var e = this._internalAbstractMeshDataInfo._morphTargetManager;
- if (e && e.vertexCount) {
- if (e.vertexCount !== this.getTotalVertices())
- return K.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),
- void (this.morphTargetManager = null);
- if (e.isUsingTextureForTargets)
- return;
- for (var t = 0; t < e.numInfluencers; t++) {
- var i = e.getActiveTarget(t)
- , n = i.getPositions();
- if (!n)
- return void K.Error("Invalid morph target. Target must have positions.");
- this.geometry.setVerticesData(Bi.PositionKind + t, n, !1, 3);
- var r = i.getNormals();
- r && this.geometry.setVerticesData(Bi.NormalKind + t, r, !1, 3);
- var o = i.getTangents();
- o && this.geometry.setVerticesData(Bi.TangentKind + t, o, !1, 3);
- var a = i.getUVs();
- a && this.geometry.setVerticesData(Bi.UVKind + "_" + t, a, !1, 2)
- }
- } else
- for (t = 0; this.geometry.isVerticesDataPresent(Bi.PositionKind + t); )
- this.geometry.removeVerticesData(Bi.PositionKind + t),
- this.geometry.isVerticesDataPresent(Bi.NormalKind + t) && this.geometry.removeVerticesData(Bi.NormalKind + t),
- this.geometry.isVerticesDataPresent(Bi.TangentKind + t) && this.geometry.removeVerticesData(Bi.TangentKind + t),
- this.geometry.isVerticesDataPresent(Bi.UVKind + t) && this.geometry.removeVerticesData(Bi.UVKind + "_" + t),
- t++
- }
- }
- ,
- t.Parse = function(e, i, n) {
- var r;
- if ((r = e.type && "LinesMesh" === e.type ? t._LinesMeshParser(e, i) : e.type && "GroundMesh" === e.type ? t._GroundMeshParser(e, i) : e.type && "GoldbergMesh" === e.type ? t._GoldbergMeshParser(e, i) : new t(e.name,i)).id = e.id,
- ye && ye.AddTagsTo(r, e.tags),
- r.position = x.FromArray(e.position),
- void 0 !== e.metadata && (r.metadata = e.metadata),
- e.rotationQuaternion ? r.rotationQuaternion = C.FromArray(e.rotationQuaternion) : e.rotation && (r.rotation = x.FromArray(e.rotation)),
- r.scaling = x.FromArray(e.scaling),
- e.localMatrix ? r.setPreTransformMatrix(P.FromArray(e.localMatrix)) : e.pivotMatrix && r.setPivotMatrix(P.FromArray(e.pivotMatrix)),
- r.setEnabled(e.isEnabled),
- r.isVisible = e.isVisible,
- r.infiniteDistance = e.infiniteDistance,
- r.showBoundingBox = e.showBoundingBox,
- r.showSubMeshesBoundingBox = e.showSubMeshesBoundingBox,
- void 0 !== e.applyFog && (r.applyFog = e.applyFog),
- void 0 !== e.pickable && (r.isPickable = e.pickable),
- void 0 !== e.alphaIndex && (r.alphaIndex = e.alphaIndex),
- r.receiveShadows = e.receiveShadows,
- r.billboardMode = e.billboardMode,
- void 0 !== e.visibility && (r.visibility = e.visibility),
- r.checkCollisions = e.checkCollisions,
- r.overrideMaterialSideOrientation = e.overrideMaterialSideOrientation,
- void 0 !== e.isBlocker && (r.isBlocker = e.isBlocker),
- r._shouldGenerateFlatShading = e.useFlatShading,
- e.freezeWorldMatrix && (r._waitingData.freezeWorldMatrix = e.freezeWorldMatrix),
- void 0 !== e.parentId && (r._waitingParentId = e.parentId),
- void 0 !== e.actions && (r._waitingData.actions = e.actions),
- void 0 !== e.overlayAlpha && (r.overlayAlpha = e.overlayAlpha),
- void 0 !== e.overlayColor && (r.overlayColor = D.FromArray(e.overlayColor)),
- void 0 !== e.renderOverlay && (r.renderOverlay = e.renderOverlay),
- r.isUnIndexed = !!e.isUnIndexed,
- r.hasVertexAlpha = e.hasVertexAlpha,
- e.delayLoadingFile ? (r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
- r.delayLoadingFile = n + e.delayLoadingFile,
- r.buildBoundingInfo(x.FromArray(e.boundingBoxMinimum), x.FromArray(e.boundingBoxMaximum)),
- e._binaryInfo && (r._binaryInfo = e._binaryInfo),
- r._delayInfo = [],
- e.hasUVs && r._delayInfo.push(Bi.UVKind),
- e.hasUVs2 && r._delayInfo.push(Bi.UV2Kind),
- e.hasUVs3 && r._delayInfo.push(Bi.UV3Kind),
- e.hasUVs4 && r._delayInfo.push(Bi.UV4Kind),
- e.hasUVs5 && r._delayInfo.push(Bi.UV5Kind),
- e.hasUVs6 && r._delayInfo.push(Bi.UV6Kind),
- e.hasColors && r._delayInfo.push(Bi.ColorKind),
- e.hasMatricesIndices && r._delayInfo.push(Bi.MatricesIndicesKind),
- e.hasMatricesWeights && r._delayInfo.push(Bi.MatricesWeightsKind),
- r._delayLoadingFunction = fr._ImportGeometry,
- dr.ForceFullSceneLoadingForIncremental && r._checkDelayState()) : fr._ImportGeometry(e, r),
- e.materialUniqueId ? r._waitingMaterialId = e.materialUniqueId : e.materialId && (r._waitingMaterialId = e.materialId),
- e.morphTargetManagerId > -1 && (r.morphTargetManager = i.getMorphTargetManagerById(e.morphTargetManagerId)),
- void 0 !== e.skeletonId && null !== e.skeletonId && (r.skeleton = i.getLastSkeletonById(e.skeletonId),
- e.numBoneInfluencers && (r.numBoneInfluencers = e.numBoneInfluencers)),
- e.animations) {
- for (var o = 0; o < e.animations.length; o++) {
- var s = e.animations[o];
- (h = b("BABYLON.Animation")) && r.animations.push(h.Parse(s))
- }
- Xe.ParseAnimationRanges(r, e, i)
- }
- if (e.autoAnimate && i.beginAnimation(r, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
- e.layerMask && !isNaN(e.layerMask) ? r.layerMask = Math.abs(parseInt(e.layerMask)) : r.layerMask = 268435455,
- e.physicsImpostor && t._PhysicsImpostorParser(i, r, e),
- e.lodMeshIds && (r._waitingData.lods = {
- ids: e.lodMeshIds,
- distances: e.lodDistances ? e.lodDistances : null,
- coverages: e.lodCoverages ? e.lodCoverages : null
- }),
- e.instances)
- for (var l = 0; l < e.instances.length; l++) {
- var c = e.instances[l]
- , u = r.createInstance(c.name);
- if (c.id && (u.id = c.id),
- ye && (c.tags ? ye.AddTagsTo(u, c.tags) : ye.AddTagsTo(u, e.tags)),
- u.position = x.FromArray(c.position),
- void 0 !== c.metadata && (u.metadata = c.metadata),
- void 0 !== c.parentId && (u._waitingParentId = c.parentId),
- void 0 !== c.isEnabled && null !== c.isEnabled && u.setEnabled(c.isEnabled),
- void 0 !== c.isVisible && null !== c.isVisible && (u.isVisible = c.isVisible),
- void 0 !== c.isPickable && null !== c.isPickable && (u.isPickable = c.isPickable),
- c.rotationQuaternion ? u.rotationQuaternion = C.FromArray(c.rotationQuaternion) : c.rotation && (u.rotation = x.FromArray(c.rotation)),
- u.scaling = x.FromArray(c.scaling),
- null != c.checkCollisions && null != c.checkCollisions && (u.checkCollisions = c.checkCollisions),
- null != c.pickable && null != c.pickable && (u.isPickable = c.pickable),
- null != c.showBoundingBox && null != c.showBoundingBox && (u.showBoundingBox = c.showBoundingBox),
- null != c.showSubMeshesBoundingBox && null != c.showSubMeshesBoundingBox && (u.showSubMeshesBoundingBox = c.showSubMeshesBoundingBox),
- null != c.alphaIndex && null != c.showSubMeshesBoundingBox && (u.alphaIndex = c.alphaIndex),
- c.physicsImpostor && t._PhysicsImpostorParser(i, u, c),
- c.animations) {
- for (o = 0; o < c.animations.length; o++) {
- var h;
- s = c.animations[o],
- (h = b("BABYLON.Animation")) && u.animations.push(h.Parse(s))
- }
- Xe.ParseAnimationRanges(u, c, i),
- c.autoAnimate && i.beginAnimation(u, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1)
- }
- }
- if (e.thinInstances) {
- var d = e.thinInstances;
- if (r.thinInstanceEnablePicking = !!d.enablePicking,
- d.matrixData ? (r.thinInstanceSetBuffer("matrix", new Float32Array(d.matrixData), 16, !1),
- r._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize,
- r._thinInstanceDataStorage.instancesCount = d.instancesCount) : r._thinInstanceDataStorage.matrixBufferSize = d.matrixBufferSize,
- e.thinInstances.userThinInstance) {
- var p = e.thinInstances.userThinInstance;
- for (var f in p.data)
- r.thinInstanceSetBuffer(f, new Float32Array(p.data[f]), p.strides[f], !1),
- r._userThinInstanceBuffersStorage.sizes[f] = p.sizes[f]
- }
- }
- return r
- }
- ,
- t.prototype.setPositionsForCPUSkinning = function() {
- var e = this._internalMeshDataInfo;
- if (!e._sourcePositions) {
- var t = this.getVerticesData(Bi.PositionKind);
- if (!t)
- return e._sourcePositions;
- e._sourcePositions = new Float32Array(t),
- this.isVertexBufferUpdatable(Bi.PositionKind) || this.setVerticesData(Bi.PositionKind, t, !0)
- }
- return e._sourcePositions
- }
- ,
- t.prototype.setNormalsForCPUSkinning = function() {
- var e = this._internalMeshDataInfo;
- if (!e._sourceNormals) {
- var t = this.getVerticesData(Bi.NormalKind);
- if (!t)
- return e._sourceNormals;
- e._sourceNormals = new Float32Array(t),
- this.isVertexBufferUpdatable(Bi.NormalKind) || this.setVerticesData(Bi.NormalKind, t, !0)
- }
- return e._sourceNormals
- }
- ,
- t.prototype.applySkeleton = function(e) {
- if (!this.geometry)
- return this;
- if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
- return this;
- if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(),
- !this.isVerticesDataPresent(Bi.PositionKind))
- return this;
- if (!this.isVerticesDataPresent(Bi.MatricesIndicesKind))
- return this;
- if (!this.isVerticesDataPresent(Bi.MatricesWeightsKind))
- return this;
- var t = this.isVerticesDataPresent(Bi.NormalKind)
- , i = this._internalMeshDataInfo;
- if (!i._sourcePositions) {
- var n = this.subMeshes.slice();
- this.setPositionsForCPUSkinning(),
- this.subMeshes = n
- }
- t && !i._sourceNormals && this.setNormalsForCPUSkinning();
- var r = this.getVerticesData(Bi.PositionKind);
- if (!r)
- return this;
- r instanceof Float32Array || (r = new Float32Array(r));
- var o = this.getVerticesData(Bi.NormalKind);
- if (t) {
- if (!o)
- return this;
- o instanceof Float32Array || (o = new Float32Array(o))
- }
- var a = this.getVerticesData(Bi.MatricesIndicesKind)
- , s = this.getVerticesData(Bi.MatricesWeightsKind);
- if (!s || !a)
- return this;
- for (var l, c = this.numBoneInfluencers > 4, u = c ? this.getVerticesData(Bi.MatricesIndicesExtraKind) : null, h = c ? this.getVerticesData(Bi.MatricesWeightsExtraKind) : null, d = e.getTransformMatrices(this), p = x.Zero(), f = new P, _ = new P, m = 0, g = 0; g < r.length; g += 3,
- m += 4) {
- var v = void 0;
- for (l = 0; l < 4; l++)
- (v = s[m + l]) > 0 && (P.FromFloat32ArrayToRefScaled(d, Math.floor(16 * a[m + l]), v, _),
- f.addToSelf(_));
- if (c)
- for (l = 0; l < 4; l++)
- (v = h[m + l]) > 0 && (P.FromFloat32ArrayToRefScaled(d, Math.floor(16 * u[m + l]), v, _),
- f.addToSelf(_));
- x.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g], i._sourcePositions[g + 1], i._sourcePositions[g + 2], f, p),
- p.toArray(r, g),
- t && (x.TransformNormalFromFloatsToRef(i._sourceNormals[g], i._sourceNormals[g + 1], i._sourceNormals[g + 2], f, p),
- p.toArray(o, g)),
- f.reset()
- }
- return this.updateVerticesData(Bi.PositionKind, r),
- t && this.updateVerticesData(Bi.NormalKind, o),
- this
- }
- ,
- t.MinMax = function(e) {
- var t = null
- , i = null;
- return e.forEach((function(e) {
- var n = e.getBoundingInfo().boundingBox;
- t && i ? (t.minimizeInPlace(n.minimumWorld),
- i.maximizeInPlace(n.maximumWorld)) : (t = n.minimumWorld,
- i = n.maximumWorld)
- }
- )),
- t && i ? {
- min: t,
- max: i
- } : {
- min: x.Zero(),
- max: x.Zero()
- }
- }
- ,
- t.Center = function(e) {
- var i = e instanceof Array ? t.MinMax(e) : e;
- return x.Center(i.min, i.max)
- }
- ,
- t.MergeMeshes = function(e, i, n, r, o, a) {
- return void 0 === i && (i = !0),
- Qn(t._MergeMeshesCoroutine(e, i, n, r, o, a, !1))
- }
- ,
- t.MergeMeshesAsync = function(e, i, n, r, o, a) {
- return void 0 === i && (i = !0),
- qn(t._MergeMeshesCoroutine(e, i, n, r, o, a, !0), Yn())
- }
- ,
- t._MergeMeshesCoroutine = function(e, i, n, r, o, a, s) {
- var l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D;
- return void 0 === i && (i = !0),
- z(this, (function(N) {
- switch (N.label) {
- case 0:
- if (0 === (e = e.filter(Boolean)).length)
- return [2, null];
- if (!n)
- for (c = 0,
- l = 0; l < e.length; l++)
- if ((c += e[l].getTotalVertices()) >= 65536)
- return K.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 (a && (o = !1),
- u = new Array,
- h = new Array,
- d = new Array,
- l = 0; l < e.length; l++) {
- if ((p = e[l]).isAnInstance)
- return K.Warn("Cannot merge instance meshes."),
- [2, null];
- if (o && d.push(p.getTotalIndices()),
- a)
- if (p.material)
- if ((f = p.material)instanceof Dr) {
- for (_ = 0; _ < f.subMaterials.length; _++)
- u.indexOf(f.subMaterials[_]) < 0 && u.push(f.subMaterials[_]);
- for (D = 0; D < p.subMeshes.length; D++)
- h.push(u.indexOf(f.subMaterials[p.subMeshes[D].materialIndex])),
- d.push(p.subMeshes[D].indexCount)
- } else
- for (u.indexOf(f) < 0 && u.push(f),
- D = 0; D < p.subMeshes.length; D++)
- h.push(u.indexOf(f)),
- d.push(p.subMeshes[D].indexCount);
- else
- for (D = 0; D < p.subMeshes.length; D++)
- h.push(0),
- d.push(p.subMeshes[D].indexCount)
- }
- return m = e[0],
- g = function(e) {
- var t = e.computeWorldMatrix(!0);
- return [$n.ExtractFromMesh(e, !1, !1), t]
- }
- ,
- v = g(m),
- y = v[0],
- b = v[1],
- s ? [4] : [3, 2];
- case 1:
- N.sent(),
- N.label = 2;
- case 2:
- T = new Array(e.length - 1),
- E = 1,
- N.label = 3;
- case 3:
- return E < e.length ? (T[E - 1] = g(e[E]),
- s ? [4] : [3, 5]) : [3, 6];
- case 4:
- N.sent(),
- N.label = 5;
- case 5:
- return E++,
- [3, 3];
- case 6:
- S = y._mergeCoroutine(b, T, n, s, !i),
- A = S.next(),
- N.label = 7;
- case 7:
- return A.done ? [3, 10] : s ? [4] : [3, 9];
- case 8:
- N.sent(),
- N.label = 9;
- case 9:
- return A = S.next(),
- [3, 7];
- case 10:
- x = A.value,
- r || (r = new t(m.name + "_merged",m.getScene())),
- R = x._applyToCoroutine(r, void 0, s),
- C = R.next(),
- N.label = 11;
- case 11:
- return C.done ? [3, 14] : s ? [4] : [3, 13];
- case 12:
- N.sent(),
- N.label = 13;
- case 13:
- return C = R.next(),
- [3, 11];
- case 14:
- if (r.checkCollisions = m.checkCollisions,
- r.overrideMaterialSideOrientation = m.overrideMaterialSideOrientation,
- i)
- for (l = 0; l < e.length; l++)
- e[l].dispose();
- if (o || a) {
- for (r.releaseSubMeshes(),
- l = 0,
- P = 0; l < d.length; )
- hr.CreateFromIndices(0, P, d[l], r, void 0, !1),
- P += d[l],
- l++;
- for (M = 0,
- I = r.subMeshes; M < I.length; M++)
- I[M].refreshBoundingInfo();
- r.computeWorldMatrix(!0)
- }
- if (a) {
- for ((O = new Dr(m.name + "_merged",m.getScene())).subMaterials = u,
- D = 0; D < r.subMeshes.length; D++)
- r.subMeshes[D].materialIndex = h[D];
- r.material = O
- } else
- r.material = m.material;
- return [2, r]
- }
- }
- ))
- }
- ,
- t.prototype.addInstance = function(e) {
- e._indexInSourceMeshInstanceArray = this.instances.length,
- this.instances.push(e)
- }
- ,
- t.prototype.removeInstance = function(e) {
- var t = e._indexInSourceMeshInstanceArray;
- if (-1 != t) {
- if (t !== this.instances.length - 1) {
- var i = this.instances[this.instances.length - 1];
- this.instances[t] = i,
- i._indexInSourceMeshInstanceArray = t
- }
- e._indexInSourceMeshInstanceArray = -1,
- this.instances.pop()
- }
- }
- ,
- t.prototype._shouldConvertRHS = function() {
- return this.overrideMaterialSideOrientation === Or.CounterClockWiseSideOrientation
- }
- ,
- t.FRONTSIDE = $n.FRONTSIDE,
- t.BACKSIDE = $n.BACKSIDE,
- t.DOUBLESIDE = $n.DOUBLESIDE,
- t.DEFAULTSIDE = $n.DEFAULTSIDE,
- t.NO_CAP = 0,
- t.CAP_START = 1,
- t.CAP_END = 2,
- t.CAP_ALL = 3,
- t.NO_FLIP = 0,
- t.FLIP_TILE = 1,
- t.ROTATE_TILE = 2,
- t.FLIP_ROW = 3,
- t.ROTATE_ROW = 4,
- t.FLIP_N_ROTATE_TILE = 5,
- t.FLIP_N_ROTATE_ROW = 6,
- t.CENTER = 0,
- t.LEFT = 1,
- t.RIGHT = 2,
- t.TOP = 3,
- t.BOTTOM = 4,
- t.INSTANCEDMESH_SORT_TRANSPARENT = !1,
- t._GroundMeshParser = function(e, t) {
- throw be("GroundMesh")
- }
- ,
- t._GoldbergMeshParser = function(e, t) {
- throw be("GoldbergMesh")
- }
- ,
- t._LinesMeshParser = function(e, t) {
- throw be("LinesMesh")
- }
- ,
- t
- }(Sr);
- y("BABYLON.Mesh", Vr),
- Vr.prototype.setMaterialByID = function(e) {
- return this.setMaterialById(e)
- }
- ,
- Vr.CreateDisc = Vr.CreateDisc || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateBox = Vr.CreateBox || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateSphere = Vr.CreateSphere || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateCylinder = Vr.CreateCylinder || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateTorusKnot = Vr.CreateTorusKnot || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateTorus = Vr.CreateTorus || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreatePlane = Vr.CreatePlane || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateGround = Vr.CreateGround || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateTiledGround = Vr.CreateTiledGround || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateGroundFromHeightMap = Vr.CreateGroundFromHeightMap || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateTube = Vr.CreateTube || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreatePolyhedron = Vr.CreatePolyhedron || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateIcoSphere = Vr.CreateIcoSphere || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateDecal = Vr.CreateDecal || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.CreateCapsule = Vr.CreateCapsule || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ,
- Vr.ExtendToGoldberg = Vr.ExtendToGoldberg || function() {
- throw new Error("Import MeshBuilder to populate this function")
- }
- ;
- var kr = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t
- }(o)
- , Gr = function() {
- this.rootNodes = [],
- this.skeletons = [],
- this.animationGroups = []
- }
- , zr = function(e) {
- function t(t) {
- var i = e.call(this) || this;
- return i._wasAddedToScene = !1,
- (t = t || E.LastCreatedScene) ? (i.scene = t,
- i.sounds = [],
- i.effectLayers = [],
- i.layers = [],
- i.lensFlareSystems = [],
- i.proceduralTextures = [],
- i.reflectionProbes = [],
- t.onDisposeObservable.add((function() {
- i._wasAddedToScene || i.dispose()
- }
- )),
- i._onContextRestoredObserver = t.getEngine().onContextRestoredObservable.add((function() {
- for (var e = 0, t = i.geometries; e < t.length; e++)
- t[e]._rebuild();
- for (var n = 0, r = i.meshes; n < r.length; n++)
- r[n]._rebuild();
- for (var o = 0, a = i.particleSystems; o < a.length; o++)
- a[o].rebuild();
- for (var s = 0, l = i.textures; s < l.length; s++)
- l[s]._rebuild()
- }
- )),
- i) : i
- }
- return U(t, e),
- t.prototype.instantiateModelsToScene = function(e, t, i) {
- var n = this;
- void 0 === t && (t = !1);
- var r = {}
- , o = {}
- , a = new Gr
- , s = []
- , l = [];
- i || (i = {
- doNotInstantiate: !0
- });
- var c = function(t, i) {
- if (r[t.uniqueId] = i.uniqueId,
- o[i.uniqueId] = i,
- e && (i.name = e(t.name)),
- i instanceof Vr) {
- var n = i;
- if (n.morphTargetManager) {
- var a = t.morphTargetManager;
- n.morphTargetManager = a.clone();
- for (var s = 0; s < a.numTargets; s++) {
- var l = a.getTarget(s)
- , c = n.morphTargetManager.getTarget(s);
- r[l.uniqueId] = c.uniqueId,
- o[c.uniqueId] = c
- }
- }
- }
- };
- return this.transformNodes.forEach((function(e) {
- if (!e.parent) {
- var t = e.instantiateHierarchy(null, i, (function(e, t) {
- c(e, t)
- }
- ));
- t && a.rootNodes.push(t)
- }
- }
- )),
- this.meshes.forEach((function(s) {
- if (!s.parent) {
- var u = s.instantiateHierarchy(null, i, (function(i, a) {
- if (c(i, a),
- a.material) {
- var s = a;
- if (s.material)
- if (t) {
- var u = i.material;
- if (-1 === l.indexOf(u)) {
- var h = u.clone(e ? e(u.name) : "Clone of " + u.name);
- if (l.push(u),
- r[u.uniqueId] = h.uniqueId,
- o[h.uniqueId] = h,
- "MultiMaterial" === u.getClassName()) {
- for (var d = u, p = 0, f = d.subMaterials; p < f.length; p++) {
- var _ = f[p];
- _ && (h = _.clone(e ? e(_.name) : "Clone of " + _.name),
- l.push(_),
- r[_.uniqueId] = h.uniqueId,
- o[h.uniqueId] = h)
- }
- d.subMaterials = d.subMaterials.map((function(e) {
- return e && o[r[e.uniqueId]]
- }
- ))
- }
- }
- "InstancedMesh" !== s.getClassName() && (s.material = o[r[u.uniqueId]])
- } else
- "MultiMaterial" === s.material.getClassName() ? -1 === n.scene.multiMaterials.indexOf(s.material) && n.scene.addMultiMaterial(s.material) : -1 === n.scene.materials.indexOf(s.material) && n.scene.addMaterial(s.material)
- }
- }
- ));
- u && a.rootNodes.push(u)
- }
- }
- )),
- this.skeletons.forEach((function(t) {
- for (var i = t.clone(e ? e(t.name) : "Clone of " + t.name), l = 0, c = n.meshes; l < c.length; l++) {
- var u = c[l];
- if (u.skeleton === t && !u.isAnInstance) {
- var h = o[r[u.uniqueId]];
- if (h.isAnInstance)
- continue;
- if (h.skeleton = i,
- -1 !== s.indexOf(i))
- continue;
- s.push(i);
- for (var d = 0, p = i.bones; d < p.length; d++) {
- var f = p[d];
- f._linkedTransformNode && (f._linkedTransformNode = o[r[f._linkedTransformNode.uniqueId]])
- }
- }
- }
- a.skeletons.push(i)
- }
- )),
- this.animationGroups.forEach((function(t) {
- var i = t.clone(e ? e(t.name) : "Clone of " + t.name, (function(e) {
- return o[r[e.uniqueId]] || e
- }
- ));
- a.animationGroups.push(i)
- }
- )),
- a
- }
- ,
- t.prototype.addAllToScene = function() {
- var e = this;
- if (!this._wasAddedToScene) {
- this._wasAddedToScene = !0,
- this.cameras.forEach((function(t) {
- e.scene.addCamera(t)
- }
- )),
- this.lights.forEach((function(t) {
- e.scene.addLight(t)
- }
- )),
- this.meshes.forEach((function(t) {
- e.scene.addMesh(t)
- }
- )),
- this.skeletons.forEach((function(t) {
- e.scene.addSkeleton(t)
- }
- )),
- this.animations.forEach((function(t) {
- e.scene.addAnimation(t)
- }
- )),
- this.animationGroups.forEach((function(t) {
- e.scene.addAnimationGroup(t)
- }
- )),
- this.multiMaterials.forEach((function(t) {
- e.scene.addMultiMaterial(t)
- }
- )),
- this.materials.forEach((function(t) {
- e.scene.addMaterial(t)
- }
- )),
- this.morphTargetManagers.forEach((function(t) {
- e.scene.addMorphTargetManager(t)
- }
- )),
- this.geometries.forEach((function(t) {
- e.scene.addGeometry(t)
- }
- )),
- this.transformNodes.forEach((function(t) {
- e.scene.addTransformNode(t)
- }
- )),
- this.actionManagers.forEach((function(t) {
- e.scene.addActionManager(t)
- }
- )),
- this.textures.forEach((function(t) {
- e.scene.addTexture(t)
- }
- )),
- this.reflectionProbes.forEach((function(t) {
- e.scene.addReflectionProbe(t)
- }
- )),
- this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
- for (var t = 0, i = this.scene._serializableComponents; t < i.length; t++)
- i[t].addFromContainer(this);
- this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null
- }
- }
- ,
- t.prototype.removeAllFromScene = function() {
- var e = this;
- this._wasAddedToScene = !1,
- this.cameras.forEach((function(t) {
- e.scene.removeCamera(t)
- }
- )),
- this.lights.forEach((function(t) {
- e.scene.removeLight(t)
- }
- )),
- this.meshes.forEach((function(t) {
- e.scene.removeMesh(t)
- }
- )),
- this.skeletons.forEach((function(t) {
- e.scene.removeSkeleton(t)
- }
- )),
- this.animations.forEach((function(t) {
- e.scene.removeAnimation(t)
- }
- )),
- this.animationGroups.forEach((function(t) {
- e.scene.removeAnimationGroup(t)
- }
- )),
- this.multiMaterials.forEach((function(t) {
- e.scene.removeMultiMaterial(t)
- }
- )),
- this.materials.forEach((function(t) {
- e.scene.removeMaterial(t)
- }
- )),
- this.morphTargetManagers.forEach((function(t) {
- e.scene.removeMorphTargetManager(t)
- }
- )),
- this.geometries.forEach((function(t) {
- e.scene.removeGeometry(t)
- }
- )),
- this.transformNodes.forEach((function(t) {
- e.scene.removeTransformNode(t)
- }
- )),
- this.actionManagers.forEach((function(t) {
- e.scene.removeActionManager(t)
- }
- )),
- this.textures.forEach((function(t) {
- e.scene.removeTexture(t)
- }
- )),
- this.reflectionProbes.forEach((function(t) {
- e.scene.removeReflectionProbe(t)
- }
- )),
- this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
- for (var t = 0, i = this.scene._serializableComponents; t < i.length; t++)
- i[t].removeFromContainer(this)
- }
- ,
- t.prototype.dispose = function() {
- this.cameras.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.cameras = [],
- this.lights.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.lights = [],
- this.meshes.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.meshes = [],
- this.skeletons.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.skeletons = [],
- this.animationGroups.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.animationGroups = [],
- this.multiMaterials.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.multiMaterials = [],
- this.materials.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.materials = [],
- this.geometries.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.geometries = [],
- this.transformNodes.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.transformNodes = [],
- this.actionManagers.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.actionManagers = [],
- this.textures.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.textures = [],
- this.reflectionProbes.slice(0).forEach((function(e) {
- e.dispose()
- }
- )),
- this.reflectionProbes = [],
- this.environmentTexture && (this.environmentTexture.dispose(),
- this.environmentTexture = null);
- for (var e = 0, t = this.scene._serializableComponents; e < t.length; e++)
- t[e].removeFromContainer(this, !0);
- this._onContextRestoredObserver && (this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null)
- }
- ,
- t.prototype._moveAssets = function(e, t, i) {
- if (e)
- for (var n = 0, r = e; n < r.length; n++) {
- var o = r[n]
- , a = !0;
- if (i)
- for (var s = 0, l = i; s < l.length; s++)
- if (o === l[s]) {
- a = !1;
- break
- }
- a && (t.push(o),
- o._parentContainer = this)
- }
- }
- ,
- t.prototype.moveAllFromScene = function(e) {
- for (var t in this._wasAddedToScene = !1,
- void 0 === e && (e = new kr),
- this)
- Object.prototype.hasOwnProperty.call(this, t) && (this[t] = this[t] || ("environmentTexture" === t ? null : []),
- this._moveAssets(this.scene[t], this[t], e[t]));
- this.environmentTexture = this.scene.environmentTexture,
- this.removeAllFromScene()
- }
- ,
- t.prototype.createRootMesh = function() {
- var e = new Vr("assetContainerRootMesh",this.scene);
- return this.meshes.forEach((function(t) {
- t.parent || e.addChild(t)
- }
- )),
- this.meshes.unshift(e),
- e
- }
- ,
- t.prototype.mergeAnimationsTo = function(e, t, i) {
- if (void 0 === e && (e = E.LastCreatedScene),
- void 0 === i && (i = null),
- !e)
- return K.Error("No scene available to merge animations to"),
- [];
- var n = i || function(t) {
- var i = null
- , n = t.animations.length ? t.animations[0].targetProperty : ""
- , r = t.name.split(".").join("").split("_primitive")[0];
- switch (n) {
- case "position":
- case "rotationQuaternion":
- i = e.getTransformNodeByName(t.name) || e.getTransformNodeByName(r);
- break;
- case "influence":
- i = e.getMorphTargetByName(t.name) || e.getMorphTargetByName(r);
- break;
- default:
- i = e.getNodeByName(t.name) || e.getNodeByName(r)
- }
- return i
- }
- ;
- this.getNodes().forEach((function(e) {
- var t = n(e);
- if (null !== t) {
- for (var i = function(e) {
- for (var i = 0, n = t.animations.filter((function(t) {
- return t.targetProperty === e.targetProperty
- }
- )); i < n.length; i++) {
- var r = n[i]
- , o = t.animations.indexOf(r, 0);
- o > -1 && t.animations.splice(o, 1)
- }
- }, r = 0, o = e.animations; r < o.length; r++)
- i(o[r]);
- t.animations = t.animations.concat(e.animations)
- }
- }
- ));
- var r = new Array;
- return this.animationGroups.slice().forEach((function(e) {
- r.push(e.clone(e.name, n)),
- e.animatables.forEach((function(e) {
- e.stop()
- }
- ))
- }
- )),
- t.forEach((function(t) {
- var i = n(t.target);
- i && (e.beginAnimation(i, t.fromFrame, t.toFrame, t.loopAnimation, t.speedRatio, t.onAnimationEnd ? t.onAnimationEnd : void 0, void 0, !0, void 0, t.onAnimationLoop ? t.onAnimationLoop : void 0),
- e.stopAnimation(t.target))
- }
- )),
- r
- }
- ,
- t
- }(o)
- , Wr = function() {
- function e(e) {
- this.SMOOTHING = .75,
- this.FFT_SIZE = 512,
- this.BARGRAPHAMPLITUDE = 256,
- this.DEBUGCANVASPOS = {
- x: 20,
- y: 20
- },
- this.DEBUGCANVASSIZE = {
- width: 320,
- height: 200
- },
- (e = e || E.LastCreatedScene) && (this._scene = e,
- vr.audioEngine ? (this._audioEngine = vr.audioEngine,
- this._audioEngine.canUseWebAudio && this._audioEngine.audioContext && (this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser(),
- this._webAudioAnalyser.minDecibels = -140,
- this._webAudioAnalyser.maxDecibels = 0,
- this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount),
- this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount),
- this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount))) : gi.Warn("No audio engine initialized, failed to create an audio analyser"))
- }
- return e.prototype.getFrequencyBinCount = function() {
- return this._audioEngine.canUseWebAudio ? this._webAudioAnalyser.frequencyBinCount : 0
- }
- ,
- e.prototype.getByteFrequencyData = function() {
- return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING,
- this._webAudioAnalyser.fftSize = this.FFT_SIZE,
- this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),
- this._byteFreqs
- }
- ,
- e.prototype.getByteTimeDomainData = function() {
- return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING,
- this._webAudioAnalyser.fftSize = this.FFT_SIZE,
- this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),
- this._byteTime
- }
- ,
- e.prototype.getFloatFrequencyData = function() {
- return this._audioEngine.canUseWebAudio && (this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING,
- this._webAudioAnalyser.fftSize = this.FFT_SIZE,
- this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),
- this._floatFreqs
- }
- ,
- e.prototype.drawDebugCanvas = function() {
- var e = this;
- if (this._audioEngine.canUseWebAudio && (this._debugCanvas || (this._debugCanvas = document.createElement("canvas"),
- this._debugCanvas.width = this.DEBUGCANVASSIZE.width,
- this._debugCanvas.height = this.DEBUGCANVASSIZE.height,
- this._debugCanvas.style.position = "absolute",
- this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px",
- this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px",
- this._debugCanvasContext = this._debugCanvas.getContext("2d"),
- document.body.appendChild(this._debugCanvas),
- this._registerFunc = function() {
- e.drawDebugCanvas()
- }
- ,
- this._scene.registerBeforeRender(this._registerFunc)),
- this._registerFunc && this._debugCanvasContext)) {
- var t = this.getByteFrequencyData();
- this._debugCanvasContext.fillStyle = "rgb(0, 0, 0)",
- this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
- for (var i = 0; i < this.getFrequencyBinCount(); i++) {
- var n = t[i] / this.BARGRAPHAMPLITUDE
- , r = this.DEBUGCANVASSIZE.height * n
- , o = this.DEBUGCANVASSIZE.height - r - 1
- , a = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount()
- , s = i / this.getFrequencyBinCount() * 360;
- this._debugCanvasContext.fillStyle = "hsl(" + s + ", 100%, 50%)",
- this._debugCanvasContext.fillRect(i * a, o, a, r)
- }
- }
- }
- ,
- e.prototype.stopDebugCanvas = function() {
- this._debugCanvas && (this._registerFunc && (this._scene.unregisterBeforeRender(this._registerFunc),
- this._registerFunc = null),
- document.body.removeChild(this._debugCanvas),
- this._debugCanvas = null,
- this._debugCanvasContext = null)
- }
- ,
- e.prototype.connectAudioNodes = function(e, t) {
- this._audioEngine.canUseWebAudio && (e.connect(this._webAudioAnalyser),
- this._webAudioAnalyser.connect(t))
- }
- ,
- e.prototype.dispose = function() {
- this._audioEngine.canUseWebAudio && this._webAudioAnalyser.disconnect()
- }
- ,
- e
- }();
- vr.AudioEngineFactory = function(e, t, i) {
- return new Hr(e,t,i)
- }
- ;
- var Hr = function() {
- function e(e, t, i) {
- void 0 === e && (e = null),
- void 0 === t && (t = null),
- void 0 === i && (i = null);
- var n = this;
- if (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 h,
- this.onAudioLockedObservable = new h,
- this._tryToRun = !1,
- this._onResize = function() {
- n._moveButtonToTopLeft()
- }
- ,
- nt()) {
- void 0 === window.AudioContext && void 0 === window.webkitAudioContext || (window.AudioContext = window.AudioContext || window.webkitAudioContext,
- this.canUseWebAudio = !0);
- var r = document.createElement("audio");
- this._hostElement = e,
- this._audioContext = t,
- this._audioDestination = i;
- try {
- r && r.canPlayType && (r.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || r.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0)
- } catch (e) {}
- try {
- r && r.canPlayType && r.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0)
- } catch (e) {}
- }
- }
- return Object.defineProperty(e.prototype, "audioContext", {
- get: function() {
- return this._audioContextInitialized ? this.unlocked || this._muteButton || this._displayMuteButton() : this._initializeAudioContext(),
- this._audioContext
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.lock = function() {
- this._triggerSuspendedState()
- }
- ,
- e.prototype.unlock = function() {
- this._triggerRunningState()
- }
- ,
- e.prototype._resumeAudioContext = function() {
- var e;
- return void 0 !== this._audioContext.resume && (e = this._audioContext.resume()),
- e || Promise.resolve()
- }
- ,
- e.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,
- "running" === this._audioContext.state && this._triggerRunningState())
- } catch (e) {
- this.canUseWebAudio = !1,
- K.Error("Web Audio: " + e.message)
- }
- }
- ,
- e.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
- }
- )))
- }
- ,
- e.prototype._triggerSuspendedState = function() {
- this.unlocked = !1,
- this.onAudioLockedObservable.notifyObservers(this),
- this._displayMuteButton()
- }
- ,
- e.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 t = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(" + (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") + "); 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) }"
- , i = document.createElement("style");
- i.appendChild(document.createTextNode(t)),
- document.getElementsByTagName("head")[0].appendChild(i),
- 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)
- }
- }
- ,
- e.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")
- }
- ,
- e.prototype._hideMuteButton = function() {
- this._muteButton && (document.body.removeChild(this._muteButton),
- this._muteButton = null)
- }
- ,
- e.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()
- }
- ,
- e.prototype.getGlobalVolume = function() {
- return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1
- }
- ,
- e.prototype.setGlobalVolume = function(e) {
- this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = e)
- }
- ,
- e.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))
- }
- ,
- e
- }()
- , Xr = function() {
- function e(t, i, n, r, o) {
- void 0 === r && (r = null);
- var a, s, l, c, u, d = this;
- if (this.autoplay = !1,
- this._loop = !1,
- this.useCustomAttenuation = !1,
- this.isPlaying = !1,
- this.isPaused = !1,
- this.refDistance = 1,
- this.rolloffFactor = 1,
- this.maxDistance = 100,
- this.distanceModel = "linear",
- this.metadata = null,
- this.onEndedObservable = new h,
- this._spatialSound = !1,
- this._panningModel = "equalpower",
- this._playbackRate = 1,
- this._streaming = !1,
- this._startTime = 0,
- this._startOffset = 0,
- this._position = x.Zero(),
- this._localDirection = new x(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 = t,
- n = n || E.LastCreatedScene)
- if (this._scene = n,
- e._SceneComponentInitialization(n),
- this._readyToPlayCallback = r,
- this._customAttenuationFunction = function(e, t, i, n, r) {
- return t < i ? e * (1 - t / i) : 0
- }
- ,
- o && (this.autoplay = o.autoplay || !1,
- this._loop = o.loop || !1,
- void 0 !== o.volume && (this._volume = o.volume),
- this._spatialSound = null !== (a = o.spatialSound) && void 0 !== a && a,
- this.maxDistance = null !== (s = o.maxDistance) && void 0 !== s ? s : 100,
- this.useCustomAttenuation = null !== (l = o.useCustomAttenuation) && void 0 !== l && l,
- this.rolloffFactor = o.rolloffFactor || 1,
- this.refDistance = o.refDistance || 1,
- this.distanceModel = o.distanceModel || "linear",
- this._playbackRate = o.playbackRate || 1,
- this._streaming = null !== (c = o.streaming) && void 0 !== c && c,
- this._length = o.length,
- this._offset = o.offset),
- (null === (u = vr.audioEngine) || void 0 === u ? void 0 : u.canUseWebAudio) && vr.audioEngine.audioContext) {
- this._soundGain = vr.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 p = !0;
- if (i)
- try {
- "string" == typeof i ? 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 f = []
- , _ = !1;
- switch (this._urlType) {
- case "MediaElement":
- this._streaming = !0,
- this._isReadyToPlay = !0,
- this._streamingSource = vr.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 = vr.audioEngine.audioContext.createMediaStreamSource(i),
- this.autoplay && this.play(0, this._offset, this._length),
- this._readyToPlayCallback && this._readyToPlayCallback();
- break;
- case "ArrayBuffer":
- i.byteLength > 0 && (_ = !0,
- this._soundLoaded(i));
- break;
- case "String":
- f.push(i);
- case "Array":
- 0 === f.length && (f = i);
- for (var m = function(e) {
- var t = f[e];
- if (_ = o && o.skipCodecCheck || -1 !== t.indexOf(".mp3", t.length - 4) && vr.audioEngine.isMP3supported || -1 !== t.indexOf(".ogg", t.length - 4) && vr.audioEngine.isOGGsupported || -1 !== t.indexOf(".wav", t.length - 4) || -1 !== t.indexOf(".m4a", t.length - 4) || -1 !== t.indexOf(".mp4", t.length - 4) || -1 !== t.indexOf("blob:"))
- return g._streaming ? (g._htmlAudioElement = new Audio(t),
- g._htmlAudioElement.controls = !1,
- g._htmlAudioElement.loop = g.loop,
- gi.SetCorsBehavior(t, g._htmlAudioElement),
- g._htmlAudioElement.preload = "auto",
- g._htmlAudioElement.addEventListener("canplaythrough", (function() {
- d._isReadyToPlay = !0,
- d.autoplay && d.play(0, d._offset, d._length),
- d._readyToPlayCallback && d._readyToPlayCallback()
- }
- )),
- document.body.appendChild(g._htmlAudioElement),
- g._htmlAudioElement.load()) : g._scene._loadFile(t, (function(e) {
- d._soundLoaded(e)
- }
- ), void 0, !0, !0, (function(e) {
- e && K.Error("XHR " + e.status + " error on: " + t + "."),
- K.Error("Sound creation aborted."),
- d._scene.mainSoundTrack.removeSound(d)
- }
- )),
- "break"
- }, g = this, v = 0; v < f.length && "break" !== m(v); v++)
- ;
- break;
- default:
- p = !1
- }
- p ? _ || (this._isReadyToPlay = !0,
- this._readyToPlayCallback && window.setTimeout((function() {
- d._readyToPlayCallback && d._readyToPlayCallback()
- }
- ), 1e3)) : K.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")
- } catch (e) {
- K.Error("Unexpected error. Sound creation aborted."),
- this._scene.mainSoundTrack.removeSound(this)
- }
- } else
- this._scene.mainSoundTrack.addSound(this),
- vr.audioEngine && !vr.audioEngine.WarnedWebAudioUnsupported && (K.Error("Web Audio is not supported by your browser."),
- vr.audioEngine.WarnedWebAudioUnsupported = !0),
- this._readyToPlayCallback && window.setTimeout((function() {
- d._readyToPlayCallback && d._readyToPlayCallback()
- }
- ), 1e3)
- }
- return Object.defineProperty(e.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(e.prototype, "currentTime", {
- get: function() {
- var e;
- if (this._htmlAudioElement)
- return this._htmlAudioElement.currentTime;
- var t = this._startOffset;
- return this.isPlaying && (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (t += vr.audioEngine.audioContext.currentTime - this._startTime),
- t
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "spatialSound", {
- get: function() {
- return this._spatialSound
- },
- set: function(e) {
- var t;
- this._spatialSound = e,
- this._spatialSound && (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && vr.audioEngine.audioContext && this._createSpatialParameters()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- var e;
- (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && (this.isPlaying && this.stop(),
- this._isReadyToPlay = !1,
- -1 === this.soundTrackId ? 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))
- }
- ,
- e.prototype.isReady = function() {
- return this._isReadyToPlay
- }
- ,
- e.prototype.getClassName = function() {
- return "Sound"
- }
- ,
- e.prototype._soundLoaded = function(e) {
- var t, i = this;
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.audioContext) && vr.audioEngine.audioContext.decodeAudioData(e, (function(e) {
- i._audioBuffer = e,
- i._isReadyToPlay = !0,
- i.autoplay && i.play(0, i._offset, i._length),
- i._readyToPlayCallback && i._readyToPlayCallback()
- }
- ), (function(e) {
- K.Error("Error while decoding audio data for: " + i.name + " / Error: " + e)
- }
- ))
- }
- ,
- e.prototype.setAudioBuffer = function(e) {
- var t;
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && (this._audioBuffer = e,
- this._isReadyToPlay = !0)
- }
- ,
- e.prototype.updateOptions = function(e) {
- var t, i, n, r, o, a, s, l, c, u;
- e && (this.loop = null !== (t = e.loop) && void 0 !== t ? t : this.loop,
- this.maxDistance = null !== (i = e.maxDistance) && void 0 !== i ? i : this.maxDistance,
- this.useCustomAttenuation = null !== (n = e.useCustomAttenuation) && void 0 !== n ? n : this.useCustomAttenuation,
- this.rolloffFactor = null !== (r = e.rolloffFactor) && void 0 !== r ? r : this.rolloffFactor,
- this.refDistance = null !== (o = e.refDistance) && void 0 !== o ? o : this.refDistance,
- this.distanceModel = null !== (a = e.distanceModel) && void 0 !== a ? a : this.distanceModel,
- this._playbackRate = null !== (s = e.playbackRate) && void 0 !== s ? s : this._playbackRate,
- this._length = null !== (l = e.length) && void 0 !== l ? l : void 0,
- this._offset = null !== (c = e.offset) && void 0 !== c ? c : void 0,
- this.setVolume(null !== (u = e.volume) && void 0 !== u ? u : this._volume),
- 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),
- void 0 !== this._offset && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset),
- void 0 !== this._length && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (0 | this._offset) + this._length))))
- }
- ,
- e.prototype._createSpatialParameters = function() {
- var e, t;
- (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && vr.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"),
- this._soundPanner = null !== (t = this._soundPanner) && void 0 !== t ? t : vr.audioEngine.audioContext.createPanner(),
- this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(),
- this._soundPanner.connect(this._outputAudioNode),
- this._inputAudioNode = this._soundPanner))
- }
- ,
- e.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))
- }
- ,
- e.prototype.switchPanningModelToHRTF = function() {
- this._panningModel = "HRTF",
- this._switchPanningModel()
- }
- ,
- e.prototype.switchPanningModelToEqualPower = function() {
- this._panningModel = "equalpower",
- this._switchPanningModel()
- }
- ,
- e.prototype._switchPanningModel = function() {
- var e;
- (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel)
- }
- ,
- e.prototype.connectToSoundTrackAudioNode = function(e) {
- var t;
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(),
- this._outputAudioNode.connect(e),
- this._isOutputConnected = !0)
- }
- ,
- e.prototype.setDirectionalCone = function(e, t, i) {
- t < e ? K.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.") : (this._coneInnerAngle = e,
- this._coneOuterAngle = t,
- this._coneOuterGain = i,
- this._isDirectional = !0,
- this.isPlaying && this.loop && (this.stop(),
- this.play(0, this._offset, this._length)))
- }
- ,
- Object.defineProperty(e.prototype, "directionalConeInnerAngle", {
- get: function() {
- return this._coneInnerAngle
- },
- set: function(e) {
- var t;
- if (e != this._coneInnerAngle) {
- if (this._coneOuterAngle < e)
- return void K.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
- this._coneInnerAngle = e,
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "directionalConeOuterAngle", {
- get: function() {
- return this._coneOuterAngle
- },
- set: function(e) {
- var t;
- if (e != this._coneOuterAngle) {
- if (e < this._coneInnerAngle)
- return void K.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
- this._coneOuterAngle = e,
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setPosition = function(e) {
- var t;
- e.equals(this._position) || (this._position.copyFrom(e),
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z) && (this._soundPanner.positionX.value = this._position.x,
- this._soundPanner.positionY.value = this._position.y,
- this._soundPanner.positionZ.value = this._position.z))
- }
- ,
- e.prototype.setLocalDirectionToMesh = function(e) {
- var t;
- this._localDirection = e,
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._connectedTransformNode && this.isPlaying && this._updateDirection()
- }
- ,
- e.prototype._updateDirection = function() {
- if (this._connectedTransformNode && this._soundPanner) {
- var e = this._connectedTransformNode.getWorldMatrix()
- , t = x.TransformNormal(this._localDirection, e);
- t.normalize(),
- this._soundPanner.orientationX.value = t.x,
- this._soundPanner.orientationY.value = t.y,
- this._soundPanner.orientationZ.value = t.z
- }
- }
- ,
- e.prototype.updateDistanceFromListener = function() {
- var e;
- if ((null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
- var t = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
- this._soundGain.gain.value = this._customAttenuationFunction(this._volume, t, this.maxDistance, this.refDistance, this.rolloffFactor)
- }
- }
- ,
- e.prototype.setAttenuationFunction = function(e) {
- this._customAttenuationFunction = e
- }
- ,
- e.prototype.play = function(e, t, i) {
- var n, r, o, a, s = this;
- if (this._isReadyToPlay && this._scene.audioEnabled && (null === (n = vr.audioEngine) || void 0 === n ? void 0 : n.audioContext))
- try {
- this._startOffset < 0 && (e = -this._startOffset,
- this._startOffset = 0);
- var l = e ? (null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.audioContext.currentTime) + e : null === (o = vr.audioEngine) || void 0 === o ? void 0 : o.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.positionX.value = this._position.x,
- this._soundPanner.positionY.value = this._position.y,
- this._soundPanner.positionZ.value = 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 = vr.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 c = function() {
- var e, t;
- if (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.unlocked) {
- var i = s._htmlAudioElement.play();
- void 0 !== i && i.catch((function() {
- var e, t;
- null === (e = vr.audioEngine) || void 0 === e || e.lock(),
- (s.loop || s.autoplay) && (null === (t = vr.audioEngine) || void 0 === t || t.onAudioUnlockedObservable.addOnce((function() {
- c()
- }
- )))
- }
- ))
- } else
- (s.loop || s.autoplay) && (null === (t = vr.audioEngine) || void 0 === t || t.onAudioUnlockedObservable.addOnce((function() {
- c()
- }
- )))
- };
- c()
- }
- } else {
- var u = function() {
- var n, r, o;
- if (null === (n = vr.audioEngine) || void 0 === n ? void 0 : n.audioContext) {
- if (i = i || s._length,
- t = t || s._offset,
- s._soundSource) {
- var a = s._soundSource;
- a.onended = function() {
- a.disconnect()
- }
- }
- if (s._soundSource = null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.audioContext.createBufferSource(),
- s._soundSource && s._inputAudioNode) {
- s._soundSource.buffer = s._audioBuffer,
- s._soundSource.connect(s._inputAudioNode),
- s._soundSource.loop = s.loop,
- void 0 !== t && (s._soundSource.loopStart = t),
- void 0 !== i && (s._soundSource.loopEnd = (0 | t) + i),
- s._soundSource.playbackRate.value = s._playbackRate,
- s._soundSource.onended = function() {
- s._onended()
- }
- ,
- l = e ? (null === (o = vr.audioEngine) || void 0 === o ? void 0 : o.audioContext.currentTime) + e : vr.audioEngine.audioContext.currentTime;
- var c = s.isPaused ? s._startOffset % s._soundSource.buffer.duration : t || 0;
- s._soundSource.start(l, c, s.loop ? void 0 : i)
- }
- }
- };
- "suspended" === (null === (a = vr.audioEngine) || void 0 === a ? void 0 : a.audioContext.state) ? setTimeout((function() {
- var e;
- "suspended" === (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext.state) ? (vr.audioEngine.lock(),
- (s.loop || s.autoplay) && vr.audioEngine.onAudioUnlockedObservable.addOnce((function() {
- u()
- }
- ))) : u()
- }
- ), 500) : u()
- }
- this._startTime = l,
- this.isPlaying = !0,
- this.isPaused = !1
- } catch (e) {
- K.Error("Error while trying to play audio: " + this.name + ", " + e.message)
- }
- }
- ,
- e.prototype._onended = function() {
- this.isPlaying = !1,
- this._startOffset = 0,
- this.onended && this.onended(),
- this.onEndedObservable.notifyObservers(this)
- }
- ,
- e.prototype.stop = function(e) {
- var t, i = this;
- 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 ((null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.audioContext) && this._soundSource) {
- var n = e ? vr.audioEngine.audioContext.currentTime + e : void 0;
- this._soundSource.stop(n),
- void 0 === n ? (this.isPlaying = !1,
- this._soundSource.onended = function() {}
- ) : this._soundSource.onended = function() {
- i.isPlaying = !1
- }
- ,
- this.isPaused || (this._startOffset = 0)
- }
- }
- ,
- e.prototype.pause = function() {
- var e;
- this.isPlaying && (this.isPaused = !0,
- this._streaming ? (this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect(),
- this.isPlaying = !1) : (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.audioContext) && (this.stop(0),
- this._startOffset += vr.audioEngine.audioContext.currentTime - this._startTime))
- }
- ,
- e.prototype.setVolume = function(e, t) {
- var i;
- (null === (i = vr.audioEngine) || void 0 === i ? void 0 : i.canUseWebAudio) && this._soundGain && (t && vr.audioEngine.audioContext ? (this._soundGain.gain.cancelScheduledValues(vr.audioEngine.audioContext.currentTime),
- this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, vr.audioEngine.audioContext.currentTime),
- this._soundGain.gain.linearRampToValueAtTime(e, vr.audioEngine.audioContext.currentTime + t)) : this._soundGain.gain.value = e),
- this._volume = e
- }
- ,
- e.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))
- }
- ,
- e.prototype.getVolume = function() {
- return this._volume
- }
- ,
- e.prototype.attachToMesh = function(e) {
- var t = 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(e) {
- return t._onRegisterAfterWorldMatrixUpdate(e)
- }
- ,
- this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)
- }
- ,
- e.prototype.detachFromMesh = function() {
- this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
- this._registerFunc = null,
- this._connectedTransformNode = null)
- }
- ,
- e.prototype._onRegisterAfterWorldMatrixUpdate = function(e) {
- var t;
- if (e.getBoundingInfo) {
- var i = e.getBoundingInfo();
- this.setPosition(i.boundingSphere.centerWorld)
- } else
- this.setPosition(e.absolutePosition);
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._isDirectional && this.isPlaying && this._updateDirection()
- }
- ,
- e.prototype.clone = function() {
- var t = this;
- if (this._streaming)
- return null;
- var i = function() {
- t._isReadyToPlay ? (r._audioBuffer = t.getAudioBuffer(),
- r._isReadyToPlay = !0,
- r.autoplay && r.play(0, t._offset, t._length)) : window.setTimeout(i, 300)
- }
- , n = {
- 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
- }
- , r = new e(this.name + "_cloned",new ArrayBuffer(0),this._scene,null,n);
- return this.useCustomAttenuation && r.setAttenuationFunction(this._customAttenuationFunction),
- r.setPosition(this._position),
- r.setPlaybackRate(this._playbackRate),
- i(),
- r
- }
- ,
- e.prototype.getAudioBuffer = function() {
- return this._audioBuffer
- }
- ,
- e.prototype.getSoundSource = function() {
- return this._soundSource
- }
- ,
- e.prototype.getSoundGain = function() {
- return this._soundGain
- }
- ,
- e.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
- }
- ,
- e.Parse = function(t, i, n, r) {
- var o, a = t.name;
- o = t.url ? n + t.url : n + a;
- var s, l = {
- autoplay: t.autoplay,
- loop: t.loop,
- volume: t.volume,
- spatialSound: t.spatialSound,
- maxDistance: t.maxDistance,
- rolloffFactor: t.rolloffFactor,
- refDistance: t.refDistance,
- distanceModel: t.distanceModel,
- playbackRate: t.playbackRate
- };
- if (r) {
- var c = function() {
- r._isReadyToPlay ? (s._audioBuffer = r.getAudioBuffer(),
- s._isReadyToPlay = !0,
- s.autoplay && s.play(0, s._offset, s._length)) : window.setTimeout(c, 300)
- };
- s = new e(a,new ArrayBuffer(0),i,null,l),
- c()
- } else
- s = new e(a,o,i,(function() {
- i._removePendingData(s)
- }
- ),l),
- i._addPendingData(s);
- if (t.position) {
- var u = x.FromArray(t.position);
- s.setPosition(u)
- }
- if (t.isDirectional && (s.setDirectionalCone(t.coneInnerAngle || 360, t.coneOuterAngle || 360, t.coneOuterGain || 0),
- t.localDirectionToMesh)) {
- var h = x.FromArray(t.localDirectionToMesh);
- s.setLocalDirectionToMesh(h)
- }
- if (t.connectedMeshId) {
- var d = i.getMeshById(t.connectedMeshId);
- d && s.attachToMesh(d)
- }
- return t.metadata && (s.metadata = t.metadata),
- s
- }
- ,
- e._SceneComponentInitialization = function(e) {
- throw be("AudioSceneComponent")
- }
- ,
- e
- }()
- , jr = function() {
- function e(e, t) {
- void 0 === t && (t = {}),
- this.id = -1,
- this._isInitialized = !1,
- (e = e || E.LastCreatedScene) && (this._scene = e,
- this.soundCollection = new Array,
- this._options = t,
- !this._options.mainTrack && this._scene.soundTracks && (this._scene.soundTracks.push(this),
- this.id = this._scene.soundTracks.length - 1))
- }
- return e.prototype._initializeSoundTrackAudioGraph = function() {
- var e;
- (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio) && vr.audioEngine.audioContext && (this._outputAudioNode = vr.audioEngine.audioContext.createGain(),
- this._outputAudioNode.connect(vr.audioEngine.masterGain),
- this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume),
- this._isInitialized = !0)
- }
- ,
- e.prototype.dispose = function() {
- if (vr.audioEngine && vr.audioEngine.canUseWebAudio) {
- for (this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(); this.soundCollection.length; )
- this.soundCollection[0].dispose();
- this._outputAudioNode && this._outputAudioNode.disconnect(),
- this._outputAudioNode = null
- }
- }
- ,
- e.prototype.addSound = function(e) {
- var t;
- this._isInitialized || this._initializeSoundTrackAudioGraph(),
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && e.connectToSoundTrackAudioNode(this._outputAudioNode),
- e.soundTrackId && (-1 === e.soundTrackId ? this._scene.mainSoundTrack.removeSound(e) : this._scene.soundTracks && this._scene.soundTracks[e.soundTrackId].removeSound(e)),
- this.soundCollection.push(e),
- e.soundTrackId = this.id
- }
- ,
- e.prototype.removeSound = function(e) {
- var t = this.soundCollection.indexOf(e);
- -1 !== t && this.soundCollection.splice(t, 1)
- }
- ,
- e.prototype.setVolume = function(e) {
- var t;
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.gain.value = e)
- }
- ,
- e.prototype.switchPanningModelToHRTF = function() {
- var e;
- if (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio)
- for (var t = 0; t < this.soundCollection.length; t++)
- this.soundCollection[t].switchPanningModelToHRTF()
- }
- ,
- e.prototype.switchPanningModelToEqualPower = function() {
- var e;
- if (null === (e = vr.audioEngine) || void 0 === e ? void 0 : e.canUseWebAudio)
- for (var t = 0; t < this.soundCollection.length; t++)
- this.soundCollection[t].switchPanningModelToEqualPower()
- }
- ,
- e.prototype.connectToAnalyser = function(e) {
- var t;
- this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
- this._connectedAnalyser = e,
- (null === (t = vr.audioEngine) || void 0 === t ? void 0 : t.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.disconnect(),
- this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, vr.audioEngine.masterGain))
- }
- ,
- e
- }();
- o.AddParser(Wi.NAME_AUDIO, (function(e, t, i, n) {
- var r, o, a = [];
- if (i.sounds = i.sounds || [],
- void 0 !== e.sounds && null !== e.sounds)
- for (var s = 0, l = e.sounds.length; s < l; s++) {
- var c = e.sounds[s];
- (null === (r = vr.audioEngine) || void 0 === r ? void 0 : r.canUseWebAudio) ? (c.url || (c.url = c.name),
- a[c.url] ? i.sounds.push(Xr.Parse(c, t, n, a[c.url])) : (o = Xr.Parse(c, t, n),
- a[c.url] = o,
- i.sounds.push(o))) : i.sounds.push(new Xr(c.name,null,t))
- }
- a = []
- }
- )),
- Object.defineProperty(mn.prototype, "mainSoundTrack", {
- get: function() {
- var e = this._getComponent(Wi.NAME_AUDIO);
- return e || (e = new Yr(this),
- this._addComponent(e)),
- this._mainSoundTrack || (this._mainSoundTrack = new jr(this,{
- mainTrack: !0
- })),
- this._mainSoundTrack
- },
- enumerable: !0,
- configurable: !0
- }),
- mn.prototype.getSoundByName = function(e) {
- var t;
- for (t = 0; t < this.mainSoundTrack.soundCollection.length; t++)
- if (this.mainSoundTrack.soundCollection[t].name === e)
- return this.mainSoundTrack.soundCollection[t];
- if (this.soundTracks)
- for (var i = 0; i < this.soundTracks.length; i++)
- for (t = 0; t < this.soundTracks[i].soundCollection.length; t++)
- if (this.soundTracks[i].soundCollection[t].name === e)
- return this.soundTracks[i].soundCollection[t];
- return null
- }
- ,
- Object.defineProperty(mn.prototype, "audioEnabled", {
- get: function() {
- var e = this._getComponent(Wi.NAME_AUDIO);
- return e || (e = new Yr(this),
- this._addComponent(e)),
- e.audioEnabled
- },
- set: function(e) {
- var t = this._getComponent(Wi.NAME_AUDIO);
- t || (t = new Yr(this),
- this._addComponent(t)),
- e ? t.enableAudio() : t.disableAudio()
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(mn.prototype, "headphone", {
- get: function() {
- var e = this._getComponent(Wi.NAME_AUDIO);
- return e || (e = new Yr(this),
- this._addComponent(e)),
- e.headphone
- },
- set: function(e) {
- var t = this._getComponent(Wi.NAME_AUDIO);
- t || (t = new Yr(this),
- this._addComponent(t)),
- e ? t.switchAudioModeForHeadphones() : t.switchAudioModeForNormalSpeakers()
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(mn.prototype, "audioListenerPositionProvider", {
- get: function() {
- var e = this._getComponent(Wi.NAME_AUDIO);
- return e || (e = new Yr(this),
- this._addComponent(e)),
- e.audioListenerPositionProvider
- },
- set: function(e) {
- var t = this._getComponent(Wi.NAME_AUDIO);
- if (t || (t = new Yr(this),
- this._addComponent(t)),
- "function" != typeof e)
- throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
- t.audioListenerPositionProvider = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(mn.prototype, "audioPositioningRefreshRate", {
- get: function() {
- var e = this._getComponent(Wi.NAME_AUDIO);
- return e || (e = new Yr(this),
- this._addComponent(e)),
- e.audioPositioningRefreshRate
- },
- set: function(e) {
- var t = this._getComponent(Wi.NAME_AUDIO);
- t || (t = new Yr(this),
- this._addComponent(t)),
- t.audioPositioningRefreshRate = e
- },
- enumerable: !0,
- configurable: !0
- });
- var Yr = function() {
- function e(e) {
- this.name = Wi.NAME_AUDIO,
- this._audioEnabled = !0,
- this._headphone = !1,
- this.audioPositioningRefreshRate = 500,
- this._audioListenerPositionProvider = null,
- this._cachedCameraDirection = new x,
- this._cachedCameraPosition = new x,
- this._lastCheck = 0,
- (e = e || E.LastCreatedScene) && (this.scene = e,
- e.soundTracks = new Array,
- e.sounds = new Array)
- }
- return Object.defineProperty(e.prototype, "audioEnabled", {
- get: function() {
- return this._audioEnabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "headphone", {
- get: function() {
- return this._headphone
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "audioListenerPositionProvider", {
- get: function() {
- return this._audioListenerPositionProvider
- },
- set: function(e) {
- this._audioListenerPositionProvider = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.register = function() {
- this.scene._afterRenderStage.registerStep(Wi.STEP_AFTERRENDER_AUDIO, this, this._afterRender)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.serialize = function(e) {
- if (e.sounds = [],
- this.scene.soundTracks)
- for (var t = 0; t < this.scene.soundTracks.length; t++)
- for (var i = this.scene.soundTracks[t], n = 0; n < i.soundCollection.length; n++)
- e.sounds.push(i.soundCollection[n].serialize())
- }
- ,
- e.prototype.addFromContainer = function(e) {
- var t = this;
- e.sounds && e.sounds.forEach((function(e) {
- e.play(),
- e.autoplay = !0,
- t.scene.mainSoundTrack.addSound(e)
- }
- ))
- }
- ,
- e.prototype.removeFromContainer = function(e, t) {
- var i = this;
- void 0 === t && (t = !1),
- e.sounds && e.sounds.forEach((function(e) {
- e.stop(),
- e.autoplay = !1,
- i.scene.mainSoundTrack.removeSound(e),
- t && e.dispose()
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- var e = this.scene;
- if (e._mainSoundTrack && e.mainSoundTrack.dispose(),
- e.soundTracks)
- for (var t = 0; t < e.soundTracks.length; t++)
- e.soundTracks[t].dispose()
- }
- ,
- e.prototype.disableAudio = function() {
- var e, t = this.scene;
- for (this._audioEnabled = !1,
- vr.audioEngine && vr.audioEngine.audioContext && vr.audioEngine.audioContext.suspend(),
- e = 0; e < t.mainSoundTrack.soundCollection.length; e++)
- t.mainSoundTrack.soundCollection[e].pause();
- if (t.soundTracks)
- for (e = 0; e < t.soundTracks.length; e++)
- for (var i = 0; i < t.soundTracks[e].soundCollection.length; i++)
- t.soundTracks[e].soundCollection[i].pause()
- }
- ,
- e.prototype.enableAudio = function() {
- var e, t = this.scene;
- for (this._audioEnabled = !0,
- vr.audioEngine && vr.audioEngine.audioContext && vr.audioEngine.audioContext.resume(),
- e = 0; e < t.mainSoundTrack.soundCollection.length; e++)
- t.mainSoundTrack.soundCollection[e].isPaused && t.mainSoundTrack.soundCollection[e].play();
- if (t.soundTracks)
- for (e = 0; e < t.soundTracks.length; e++)
- for (var i = 0; i < t.soundTracks[e].soundCollection.length; i++)
- t.soundTracks[e].soundCollection[i].isPaused && t.soundTracks[e].soundCollection[i].play()
- }
- ,
- e.prototype.switchAudioModeForHeadphones = function() {
- var e = this.scene;
- if (this._headphone = !0,
- e.mainSoundTrack.switchPanningModelToHRTF(),
- e.soundTracks)
- for (var t = 0; t < e.soundTracks.length; t++)
- e.soundTracks[t].switchPanningModelToHRTF()
- }
- ,
- e.prototype.switchAudioModeForNormalSpeakers = function() {
- var e = this.scene;
- if (this._headphone = !1,
- e.mainSoundTrack.switchPanningModelToEqualPower(),
- e.soundTracks)
- for (var t = 0; t < e.soundTracks.length; t++)
- e.soundTracks[t].switchPanningModelToEqualPower()
- }
- ,
- e.prototype._afterRender = function() {
- var t = ct.Now;
- if (!(this._lastCheck && t - this._lastCheck < this.audioPositioningRefreshRate)) {
- this._lastCheck = t;
- var i = this.scene;
- if (this._audioEnabled && i._mainSoundTrack && i.soundTracks && (0 !== i._mainSoundTrack.soundCollection.length || 1 !== i.soundTracks.length)) {
- var n = vr.audioEngine;
- if (n && n.audioContext) {
- if (this._audioListenerPositionProvider) {
- var r = this._audioListenerPositionProvider();
- r.x = r.x || 0,
- r.y = r.y || 0,
- r.z = r.z || 0,
- n.audioContext.listener.setPosition(r.x, r.y, r.z)
- } else {
- var o = void 0;
- if (o = i.activeCameras && i.activeCameras.length > 0 ? i.activeCameras[0] : i.activeCamera) {
- this._cachedCameraPosition.equals(o.globalPosition) || (this._cachedCameraPosition.copyFrom(o.globalPosition),
- n.audioContext.listener.setPosition(o.globalPosition.x, o.globalPosition.y, o.globalPosition.z)),
- o.rigCameras && o.rigCameras.length > 0 && (o = o.rigCameras[0]);
- var a = P.Invert(o.getViewMatrix())
- , s = x.TransformNormal(e._CameraDirection, a);
- s.normalize(),
- isNaN(s.x) || isNaN(s.y) || isNaN(s.z) || this._cachedCameraDirection.equals(s) || (this._cachedCameraDirection.copyFrom(s),
- n.audioContext.listener.setOrientation(s.x, s.y, s.z, 0, 1, 0))
- } else
- n.audioContext.listener.setPosition(0, 0, 0)
- }
- var l = void 0;
- for (l = 0; l < i.mainSoundTrack.soundCollection.length; l++)
- (u = i.mainSoundTrack.soundCollection[l]).useCustomAttenuation && u.updateDistanceFromListener();
- if (i.soundTracks)
- for (l = 0; l < i.soundTracks.length; l++)
- for (var c = 0; c < i.soundTracks[l].soundCollection.length; c++) {
- var u;
- (u = i.soundTracks[l].soundCollection[c]).useCustomAttenuation && u.updateDistanceFromListener()
- }
- }
- }
- }
- }
- ,
- e._CameraDirection = new x(0,0,-1),
- e
- }();
- Xr._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_AUDIO);
- t || (t = new Yr(e),
- e._addComponent(t))
- }
- ;
- var Kr = function() {
- function e(e, t, i) {
- var n = this;
- if (this.loop = !1,
- this._coneInnerAngle = 360,
- this._coneOuterAngle = 360,
- this._volume = 1,
- this.isPlaying = !1,
- this.isPaused = !1,
- this._sounds = [],
- this._weights = [],
- t.length !== i.length)
- throw new Error("Sounds length does not equal weights length");
- this.loop = e,
- this._weights = i;
- for (var r = 0, o = 0, a = i; o < a.length; o++)
- r += a[o];
- for (var s = r > 0 ? 1 / r : 0, l = 0; l < this._weights.length; l++)
- this._weights[l] *= s;
- this._sounds = t;
- for (var c = 0, u = this._sounds; c < u.length; c++)
- u[c].onEndedObservable.add((function() {
- n._onended()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "directionalConeInnerAngle", {
- get: function() {
- return this._coneInnerAngle
- },
- set: function(e) {
- if (e !== this._coneInnerAngle) {
- if (this._coneOuterAngle < e)
- return void K.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
- this._coneInnerAngle = e;
- for (var t = 0, i = this._sounds; t < i.length; t++)
- i[t].directionalConeInnerAngle = e
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "directionalConeOuterAngle", {
- get: function() {
- return this._coneOuterAngle
- },
- set: function(e) {
- if (e !== this._coneOuterAngle) {
- if (e < this._coneInnerAngle)
- return void K.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
- this._coneOuterAngle = e;
- for (var t = 0, i = this._sounds; t < i.length; t++)
- i[t].directionalConeOuterAngle = e
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "volume", {
- get: function() {
- return this._volume
- },
- set: function(e) {
- if (e !== this._volume)
- for (var t = 0, i = this._sounds; t < i.length; t++)
- i[t].setVolume(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._onended = function() {
- void 0 !== this._currentIndex && (this._sounds[this._currentIndex].autoplay = !1),
- this.loop && this.isPlaying ? this.play() : this.isPlaying = !1
- }
- ,
- e.prototype.pause = function() {
- this.isPaused = !0,
- void 0 !== this._currentIndex && this._sounds[this._currentIndex].pause()
- }
- ,
- e.prototype.stop = function() {
- this.isPlaying = !1,
- void 0 !== this._currentIndex && this._sounds[this._currentIndex].stop()
- }
- ,
- e.prototype.play = function(e) {
- if (!this.isPaused) {
- this.stop();
- for (var t = Math.random(), i = 0, n = 0; n < this._weights.length; n++)
- if (t <= (i += this._weights[n])) {
- this._currentIndex = n;
- break
- }
- }
- var r = this._sounds[this._currentIndex];
- r.isReady() ? r.play(0, this.isPaused ? void 0 : e) : r.autoplay = !0,
- this.isPlaying = !0,
- this.isPaused = !1
- }
- ,
- e
- }()
- , Qr = function() {
- function e(e) {
- this._texture = null,
- this._isEnabled = !0,
- this.isEnabled = !0,
- this.time = 0,
- (e = e || E.LastCreatedScene) && (this._scene = e,
- this.animationParameters = new R(0,0,0,30))
- }
- return e.prototype._markSubMeshesAsAttributesDirty = function() {
- for (var e = 0, t = this._scene.meshes; e < t.length; e++) {
- var i = t[e];
- i.bakedVertexAnimationManager === this && i._markSubMeshesAsAttributesDirty()
- }
- }
- ,
- e.prototype.bind = function(e, t) {
- if (void 0 === t && (t = !1),
- this._texture && this._isEnabled) {
- var i = this._texture.getSize();
- e.setFloat2("bakedVertexAnimationTextureSizeInverted", 1 / i.width, 1 / i.height),
- e.setFloat("bakedVertexAnimationTime", this.time),
- t || e.setVector4("bakedVertexAnimationSettings", this.animationParameters),
- e.setTexture("bakedVertexAnimationTexture", this._texture)
- }
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this._scene);
- return this.copyTo(t),
- t
- }
- ,
- e.prototype.setAnimationParameters = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 30),
- this.animationParameters = new R(e,t,i,n)
- }
- ,
- e.prototype.dispose = function(e) {
- var t;
- e && (null === (t = this._texture) || void 0 === t || t.dispose())
- }
- ,
- e.prototype.getClassName = function() {
- return "BakedVertexAnimationManager"
- }
- ,
- e.prototype.copyTo = function(e) {
- Ge.Clone((function() {
- return e
- }
- ), this)
- }
- ,
- e.prototype.serialize = function() {
- return Ge.Serialize(this)
- }
- ,
- e.prototype.parse = function(e, t, i) {
- var n = this;
- Ge.Parse((function() {
- return n
- }
- ), e, t, i)
- }
- ,
- k([Pe(), Re("_markSubMeshesAsAttributesDirty")], e.prototype, "texture", void 0),
- k([Ce(), Re("_markSubMeshesAsAttributesDirty")], e.prototype, "isEnabled", void 0),
- k([Ce()], e.prototype, "animationParameters", void 0),
- k([Ce()], e.prototype, "time", void 0),
- e
- }()
- , qr = function() {
- function e(e) {
- this._wrapU = a.TEXTURE_WRAP_ADDRESSMODE,
- this._wrapV = a.TEXTURE_WRAP_ADDRESSMODE,
- this.wrapR = a.TEXTURE_WRAP_ADDRESSMODE,
- this.anisotropicFilteringLevel = 4,
- this.delayLoadState = a.DELAYLOADSTATE_NONE,
- this._texture = null,
- this._engine = null,
- this._cachedSize = je.Zero(),
- this._cachedBaseSize = je.Zero(),
- this._initialSamplingMode = a.TEXTURE_BILINEAR_SAMPLINGMODE,
- this._texture = e,
- this._texture && (this._engine = this._texture.getEngine())
- }
- return Object.defineProperty(e.prototype, "wrapU", {
- get: function() {
- return this._wrapU
- },
- set: function(e) {
- this._wrapU = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wrapV", {
- get: function() {
- return this._wrapV
- },
- set: function(e) {
- this._wrapV = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "coordinatesMode", {
- get: function() {
- return 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isCube", {
- get: function() {
- return !!this._texture && this._texture.isCube
- },
- set: function(e) {
- this._texture && (this._texture.isCube = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "is3D", {
- get: function() {
- return !!this._texture && this._texture.is3D
- },
- set: function(e) {
- this._texture && (this._texture.is3D = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "is2DArray", {
- get: function() {
- return !!this._texture && this._texture.is2DArray
- },
- set: function(e) {
- this._texture && (this._texture.is2DArray = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ThinTexture"
- }
- ,
- e.prototype.isReady = function() {
- return this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED ? (this.delayLoad(),
- !1) : !!this._texture && this._texture.isReady
- }
- ,
- e.prototype.delayLoad = function() {}
- ,
- e.prototype.getInternalTexture = function() {
- return this._texture
- }
- ,
- e.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
- }
- ,
- e.prototype.getBaseSize = function() {
- return this.isReady() && this._texture ? 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) : (this._cachedBaseSize.width = 0,
- this._cachedBaseSize.height = 0,
- this._cachedBaseSize)
- }
- ,
- Object.defineProperty(e.prototype, "samplingMode", {
- get: function() {
- return this._texture ? this._texture.samplingMode : this._initialSamplingMode
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.updateSamplingMode = function(e) {
- this._texture && this._engine && this._engine.updateTextureSamplingMode(e, this._texture)
- }
- ,
- e.prototype.releaseInternalTexture = function() {
- this._texture && (this._texture.dispose(),
- this._texture = null)
- }
- ,
- e.prototype.dispose = function() {
- this._texture && (this.releaseInternalTexture(),
- this._engine = null)
- }
- ,
- e
- }()
- , Zr = function(e) {
- function t(i) {
- var n = e.call(this, null) || this;
- return n.metadata = null,
- n.reservedDataStore = null,
- n._hasAlpha = !1,
- n._getAlphaFromRGB = !1,
- n.level = 1,
- n._coordinatesIndex = 0,
- n._coordinatesMode = a.TEXTURE_EXPLICIT_MODE,
- n.wrapR = a.TEXTURE_WRAP_ADDRESSMODE,
- n.anisotropicFilteringLevel = t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,
- n._isCube = !1,
- n._gammaSpace = !0,
- n.invertZ = !1,
- n.lodLevelInAlpha = !1,
- n.isRenderTarget = !1,
- n._prefiltered = !1,
- n._forceSerialize = !1,
- n.animations = new Array,
- n.onDisposeObservable = new h,
- n._onDisposeObserver = null,
- n._scene = null,
- n._uid = null,
- n._parentContainer = null,
- n._loadingError = !1,
- i ? t._IsScene(i) ? n._scene = i : n._engine = i : n._scene = E.LastCreatedScene,
- n._scene && (n.uniqueId = n._scene.getUniqueId(),
- n._scene.addTexture(n),
- n._engine = n._scene.getEngine()),
- n._uid = null,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "hasAlpha", {
- get: function() {
- return this._hasAlpha
- },
- set: function(e) {
- var t = this;
- this._hasAlpha !== e && (this._hasAlpha = e,
- this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(t)
- }
- )))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "getAlphaFromRGB", {
- get: function() {
- return this._getAlphaFromRGB
- },
- set: function(e) {
- var t = this;
- this._getAlphaFromRGB !== e && (this._getAlphaFromRGB = e,
- this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(t)
- }
- )))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "coordinatesIndex", {
- get: function() {
- return this._coordinatesIndex
- },
- set: function(e) {
- var t = this;
- this._coordinatesIndex !== e && (this._coordinatesIndex = e,
- this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(t)
- }
- )))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "coordinatesMode", {
- get: function() {
- return this._coordinatesMode
- },
- set: function(e) {
- var t = this;
- this._coordinatesMode !== e && (this._coordinatesMode = e,
- this._scene && this._scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(t)
- }
- )))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wrapU", {
- get: function() {
- return this._wrapU
- },
- set: function(e) {
- this._wrapU = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wrapV", {
- get: function() {
- return this._wrapV
- },
- set: function(e) {
- this._wrapV = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isCube", {
- get: function() {
- return this._texture ? this._texture.isCube : this._isCube
- },
- set: function(e) {
- this._texture ? this._texture.isCube = e : this._isCube = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "is3D", {
- get: function() {
- return !!this._texture && this._texture.is3D
- },
- set: function(e) {
- this._texture && (this._texture.is3D = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "is2DArray", {
- get: function() {
- return !!this._texture && this._texture.is2DArray
- },
- set: function(e) {
- this._texture && (this._texture.is2DArray = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "gammaSpace", {
- get: function() {
- return this._texture ? (null === this._texture._gammaSpace && (this._texture._gammaSpace = this._gammaSpace),
- this._texture._gammaSpace && !this._texture._useSRGBBuffer) : this._gammaSpace
- },
- set: function(e) {
- if (this._texture) {
- if (this._texture._gammaSpace === e)
- return;
- this._texture._gammaSpace = e
- } else {
- if (this._gammaSpace === e)
- return;
- this._gammaSpace = e
- }
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isRGBD", {
- get: function() {
- return null != this._texture && this._texture._isRGBD
- },
- set: function(e) {
- this._texture && (this._texture._isRGBD = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "noMipmap", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lodGenerationOffset", {
- get: function() {
- return this._texture ? this._texture._lodGenerationOffset : 0
- },
- set: function(e) {
- this._texture && (this._texture._lodGenerationOffset = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lodGenerationScale", {
- get: function() {
- return this._texture ? this._texture._lodGenerationScale : 0
- },
- set: function(e) {
- this._texture && (this._texture._lodGenerationScale = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "linearSpecularLOD", {
- get: function() {
- return !!this._texture && this._texture._linearSpecularLOD
- },
- set: function(e) {
- this._texture && (this._texture._linearSpecularLOD = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "irradianceTexture", {
- get: function() {
- return this._texture ? this._texture._irradianceTexture : null
- },
- set: function(e) {
- this._texture && (this._texture._irradianceTexture = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uid", {
- get: function() {
- return this._uid || (this._uid = fi()),
- this._uid
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.toString = function() {
- return this.name
- }
- ,
- t.prototype.getClassName = function() {
- return "BaseTexture"
- }
- ,
- Object.defineProperty(t.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isBlocking", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "loadingError", {
- get: function() {
- return this._loadingError
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "errorObject", {
- get: function() {
- return this._errorObject
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getScene = function() {
- return this._scene
- }
- ,
- t.prototype._getEngine = function() {
- return this._engine
- }
- ,
- t.prototype.checkTransformsAreIdentical = function(e) {
- return null !== e
- }
- ,
- t.prototype.getTextureMatrix = function() {
- return P.IdentityReadOnly
- }
- ,
- t.prototype.getReflectionTextureMatrix = function() {
- return P.IdentityReadOnly
- }
- ,
- t.prototype.isReadyOrNotBlocking = function() {
- return !this.isBlocking || this.isReady() || this.loadingError
- }
- ,
- t.prototype.scale = function(e) {}
- ,
- Object.defineProperty(t.prototype, "canRescale", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._getFromCache = function(e, t, i, n, r) {
- var o = this._getEngine();
- if (!o)
- return null;
- for (var a = o._getUseSRGBBuffer(!!r, t), s = o.getLoadedTexturesCache(), l = 0; l < s.length; l++) {
- var c = s[l];
- if ((void 0 === r || a === c._useSRGBBuffer) && !(void 0 !== n && n !== c.invertY || c.url !== e || c.generateMipMaps !== !t || i && i !== c.samplingMode))
- return c.incrementReferences(),
- c
- }
- return null
- }
- ,
- t.prototype._rebuild = function() {}
- ,
- t.prototype.clone = function() {
- return null
- }
- ,
- Object.defineProperty(t.prototype, "textureType", {
- get: function() {
- return this._texture && void 0 !== this._texture.type ? this._texture.type : a.TEXTURETYPE_UNSIGNED_INT
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "textureFormat", {
- get: function() {
- return this._texture && void 0 !== this._texture.format ? this._texture.format : a.TEXTUREFORMAT_RGBA
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._markAllSubMeshesAsTexturesDirty = function() {
- var e = this.getScene();
- e && e.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
- }
- ,
- t.prototype.readPixels = function(e, t, i, n, r) {
- if (void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = null),
- void 0 === n && (n = !0),
- void 0 === r && (r = !1),
- !this._texture)
- return null;
- var o = this.getSize()
- , a = o.width
- , s = o.height
- , l = this._getEngine();
- if (!l)
- return null;
- 0 != t && (a /= Math.pow(2, t),
- s /= Math.pow(2, t),
- a = Math.round(a),
- s = Math.round(s));
- try {
- return this._texture.isCube ? l._readTexturePixels(this._texture, a, s, e, t, i, n, r) : l._readTexturePixels(this._texture, a, s, -1, t, i, n, r)
- } catch (e) {
- return null
- }
- }
- ,
- t.prototype._readPixelsSync = function(e, t, i, n, r) {
- if (void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = null),
- void 0 === n && (n = !0),
- void 0 === r && (r = !1),
- !this._texture)
- return null;
- var o = this.getSize()
- , a = o.width
- , s = o.height
- , l = this._getEngine();
- if (!l)
- return null;
- 0 != t && (a /= Math.pow(2, t),
- s /= Math.pow(2, t),
- a = Math.round(a),
- s = Math.round(s));
- try {
- return this._texture.isCube ? l._readTexturePixelsSync(this._texture, a, s, e, t, i, n, r) : l._readTexturePixelsSync(this._texture, a, s, -1, t, i, n, r)
- } catch (e) {
- return null
- }
- }
- ,
- Object.defineProperty(t.prototype, "_lodTextureHigh", {
- get: function() {
- return this._texture ? this._texture._lodTextureHigh : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_lodTextureMid", {
- get: function() {
- return this._texture ? this._texture._lodTextureMid : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_lodTextureLow", {
- get: function() {
- return this._texture ? this._texture._lodTextureLow : null
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.dispose = function() {
- if (this._scene) {
- this._scene.stopAnimation && this._scene.stopAnimation(this),
- this._scene._removePendingData(this);
- var t = this._scene.textures.indexOf(this);
- if (t >= 0 && this._scene.textures.splice(t, 1),
- this._scene.onTextureRemovedObservable.notifyObservers(this),
- this._scene = null,
- this._parentContainer) {
- var i = this._parentContainer.textures.indexOf(this);
- i > -1 && this._parentContainer.textures.splice(i, 1),
- this._parentContainer = null
- }
- }
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.metadata = null,
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.serialize = function() {
- if (!this.name)
- return null;
- var e = Ge.Serialize(this);
- return Ge.AppendSerializedAnimations(this, e),
- e
- }
- ,
- t.WhenAllReady = function(e, t) {
- var i = e.length;
- if (0 !== i)
- for (var n = 0; n < e.length; n++) {
- var r = e[n];
- if (r.isReady())
- 0 == --i && t();
- else {
- var o = r.onLoadObservable;
- o && o.addOnce((function() {
- 0 == --i && t()
- }
- ))
- }
- }
- else
- t()
- }
- ,
- t._IsScene = function(e) {
- return "Scene" === e.getClassName()
- }
- ,
- t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4,
- k([Ce()], t.prototype, "uniqueId", void 0),
- k([Ce()], t.prototype, "name", void 0),
- k([Ce()], t.prototype, "metadata", void 0),
- k([Ce("hasAlpha")], t.prototype, "_hasAlpha", void 0),
- k([Ce("getAlphaFromRGB")], t.prototype, "_getAlphaFromRGB", void 0),
- k([Ce()], t.prototype, "level", void 0),
- k([Ce("coordinatesIndex")], t.prototype, "_coordinatesIndex", void 0),
- k([Ce("coordinatesMode")], t.prototype, "_coordinatesMode", void 0),
- k([Ce()], t.prototype, "wrapU", null),
- k([Ce()], t.prototype, "wrapV", null),
- k([Ce()], t.prototype, "wrapR", void 0),
- k([Ce()], t.prototype, "anisotropicFilteringLevel", void 0),
- k([Ce()], t.prototype, "isCube", null),
- k([Ce()], t.prototype, "is3D", null),
- k([Ce()], t.prototype, "is2DArray", null),
- k([Ce()], t.prototype, "gammaSpace", null),
- k([Ce()], t.prototype, "invertZ", void 0),
- k([Ce()], t.prototype, "lodLevelInAlpha", void 0),
- k([Ce()], t.prototype, "lodGenerationOffset", null),
- k([Ce()], t.prototype, "lodGenerationScale", null),
- k([Ce()], t.prototype, "linearSpecularLOD", null),
- k([Pe()], t.prototype, "irradianceTexture", null),
- k([Ce()], t.prototype, "isRenderTarget", void 0),
- t
- }(qr);
- function Jr(e, t, i) {
- void 0 === i && (i = !1);
- var n = t.width
- , r = t.height;
- if (e instanceof Float32Array) {
- for (var o = e.byteLength / e.BYTES_PER_ELEMENT, a = new Uint8Array(o); --o >= 0; ) {
- var s = e[o];
- s < 0 ? s = 0 : s > 1 && (s = 1),
- a[o] = 255 * s
- }
- e = a
- }
- var l = document.createElement("canvas");
- l.width = n,
- l.height = r;
- var c = l.getContext("2d");
- if (!c)
- return null;
- var u = c.createImageData(n, r);
- if (u.data.set(e),
- c.putImageData(u, 0, 0),
- i) {
- var h = document.createElement("canvas");
- h.width = n,
- h.height = r;
- var d = h.getContext("2d");
- return d ? (d.translate(0, r),
- d.scale(1, -1),
- d.drawImage(l, 0, 0),
- h.toDataURL("image/png")) : null
- }
- return l.toDataURL("image/png")
- }
- function $r(e, t, i) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 0);
- var n = e.getInternalTexture();
- if (!n)
- return null;
- var r = e._readPixelsSync(t, i);
- return r ? Jr(r, e.getSize(), n.invertY) : null
- }
- function eo(e, t, i) {
- return void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- G(this, void 0, void 0, (function() {
- var n, r;
- return z(this, (function(o) {
- switch (o.label) {
- case 0:
- return (n = e.getInternalTexture()) ? [4, e.readPixels(t, i)] : [2, null];
- case 1:
- return (r = o.sent()) ? [2, Jr(r, e.getSize(), n.invertY)] : [2, null]
- }
- }
- ))
- }
- ))
- }
- var to = {
- GenerateBase64StringFromPixelData: Jr,
- GenerateBase64StringFromTexture: $r,
- GenerateBase64StringFromTextureAsync: eo
- }
- , io = function(e) {
- function t(i, n, r, o, s, l, c, u, d, p, f, _, m) {
- void 0 === s && (s = t.TRILINEAR_SAMPLINGMODE),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === d && (d = !1);
- var g, v, y, b, T, E, S, A, x, R = this;
- (R = e.call(this, n) || this).url = null,
- R.uOffset = 0,
- R.vOffset = 0,
- R.uScale = 1,
- R.vScale = 1,
- R.uAng = 0,
- R.vAng = 0,
- R.wAng = 0,
- R.uRotationCenter = .5,
- R.vRotationCenter = .5,
- R.wRotationCenter = .5,
- R.homogeneousRotationInUVTransform = !1,
- R.inspectableCustomProperties = null,
- R._noMipmap = !1,
- R._invertY = !1,
- R._rowGenerationMatrix = null,
- R._cachedTextureMatrix = null,
- R._projectionModeMatrix = null,
- R._t0 = null,
- R._t1 = null,
- R._t2 = null,
- R._cachedUOffset = -1,
- R._cachedVOffset = -1,
- R._cachedUScale = 0,
- R._cachedVScale = 0,
- R._cachedUAng = -1,
- R._cachedVAng = -1,
- R._cachedWAng = -1,
- R._cachedProjectionMatrixId = -1,
- R._cachedURotationCenter = -1,
- R._cachedVRotationCenter = -1,
- R._cachedWRotationCenter = -1,
- R._cachedHomogeneousRotationInUVTransform = !1,
- R._cachedCoordinatesMode = -1,
- R._buffer = null,
- R._deleteBuffer = !1,
- R._format = null,
- R._delayedOnLoad = null,
- R._delayedOnError = null,
- R.onLoadObservable = new h,
- R._isBlocking = !0,
- R.name = i || "",
- R.url = i;
- var C = !1;
- "object" == typeof r && null !== r ? (x = null !== (g = r.noMipmap) && void 0 !== g && g,
- o = null !== (v = r.invertY) && void 0 !== v ? v : !pr.UseOpenGLOrientationForUV,
- s = null !== (y = r.samplingMode) && void 0 !== y ? y : t.TRILINEAR_SAMPLINGMODE,
- l = null !== (b = r.onLoad) && void 0 !== b ? b : null,
- c = null !== (T = r.onError) && void 0 !== T ? T : null,
- u = null !== (E = r.buffer) && void 0 !== E ? E : null,
- d = null !== (S = r.deleteBuffer) && void 0 !== S && S,
- p = r.format,
- f = r.mimeType,
- _ = r.loaderOptions,
- m = r.creationFlags,
- C = null !== (A = r.useSRGBBuffer) && void 0 !== A && A) : x = !!r,
- R._noMipmap = x,
- R._invertY = void 0 === o ? !pr.UseOpenGLOrientationForUV : o,
- R._initialSamplingMode = s,
- R._buffer = u,
- R._deleteBuffer = d,
- R._mimeType = f,
- R._loaderOptions = _,
- R._creationFlags = m,
- R._useSRGBBuffer = C,
- p && (R._format = p);
- var P = R.getScene()
- , M = R._getEngine();
- if (!M)
- return R;
- M.onBeforeTextureInitObservable.notifyObservers(R);
- var I = function() {
- R._texture && (R._texture._invertVScale && (R.vScale *= -1,
- R.vOffset += 1),
- null !== R._texture._cachedWrapU && (R.wrapU = R._texture._cachedWrapU,
- R._texture._cachedWrapU = null),
- null !== R._texture._cachedWrapV && (R.wrapV = R._texture._cachedWrapV,
- R._texture._cachedWrapV = null),
- null !== R._texture._cachedWrapR && (R.wrapR = R._texture._cachedWrapR,
- R._texture._cachedWrapR = null)),
- R.onLoadObservable.hasObservers() && R.onLoadObservable.notifyObservers(R),
- l && l(),
- !R.isBlocking && P && P.resetCachedMaterial()
- }
- , O = function(e, i) {
- R._loadingError = !0,
- R._errorObject = {
- message: e,
- exception: i
- },
- c && c(e, i),
- t.OnTextureLoadErrorObservable.notifyObservers(R)
- };
- if (!R.url)
- return R._delayedOnLoad = I,
- R._delayedOnError = O,
- R;
- if (R._texture = R._getFromCache(R.url, x, s, R._invertY, C),
- R._texture)
- if (R._texture.isReady)
- Xt.SetImmediate((function() {
- return I()
- }
- ));
- else {
- var D = R._texture.onLoadedObservable.add(I);
- R._texture.onErrorObservable.add((function(e) {
- var t;
- O(e.message, e.exception),
- null === (t = R._texture) || void 0 === t || t.onLoadedObservable.remove(D)
- }
- ))
- }
- else if (P && P.useDelayedTextureLoading)
- R.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
- R._delayedOnLoad = I,
- R._delayedOnError = O;
- else {
- try {
- R._texture = M.createTexture(R.url, x, R._invertY, P, s, I, O, R._buffer, void 0, R._format, null, f, _, m, C)
- } catch (e) {
- throw O("error loading", e),
- e
- }
- d && (R._buffer = null)
- }
- return R
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "noMipmap", {
- get: function() {
- return this._noMipmap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "mimeType", {
- get: function() {
- return this._mimeType
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isBlocking", {
- get: function() {
- return this._isBlocking
- },
- set: function(e) {
- this._isBlocking = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "invertY", {
- get: function() {
- return this._invertY
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.updateURL = function(e, t, i) {
- void 0 === t && (t = null),
- this.url && (this.releaseInternalTexture(),
- this.getScene().markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),
- this.name && !ae(this.name, "data:") || (this.name = e),
- this.url = e,
- this._buffer = t,
- this.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
- i && (this._delayedOnLoad = i),
- this.delayLoad()
- }
- ,
- t.prototype.delayLoad = function() {
- if (this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED) {
- var e = this.getScene();
- e && (this.delayLoadState = a.DELAYLOADSTATE_LOADED,
- this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY, this._useSRGBBuffer),
- this._texture ? this._delayedOnLoad && (this._texture.isReady ? Xt.SetImmediate(this._delayedOnLoad) : this._texture.onLoadedObservable.add(this._delayedOnLoad)) : (this._texture = e.getEngine().createTexture(this.url, this._noMipmap, this._invertY, e, 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)
- }
- }
- ,
- t.prototype._prepareRowForTextureGeneration = function(e, t, i, n) {
- e *= this._cachedUScale,
- t *= this._cachedVScale,
- e -= this.uRotationCenter * this._cachedUScale,
- t -= this.vRotationCenter * this._cachedVScale,
- i -= this.wRotationCenter,
- x.TransformCoordinatesFromFloatsToRef(e, t, i, this._rowGenerationMatrix, n),
- n.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset,
- n.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset,
- n.z += this.wRotationCenter
- }
- ,
- t.prototype.checkTransformsAreIdentical = function(e) {
- return null !== e && this.uOffset === e.uOffset && this.vOffset === e.vOffset && this.uScale === e.uScale && this.vScale === e.vScale && this.uAng === e.uAng && this.vAng === e.vAng && this.wAng === e.wAng
- }
- ,
- t.prototype.getTextureMatrix = function(e) {
- var t = this;
- if (void 0 === e && (e = 1),
- this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale * e === 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 * e,
- 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 = P.Zero(),
- this._rowGenerationMatrix = new P,
- this._t0 = x.Zero(),
- this._t1 = x.Zero(),
- this._t2 = x.Zero()),
- P.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix),
- this.homogeneousRotationInUVTransform ? (P.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, I.Matrix[0]),
- P.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, I.Matrix[1]),
- P.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, I.Matrix[2]),
- P.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, I.Matrix[3]),
- I.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix),
- this._cachedTextureMatrix.multiplyToRef(I.Matrix[1], this._cachedTextureMatrix),
- this._cachedTextureMatrix.multiplyToRef(I.Matrix[2], this._cachedTextureMatrix),
- this._cachedTextureMatrix.multiplyToRef(I.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),
- P.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 i = this.getScene();
- return i ? (i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(t)
- }
- )),
- this._cachedTextureMatrix) : this._cachedTextureMatrix
- }
- ,
- t.prototype.getReflectionTextureMatrix = function() {
- var e = this
- , i = this.getScene();
- if (!i)
- 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 !== t.PROJECTION_MODE)
- return this._cachedTextureMatrix;
- if (this._cachedProjectionMatrixId === i.getProjectionMatrix().updateFlag)
- return this._cachedTextureMatrix
- }
- this._cachedTextureMatrix || (this._cachedTextureMatrix = P.Zero()),
- this._projectionModeMatrix || (this._projectionModeMatrix = P.Zero());
- var n = 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 t.PLANAR_MODE:
- P.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 t.PROJECTION_MODE:
- P.FromValuesToRef(.5, 0, 0, 0, 0, -.5, 0, 0, 0, 0, 0, 0, .5, .5, 1, 1, this._projectionModeMatrix);
- var r = i.getProjectionMatrix();
- this._cachedProjectionMatrixId = r.updateFlag,
- r.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
- break;
- default:
- P.IdentityToRef(this._cachedTextureMatrix)
- }
- return n && i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
- return -1 !== t.getActiveTextures().indexOf(e)
- }
- )),
- this._cachedTextureMatrix
- }
- ,
- t.prototype.clone = function() {
- var e = this
- , i = {
- 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 Ge.Clone((function() {
- return new t(e._texture ? e._texture.url : null,e.getScene(),i)
- }
- ), this)
- }
- ,
- t.prototype.serialize = function() {
- var i = this.name;
- t.SerializeBuffers || ae(this.name, "data:") && (this.name = ""),
- ae(this.name, "data:") && this.url === this.name && (this.url = "");
- var n = e.prototype.serialize.call(this);
- return n ? ((t.SerializeBuffers || t.ForceSerializeBuffers) && ("string" == typeof this._buffer && "data:" === this._buffer.substr(0, 5) ? (n.base64String = this._buffer,
- n.name = n.name.replace("data:", "")) : this.url && ae(this.url, "data:") && this._buffer instanceof Uint8Array ? n.base64String = "data:image/png;base64," + le(this._buffer) : (t.ForceSerializeBuffers || this.url && ae(this.url, "blob:") || this._forceSerialize) && (n.base64String = !this._engine || this._engine._features.supportSyncTextureRead ? $r(this) : eo(this))),
- n.invertY = this._invertY,
- n.samplingMode = this.samplingMode,
- n._creationFlags = this._creationFlags,
- n._useSRGBBuffer = this._useSRGBBuffer,
- this.name = i,
- n) : null
- }
- ,
- t.prototype.getClassName = function() {
- return "Texture"
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onLoadObservable.clear(),
- this._delayedOnLoad = null,
- this._delayedOnError = null
- }
- ,
- t.Parse = function(e, i, n) {
- if (e.customType) {
- var r = pi.Instantiate(e.customType).Parse(e, i, n);
- return e.samplingMode && r.updateSamplingMode && r._samplingMode && r._samplingMode !== e.samplingMode && r.updateSamplingMode(e.samplingMode),
- r
- }
- if (e.isCube && !e.isRenderTarget)
- return t._CubeTextureParser(e, i, n);
- if (!e.name && !e.isRenderTarget)
- return null;
- var o = function() {
- if (a && a._texture && (a._texture._cachedWrapU = null,
- a._texture._cachedWrapV = null,
- a._texture._cachedWrapR = null),
- e.samplingMode) {
- var t = e.samplingMode;
- a && a.samplingMode !== t && a.updateSamplingMode(t)
- }
- if (a && e.animations)
- for (var i = 0; i < e.animations.length; i++) {
- var n = e.animations[i]
- , r = b("BABYLON.Animation");
- r && a.animations.push(r.Parse(n))
- }
- }
- , a = Ge.Parse((function() {
- var r, a, s, l, c = !0;
- if (e.noMipmap && (c = !1),
- e.mirrorPlane) {
- var u = t._CreateMirror(e.name, e.renderTargetSize, i, c);
- return u._waitingRenderList = e.renderList,
- u.mirrorPlane = hn.FromArray(e.mirrorPlane),
- o(),
- u
- }
- if (e.isRenderTarget) {
- var h = null;
- if (e.isCube) {
- if (i.reflectionProbes)
- for (var d = 0; d < i.reflectionProbes.length; d++) {
- var p = i.reflectionProbes[d];
- if (p.name === e.name)
- return p.cubeTexture
- }
- } else
- (h = t._CreateRenderTargetTexture(e.name, e.renderTargetSize, i, c, null !== (r = e._creationFlags) && void 0 !== r ? r : 0))._waitingRenderList = e.renderList;
- return o(),
- h
- }
- if (e.base64String)
- l = t.CreateFromBase64String(e.base64String, e.name, i, !c, e.invertY, e.samplingMode, o, null !== (a = e._creationFlags) && void 0 !== a ? a : 0, null !== (s = e._useSRGBBuffer) && void 0 !== s && s);
- else {
- var f = void 0;
- f = e.name && e.name.indexOf("://") > 0 ? e.name : n + e.name,
- (ae(e.url, "data:") || t.UseSerializedUrlIfAny && e.url) && (f = e.url),
- l = new t(f,i,!c,e.invertY,e.samplingMode,o)
- }
- return l
- }
- ), e, i);
- return a
- }
- ,
- t.CreateFromBase64String = function(e, i, n, r, o, s, l, c, u, h) {
- return void 0 === s && (s = t.TRILINEAR_SAMPLINGMODE),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = a.TEXTUREFORMAT_RGBA),
- new t("data:" + i,n,r,o,s,l,c,e,!1,u,void 0,void 0,h)
- }
- ,
- t.LoadFromDataString = function(e, i, n, r, o, s, l, c, u, h, d) {
- return void 0 === r && (r = !1),
- void 0 === s && (s = !0),
- void 0 === l && (l = t.TRILINEAR_SAMPLINGMODE),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = a.TEXTUREFORMAT_RGBA),
- "data:" !== e.substr(0, 5) && (e = "data:" + e),
- new t(e,n,o,s,l,c,u,i,r,h,void 0,void 0,d)
- }
- ,
- t.SerializeBuffers = !0,
- t.ForceSerializeBuffers = !1,
- t.OnTextureLoadErrorObservable = new h,
- t._CubeTextureParser = function(e, t, i) {
- throw be("CubeTexture")
- }
- ,
- t._CreateMirror = function(e, t, i, n) {
- throw be("MirrorTexture")
- }
- ,
- t._CreateRenderTargetTexture = function(e, t, i, n, r) {
- throw be("RenderTargetTexture")
- }
- ,
- t.NEAREST_SAMPLINGMODE = a.TEXTURE_NEAREST_SAMPLINGMODE,
- t.NEAREST_NEAREST_MIPLINEAR = a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,
- t.BILINEAR_SAMPLINGMODE = a.TEXTURE_BILINEAR_SAMPLINGMODE,
- t.LINEAR_LINEAR_MIPNEAREST = a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,
- t.TRILINEAR_SAMPLINGMODE = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- t.LINEAR_LINEAR_MIPLINEAR = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,
- t.NEAREST_NEAREST_MIPNEAREST = a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,
- t.NEAREST_LINEAR_MIPNEAREST = a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,
- t.NEAREST_LINEAR_MIPLINEAR = a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,
- t.NEAREST_LINEAR = a.TEXTURE_NEAREST_LINEAR,
- t.NEAREST_NEAREST = a.TEXTURE_NEAREST_NEAREST,
- t.LINEAR_NEAREST_MIPNEAREST = a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,
- t.LINEAR_NEAREST_MIPLINEAR = a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,
- t.LINEAR_LINEAR = a.TEXTURE_LINEAR_LINEAR,
- t.LINEAR_NEAREST = a.TEXTURE_LINEAR_NEAREST,
- t.EXPLICIT_MODE = a.TEXTURE_EXPLICIT_MODE,
- t.SPHERICAL_MODE = a.TEXTURE_SPHERICAL_MODE,
- t.PLANAR_MODE = a.TEXTURE_PLANAR_MODE,
- t.CUBIC_MODE = a.TEXTURE_CUBIC_MODE,
- t.PROJECTION_MODE = a.TEXTURE_PROJECTION_MODE,
- t.SKYBOX_MODE = a.TEXTURE_SKYBOX_MODE,
- t.INVCUBIC_MODE = a.TEXTURE_INVCUBIC_MODE,
- t.EQUIRECTANGULAR_MODE = a.TEXTURE_EQUIRECTANGULAR_MODE,
- t.FIXED_EQUIRECTANGULAR_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,
- t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
- t.CLAMP_ADDRESSMODE = a.TEXTURE_CLAMP_ADDRESSMODE,
- t.WRAP_ADDRESSMODE = a.TEXTURE_WRAP_ADDRESSMODE,
- t.MIRROR_ADDRESSMODE = a.TEXTURE_MIRROR_ADDRESSMODE,
- t.UseSerializedUrlIfAny = !1,
- k([Ce()], t.prototype, "url", void 0),
- k([Ce()], t.prototype, "uOffset", void 0),
- k([Ce()], t.prototype, "vOffset", void 0),
- k([Ce()], t.prototype, "uScale", void 0),
- k([Ce()], t.prototype, "vScale", void 0),
- k([Ce()], t.prototype, "uAng", void 0),
- k([Ce()], t.prototype, "vAng", void 0),
- k([Ce()], t.prototype, "wAng", void 0),
- k([Ce()], t.prototype, "uRotationCenter", void 0),
- k([Ce()], t.prototype, "vRotationCenter", void 0),
- k([Ce()], t.prototype, "wRotationCenter", void 0),
- k([Ce()], t.prototype, "homogeneousRotationInUVTransform", void 0),
- k([Ce()], t.prototype, "isBlocking", null),
- t
- }(Zr);
- function no(e, t, i, n) {
- var r, o = 1;
- n === a.TEXTURETYPE_FLOAT ? r = new Float32Array(t * i * 4) : n === a.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * i * 4),
- o = 15360) : r = n === a.TEXTURETYPE_UNSIGNED_INTEGER ? new Uint32Array(t * i * 4) : new Uint8Array(t * i * 4);
- for (var s = 0; s < t; s++)
- for (var l = 0; l < i; l++) {
- var c = 3 * (l * t + s)
- , u = 4 * (l * t + s);
- r[u + 0] = e[c + 0],
- r[u + 1] = e[c + 1],
- r[u + 2] = e[c + 2],
- r[u + 3] = o
- }
- return r
- }
- function ro(e) {
- return function(t, i, n, r, o, s, l, c, u, h) {
- void 0 === u && (u = null),
- void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
- var d = e ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
- , p = e ? At.Raw3D : At.Raw2DArray
- , f = new Lt(this,p);
- f.baseWidth = i,
- f.baseHeight = n,
- f.baseDepth = r,
- f.width = i,
- f.height = n,
- f.depth = r,
- f.format = o,
- f.type = h,
- f.generateMipMaps = s,
- f.samplingMode = c,
- e ? f.is3D = !0 : f.is2DArray = !0,
- this._doNotHandleContextLost || (f._bufferView = t),
- e ? this.updateRawTexture3D(f, t, o, l, u, h) : this.updateRawTexture2DArray(f, t, o, l, u, h),
- this._bindTextureDirectly(d, f, !0);
- var _ = this._getSamplingParameters(c, s);
- return this._gl.texParameteri(d, this._gl.TEXTURE_MAG_FILTER, _.mag),
- this._gl.texParameteri(d, this._gl.TEXTURE_MIN_FILTER, _.min),
- s && this._gl.generateMipmap(d),
- this._bindTextureDirectly(d, null),
- this._internalTexturesCache.push(f),
- f
- }
- }
- function oo(e) {
- return function(t, i, n, r, o, s) {
- void 0 === o && (o = null),
- void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT);
- var l = e ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
- , c = this._getWebGLTextureType(s)
- , u = this._getInternalFormat(n)
- , h = this._getRGBABufferInternalSizedFormat(s, n);
- this._bindTextureDirectly(l, t, !0),
- this._unpackFlipY(void 0 === r || !!r),
- this._doNotHandleContextLost || (t._bufferView = i,
- t.format = n,
- t.invertY = r,
- t._compression = o),
- t.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
- o && i ? this._gl.compressedTexImage3D(l, 0, this.getCaps().s3tc[o], t.width, t.height, t.depth, 0, i) : this._gl.texImage3D(l, 0, h, t.width, t.height, t.depth, 0, u, c, i),
- t.generateMipMaps && this._gl.generateMipmap(l),
- this._bindTextureDirectly(l, null),
- t.isReady = !0
- }
- }
- y("BABYLON.Texture", io),
- Ge._TextureParser = io.Parse,
- Ht.prototype.updateRawTexture = function(e, t, i, n, r, o) {
- if (void 0 === r && (r = null),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- e) {
- var s = this._getRGBABufferInternalSizedFormat(o, i)
- , l = this._getInternalFormat(i)
- , c = this._getWebGLTextureType(o);
- this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
- this._unpackFlipY(void 0 === n || !!n),
- this._doNotHandleContextLost || (e._bufferView = t,
- e.format = i,
- e.type = o,
- e.invertY = n,
- e._compression = r),
- e.width % 4 != 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
- r && t ? this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[r], e.width, e.height, 0, t) : this._gl.texImage2D(this._gl.TEXTURE_2D, 0, s, e.width, e.height, 0, l, c, t),
- e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- e.isReady = !0
- }
- }
- ,
- Ht.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
- void 0 === l && (l = null),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = 0);
- var h = new Lt(this,At.Raw);
- h.baseWidth = t,
- h.baseHeight = i,
- h.width = t,
- h.height = i,
- h.format = n,
- h.generateMipMaps = r,
- h.samplingMode = s,
- h.invertY = o,
- h._compression = l,
- h.type = c,
- this._doNotHandleContextLost || (h._bufferView = e),
- this.updateRawTexture(h, e, n, o, l, c),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, h, !0);
- var d = this._getSamplingParameters(s, r);
- return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, d.mag),
- this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, d.min),
- r && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- this._internalTexturesCache.push(h),
- h
- }
- ,
- Ht.prototype.createRawCubeTexture = function(e, t, i, n, r, o, s, l) {
- void 0 === l && (l = null);
- var c = this._gl
- , u = new Lt(this,At.CubeRaw);
- u.isCube = !0,
- u.format = i,
- u.type = n,
- this._doNotHandleContextLost || (u._bufferViewArray = e);
- var h = this._getWebGLTextureType(n)
- , d = this._getInternalFormat(i);
- d === c.RGB && (d = c.RGBA),
- h !== c.FLOAT || this._caps.textureFloatLinearFiltering ? h !== this._gl.HALF_FLOAT_OES || this._caps.textureHalfFloatLinearFiltering ? h !== c.FLOAT || this._caps.textureFloatRender ? h !== c.HALF_FLOAT || this._caps.colorBufferFloat || (r = !1,
- K.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
- K.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
- s = a.TEXTURE_NEAREST_SAMPLINGMODE,
- K.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1,
- s = a.TEXTURE_NEAREST_SAMPLINGMODE,
- K.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));
- var p = t
- , f = p;
- u.width = p,
- u.height = f,
- !this.needPOTTextures || gi.IsExponentOfTwo(u.width) && gi.IsExponentOfTwo(u.height) || (r = !1),
- e && this.updateRawCubeTexture(u, e, i, n, o, l),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, u, !0),
- e && r && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
- var _ = this._getSamplingParameters(s, r);
- return c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MAG_FILTER, _.mag),
- c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_MIN_FILTER, _.min),
- c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_WRAP_S, c.CLAMP_TO_EDGE),
- c.texParameteri(c.TEXTURE_CUBE_MAP, c.TEXTURE_WRAP_T, c.CLAMP_TO_EDGE),
- this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, null),
- u.generateMipMaps = r,
- u.samplingMode = s,
- u
- }
- ,
- Ht.prototype.updateRawCubeTexture = function(e, t, i, n, r, o, a) {
- void 0 === o && (o = null),
- void 0 === a && (a = 0),
- e._bufferViewArray = t,
- e.format = i,
- e.type = n,
- e.invertY = r,
- e._compression = o;
- var s = this._gl
- , l = this._getWebGLTextureType(n)
- , c = this._getInternalFormat(i)
- , u = this._getRGBABufferInternalSizedFormat(n)
- , h = !1;
- c === s.RGB && (c = s.RGBA,
- h = !0),
- this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, e, !0),
- this._unpackFlipY(void 0 === r || !!r),
- e.width % 4 != 0 && s.pixelStorei(s.UNPACK_ALIGNMENT, 1);
- for (var d = 0; d < 6; d++) {
- var p = t[d];
- o ? s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, this.getCaps().s3tc[o], e.width, e.height, 0, p) : (h && (p = no(p, e.width, e.height, n)),
- s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X + d, a, u, e.width, e.height, 0, c, l, p))
- }
- (!this.needPOTTextures || gi.IsExponentOfTwo(e.width) && gi.IsExponentOfTwo(e.height)) && e.generateMipMaps && 0 === a && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
- e.isReady = !0
- }
- ,
- Ht.prototype.createRawCubeTextureFromUrl = function(e, t, i, n, r, o, s, l, c, u, h, d) {
- var p = this;
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === d && (d = !1);
- var f = this._gl
- , _ = this.createRawCubeTexture(null, i, n, r, !o, d, h, null);
- return null == t || t._addPendingData(_),
- _.url = e,
- this._internalTexturesCache.push(_),
- this._loadFile(e, (function(e) {
- !function(e) {
- var i = _.width
- , o = s(e);
- if (o) {
- if (l) {
- var a = p._getWebGLTextureType(r)
- , u = p._getInternalFormat(n)
- , h = p._getRGBABufferInternalSizedFormat(r)
- , m = !1;
- u === f.RGB && (u = f.RGBA,
- m = !0),
- p._bindTextureDirectly(f.TEXTURE_CUBE_MAP, _, !0),
- p._unpackFlipY(!1);
- for (var g = l(o), v = 0; v < g.length; v++)
- for (var y = i >> v, b = 0; b < 6; b++) {
- var T = g[v][b];
- m && (T = no(T, y, y, r)),
- f.texImage2D(b, v, h, y, y, 0, u, a, T)
- }
- p._bindTextureDirectly(f.TEXTURE_CUBE_MAP, null)
- } else
- p.updateRawCubeTexture(_, o, n, r, d);
- _.isReady = !0,
- null == t || t._removePendingData(_),
- c && c()
- }
- }(e)
- }
- ), void 0, null == t ? void 0 : t.offlineProvider, !0, (function(e, i) {
- null == t || t._removePendingData(_),
- u && e && u(e.status + " " + e.statusText, i)
- }
- )),
- _
- }
- ,
- Ht.prototype.createRawTexture2DArray = ro(!1),
- Ht.prototype.createRawTexture3D = ro(!0),
- Ht.prototype.updateRawTexture2DArray = oo(!1),
- Ht.prototype.updateRawTexture3D = oo(!0);
- var ao = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h) {
- void 0 === s && (s = !0),
- void 0 === l && (l = !1),
- void 0 === c && (c = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT);
- var d = e.call(this, null, o, !s, l, void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0, h) || this;
- return d.format = r,
- d._engine ? (d._engine._caps.textureFloatLinearFiltering || u !== a.TEXTURETYPE_FLOAT || (c = a.TEXTURE_NEAREST_SAMPLINGMODE),
- d._engine._caps.textureHalfFloatLinearFiltering || u !== a.TEXTURETYPE_HALF_FLOAT || (c = a.TEXTURE_NEAREST_SAMPLINGMODE),
- d._texture = d._engine.createRawTexture(t, i, n, r, s, l, c, null, u, null != h ? h : 0),
- d.wrapU = io.CLAMP_ADDRESSMODE,
- d.wrapV = io.CLAMP_ADDRESSMODE,
- d) : d
- }
- return U(t, e),
- t.prototype.update = function(e) {
- this._getEngine().updateRawTexture(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
- }
- ,
- t.CreateLuminanceTexture = function(e, i, n, r, o, s, l) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- new t(e,i,n,a.TEXTUREFORMAT_LUMINANCE,r,o,s,l)
- }
- ,
- t.CreateLuminanceAlphaTexture = function(e, i, n, r, o, s, l) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- new t(e,i,n,a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,s,l)
- }
- ,
- t.CreateAlphaTexture = function(e, i, n, r, o, s, l) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- new t(e,i,n,a.TEXTUREFORMAT_ALPHA,r,o,s,l)
- }
- ,
- t.CreateRGBTexture = function(e, i, n, r, o, s, l, c) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- new t(e,i,n,a.TEXTUREFORMAT_RGB,r,o,s,l,c)
- }
- ,
- t.CreateRGBATexture = function(e, i, n, r, o, s, l, c) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c)
- }
- ,
- t.CreateRGBAStorageTexture = function(e, i, n, r, o, s, l, c) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)
- }
- ,
- t.CreateRTexture = function(e, i, n, r, o, s, l, c) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = io.TRILINEAR_SAMPLINGMODE),
- void 0 === c && (c = a.TEXTURETYPE_FLOAT),
- new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c)
- }
- ,
- t.CreateRStorageTexture = function(e, i, n, r, o, s, l, c) {
- return void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = io.TRILINEAR_SAMPLINGMODE),
- void 0 === c && (c = a.TEXTURETYPE_FLOAT),
- new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)
- }
- ,
- t
- }(io)
- , so = function() {
- function e(e, t) {
- this._scene = e,
- this._mesh = t
- }
- return e.prototype.bakeVertexData = function(e) {
- return G(this, void 0, void 0, (function() {
- var t, i, n, r, o, a, s, l;
- return z(this, (function(c) {
- switch (c.label) {
- case 0:
- if (!this._mesh.skeleton)
- throw new Error("No skeleton in this mesh.");
- if (t = this._mesh.skeleton.bones.length,
- i = e.reduce((function(e, t) {
- return e + t.to - t.from + 1
- }
- ), 0),
- isNaN(i))
- throw new Error("Invalid animation ranges.");
- n = 0,
- r = new Float32Array(4 * (t + 1) * 4 * i),
- this._scene.stopAnimation(this._mesh),
- this._mesh.skeleton.returnToRest(),
- o = 0,
- a = e,
- c.label = 1;
- case 1:
- if (!(o < a.length))
- return [3, 6];
- s = a[o],
- l = s.from,
- c.label = 2;
- case 2:
- return l <= s.to ? [4, this._executeAnimationFrame(r, l, n++)] : [3, 5];
- case 3:
- c.sent(),
- c.label = 4;
- case 4:
- return l++,
- [3, 2];
- case 5:
- return o++,
- [3, 1];
- case 6:
- return [2, r]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype._executeAnimationFrame = function(e, t, i) {
- return G(this, void 0, void 0, (function() {
- var n = this;
- return z(this, (function(r) {
- return [2, new Promise((function(r, o) {
- n._scene.beginAnimation(n._mesh.skeleton, t, t, !1, 1, (function() {
- var t = n._mesh.skeleton.getTransformMatrices(n._mesh);
- e.set(t, i * t.length),
- r()
- }
- ))
- }
- ))]
- }
- ))
- }
- ))
- }
- ,
- e.prototype.textureFromBakedVertexData = function(e) {
- if (!this._mesh.skeleton)
- throw new Error("No skeleton in this mesh.");
- var t = this._mesh.skeleton.bones.length
- , i = ao.CreateRGBATexture(e, 4 * (t + 1), e.length / (4 * (t + 1) * 4), this._scene, !1, !1, io.NEAREST_NEAREST, a.TEXTURETYPE_FLOAT);
- return i.name = "VAT" + this._mesh.skeleton.name,
- i
- }
- ,
- e.prototype.serializeBakedVertexDataToObject = function(e) {
- if (!this._mesh.skeleton)
- throw new Error("No skeleton in this mesh.");
- var t = this._mesh.skeleton.bones.length
- , i = 4 * (t + 1)
- , n = e.length / (4 * (t + 1) * 4);
- return {
- vertexData: le(e),
- width: i,
- height: n
- }
- }
- ,
- e.prototype.loadBakedVertexDataFromObject = function(e) {
- return new Float32Array(ue(e.vertexData))
- }
- ,
- e.prototype.serializeBakedVertexDataToJSON = function(e) {
- return JSON.stringify(this.serializeBakedVertexDataToObject(e))
- }
- ,
- e.prototype.loadBakedVertexDataFromJSON = function(e) {
- return this.loadBakedVertexDataFromObject(JSON.parse(e))
- }
- ,
- e
- }()
- , lo = function() {
- function e() {
- 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(e.prototype, "name", {
- get: function() {
- return "AutoRotation"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zoomStopsAnimation", {
- get: function() {
- return this._zoomStopsAnimation
- },
- set: function(e) {
- this._zoomStopsAnimation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "idleRotationSpeed", {
- get: function() {
- return this._idleRotationSpeed
- },
- set: function(e) {
- this._idleRotationSpeed = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "idleRotationWaitTime", {
- get: function() {
- return this._idleRotationWaitTime
- },
- set: function(e) {
- this._idleRotationWaitTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "idleRotationSpinupTime", {
- get: function() {
- return this._idleRotationSpinupTime
- },
- set: function(e) {
- this._idleRotationSpinupTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotationInProgress", {
- get: function() {
- return Math.abs(this._cameraRotationSpeed) > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(e) {
- var t = this;
- this._attachedCamera = e;
- var i = this._attachedCamera.getScene();
- this._onPrePointerObservableObserver = i.onPrePointerObservable.add((function(e) {
- e.type !== Xi.POINTERDOWN ? e.type === Xi.POINTERUP && (t._isPointerDown = !1) : t._isPointerDown = !0
- }
- )),
- this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add((function() {
- var e = ct.Now
- , i = 0;
- null != t._lastFrameTime && (i = e - t._lastFrameTime),
- t._lastFrameTime = e,
- t._applyUserInteraction();
- var n = e - t._lastInteractionTime - t._idleRotationWaitTime
- , r = Math.max(Math.min(n / t._idleRotationSpinupTime, 1), 0);
- t._cameraRotationSpeed = t._idleRotationSpeed * r,
- t._attachedCamera && (t._attachedCamera.alpha -= t._cameraRotationSpeed * (i / 1e3))
- }
- ))
- }
- ,
- e.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
- }
- }
- ,
- e.prototype.resetLastInteractionTime = function(e) {
- this._lastInteractionTime = null != e ? e : ct.Now
- }
- ,
- e.prototype._userIsZooming = function() {
- return !!this._attachedCamera && 0 !== this._attachedCamera.inertialRadiusOffset
- }
- ,
- e.prototype._shouldAnimationStopForInteraction = function() {
- if (!this._attachedCamera)
- return !1;
- var e = !1;
- return this._lastFrameRadius === this._attachedCamera.radius && 0 !== this._attachedCamera.inertialRadiusOffset && (e = !0),
- this._lastFrameRadius = this._attachedCamera.radius,
- this._zoomStopsAnimation ? e : this._userIsZooming()
- }
- ,
- e.prototype._applyUserInteraction = function() {
- this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = ct.Now)
- }
- ,
- e.prototype._userIsMoving = function() {
- return !!this._attachedCamera && (0 !== this._attachedCamera.inertialAlphaOffset || 0 !== this._attachedCamera.inertialBetaOffset || 0 !== this._attachedCamera.inertialRadiusOffset || 0 !== this._attachedCamera.inertialPanningX || 0 !== this._attachedCamera.inertialPanningY || this._isPointerDown)
- }
- ,
- e
- }()
- , co = function() {
- function e() {
- 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(e.prototype, "name", {
- get: function() {
- return "Bouncing"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "autoTransitionRange", {
- get: function() {
- return this._autoTransitionRange
- },
- set: function(e) {
- var t = this;
- if (this._autoTransitionRange !== e) {
- this._autoTransitionRange = e;
- var i = this._attachedCamera;
- i && (e ? this._onMeshTargetChangedObserver = i.onMeshTargetChangedObservable.add((function(e) {
- if (e) {
- e.computeWorldMatrix(!0);
- var i = e.getBoundingInfo().diagonalLength;
- t.lowerRadiusTransitionRange = .05 * i,
- t.upperRadiusTransitionRange = .05 * i
- }
- }
- )) : this._onMeshTargetChangedObserver && i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(e) {
- var t = this;
- this._attachedCamera = e,
- this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add((function() {
- t._attachedCamera && (t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit) && t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),
- t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit) && t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))
- }
- ))
- }
- ,
- e.prototype.detach = function() {
- this._attachedCamera && (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
- this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
- this._attachedCamera = null)
- }
- ,
- e.prototype._isRadiusAtLimit = function(e) {
- return !!this._attachedCamera && this._attachedCamera.radius === e && !this._radiusIsAnimating
- }
- ,
- e.prototype._applyBoundRadiusAnimation = function(t) {
- var i = this;
- if (this._attachedCamera) {
- this._radiusBounceTransition || (e.EasingFunction.setEasingMode(e.EasingMode),
- this._radiusBounceTransition = Qe.CreateAnimation("radius", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)),
- this._cachedWheelPrecision = this._attachedCamera.wheelPrecision,
- this._attachedCamera.wheelPrecision = 1 / 0,
- this._attachedCamera.inertialRadiusOffset = 0,
- this.stopAllAnimations(),
- this._radiusIsAnimating = !0;
- var n = Qe.TransitionTo("radius", this._attachedCamera.radius + t, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, (function() {
- return i._clearAnimationLocks()
- }
- ));
- n && this._animatables.push(n)
- }
- }
- ,
- e.prototype._clearAnimationLocks = function() {
- this._radiusIsAnimating = !1,
- this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision)
- }
- ,
- e.prototype.stopAllAnimations = function() {
- for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
- this._animatables[0].onAnimationEnd = null,
- this._animatables[0].stop(),
- this._animatables.shift()
- }
- ,
- e.EasingFunction = new On(.3),
- e.EasingMode = Mn.EASINGMODE_EASEOUT,
- e
- }()
- , uo = function() {
- function e() {
- this.onTargetFramingAnimationEndObservable = new h,
- this._mode = e.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(e.prototype, "name", {
- get: function() {
- return "Framing"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mode", {
- get: function() {
- return this._mode
- },
- set: function(e) {
- this._mode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "radiusScale", {
- get: function() {
- return this._radiusScale
- },
- set: function(e) {
- this._radiusScale = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "positionScale", {
- get: function() {
- return this._positionScale
- },
- set: function(e) {
- this._positionScale = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "defaultElevation", {
- get: function() {
- return this._defaultElevation
- },
- set: function(e) {
- this._defaultElevation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "elevationReturnTime", {
- get: function() {
- return this._elevationReturnTime
- },
- set: function(e) {
- this._elevationReturnTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "elevationReturnWaitTime", {
- get: function() {
- return this._elevationReturnWaitTime
- },
- set: function(e) {
- this._elevationReturnWaitTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zoomStopsAnimation", {
- get: function() {
- return this._zoomStopsAnimation
- },
- set: function(e) {
- this._zoomStopsAnimation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "framingTime", {
- get: function() {
- return this._framingTime
- },
- set: function(e) {
- this._framingTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(t) {
- var i = this;
- this._attachedCamera = t;
- var n = this._attachedCamera.getScene();
- e.EasingFunction.setEasingMode(e.EasingMode),
- this._onPrePointerObservableObserver = n.onPrePointerObservable.add((function(e) {
- e.type !== Xi.POINTERDOWN ? e.type === Xi.POINTERUP && (i._isPointerDown = !1) : i._isPointerDown = !0
- }
- )),
- this._onMeshTargetChangedObserver = t.onMeshTargetChangedObservable.add((function(e) {
- e && i.zoomOnMesh(e, void 0, (function() {
- i.onTargetFramingAnimationEndObservable.notifyObservers()
- }
- ))
- }
- )),
- this._onAfterCheckInputsObserver = t.onAfterCheckInputsObservable.add((function() {
- i._applyUserInteraction(),
- i._maintainCameraAboveGround()
- }
- ))
- }
- ,
- e.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
- }
- }
- ,
- e.prototype.zoomOnMesh = function(e, t, i) {
- void 0 === t && (t = !1),
- void 0 === i && (i = null),
- e.computeWorldMatrix(!0);
- var n = e.getBoundingInfo().boundingBox;
- this.zoomOnBoundingInfo(n.minimumWorld, n.maximumWorld, t, i)
- }
- ,
- e.prototype.zoomOnMeshHierarchy = function(e, t, i) {
- void 0 === t && (t = !1),
- void 0 === i && (i = null),
- e.computeWorldMatrix(!0);
- var n = e.getHierarchyBoundingVectors(!0);
- this.zoomOnBoundingInfo(n.min, n.max, t, i)
- }
- ,
- e.prototype.zoomOnMeshesHierarchy = function(e, t, i) {
- void 0 === t && (t = !1),
- void 0 === i && (i = null);
- for (var n = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE), r = new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE), o = 0; o < e.length; o++) {
- var a = e[o].getHierarchyBoundingVectors(!0);
- x.CheckExtends(a.min, n, r),
- x.CheckExtends(a.max, n, r)
- }
- this.zoomOnBoundingInfo(n, r, t, i)
- }
- ,
- e.prototype.zoomOnBoundingInfo = function(t, i, n, r) {
- var o, a = this;
- if (void 0 === n && (n = !1),
- void 0 === r && (r = null),
- this._attachedCamera) {
- var s = t.y
- , l = s + (i.y - s) * this._positionScale
- , c = i.subtract(t).scale(.5);
- if (n)
- o = new x(0,l,0);
- else {
- var u = t.add(c);
- o = new x(u.x,l,u.z)
- }
- this._vectorTransition || (this._vectorTransition = Qe.CreateAnimation("target", Qe.ANIMATIONTYPE_VECTOR3, 60, e.EasingFunction)),
- this._betaIsAnimating = !0;
- var h = Qe.TransitionTo("target", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
- h && this._animatables.push(h);
- var d = 0;
- if (this._mode === e.FitFrustumSidesMode) {
- var p = this._calculateLowerRadiusFromModelBoundingSphere(t, i);
- this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = c.length() + this._attachedCamera.minZ),
- d = p
- } else
- this._mode === e.IgnoreBoundsSizeMode && (d = this._calculateLowerRadiusFromModelBoundingSphere(t, i),
- this.autoCorrectCameraLimitsAndSensibility && null === this._attachedCamera.lowerRadiusLimit && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
- if (this.autoCorrectCameraLimitsAndSensibility) {
- var f = i.subtract(t).length();
- this._attachedCamera.panningSensibility = 5e3 / f,
- this._attachedCamera.wheelPrecision = 100 / d
- }
- this._radiusTransition || (this._radiusTransition = Qe.CreateAnimation("radius", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction)),
- (h = Qe.TransitionTo("radius", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, (function() {
- a.stopAllAnimations(),
- r && r(),
- a._attachedCamera && a._attachedCamera.useInputToRestoreState && a._attachedCamera.storeState()
- }
- ))) && this._animatables.push(h)
- }
- }
- ,
- e.prototype._calculateLowerRadiusFromModelBoundingSphere = function(t, i) {
- var n = i.subtract(t).length()
- , r = this._getFrustumSlope()
- , o = .5 * n * this._radiusScale
- , a = o * Math.sqrt(1 + 1 / (r.x * r.x))
- , s = o * Math.sqrt(1 + 1 / (r.y * r.y))
- , l = Math.max(a, s)
- , c = this._attachedCamera;
- return c ? (c.lowerRadiusLimit && this._mode === e.IgnoreBoundsSizeMode && (l = l < c.lowerRadiusLimit ? c.lowerRadiusLimit : l),
- c.upperRadiusLimit && (l = l > c.upperRadiusLimit ? c.upperRadiusLimit : l),
- l) : 0
- }
- ,
- e.prototype._maintainCameraAboveGround = function() {
- var t = this;
- if (!(this._elevationReturnTime < 0)) {
- var i = ct.Now - this._lastInteractionTime
- , n = .5 * Math.PI - this._defaultElevation
- , r = .5 * Math.PI;
- if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > r && i >= this._elevationReturnWaitTime) {
- this._betaIsAnimating = !0,
- this.stopAllAnimations(),
- this._betaTransition || (this._betaTransition = Qe.CreateAnimation("beta", Qe.ANIMATIONTYPE_FLOAT, 60, e.EasingFunction));
- var o = Qe.TransitionTo("beta", n, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, (function() {
- t._clearAnimationLocks(),
- t.stopAllAnimations()
- }
- ));
- o && this._animatables.push(o)
- }
- }
- }
- ,
- e.prototype._getFrustumSlope = function() {
- var e = this._attachedCamera;
- if (!e)
- return A.Zero();
- var t = e.getScene().getEngine().getAspectRatio(e)
- , i = Math.tan(e.fov / 2);
- return new A(i * t,i)
- }
- ,
- e.prototype._clearAnimationLocks = function() {
- this._betaIsAnimating = !1
- }
- ,
- e.prototype._applyUserInteraction = function() {
- this.isUserIsMoving && (this._lastInteractionTime = ct.Now,
- this.stopAllAnimations(),
- this._clearAnimationLocks())
- }
- ,
- e.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(e.prototype, "isUserIsMoving", {
- get: function() {
- return !!this._attachedCamera && (0 !== this._attachedCamera.inertialAlphaOffset || 0 !== this._attachedCamera.inertialBetaOffset || 0 !== this._attachedCamera.inertialRadiusOffset || 0 !== this._attachedCamera.inertialPanningX || 0 !== this._attachedCamera.inertialPanningY || this._isPointerDown)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.EasingFunction = new Fn,
- e.EasingMode = Mn.EASINGMODE_EASEINOUT,
- e.IgnoreBoundsSizeMode = 0,
- e.FitFrustumSidesMode = 1,
- e
- }()
- , ho = function(e, t, i, n) {
- void 0 === t && (t = new x),
- void 0 === i && (i = 0),
- void 0 === n && (n = !1),
- this.direction = e,
- this.rotatedDirection = t,
- this.diff = i,
- this.ignore = n
- }
- , po = function() {
- function e(e) {
- this._ui = e,
- this.name = "AttachToBoxBehavior",
- this.distanceAwayFromFace = .15,
- this.distanceAwayFromBottomOfFace = .15,
- this._faceVectors = [new ho(x.Up()), new ho(x.Down()), new ho(x.Left()), new ho(x.Right()), new ho(x.Forward()), new ho(x.Forward().scaleInPlace(-1))],
- this._tmpMatrix = new P,
- this._tmpVector = new x,
- this._zeroVector = x.Zero(),
- this._lookAtTmpMatrix = new P
- }
- return e.prototype.init = function() {}
- ,
- e.prototype._closestFace = function(e) {
- var t = this;
- return this._faceVectors.forEach((function(i) {
- t._target.rotationQuaternion || (t._target.rotationQuaternion = C.RotationYawPitchRoll(t._target.rotation.y, t._target.rotation.x, t._target.rotation.z)),
- t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),
- x.TransformCoordinatesToRef(i.direction, t._tmpMatrix, i.rotatedDirection),
- i.diff = x.GetAngleBetweenVectors(i.rotatedDirection, e, x.Cross(i.rotatedDirection, e))
- }
- )),
- this._faceVectors.reduce((function(e, t) {
- return e.ignore ? t : t.ignore || e.diff < t.diff ? e : t
- }
- ), this._faceVectors[0])
- }
- ,
- e.prototype._lookAtToRef = function(e, t, i) {
- void 0 === t && (t = new x(0,1,0)),
- P.LookAtLHToRef(this._zeroVector, e, t, this._lookAtTmpMatrix),
- this._lookAtTmpMatrix.invert(),
- C.FromRotationMatrixToRef(this._lookAtTmpMatrix, i)
- }
- ,
- e.prototype.attach = function(e) {
- var t = this;
- this._target = e,
- this._scene = this._target.getScene(),
- this._onRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
- if (t._scene.activeCamera) {
- var i = t._scene.activeCamera.position;
- t._scene.activeCamera.devicePosition && (i = t._scene.activeCamera.devicePosition);
- var n = t._closestFace(i.subtract(e.position));
- t._scene.activeCamera.leftCamera ? t._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix) : t._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix),
- x.TransformCoordinatesToRef(x.Up(), t._tmpMatrix, t._tmpVector),
- t._faceVectors.forEach((function(e) {
- n.direction.x && e.direction.x && (e.ignore = !0),
- n.direction.y && e.direction.y && (e.ignore = !0),
- n.direction.z && e.direction.z && (e.ignore = !0)
- }
- ));
- var r = t._closestFace(t._tmpVector);
- t._faceVectors.forEach((function(e) {
- e.ignore = !1
- }
- )),
- t._ui.position.copyFrom(e.position),
- n.direction.x && (n.rotatedDirection.scaleToRef(e.scaling.x / 2 + t.distanceAwayFromFace, t._tmpVector),
- t._ui.position.addInPlace(t._tmpVector)),
- n.direction.y && (n.rotatedDirection.scaleToRef(e.scaling.y / 2 + t.distanceAwayFromFace, t._tmpVector),
- t._ui.position.addInPlace(t._tmpVector)),
- n.direction.z && (n.rotatedDirection.scaleToRef(e.scaling.z / 2 + t.distanceAwayFromFace, t._tmpVector),
- t._ui.position.addInPlace(t._tmpVector)),
- t._ui.rotationQuaternion || (t._ui.rotationQuaternion = C.RotationYawPitchRoll(t._ui.rotation.y, t._ui.rotation.x, t._ui.rotation.z)),
- n.rotatedDirection.scaleToRef(-1, t._tmpVector),
- t._lookAtToRef(t._tmpVector, r.rotatedDirection, t._ui.rotationQuaternion),
- r.direction.x && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.x / 2, t._tmpVector),
- r.direction.y && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.y / 2, t._tmpVector),
- r.direction.z && t._ui.up.scaleToRef(t.distanceAwayFromBottomOfFace - e.scaling.z / 2, t._tmpVector),
- t._ui.position.addInPlace(t._tmpVector)
- }
- }
- ))
- }
- ,
- e.prototype.detach = function() {
- this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)
- }
- ,
- e
- }()
- , fo = function() {
- function e() {
- var e = this;
- this.delay = 0,
- this.fadeInTime = 300,
- this._millisecondsPerFrame = 1e3 / 60,
- this._hovered = !1,
- this._hoverValue = 0,
- this._ownerNode = null,
- this._update = function() {
- if (e._ownerNode) {
- if (e._hoverValue += e._hovered ? e._millisecondsPerFrame : -e._millisecondsPerFrame,
- e._setAllVisibility(e._ownerNode, (e._hoverValue - e.delay) / e.fadeInTime),
- e._ownerNode.visibility > 1)
- return e._setAllVisibility(e._ownerNode, 1),
- void (e._hoverValue = e.fadeInTime + e.delay);
- if (e._ownerNode.visibility < 0 && (e._setAllVisibility(e._ownerNode, 0),
- e._hoverValue < 0))
- return void (e._hoverValue = 0);
- setTimeout(e._update, e._millisecondsPerFrame)
- }
- }
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "FadeInOut"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(e) {
- this._ownerNode = e,
- this._setAllVisibility(this._ownerNode, 0)
- }
- ,
- e.prototype.detach = function() {
- this._ownerNode = null
- }
- ,
- e.prototype.fadeIn = function(e) {
- this._hovered = e,
- this._update()
- }
- ,
- e.prototype._setAllVisibility = function(e, t) {
- var i = this;
- e.visibility = t,
- e.getChildMeshes().forEach((function(e) {
- i._setAllVisibility(e, t)
- }
- ))
- }
- ,
- e
- }()
- , _o = function() {
- function e(e, t, i) {
- void 0 === i && (i = Number.MAX_VALUE),
- this.origin = e,
- this.direction = t,
- this.length = i
- }
- return e.prototype.clone = function() {
- return new e(this.origin.clone(),this.direction.clone(),this.length)
- }
- ,
- e.prototype.intersectsBoxMinMax = function(t, i, n) {
- void 0 === n && (n = 0);
- var r, o, a, s, l = e._TmpVector3[0].copyFromFloats(t.x - n, t.y - n, t.z - n), c = e._TmpVector3[1].copyFromFloats(i.x + n, i.y + n, i.z + n), u = 0, h = Number.MAX_VALUE;
- if (Math.abs(this.direction.x) < 1e-7) {
- if (this.origin.x < l.x || this.origin.x > c.x)
- return !1
- } else if (r = 1 / this.direction.x,
- o = (l.x - this.origin.x) * r,
- (a = (c.x - this.origin.x) * r) == -1 / 0 && (a = 1 / 0),
- o > a && (s = o,
- o = a,
- a = s),
- (u = Math.max(o, u)) > (h = Math.min(a, h)))
- return !1;
- if (Math.abs(this.direction.y) < 1e-7) {
- if (this.origin.y < l.y || this.origin.y > c.y)
- return !1
- } else if (r = 1 / this.direction.y,
- o = (l.y - this.origin.y) * r,
- (a = (c.y - this.origin.y) * r) == -1 / 0 && (a = 1 / 0),
- o > a && (s = o,
- o = a,
- a = s),
- (u = Math.max(o, u)) > (h = Math.min(a, h)))
- return !1;
- if (Math.abs(this.direction.z) < 1e-7) {
- if (this.origin.z < l.z || this.origin.z > c.z)
- return !1
- } else if (r = 1 / this.direction.z,
- o = (l.z - this.origin.z) * r,
- (a = (c.z - this.origin.z) * r) == -1 / 0 && (a = 1 / 0),
- o > a && (s = o,
- o = a,
- a = s),
- (u = Math.max(o, u)) > (h = Math.min(a, h)))
- return !1;
- return !0
- }
- ,
- e.prototype.intersectsBox = function(e, t) {
- return void 0 === t && (t = 0),
- this.intersectsBoxMinMax(e.minimum, e.maximum, t)
- }
- ,
- e.prototype.intersectsSphere = function(e, t) {
- void 0 === t && (t = 0);
- var i = e.center.x - this.origin.x
- , n = e.center.y - this.origin.y
- , r = e.center.z - this.origin.z
- , o = i * i + n * n + r * r
- , a = e.radius + t
- , s = a * a;
- if (o <= s)
- return !0;
- var l = i * this.direction.x + n * this.direction.y + r * this.direction.z;
- return !(l < 0) && o - l * l <= s
- }
- ,
- e.prototype.intersectsTriangle = function(t, i, n) {
- var r = e._TmpVector3[0]
- , o = e._TmpVector3[1]
- , a = e._TmpVector3[2]
- , s = e._TmpVector3[3]
- , l = e._TmpVector3[4];
- i.subtractToRef(t, r),
- n.subtractToRef(t, o),
- x.CrossToRef(this.direction, o, a);
- var c = x.Dot(r, a);
- if (0 === c)
- return null;
- var u = 1 / c;
- this.origin.subtractToRef(t, s);
- var h = x.Dot(s, a) * u;
- if (h < 0 || h > 1)
- return null;
- x.CrossToRef(s, r, l);
- var d = x.Dot(this.direction, l) * u;
- if (d < 0 || h + d > 1)
- return null;
- var p = x.Dot(o, l) * u;
- return p > this.length ? null : new er(1 - h - d,h,p)
- }
- ,
- e.prototype.intersectsPlane = function(e) {
- var t, i = x.Dot(e.normal, this.direction);
- if (Math.abs(i) < 9.99999997475243e-7)
- return null;
- var n = x.Dot(e.normal, this.origin);
- return (t = (-e.d - n) / i) < 0 ? t < -9.99999997475243e-7 ? null : 0 : t
- }
- ,
- e.prototype.intersectsAxis = function(e, t) {
- switch (void 0 === t && (t = 0),
- e) {
- case "y":
- return (i = (this.origin.y - t) / this.direction.y) > 0 ? null : new x(this.origin.x + this.direction.x * -i,t,this.origin.z + this.direction.z * -i);
- case "x":
- return (i = (this.origin.x - t) / this.direction.x) > 0 ? null : new x(t,this.origin.y + this.direction.y * -i,this.origin.z + this.direction.z * -i);
- case "z":
- var i;
- return (i = (this.origin.z - t) / this.direction.z) > 0 ? null : new x(this.origin.x + this.direction.x * -i,this.origin.y + this.direction.y * -i,t);
- default:
- return null
- }
- }
- ,
- e.prototype.intersectsMesh = function(t, i) {
- var n = I.Matrix[0];
- return t.getWorldMatrix().invertToRef(n),
- this._tmpRay ? e.TransformToRef(this, n, this._tmpRay) : this._tmpRay = e.Transform(this, n),
- t.intersects(this._tmpRay, i)
- }
- ,
- e.prototype.intersectsMeshes = function(e, t, i) {
- i ? i.length = 0 : i = [];
- for (var n = 0; n < e.length; n++) {
- var r = this.intersectsMesh(e[n], t);
- r.hit && i.push(r)
- }
- return i.sort(this._comparePickingInfo),
- i
- }
- ,
- e.prototype._comparePickingInfo = function(e, t) {
- return e.distance < t.distance ? -1 : e.distance > t.distance ? 1 : 0
- }
- ,
- e.prototype.intersectionSegment = function(t, i, n) {
- var r = this.origin
- , o = I.Vector3[0]
- , a = I.Vector3[1]
- , s = I.Vector3[2]
- , l = I.Vector3[3];
- i.subtractToRef(t, o),
- this.direction.scaleToRef(e._Rayl, s),
- r.addToRef(s, a),
- t.subtractToRef(r, l);
- var c, u, h = x.Dot(o, o), d = x.Dot(o, s), p = x.Dot(s, s), f = x.Dot(o, l), _ = x.Dot(s, l), m = h * p - d * d, g = m, v = m;
- m < e._Smallnum ? (c = 0,
- g = 1,
- u = _,
- v = p) : (u = h * _ - d * f,
- (c = d * _ - p * f) < 0 ? (c = 0,
- u = _,
- v = p) : c > g && (c = g,
- u = _ + d,
- v = p)),
- u < 0 ? (u = 0,
- -f < 0 ? c = 0 : -f > h ? c = g : (c = -f,
- g = h)) : u > v && (u = v,
- -f + d < 0 ? c = 0 : -f + d > h ? c = g : (c = -f + d,
- g = h));
- var y = Math.abs(c) < e._Smallnum ? 0 : c / g
- , b = Math.abs(u) < e._Smallnum ? 0 : u / v
- , T = I.Vector3[4];
- s.scaleToRef(b, T);
- var E = I.Vector3[5];
- o.scaleToRef(y, E),
- E.addInPlace(l);
- var S = I.Vector3[6];
- return E.subtractToRef(T, S),
- b > 0 && b <= this.length && S.lengthSquared() < n * n ? E.length() : -1
- }
- ,
- e.prototype.update = function(t, i, n, r, o, a, s, l) {
- if (void 0 === l && (l = !1),
- l) {
- e._RayDistant || (e._RayDistant = e.Zero()),
- e._RayDistant.unprojectRayToRef(t, i, n, r, P.IdentityReadOnly, a, s);
- var c = I.Matrix[0];
- o.invertToRef(c),
- e.TransformToRef(e._RayDistant, c, this)
- } else
- this.unprojectRayToRef(t, i, n, r, o, a, s);
- return this
- }
- ,
- e.Zero = function() {
- return new e(x.Zero(),x.Zero())
- }
- ,
- e.CreateNew = function(t, i, n, r, o, a, s) {
- return e.Zero().update(t, i, n, r, o, a, s)
- }
- ,
- e.CreateNewFromTo = function(t, i, n) {
- void 0 === n && (n = P.IdentityReadOnly);
- var r = i.subtract(t)
- , o = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z);
- return r.normalize(),
- e.Transform(new e(t,r,o), n)
- }
- ,
- e.Transform = function(t, i) {
- var n = new e(new x(0,0,0),new x(0,0,0));
- return e.TransformToRef(t, i, n),
- n
- }
- ,
- e.TransformToRef = function(e, t, i) {
- x.TransformCoordinatesToRef(e.origin, t, i.origin),
- x.TransformNormalToRef(e.direction, t, i.direction),
- i.length = e.length;
- var n = i.direction
- , r = n.length();
- if (0 !== r && 1 !== r) {
- var o = 1 / r;
- n.x *= o,
- n.y *= o,
- n.z *= o,
- i.length *= r
- }
- }
- ,
- e.prototype.unprojectRayToRef = function(e, t, i, n, r, o, a) {
- var s, l = I.Matrix[0];
- r.multiplyToRef(o, l),
- l.multiplyToRef(a, l),
- l.invert();
- var c = I.Vector3[0];
- c.x = e / i * 2 - 1,
- c.y = -(t / n * 2 - 1),
- c.z = (null === (s = E.LastCreatedEngine) || void 0 === s ? void 0 : s.isNDCHalfZRange) ? 0 : -1;
- var u = I.Vector3[1].copyFromFloats(c.x, c.y, 1 - 1e-8)
- , h = I.Vector3[2]
- , d = I.Vector3[3];
- x._UnprojectFromInvertedMatrixToRef(c, l, h),
- x._UnprojectFromInvertedMatrixToRef(u, l, d),
- this.origin.copyFrom(h),
- d.subtractToRef(h, this.direction),
- this.direction.normalize()
- }
- ,
- e._TmpVector3 = g.BuildArray(6, x.Zero),
- e._RayDistant = e.Zero(),
- e._Smallnum = 1e-8,
- e._Rayl = 1e9,
- e
- }();
- mn.prototype.createPickingRay = function(e, t, i, n, r) {
- void 0 === r && (r = !1);
- var o = _o.Zero();
- return this.createPickingRayToRef(e, t, i, o, n, r),
- o
- }
- ,
- mn.prototype.createPickingRayToRef = function(e, t, i, n, r, o, a) {
- void 0 === o && (o = !1),
- void 0 === a && (a = !1);
- var s = this.getEngine();
- if (!r) {
- if (!this.activeCamera)
- return this;
- r = this.activeCamera
- }
- var l = r.viewport.toGlobal(s.getRenderWidth(), s.getRenderHeight());
- return e = e / s.getHardwareScalingLevel() - l.x,
- t = t / s.getHardwareScalingLevel() - (s.getRenderHeight() - l.y - l.height),
- n.update(e, t, l.width, l.height, i || P.IdentityReadOnly, o ? P.IdentityReadOnly : r.getViewMatrix(), r.getProjectionMatrix(), a),
- this
- }
- ,
- mn.prototype.createPickingRayInCameraSpace = function(e, t, i) {
- var n = _o.Zero();
- return this.createPickingRayInCameraSpaceToRef(e, t, n, i),
- n
- }
- ,
- mn.prototype.createPickingRayInCameraSpaceToRef = function(e, t, i, n) {
- if (!Ui)
- return this;
- var r = this.getEngine();
- if (!n) {
- if (!this.activeCamera)
- throw new Error("Active camera not set");
- n = this.activeCamera
- }
- var o = n.viewport.toGlobal(r.getRenderWidth(), r.getRenderHeight())
- , a = P.Identity();
- return e = e / r.getHardwareScalingLevel() - o.x,
- t = t / r.getHardwareScalingLevel() - (r.getRenderHeight() - o.y - o.height),
- i.update(e, t, o.width, o.height, a, a, n.getProjectionMatrix()),
- this
- }
- ,
- mn.prototype._internalPickForMesh = function(e, t, i, n, r, o, a, s) {
- var l = t(n, i.enableDistantPicking)
- , c = i.intersects(l, r, a, o, n, s);
- return c && c.hit ? !r && null != e && c.distance >= e.distance ? null : c : null
- }
- ,
- mn.prototype._internalPick = function(e, t, i, n, r) {
- if (!Ui)
- return null;
- for (var o = null, a = 0; a < this.meshes.length; a++) {
- var s = this.meshes[a];
- if (t) {
- if (!t(s))
- continue
- } else if (!s.isEnabled() || !s.isVisible || !s.isPickable)
- continue;
- var l, c = s.getWorldMatrix();
- if (s.hasThinInstances && s.thinInstanceEnablePicking) {
- if (l = this._internalPickForMesh(o, e, s, c, !0, !0, r)) {
- if (n)
- return l;
- for (var u = I.Matrix[1], h = s.thinInstanceGetWorldMatrices(), d = 0; d < h.length; d++) {
- h[d].multiplyToRef(c, u);
- var p = this._internalPickForMesh(o, e, s, u, i, n, r, !0);
- if (p && ((o = p).thinInstanceIndex = d,
- i))
- return o
- }
- }
- } else if ((l = this._internalPickForMesh(o, e, s, c, i, n, r)) && (o = l,
- i))
- return o
- }
- return o || new Ui
- }
- ,
- mn.prototype._internalMultiPick = function(e, t, i) {
- if (!Ui)
- return null;
- for (var n = new Array, r = 0; r < this.meshes.length; r++) {
- var o = this.meshes[r];
- if (t) {
- if (!t(o))
- continue
- } else if (!o.isEnabled() || !o.isVisible || !o.isPickable)
- continue;
- var a, s = o.getWorldMatrix();
- if (o.hasThinInstances && o.thinInstanceEnablePicking) {
- if (a = this._internalPickForMesh(null, e, o, s, !0, !0, i))
- for (var l = I.Matrix[1], c = o.thinInstanceGetWorldMatrices(), u = 0; u < c.length; u++) {
- c[u].multiplyToRef(s, l);
- var h = this._internalPickForMesh(null, e, o, l, !1, !1, i, !0);
- h && (h.thinInstanceIndex = u,
- n.push(h))
- }
- } else
- (a = this._internalPickForMesh(null, e, o, s, !1, !1, i)) && n.push(a)
- }
- return n
- }
- ,
- mn.prototype.pickWithBoundingInfo = function(e, t, i, n, r) {
- var o = this;
- if (!Ui)
- return null;
- var a = this._internalPick((function(i) {
- return o._tempPickingRay || (o._tempPickingRay = _o.Zero()),
- o.createPickingRayToRef(e, t, i, o._tempPickingRay, r || null),
- o._tempPickingRay
- }
- ), i, n, !0);
- return a && (a.ray = this.createPickingRay(e, t, P.Identity(), r || null)),
- a
- }
- ,
- mn.prototype.pick = function(e, t, i, n, r, o, a) {
- var s = this;
- if (void 0 === a && (a = !1),
- !Ui)
- return null;
- var l = this._internalPick((function(i, n) {
- return s._tempPickingRay || (s._tempPickingRay = _o.Zero()),
- s.createPickingRayToRef(e, t, i, s._tempPickingRay, r || null, !1, n),
- s._tempPickingRay
- }
- ), i, n, !1, o);
- return l && (l.ray = this.createPickingRay(e, t, P.Identity(), r || null)),
- l
- }
- ,
- mn.prototype.pickWithRay = function(e, t, i, n) {
- var r = this
- , o = this._internalPick((function(t) {
- return r._pickWithRayInverseMatrix || (r._pickWithRayInverseMatrix = P.Identity()),
- t.invertToRef(r._pickWithRayInverseMatrix),
- r._cachedRayForTransform || (r._cachedRayForTransform = _o.Zero()),
- _o.TransformToRef(e, r._pickWithRayInverseMatrix, r._cachedRayForTransform),
- r._cachedRayForTransform
- }
- ), t, i, !1, n);
- return o && (o.ray = e),
- o
- }
- ,
- mn.prototype.multiPick = function(e, t, i, n, r) {
- var o = this;
- return this._internalMultiPick((function(i) {
- return o.createPickingRay(e, t, i, n || null)
- }
- ), i, r)
- }
- ,
- mn.prototype.multiPickWithRay = function(e, t, i) {
- var n = this;
- return this._internalMultiPick((function(t) {
- return n._pickWithRayInverseMatrix || (n._pickWithRayInverseMatrix = P.Identity()),
- t.invertToRef(n._pickWithRayInverseMatrix),
- n._cachedRayForTransform || (n._cachedRayForTransform = _o.Zero()),
- _o.TransformToRef(e, n._pickWithRayInverseMatrix, n._cachedRayForTransform),
- n._cachedRayForTransform
- }
- ), t, i)
- }
- ,
- Rr.prototype.getForwardRay = function(e, t, i) {
- return void 0 === e && (e = 100),
- this.getForwardRayToRef(new _o(x.Zero(),x.Zero(),e), e, t, i)
- }
- ,
- Rr.prototype.getForwardRayToRef = function(e, t, i, n) {
- return void 0 === t && (t = 100),
- i || (i = this.getWorldMatrix()),
- e.length = t,
- n ? e.origin.copyFrom(n) : e.origin.copyFrom(this.position),
- I.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- x.TransformNormalToRef(I.Vector3[2], i, I.Vector3[3]),
- x.NormalizeToRef(I.Vector3[3], e.direction),
- e
- }
- ;
- var mo = function() {
- function e() {}
- return e._RemoveAndStorePivotPoint = function(t) {
- t && 0 === e._PivotCached && (t.getPivotPointToRef(e._OldPivotPoint),
- e._PivotPostMultiplyPivotMatrix = t._postMultiplyPivotMatrix,
- e._OldPivotPoint.equalsToFloats(0, 0, 0) || (t.setPivotMatrix(P.IdentityReadOnly),
- e._OldPivotPoint.subtractToRef(t.getPivotPoint(), e._PivotTranslation),
- e._PivotTmpVector.copyFromFloats(1, 1, 1),
- e._PivotTmpVector.subtractInPlace(t.scaling),
- e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),
- t.position.addInPlace(e._PivotTmpVector))),
- e._PivotCached++
- }
- ,
- e._RestorePivotPoint = function(t) {
- t && !e._OldPivotPoint.equalsToFloats(0, 0, 0) && 1 === e._PivotCached && (t.setPivotPoint(e._OldPivotPoint),
- t._postMultiplyPivotMatrix = e._PivotPostMultiplyPivotMatrix,
- e._PivotTmpVector.copyFromFloats(1, 1, 1),
- e._PivotTmpVector.subtractInPlace(t.scaling),
- e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),
- t.position.subtractInPlace(e._PivotTmpVector)),
- this._PivotCached--
- }
- ,
- e._PivotCached = 0,
- e._OldPivotPoint = new x,
- e._PivotTranslation = new x,
- e._PivotTmpVector = new x,
- e._PivotPostMultiplyPivotMatrix = !1,
- e
- }();
- function go(e) {
- var t = []
- , i = []
- , n = []
- , r = []
- , o = e.width || e.size || 1
- , a = e.height || e.size || 1
- , s = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE
- , l = o / 2
- , c = a / 2;
- i.push(-l, -c, 0),
- n.push(0, 0, -1),
- r.push(0, pr.UseOpenGLOrientationForUV ? 1 : 0),
- i.push(l, -c, 0),
- n.push(0, 0, -1),
- r.push(1, pr.UseOpenGLOrientationForUV ? 1 : 0),
- i.push(l, c, 0),
- n.push(0, 0, -1),
- r.push(1, pr.UseOpenGLOrientationForUV ? 0 : 1),
- i.push(-l, c, 0),
- n.push(0, 0, -1),
- r.push(0, pr.UseOpenGLOrientationForUV ? 0 : 1),
- t.push(0),
- t.push(1),
- t.push(2),
- t.push(0),
- t.push(2),
- t.push(3),
- $n._ComputeSides(s, i, t, n, r, e.frontUVs, e.backUVs);
- var u = new $n;
- return u.indices = t,
- u.positions = i,
- u.normals = n,
- u.uvs = r,
- u
- }
- function vo(e, t, i) {
- void 0 === t && (t = {}),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- go(t).applyToMesh(n, t.updatable),
- t.sourcePlane && (n.translate(t.sourcePlane.normal, -t.sourcePlane.d),
- n.setDirection(t.sourcePlane.normal.scale(-1))),
- n
- }
- var yo = {
- CreatePlane: vo
- };
- $n.CreatePlane = go,
- Vr.CreatePlane = function(e, t, i, n, r) {
- return vo(e, {
- size: t,
- width: t,
- height: t,
- sideOrientation: r,
- updatable: n
- }, i)
- }
- ;
- var bo, To, Eo, So, Ao = function() {
- function e(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 h,
- this.onDragStartObservable = new h,
- this.onDragEndObservable = new h,
- this.onEnabledObservable = new h,
- this.moveAttached = !0,
- this._enabled = !0,
- this.startAndReleaseDragOnPointerEvents = !0,
- this.detachCameraControls = !0,
- this.useObjectOrientationForDragging = !0,
- this.validateDrag = function(e) {
- return !0
- }
- ,
- this._tmpVector = new x(0,0,0),
- this._alternatePickedPoint = new x(0,0,0),
- this._worldDragAxis = new x(0,0,0),
- this._targetPosition = new x(0,0,0),
- this._attachedToElement = !1,
- this._startDragRay = new _o(new x,new x),
- this._lastPointerRay = {},
- this._dragDelta = new x,
- this._pointA = new x(0,0,0),
- this._pointC = new x(0,0,0),
- this._localAxis = new x(0,0,0),
- this._lookAt = new x(0,0,0),
- this._options = e || {};
- var t = 0;
- if (this._options.dragAxis && t++,
- this._options.dragPlaneNormal && t++,
- t > 1)
- throw "Multiple drag modes specified in dragBehavior options. Only one expected"
- }
- return Object.defineProperty(e.prototype, "currentDraggingPointerID", {
- get: function() {
- return this.currentDraggingPointerId
- },
- set: function(e) {
- this.currentDraggingPointerId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.prototype, "options", {
- get: function() {
- return this._options
- },
- set: function(e) {
- this._options = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "PointerDrag"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(t, i) {
- var n = this;
- this._scene = t.getScene(),
- t.isNearGrabbable = !0,
- this.attachedNode = t,
- e._PlaneScene || (this._debugMode ? e._PlaneScene = this._scene : (e._PlaneScene = new mn(this._scene.getEngine(),{
- virtual: !0
- }),
- e._PlaneScene.detachControl(),
- this._scene.onDisposeObservable.addOnce((function() {
- e._PlaneScene.dispose(),
- e._PlaneScene = null
- }
- )))),
- this._dragPlane = vo("pointerDragPlane", {
- size: this._debugMode ? 1 : 1e4,
- updatable: !1,
- sideOrientation: Vr.DOUBLESIDE
- }, e._PlaneScene),
- this.lastDragPosition = new x(0,0,0);
- var r = i || function(e) {
- return n.attachedNode == e || e.isDescendantOf(n.attachedNode)
- }
- ;
- this._pointerObserver = this._scene.onPointerObservable.add((function(t) {
- if (n.enabled) {
- if (t.type == Xi.POINTERDOWN)
- n.startAndReleaseDragOnPointerEvents && !n.dragging && t.pickInfo && t.pickInfo.hit && t.pickInfo.pickedMesh && t.pickInfo.pickedPoint && t.pickInfo.ray && r(t.pickInfo.pickedMesh) && n._startDrag(t.event.pointerId, t.pickInfo.ray, t.pickInfo.pickedPoint);
- else if (t.type == Xi.POINTERUP)
- n.startAndReleaseDragOnPointerEvents && n.currentDraggingPointerId == t.event.pointerId && n.releaseDrag();
- else if (t.type == Xi.POINTERMOVE) {
- var i = t.event.pointerId;
- if (n.currentDraggingPointerId === e._AnyMouseId && i !== e._AnyMouseId) {
- var o = t.event;
- ("mouse" === o.pointerType || !n._scene.getEngine().hostInformation.isMobile && o instanceof MouseEvent) && (n._lastPointerRay[n.currentDraggingPointerId] && (n._lastPointerRay[i] = n._lastPointerRay[n.currentDraggingPointerId],
- delete n._lastPointerRay[n.currentDraggingPointerId]),
- n.currentDraggingPointerId = i)
- }
- n._lastPointerRay[i] || (n._lastPointerRay[i] = new _o(new x,new x)),
- t.pickInfo && t.pickInfo.ray && (n._lastPointerRay[i].origin.copyFrom(t.pickInfo.ray.origin),
- n._lastPointerRay[i].direction.copyFrom(t.pickInfo.ray.direction),
- n.currentDraggingPointerId == i && n.dragging && n._moveDrag(t.pickInfo.ray))
- }
- } else
- n._attachedToElement && n.releaseDrag()
- }
- )),
- this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
- if (n._moving && n.moveAttached) {
- var e = !1;
- mo._RemoveAndStorePivotPoint(n.attachedNode),
- n._targetPosition.subtractToRef(n.attachedNode.absolutePosition, n._tmpVector),
- n._tmpVector.scaleInPlace(n.dragDeltaRatio),
- n.attachedNode.getAbsolutePosition().addToRef(n._tmpVector, n._tmpVector),
- n.validateDrag(n._tmpVector) && (n.attachedNode.setAbsolutePosition(n._tmpVector),
- e = !0),
- mo._RestorePivotPoint(n.attachedNode),
- e && n.attachedNode.computeWorldMatrix()
- }
- }
- ))
- }
- ,
- e.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 ("ArcRotateCamera" === this._scene.activeCamera.getClassName()) {
- var e = this._scene.activeCamera;
- e.attachControl(!e.inputs || e.inputs.noPreventDefault, e._useCtrlForPanning, e._panningMouseButton)
- } else
- this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs || this._scene.activeCamera.inputs.noPreventDefault);
- this._attachedToElement = !1
- }
- }
- ,
- e.prototype.startDrag = function(t, i, n) {
- void 0 === t && (t = e._AnyMouseId),
- this._startDrag(t, i, n);
- var r = this._lastPointerRay[t];
- t === e._AnyMouseId && (r = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),
- r && this._moveDrag(r)
- }
- ,
- e.prototype._startDrag = function(e, t, i) {
- if (this._scene.activeCamera && !this.dragging && this.attachedNode) {
- mo._RemoveAndStorePivotPoint(this.attachedNode),
- t ? (this._startDragRay.direction.copyFrom(t.direction),
- this._startDragRay.origin.copyFrom(t.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, i || this._tmpVector);
- var n = this._pickWithRayOnDragPlane(this._startDragRay);
- n && (this.dragging = !0,
- this.currentDraggingPointerId = e,
- this.lastDragPosition.copyFrom(n),
- this.onDragStartObservable.notifyObservers({
- dragPlanePoint: n,
- 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)),
- mo._RestorePivotPoint(this.attachedNode)
- }
- }
- ,
- e.prototype._moveDrag = function(e) {
- this._moving = !0;
- var t = this._pickWithRayOnDragPlane(e);
- if (t) {
- mo._RemoveAndStorePivotPoint(this.attachedNode),
- this.updateDragPlane && this._updateDragPlanePosition(e, t);
- var i = 0;
- this._options.dragAxis ? (this.useObjectOrientationForDragging ? x.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis),
- t.subtractToRef(this.lastDragPosition, this._tmpVector),
- i = x.Dot(this._tmpVector, this._worldDragAxis),
- this._worldDragAxis.scaleToRef(i, this._dragDelta)) : (i = this._dragDelta.length(),
- t.subtractToRef(this.lastDragPosition, this._dragDelta)),
- this._targetPosition.addInPlace(this._dragDelta),
- this.onDragObservable.notifyObservers({
- dragDistance: i,
- delta: this._dragDelta,
- dragPlanePoint: t,
- dragPlaneNormal: this._dragPlane.forward,
- pointerId: this.currentDraggingPointerId
- }),
- this.lastDragPosition.copyFrom(t),
- mo._RestorePivotPoint(this.attachedNode)
- }
- }
- ,
- e.prototype._pickWithRayOnDragPlane = function(t) {
- var i = this;
- if (!t)
- return null;
- var n = Math.acos(x.Dot(this._dragPlane.forward, t.direction));
- if (n > Math.PI / 2 && (n = Math.PI - n),
- this.maxDragAngle > 0 && n > this.maxDragAngle) {
- if (this._useAlternatePickedPointAboveMaxDragAngle) {
- this._tmpVector.copyFrom(t.direction),
- this.attachedNode.absolutePosition.subtractToRef(t.origin, this._alternatePickedPoint),
- this._alternatePickedPoint.normalize(),
- this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * x.Dot(this._alternatePickedPoint, this._tmpVector)),
- this._tmpVector.addInPlace(this._alternatePickedPoint);
- var r = x.Dot(this._dragPlane.forward, this._tmpVector);
- return this._dragPlane.forward.scaleToRef(-r, this._alternatePickedPoint),
- this._alternatePickedPoint.addInPlace(this._tmpVector),
- this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),
- this._alternatePickedPoint
- }
- return null
- }
- var o = e._PlaneScene.pickWithRay(t, (function(e) {
- return e == i._dragPlane
- }
- ));
- return o && o.hit && o.pickedMesh && o.pickedPoint ? o.pickedPoint : null
- }
- ,
- e.prototype._updateDragPlanePosition = function(e, t) {
- this._pointA.copyFrom(t),
- this._options.dragAxis ? (this.useObjectOrientationForDragging ? x.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(x.Dot(this._localAxis, this._pointC)) > .999 ? Math.abs(x.Dot(x.UpReadOnly, this._pointC)) > .999 ? this._lookAt.copyFrom(x.Right()) : this._lookAt.copyFrom(x.UpReadOnly) : (x.CrossToRef(this._localAxis, this._pointC, this._lookAt),
- x.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 ? x.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)
- }
- ,
- e.prototype.detach = function() {
- this.attachedNode && (this.attachedNode.isNearGrabbable = !1),
- this._pointerObserver && this._scene.onPointerObservable.remove(this._pointerObserver),
- this._beforeRenderObserver && this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),
- this._dragPlane && this._dragPlane.dispose(),
- this.releaseDrag()
- }
- ,
- e._AnyMouseId = -2,
- e
- }(), xo = function() {
- function e() {
- this._startDistance = 0,
- this._initialScale = new x(0,0,0),
- this._targetScale = new x(0,0,0),
- this._sceneRenderObserver = null,
- this._dragBehaviorA = new Ao({}),
- this._dragBehaviorA.moveAttached = !1,
- this._dragBehaviorB = new Ao({}),
- this._dragBehaviorB.moveAttached = !1
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "MultiPointerScale"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype._getCurrentDistance = function() {
- return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()
- }
- ,
- e.prototype.attach = function(e) {
- var t = this;
- this._ownerNode = e,
- this._dragBehaviorA.onDragStartObservable.add((function() {
- t._dragBehaviorA.dragging && t._dragBehaviorB.dragging && (t._dragBehaviorA.currentDraggingPointerId == t._dragBehaviorB.currentDraggingPointerId ? t._dragBehaviorA.releaseDrag() : (t._initialScale.copyFrom(e.scaling),
- t._startDistance = t._getCurrentDistance()))
- }
- )),
- this._dragBehaviorB.onDragStartObservable.add((function() {
- t._dragBehaviorA.dragging && t._dragBehaviorB.dragging && (t._dragBehaviorA.currentDraggingPointerId == t._dragBehaviorB.currentDraggingPointerId ? t._dragBehaviorB.releaseDrag() : (t._initialScale.copyFrom(e.scaling),
- t._startDistance = t._getCurrentDistance()))
- }
- )),
- [this._dragBehaviorA, this._dragBehaviorB].forEach((function(e) {
- e.onDragObservable.add((function() {
- if (t._dragBehaviorA.dragging && t._dragBehaviorB.dragging) {
- var e = t._getCurrentDistance() / t._startDistance;
- t._initialScale.scaleToRef(e, t._targetScale)
- }
- }
- ))
- }
- )),
- e.addBehavior(this._dragBehaviorA),
- e.addBehavior(this._dragBehaviorB),
- this._sceneRenderObserver = e.getScene().onBeforeRenderObservable.add((function() {
- if (t._dragBehaviorA.dragging && t._dragBehaviorB.dragging) {
- var i = t._targetScale.subtract(e.scaling).scaleInPlace(.1);
- i.length() > .01 && e.scaling.addInPlace(i)
- }
- }
- ))
- }
- ,
- e.prototype.detach = function() {
- var e = this;
- this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),
- [this._dragBehaviorA, this._dragBehaviorB].forEach((function(t) {
- t.onDragStartObservable.clear(),
- t.onDragObservable.clear(),
- e._ownerNode.removeBehavior(t)
- }
- ))
- }
- ,
- e
- }(), Ro = function() {
- function e() {
- this._attachedToElement = !1,
- this._virtualMeshesInfo = {},
- this._tmpVector = new x,
- this._tmpQuaternion = new C,
- 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 h,
- this.onDragObservable = new h,
- this.onDragEndObservable = new h,
- this.allowMultiPointer = !0
- }
- return Object.defineProperty(e.prototype, "currentDraggingPointerId", {
- get: function() {
- return void 0 !== this.currentDraggingPointerIds[0] ? this.currentDraggingPointerIds[0] : -1
- },
- set: function(e) {
- this.currentDraggingPointerIds[0] = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentDraggingPointerID", {
- get: function() {
- return this.currentDraggingPointerId
- },
- set: function(e) {
- this.currentDraggingPointerId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "BaseSixDofDrag"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isMoving", {
- get: function() {
- return this._moving
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- Object.defineProperty(e.prototype, "_pointerCamera", {
- get: function() {
- return this._scene.cameraToUseForPointers ? this._scene.cameraToUseForPointers : this._scene.activeCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createVirtualMeshInfo = function() {
- var t = new Sr("",e._virtualScene);
- t.rotationQuaternion = new C;
- var i = new Sr("",e._virtualScene);
- i.rotationQuaternion = new C;
- var n = new Sr("",e._virtualScene);
- return n.rotationQuaternion = new C,
- {
- dragging: !1,
- moving: !1,
- dragMesh: t,
- originMesh: i,
- pivotMesh: n,
- startingPivotPosition: new x,
- startingPivotOrientation: new C,
- startingPosition: new x,
- startingOrientation: new C,
- lastOriginPosition: new x,
- lastDragPosition: new x
- }
- }
- ,
- e.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)
- }
- ,
- e.prototype._pointerUpdate2D = function(e, t, i) {
- !this._pointerCamera || this._pointerCamera.cameraRigMode != Rr.RIG_MODE_NONE || this._pointerCamera._isLeftCamera || this._pointerCamera._isRightCamera || (e.origin.copyFrom(this._pointerCamera.globalPosition),
- i = 0);
- var n = this._virtualMeshesInfo[t]
- , r = I.Vector3[0];
- e.origin.subtractToRef(n.lastOriginPosition, r),
- n.lastOriginPosition.copyFrom(e.origin);
- var o = -x.Dot(r, e.direction);
- n.originMesh.addChild(n.dragMesh),
- n.originMesh.addChild(n.pivotMesh),
- this._applyZOffset(n.dragMesh, o, i),
- this._applyZOffset(n.pivotMesh, o, i),
- n.originMesh.position.copyFrom(e.origin);
- var a = I.Vector3[0];
- e.origin.addToRef(e.direction, a),
- n.originMesh.lookAt(a),
- n.originMesh.removeChild(n.dragMesh),
- n.originMesh.removeChild(n.pivotMesh)
- }
- ,
- e.prototype._pointerUpdateXR = function(e, t, i, n) {
- var r = this._virtualMeshesInfo[i];
- if (r.originMesh.position.copyFrom(e.position),
- this._dragging === this._dragType.NEAR_DRAG && t ? r.originMesh.rotationQuaternion.copyFrom(t.rotationQuaternion) : r.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion),
- r.pivotMesh.computeWorldMatrix(!0),
- r.dragMesh.computeWorldMatrix(!0),
- 0 !== n) {
- var o = I.Vector3[0]
- , a = I.Vector3[1];
- o.copyFrom(this._pointerCamera.getForwardRay().direction),
- r.originMesh.position.subtractToRef(r.lastOriginPosition, a),
- r.lastOriginPosition.copyFrom(r.originMesh.position);
- var s = a.length();
- a.normalize();
- var l = I.Vector3[2]
- , c = I.Vector3[3];
- r.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, l),
- r.dragMesh.absolutePosition.subtractToRef(r.originMesh.position, c);
- var u = c.length();
- l.normalize(),
- c.normalize();
- var h = Math.abs(x.Dot(a, c)) * x.Dot(a, o) * n * s * u;
- h < 0 && .01 - u > h && (h = Math.min(.01 - u, 0)),
- c.scaleInPlace(h),
- c.addToRef(r.pivotMesh.absolutePosition, this._tmpVector),
- r.pivotMesh.setAbsolutePosition(this._tmpVector),
- c.addToRef(r.dragMesh.absolutePosition, this._tmpVector),
- r.dragMesh.setAbsolutePosition(this._tmpVector)
- }
- }
- ,
- e.prototype.attach = function(t) {
- var i = this;
- this._ownerNode = t,
- this._scene = this._ownerNode.getScene(),
- e._virtualScene || (e._virtualScene = new mn(this._scene.getEngine(),{
- virtual: !0
- }),
- e._virtualScene.detachControl()),
- this._pointerObserver = this._scene.onPointerObservable.add((function(e) {
- var t = e.event.pointerId;
- i._virtualMeshesInfo[t] || (i._virtualMeshesInfo[t] = i._createVirtualMeshInfo());
- var n, r = i._virtualMeshesInfo[t], o = "xr" === e.event.pointerType;
- if (e.type == Xi.POINTERDOWN) {
- if (!r.dragging && e.pickInfo && e.pickInfo.hit && e.pickInfo.pickedMesh && e.pickInfo.pickedPoint && e.pickInfo.ray && (!o || e.pickInfo.aimTransform) && (n = e.pickInfo.pickedMesh,
- i._ownerNode === n || n.isDescendantOf(i._ownerNode) && (!i.draggableMeshes || -1 !== i.draggableMeshes.indexOf(n)))) {
- if (!i.allowMultiPointer && i.currentDraggingPointerIds.length > 0)
- return;
- !i._pointerCamera || i._pointerCamera.cameraRigMode !== Rr.RIG_MODE_NONE || i._pointerCamera._isLeftCamera || i._pointerCamera._isRightCamera || e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),
- i._ownerNode.computeWorldMatrix(!0);
- var a = i._virtualMeshesInfo[t];
- o ? (i._dragging = e.pickInfo.originMesh ? i._dragType.NEAR_DRAG : i._dragType.DRAG_WITH_CONTROLLER,
- a.originMesh.position.copyFrom(e.pickInfo.aimTransform.position),
- i._dragging === i._dragType.NEAR_DRAG && e.pickInfo.gripTransform ? a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.gripTransform.rotationQuaternion) : a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.aimTransform.rotationQuaternion)) : (i._dragging = i._dragType.DRAG,
- a.originMesh.position.copyFrom(e.pickInfo.ray.origin)),
- a.lastOriginPosition.copyFrom(a.originMesh.position),
- a.dragMesh.position.copyFrom(e.pickInfo.pickedPoint),
- a.lastDragPosition.copyFrom(e.pickInfo.pickedPoint),
- a.pivotMesh.position.copyFrom(i._ownerNode.getAbsolutePivotPoint()),
- a.pivotMesh.rotationQuaternion.copyFrom(i._ownerNode.absoluteRotationQuaternion),
- a.startingPosition.copyFrom(a.dragMesh.position),
- a.startingPivotPosition.copyFrom(a.pivotMesh.position),
- a.startingOrientation.copyFrom(a.dragMesh.rotationQuaternion),
- a.startingPivotOrientation.copyFrom(a.pivotMesh.rotationQuaternion),
- o ? (a.originMesh.addChild(a.dragMesh),
- a.originMesh.addChild(a.pivotMesh)) : a.originMesh.lookAt(a.dragMesh.position),
- a.dragging = !0,
- -1 === i.currentDraggingPointerIds.indexOf(t) && i.currentDraggingPointerIds.push(t),
- 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(a.pivotMesh.position, a.pivotMesh.rotationQuaternion, t),
- i.onDragStartObservable.notifyObservers({
- position: a.pivotMesh.position
- })
- }
- } else if (e.type == Xi.POINTERUP || e.type == Xi.POINTERDOUBLETAP) {
- var s = i.currentDraggingPointerIds.indexOf(t);
- r.dragging = !1,
- -1 !== s && (i.currentDraggingPointerIds.splice(s, 1),
- 0 === i.currentDraggingPointerIds.length && (i._moving = !1,
- i._dragging = i._dragType.NONE,
- i.detachCameraControls && i._attachedToElement && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.attachControl(!0),
- i._attachedToElement = !1)),
- r.originMesh.removeChild(r.dragMesh),
- r.originMesh.removeChild(r.pivotMesh),
- i._targetDragEnd(t),
- i.onDragEndObservable.notifyObservers({}))
- } else if (e.type == Xi.POINTERMOVE && -1 !== (s = i.currentDraggingPointerIds.indexOf(t)) && r.dragging && e.pickInfo && (e.pickInfo.ray || e.pickInfo.aimTransform)) {
- var l = i.zDragFactor;
- (i.currentDraggingPointerIds.length > 1 || e.pickInfo.originMesh) && (l = 0),
- i._ownerNode.computeWorldMatrix(!0),
- o ? i._pointerUpdateXR(e.pickInfo.aimTransform, e.pickInfo.gripTransform, t, l) : i._pointerUpdate2D(e.pickInfo.ray, t, l),
- i._tmpQuaternion.copyFrom(r.startingPivotOrientation),
- i._tmpQuaternion.x = -i._tmpQuaternion.x,
- i._tmpQuaternion.y = -i._tmpQuaternion.y,
- i._tmpQuaternion.z = -i._tmpQuaternion.z,
- r.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion, i._tmpQuaternion),
- r.pivotMesh.absolutePosition.subtractToRef(r.startingPivotPosition, i._tmpVector),
- i.onDragObservable.notifyObservers({
- delta: i._tmpVector,
- position: r.pivotMesh.position,
- pickInfo: e.pickInfo
- }),
- i._targetDrag(i._tmpVector, i._tmpQuaternion, t),
- r.lastDragPosition.copyFrom(r.dragMesh.absolutePosition),
- i._moving = !0
- }
- }
- ))
- }
- ,
- e.prototype._applyZOffset = function(e, t, i) {
- e.position.z -= e.position.z < 1 ? t * i : t * i * e.position.z,
- e.position.z < 0 && (e.position.z = 0)
- }
- ,
- e.prototype._targetDragStart = function(e, t, i) {}
- ,
- e.prototype._targetDrag = function(e, t, i) {}
- ,
- e.prototype._targetDragEnd = function(e) {}
- ,
- e.prototype.detach = function() {
- for (var e in this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._pointerCamera.attachControl(!0),
- this._attachedToElement = !1),
- this._scene.onPointerObservable.remove(this._pointerObserver)),
- this._virtualMeshesInfo)
- this._virtualMeshesInfo[e].originMesh.dispose(),
- this._virtualMeshesInfo[e].dragMesh.dispose();
- this.onDragEndObservable.clear(),
- this.onDragObservable.clear(),
- this.onDragStartObservable.clear()
- }
- ,
- e
- }(), Co = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t._sceneRenderObserver = null,
- t._targetPosition = new x(0,0,0),
- t._targetOrientation = new C,
- t._targetScaling = new x(1,1,1),
- t._startingPosition = new x(0,0,0),
- t._startingOrientation = new C,
- t._startingScaling = new x(1,1,1),
- t.onPositionChangedObservable = new h,
- t.dragDeltaRatio = .2,
- t.rotateDraggedObject = !0,
- t.rotateAroundYOnly = !1,
- t.rotateWithMotionController = !0,
- t.disableMovement = !1,
- t.faceCameraOnDragStart = !1,
- t
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "name", {
- get: function() {
- return "SixDofDrag"
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.attach = function(t) {
- var i = this;
- e.prototype.attach.call(this, t),
- t.isNearGrabbable = !0,
- this._virtualTransformNode = new yr("virtual_sixDof",Ro._virtualScene),
- this._virtualTransformNode.rotationQuaternion = C.Identity(),
- this._sceneRenderObserver = t.getScene().onBeforeRenderObservable.add((function() {
- if (1 === i.currentDraggingPointerIds.length && i._moving && !i.disableMovement) {
- var e = t.parent;
- t.setParent(null),
- t.position.addInPlace(i._targetPosition.subtract(t.position).scale(i.dragDeltaRatio)),
- i.onPositionChangedObservable.notifyObservers({
- position: t.absolutePosition
- }),
- (!e || e.scaling && !e.scaling.isNonUniformWithinEpsilon(.001)) && C.SlerpToRef(t.rotationQuaternion, i._targetOrientation, i.dragDeltaRatio, t.rotationQuaternion),
- t.setParent(e)
- }
- }
- ))
- }
- ,
- t.prototype._getPositionOffsetAround = function(e, t, i) {
- var n = I.Matrix[0]
- , r = I.Matrix[1]
- , o = I.Matrix[2]
- , a = I.Matrix[3]
- , s = I.Matrix[4];
- return P.TranslationToRef(e.x, e.y, e.z, n),
- P.TranslationToRef(-e.x, -e.y, -e.z, r),
- P.FromQuaternionToRef(i, o),
- P.ScalingToRef(t, t, t, a),
- r.multiplyToRef(o, s),
- s.multiplyToRef(a, s),
- s.multiplyToRef(n, s),
- s.getTranslation()
- }
- ,
- t.prototype._onePointerPositionUpdated = function(e, t) {
- I.Vector3[0].setAll(0),
- this._dragging === this._dragType.DRAG ? this.rotateDraggedObject && (this.rotateAroundYOnly ? C.RotationYawPitchRollToRef(t.toEulerAngles().y, 0, 0, I.Quaternion[0]) : I.Quaternion[0].copyFrom(t),
- I.Quaternion[0].multiplyToRef(this._startingOrientation, this._targetOrientation)) : (this._dragging === this._dragType.NEAR_DRAG || this._dragging === this._dragType.DRAG_WITH_CONTROLLER && this.rotateWithMotionController) && t.multiplyToRef(this._startingOrientation, this._targetOrientation),
- this._targetPosition.copyFrom(this._startingPosition).addInPlace(e)
- }
- ,
- t.prototype._twoPointersPositionUpdated = function() {
- var e = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition
- , t = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition
- , i = I.Vector3[0];
- e.addToRef(t, i),
- i.scaleInPlace(.5);
- var n = I.Vector3[1];
- t.subtractToRef(e, n);
- var r = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition
- , o = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition
- , a = I.Vector3[2];
- r.addToRef(o, a),
- a.scaleInPlace(.5);
- var s = I.Vector3[3];
- o.subtractToRef(r, s);
- var l = s.length() / n.length()
- , c = a.subtract(i)
- , u = C.FromEulerAngles(0, x.GetAngleBetweenVectorsOnPlane(n.normalize(), s.normalize(), x.UpReadOnly), 0)
- , h = this._ownerNode.parent;
- this._ownerNode.setParent(null);
- var d = this._getPositionOffsetAround(i.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), l, u);
- this._virtualTransformNode.rotationQuaternion.multiplyToRef(u, this._ownerNode.rotationQuaternion),
- this._virtualTransformNode.scaling.scaleToRef(l, this._ownerNode.scaling),
- this._virtualTransformNode.position.addToRef(c.addInPlace(d), this._ownerNode.position),
- this.onPositionChangedObservable.notifyObservers({
- position: this._ownerNode.position
- }),
- this._ownerNode.setParent(h)
- }
- ,
- t.prototype._targetDragStart = function() {
- var e = this.currentDraggingPointerIds.length
- , t = this._ownerNode.parent;
- this._ownerNode.rotationQuaternion || (this._ownerNode.rotationQuaternion = C.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z));
- var i = this._ownerNode.getAbsolutePivotPoint();
- if (this._ownerNode.setParent(null),
- 1 === e) {
- 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 n = I.Vector3[0];
- this._scene.activeCamera.position.subtractToRef(i, n),
- n.normalize();
- var r = I.Quaternion[0];
- this._scene.useRightHandedSystem ? C.FromLookDirectionRHToRef(n, new x(0,1,0), r) : C.FromLookDirectionLHToRef(n, new x(0,1,0), r),
- r.normalize(),
- C.RotationYawPitchRollToRef(r.toEulerAngles().y, 0, 0, I.Quaternion[0]),
- this._targetOrientation.copyFrom(I.Quaternion[0])
- }
- this._startingPosition.copyFrom(this._targetPosition),
- this._startingOrientation.copyFrom(this._targetOrientation),
- this._startingScaling.copyFrom(this._targetScaling)
- } else
- 2 === e && (this._virtualTransformNode.setPivotPoint(new x(0,0,0), Ji.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(i, Ji.WORLD),
- this._resetVirtualMeshesPosition());
- this._ownerNode.setParent(t)
- }
- ,
- t.prototype._targetDrag = function(e, t) {
- 1 === this.currentDraggingPointerIds.length ? this._onePointerPositionUpdated(e, t) : 2 === this.currentDraggingPointerIds.length && this._twoPointersPositionUpdated()
- }
- ,
- t.prototype._targetDragEnd = function() {
- if (1 === this.currentDraggingPointerIds.length) {
- this._resetVirtualMeshesPosition();
- var e = this.faceCameraOnDragStart;
- this.faceCameraOnDragStart = !1,
- this._targetDragStart(),
- this.faceCameraOnDragStart = e
- }
- }
- ,
- t.prototype.detach = function() {
- e.prototype.detach.call(this),
- this._ownerNode && (this._ownerNode.isNearGrabbable = !1,
- this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),
- this._virtualTransformNode && this._virtualTransformNode.dispose()
- }
- ,
- t
- }(Ro), Po = function() {
- function e() {
- this._attachPointLocalOffset = new x,
- this._workingPosition = new x,
- this._workingQuaternion = new C,
- this._lastTick = -1,
- this._hit = !1,
- this.hitNormalOffset = .05,
- this.meshes = [],
- this.interpolatePose = !0,
- this.lerpTime = 250,
- this.keepOrientationVertical = !0,
- this.enabled = !0,
- this.maxStickingDistance = .8
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "SurfaceMagnetism"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(e, t) {
- this._attachedMesh = e,
- this._scene = t || e.getScene(),
- this._attachedMesh.rotationQuaternion || (this._attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(this._attachedMesh.rotation.y, this._attachedMesh.rotation.x, this._attachedMesh.rotation.z)),
- this.updateAttachPoint(),
- this._workingPosition.copyFrom(this._attachedMesh.position),
- this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion),
- this._addObservables()
- }
- ,
- e.prototype.detach = function() {
- this._attachedMesh = null,
- this._removeObservables()
- }
- ,
- e.prototype._getTargetPose = function(e) {
- if (!this._attachedMesh)
- return null;
- if (e && e.hit) {
- var t = e.getNormal(!0, !0)
- , i = e.pickedPoint;
- if (!t || !i)
- return null;
- t.normalize();
- var n = I.Vector3[0];
- return n.copyFrom(t),
- n.scaleInPlace(this.hitNormalOffset),
- n.addInPlace(i),
- this._attachedMesh.parent && (I.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),
- x.TransformNormalToRef(n, I.Matrix[0], n)),
- {
- position: n,
- quaternion: C.RotationYawPitchRoll(-Math.atan2(t.x, -t.z), this.keepOrientationVertical ? 0 : Math.atan2(t.y, Math.sqrt(t.z * t.z + t.x * t.x)), 0)
- }
- }
- return null
- }
- ,
- e.prototype.updateAttachPoint = function() {
- this._getAttachPointOffsetToRef(this._attachPointLocalOffset)
- }
- ,
- e.prototype.findAndUpdateTarget = function(e) {
- if (this._hit = !1,
- !e.ray)
- return !1;
- var t = e.ray.intersectsMeshes(this.meshes)[0];
- if (this._attachedMesh && t && t.hit && t.pickedMesh) {
- var i = this._getTargetPose(t);
- i && x.Distance(this._attachedMesh.position, i.position) < this.maxStickingDistance && (this._workingPosition.copyFrom(i.position),
- this._workingQuaternion.copyFrom(i.quaternion),
- this._hit = !0)
- }
- return this._hit
- }
- ,
- e.prototype._getAttachPointOffsetToRef = function(e) {
- if (this._attachedMesh) {
- var t = I.Quaternion[0];
- t.copyFrom(this._attachedMesh.rotationQuaternion),
- this._attachedMesh.rotationQuaternion.copyFromFloats(0, 0, 0, 1),
- this._attachedMesh.computeWorldMatrix();
- var i = this._attachedMesh.getHierarchyBoundingVectors()
- , n = I.Vector3[0];
- i.max.addToRef(i.min, n),
- n.scaleInPlace(.5),
- n.z = i.max.z;
- var r = I.Matrix[0];
- this._attachedMesh.getWorldMatrix().invertToRef(r),
- x.TransformCoordinatesToRef(n, r, e),
- this._attachedMesh.rotationQuaternion.copyFrom(t)
- } else
- e.setAll(0)
- }
- ,
- e.prototype._updateTransformToGoal = function(e) {
- if (this._attachedMesh && this._hit) {
- var t = this._attachedMesh.parent;
- this._attachedMesh.setParent(null);
- var i = I.Vector3[0];
- if (x.TransformNormalToRef(this._attachPointLocalOffset, this._attachedMesh.getWorldMatrix(), i),
- !this.interpolatePose)
- return this._attachedMesh.position.copyFrom(this._workingPosition).subtractInPlace(i),
- void this._attachedMesh.rotationQuaternion.copyFrom(this._workingQuaternion);
- var n = new x;
- x.SmoothToRef(this._attachedMesh.position, this._workingPosition, e, this.lerpTime, n),
- this._attachedMesh.position.copyFrom(n);
- var r = new C;
- r.copyFrom(this._attachedMesh.rotationQuaternion),
- C.SmoothToRef(r, this._workingQuaternion, e, this.lerpTime, this._attachedMesh.rotationQuaternion),
- this._attachedMesh.setParent(t)
- }
- }
- ,
- e.prototype._addObservables = function() {
- var e = this;
- this._pointerObserver = this._scene.onPointerObservable.add((function(t) {
- e.enabled && t.type == Xi.POINTERMOVE && t.pickInfo && e.findAndUpdateTarget(t.pickInfo)
- }
- )),
- this._lastTick = Date.now(),
- this._onBeforeRender = this._scene.onBeforeRenderObservable.add((function() {
- var t = Date.now();
- e._updateTransformToGoal(t - e._lastTick),
- e._lastTick = t
- }
- ))
- }
- ,
- e.prototype._removeObservables = function() {
- this._scene.onPointerObservable.remove(this._pointerObserver),
- this._scene.onBeforeRenderObservable.remove(this._onBeforeRender),
- this._pointerObserver = null,
- this._onBeforeRender = null
- }
- ,
- e
- }(), Mo = function() {
- function e() {
- this._tmpQuaternion = new C,
- this._tmpVectors = [new x, new x, new x, new x, new x, new x, new x],
- this._tmpMatrix = new P,
- this._tmpInvertView = new P,
- this._tmpForward = new x,
- this._tmpNodeForward = new x,
- this._tmpPosition = new x,
- this._workingPosition = new x,
- this._workingQuaternion = new C,
- this._lastTick = -1,
- this._recenterNextUpdate = !0,
- this.interpolatePose = !0,
- this.lerpTime = 500,
- this.ignoreCameraPitchAndRoll = !1,
- this.pitchOffset = 15,
- this.maxViewVerticalDegrees = 30,
- this.maxViewHorizontalDegrees = 30,
- this.orientToCameraDeadzoneDegrees = 60,
- this.ignoreDistanceClamp = !1,
- this.ignoreAngleClamp = !1,
- this.verticalMaxDistance = 0,
- this.defaultDistance = .8,
- this.maximumDistance = 2,
- this.minimumDistance = .3,
- this.useFixedVerticalOffset = !1,
- this.fixedVerticalOffset = 0,
- this._enabled = !0
- }
- return Object.defineProperty(e.prototype, "followedCamera", {
- get: function() {
- return this._followedCamera || this._scene.activeCamera
- },
- set: function(e) {
- this._followedCamera = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "Follow"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(e, t) {
- this._scene = e.getScene(),
- this.attachedNode = e,
- t && (this.followedCamera = t),
- this._addObservables()
- }
- ,
- e.prototype.detach = function() {
- this.attachedNode = null,
- this._removeObservables()
- }
- ,
- e.prototype.recenter = function() {
- this._recenterNextUpdate = !0
- }
- ,
- e.prototype._angleBetweenVectorAndPlane = function(e, t) {
- return this._tmpVectors[0].copyFrom(e),
- e = this._tmpVectors[0],
- this._tmpVectors[1].copyFrom(t),
- t = this._tmpVectors[1],
- e.normalize(),
- t.normalize(),
- Math.PI / 2 - Math.acos(x.Dot(e, t))
- }
- ,
- e.prototype._length2D = function(e) {
- return Math.sqrt(e.x * e.x + e.z * e.z)
- }
- ,
- e.prototype._distanceClamp = function(e, t) {
- void 0 === t && (t = !1);
- var i = this.minimumDistance
- , n = this.maximumDistance
- , r = this.defaultDistance
- , o = this._tmpVectors[0];
- o.copyFrom(e);
- var a = o.length();
- if (o.normalizeFromLength(a),
- this.ignoreCameraPitchAndRoll) {
- i = this._length2D(o) * i,
- n = this._length2D(o) * n;
- var s = this._length2D(e);
- o.scaleInPlace(a / s),
- a = s
- }
- var l;
- return l = t ? r : d.Clamp(a, i, n),
- e.copyFrom(o).scaleInPlace(l),
- a !== l
- }
- ,
- e.prototype._applyVerticalClamp = function(e) {
- 0 !== this.verticalMaxDistance && (e.y = d.Clamp(e.y, -this.verticalMaxDistance, this.verticalMaxDistance))
- }
- ,
- e.prototype._toOrientationQuatToRef = function(e, t) {
- C.RotationYawPitchRollToRef(Math.atan2(e.x, e.z), Math.atan2(e.y, Math.sqrt(e.z * e.z + e.x * e.x)), 0, t)
- }
- ,
- e.prototype._applyPitchOffset = function(e) {
- var t = this._tmpVectors[0]
- , i = this._tmpVectors[1];
- t.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- i.copyFromFloats(1, 0, 0),
- x.TransformNormalToRef(t, e, t),
- t.y = 0,
- t.normalize(),
- x.TransformNormalToRef(i, e, i),
- C.RotationAxisToRef(i, this.pitchOffset * Math.PI / 180, this._tmpQuaternion),
- t.rotateByQuaternionToRef(this._tmpQuaternion, t),
- this._toOrientationQuatToRef(t, this._tmpQuaternion),
- this._tmpQuaternion.toRotationMatrix(this._tmpMatrix),
- e.copyFrom(this._tmpMatrix)
- }
- ,
- e.prototype._angularClamp = function(e, t) {
- var i = this._tmpVectors[5];
- i.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1);
- var n = this._tmpVectors[6];
- n.copyFromFloats(1, 0, 0),
- x.TransformNormalToRef(i, e, i),
- x.TransformNormalToRef(n, e, n);
- var r = x.UpReadOnly;
- if (t.length() < m)
- return !1;
- var o = !1
- , a = this._tmpQuaternion;
- if (this.ignoreCameraPitchAndRoll) {
- var s = x.GetAngleBetweenVectorsOnPlane(t, i, n);
- C.RotationAxisToRef(n, s, a),
- t.rotateByQuaternionToRef(a, t)
- } else {
- var l = -x.GetAngleBetweenVectorsOnPlane(t, i, n)
- , c = this.maxViewVerticalDegrees * Math.PI / 180 * .5;
- l < -c ? (C.RotationAxisToRef(n, -l - c, a),
- t.rotateByQuaternionToRef(a, t),
- o = !0) : l > c && (C.RotationAxisToRef(n, -l + c, a),
- t.rotateByQuaternionToRef(a, t),
- o = !0)
- }
- var u = this._angleBetweenVectorAndPlane(t, n) * (this._scene.useRightHandedSystem ? -1 : 1)
- , h = this.maxViewHorizontalDegrees * Math.PI / 180 * .5;
- return u < -h ? (C.RotationAxisToRef(r, -u - h, a),
- t.rotateByQuaternionToRef(a, t),
- o = !0) : u > h && (C.RotationAxisToRef(r, -u + h, a),
- t.rotateByQuaternionToRef(a, t),
- o = !0),
- o
- }
- ,
- e.prototype._orientationClamp = function(e, t) {
- var i, n = this._tmpVectors[0];
- n.copyFrom(e).scaleInPlace(-1).normalize();
- var r = this._tmpVectors[1]
- , o = this._tmpVectors[2];
- r.copyFromFloats(0, 1, 0),
- x.CrossToRef(n, r, o);
- var a = o.length();
- a < m || (o.normalizeFromLength(a),
- x.CrossToRef(o, n, r),
- (null === (i = this.attachedNode) || void 0 === i ? void 0 : i.getScene().useRightHandedSystem) ? C.FromLookDirectionRHToRef(n, r, t) : C.FromLookDirectionLHToRef(n, r, t))
- }
- ,
- e.prototype._passedOrientationDeadzone = function(e, t) {
- var i = this._tmpVectors[5];
- return i.copyFrom(e),
- i.normalize(),
- 180 * Math.abs(x.GetAngleBetweenVectorsOnPlane(t, i, x.UpReadOnly)) / Math.PI > this.orientToCameraDeadzoneDegrees
- }
- ,
- e.prototype._updateLeashing = function(e) {
- if (this.attachedNode && this._enabled) {
- var t = this.attachedNode.parent;
- this.attachedNode.setParent(null);
- var i = this.attachedNode.getWorldMatrix()
- , n = this._workingPosition
- , r = this._workingQuaternion
- , o = this.attachedNode.getPivotPoint()
- , a = this._tmpInvertView;
- a.copyFrom(e.getViewMatrix()),
- a.invert(),
- x.TransformCoordinatesToRef(o, i, n);
- var s = this._tmpPosition;
- s.copyFromFloats(0, 0, 0),
- x.TransformCoordinatesToRef(s, i, s),
- s.scaleInPlace(-1).subtractInPlace(o),
- n.subtractInPlace(e.globalPosition),
- this.ignoreCameraPitchAndRoll && this._applyPitchOffset(a);
- var l = !1
- , c = this._tmpForward;
- c.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- x.TransformNormalToRef(c, a, c);
- var u = this._tmpNodeForward;
- if (u.copyFromFloats(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- x.TransformNormalToRef(u, i, u),
- this._recenterNextUpdate)
- n.copyFrom(c).scaleInPlace(this.defaultDistance);
- else if (this.ignoreAngleClamp) {
- var h = n.length();
- n.copyFrom(c).scaleInPlace(h)
- } else
- l = this._angularClamp(a, n);
- var d = !1;
- this.ignoreDistanceClamp || (d = this._distanceClamp(n, l),
- this._applyVerticalClamp(n)),
- this.useFixedVerticalOffset && (n.y = s.y - e.globalPosition.y + this.fixedVerticalOffset),
- (l || d || this._passedOrientationDeadzone(n, u) || this._recenterNextUpdate) && this._orientationClamp(n, r),
- this._workingPosition.subtractInPlace(o),
- this._recenterNextUpdate = !1,
- this.attachedNode.setParent(t)
- }
- }
- ,
- e.prototype._updateTransformToGoal = function(e) {
- if (this.attachedNode && this.followedCamera && this._enabled) {
- this.attachedNode.rotationQuaternion || (this.attachedNode.rotationQuaternion = C.Identity());
- var t = this.attachedNode.parent;
- if (this.attachedNode.setParent(null),
- !this.interpolatePose)
- return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition),
- void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);
- var i = new x;
- i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),
- x.SmoothToRef(i, this._workingPosition, e, this.lerpTime, i),
- i.addInPlace(this.followedCamera.globalPosition),
- this.attachedNode.position.copyFrom(i);
- var n = new C;
- n.copyFrom(this.attachedNode.rotationQuaternion),
- C.SmoothToRef(n, this._workingQuaternion, e, this.lerpTime, this.attachedNode.rotationQuaternion),
- this.attachedNode.setParent(t)
- }
- }
- ,
- e.prototype._addObservables = function() {
- var e = this;
- this._lastTick = Date.now(),
- this._onBeforeRender = this._scene.onBeforeRenderObservable.add((function() {
- if (e.followedCamera) {
- var t = Date.now();
- e._updateLeashing(e.followedCamera),
- e._updateTransformToGoal(t - e._lastTick),
- e._lastTick = t
- }
- }
- ))
- }
- ,
- e.prototype._removeObservables = function() {
- this._onBeforeRender && this._scene.onBeforeRenderObservable.remove(this._onBeforeRender)
- }
- ,
- e
- }(), Io = function() {
- function e() {}
- return e.ANCHOR_SYSTEM = "xr-anchor-system",
- e.BACKGROUND_REMOVER = "xr-background-remover",
- e.HIT_TEST = "xr-hit-test",
- e.MESH_DETECTION = "xr-mesh-detection",
- e.PHYSICS_CONTROLLERS = "xr-physics-controller",
- e.PLANE_DETECTION = "xr-plane-detection",
- e.POINTER_SELECTION = "xr-controller-pointer-selection",
- e.TELEPORTATION = "xr-controller-teleportation",
- e.FEATURE_POINTS = "xr-feature-points",
- e.HAND_TRACKING = "xr-hand-tracking",
- e.IMAGE_TRACKING = "xr-image-tracking",
- e.NEAR_INTERACTION = "xr-near-interaction",
- e.DOM_OVERLAY = "xr-dom-overlay",
- e.MOVEMENT = "xr-controller-movement",
- e.LIGHT_ESTIMATION = "xr-light-estimation",
- e.EYE_TRACKING = "xr-eye-tracking",
- e.WALKING_LOCOMOTION = "xr-walking-locomotion",
- e.LAYERS = "xr-layers",
- e
- }(), Oo = function() {
- function e(e) {
- var t = this;
- this._xrSessionManager = e,
- this._features = {},
- this._xrSessionManager.onXRSessionInit.add((function() {
- t.getEnabledFeatures().forEach((function(e) {
- var i = t._features[e];
- !i.enabled || i.featureImplementation.attached || i.featureImplementation.disableAutoAttach || t.attachFeature(e)
- }
- ))
- }
- )),
- this._xrSessionManager.onXRSessionEnded.add((function() {
- t.getEnabledFeatures().forEach((function(e) {
- var i = t._features[e];
- i.enabled && i.featureImplementation.attached && t.detachFeature(e)
- }
- ))
- }
- ))
- }
- return e.AddWebXRFeature = function(e, t, i, n) {
- void 0 === i && (i = 1),
- void 0 === n && (n = !1),
- this._AvailableFeatures[e] = this._AvailableFeatures[e] || {
- latest: i
- },
- i > this._AvailableFeatures[e].latest && (this._AvailableFeatures[e].latest = i),
- n && (this._AvailableFeatures[e].stable = i),
- this._AvailableFeatures[e][i] = t
- }
- ,
- e.ConstructFeature = function(e, t, i, n) {
- void 0 === t && (t = 1);
- var r = this._AvailableFeatures[e][t];
- if (!r)
- throw new Error("feature not found");
- return r(i, n)
- }
- ,
- e.GetAvailableFeatures = function() {
- return Object.keys(this._AvailableFeatures)
- }
- ,
- e.GetAvailableVersions = function(e) {
- return Object.keys(this._AvailableFeatures[e])
- }
- ,
- e.GetLatestVersionOfFeature = function(e) {
- return this._AvailableFeatures[e] && this._AvailableFeatures[e].latest || -1
- }
- ,
- e.GetStableVersionOfFeature = function(e) {
- return this._AvailableFeatures[e] && this._AvailableFeatures[e].stable || -1
- }
- ,
- e.prototype.attachFeature = function(e) {
- var t = this._features[e];
- t && t.enabled && !t.featureImplementation.attached && t.featureImplementation.attach()
- }
- ,
- e.prototype.detachFeature = function(e) {
- var t = this._features[e];
- t && t.featureImplementation.attached && t.featureImplementation.detach()
- }
- ,
- e.prototype.disableFeature = function(e) {
- var t = "string" == typeof e ? e : e.Name
- , i = this._features[t];
- return !(!i || !i.enabled || (i.enabled = !1,
- this.detachFeature(t),
- i.featureImplementation.dispose(),
- delete this._features[t],
- 0))
- }
- ,
- e.prototype.dispose = function() {
- var e = this;
- this.getEnabledFeatures().forEach((function(t) {
- e.disableFeature(t)
- }
- ))
- }
- ,
- e.prototype.enableFeature = function(t, i, n, r, o) {
- var a = this;
- void 0 === i && (i = "latest"),
- void 0 === n && (n = {}),
- void 0 === r && (r = !0),
- void 0 === o && (o = !0);
- var s = "string" == typeof t ? t : t.Name
- , l = 0;
- if ("string" == typeof i) {
- if (!i)
- throw new Error("Error in provided version - ".concat(s, " (").concat(i, ")"));
- if (-1 === (l = "stable" === i ? e.GetStableVersionOfFeature(s) : "latest" === i ? e.GetLatestVersionOfFeature(s) : +i) || isNaN(l))
- throw new Error("feature not found - ".concat(s, " (").concat(i, ")"))
- } else
- l = i;
- var c = e._ConflictingFeatures[s];
- if (void 0 !== c && -1 !== this.getEnabledFeatures().indexOf(c))
- throw new Error("Feature ".concat(s, " cannot be enabled while ").concat(c, " is enabled."));
- var u = this._features[s]
- , h = e.ConstructFeature(s, l, this._xrSessionManager, n);
- if (!h)
- throw new Error("feature not found - ".concat(s));
- u && this.disableFeature(s);
- var d = h();
- if (d.dependsOn) {
- var p = d.dependsOn.every((function(e) {
- return !!a._features[e]
- }
- ));
- if (!p)
- throw new Error("Dependant features missing. Make sure the following features are enabled - ".concat(d.dependsOn.join(", ")))
- }
- if (d.isCompatible())
- return this._features[s] = {
- featureImplementation: d,
- enabled: !0,
- version: l,
- required: o
- },
- r ? this._xrSessionManager.session && !this._features[s].featureImplementation.attached && this.attachFeature(s) : this._features[s].featureImplementation.disableAutoAttach = !0,
- this._features[s].featureImplementation;
- if (o)
- throw new Error("required feature not compatible");
- return gi.Warn("Feature ".concat(s, " not compatible with the current environment/browser and was not enabled.")),
- d
- }
- ,
- e.prototype.getEnabledFeature = function(e) {
- return this._features[e] && this._features[e].featureImplementation
- }
- ,
- e.prototype.getEnabledFeatures = function() {
- return Object.keys(this._features)
- }
- ,
- e.prototype._extendXRSessionInitObject = function(e) {
- return G(this, void 0, void 0, (function() {
- var t, i, n, r, o, a, s;
- return z(this, (function(l) {
- switch (l.label) {
- case 0:
- t = this.getEnabledFeatures(),
- i = 0,
- n = t,
- l.label = 1;
- case 1:
- return i < n.length ? (r = n[i],
- o = this._features[r],
- (a = o.featureImplementation.xrNativeFeatureName) && (o.required ? (e.requiredFeatures = e.requiredFeatures || [],
- -1 === e.requiredFeatures.indexOf(a) && e.requiredFeatures.push(a)) : (e.optionalFeatures = e.optionalFeatures || [],
- -1 === e.optionalFeatures.indexOf(a) && e.optionalFeatures.push(a))),
- o.featureImplementation.getXRSessionInitExtension ? [4, o.featureImplementation.getXRSessionInitExtension()] : [3, 3]) : [3, 4];
- case 2:
- s = l.sent(),
- e = V(V({}, e), s),
- l.label = 3;
- case 3:
- return i++,
- [3, 1];
- case 4:
- return [2, e]
- }
- }
- ))
- }
- ))
- }
- ,
- e._AvailableFeatures = {},
- e._ConflictingFeatures = ((bo = {})[Io.TELEPORTATION] = Io.MOVEMENT,
- bo[Io.MOVEMENT] = Io.TELEPORTATION,
- bo),
- e
- }();
- !function(e) {
- e[e.ABOVE_FINGER_TIPS = 0] = "ABOVE_FINGER_TIPS",
- e[e.RADIAL_SIDE = 1] = "RADIAL_SIDE",
- e[e.ULNAR_SIDE = 2] = "ULNAR_SIDE",
- e[e.BELOW_WRIST = 3] = "BELOW_WRIST"
- }(To || (To = {})),
- function(e) {
- e[e.LOOK_AT_CAMERA = 0] = "LOOK_AT_CAMERA",
- e[e.HAND_ROTATION = 1] = "HAND_ROTATION"
- }(Eo || (Eo = {})),
- function(e) {
- e[e.ALWAYS_VISIBLE = 0] = "ALWAYS_VISIBLE",
- e[e.PALM_UP = 1] = "PALM_UP",
- e[e.GAZE_FOCUS = 2] = "GAZE_FOCUS",
- e[e.PALM_AND_GAZE = 3] = "PALM_AND_GAZE"
- }(So || (So = {}));
- var Do = function() {
- function e() {
- this._sceneRenderObserver = null,
- this._zoneAxis = {},
- this.handConstraintVisibility = So.PALM_AND_GAZE,
- this.palmUpStrictness = .95,
- this.gazeProximityRadius = .15,
- this.targetOffset = .1,
- this.targetZone = To.ULNAR_SIDE,
- this.zoneOrientationMode = Eo.HAND_ROTATION,
- this.nodeOrientationMode = Eo.HAND_ROTATION,
- this.handedness = "none",
- this.lerpTime = 100,
- this._zoneAxis[To.ABOVE_FINGER_TIPS] = new x(0,1,0),
- this._zoneAxis[To.RADIAL_SIDE] = new x(-1,0,0),
- this._zoneAxis[To.ULNAR_SIDE] = new x(1,0,0),
- this._zoneAxis[To.BELOW_WRIST] = new x(0,-1,0)
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "HandConstraint"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.enable = function() {
- this._node.setEnabled(!0)
- }
- ,
- e.prototype.disable = function() {
- this._node.setEnabled(!1)
- }
- ,
- e.prototype._getHandPose = function() {
- if (!this._handTracking)
- return null;
- var e;
- if (e = "none" === this.handedness ? this._handTracking.getHandByHandedness("left") || this._handTracking.getHandByHandedness("right") : this._handTracking.getHandByHandedness(this.handedness)) {
- var t = e.getJointMesh("pinky-finger-metacarpal")
- , i = e.getJointMesh("middle-finger-metacarpal")
- , n = e.getJointMesh("wrist");
- if (n && i && t) {
- var r = {
- position: i.absolutePosition,
- quaternion: new C,
- id: e.xrController.uniqueId
- }
- , o = I.Vector3[0]
- , a = I.Vector3[1]
- , s = I.Vector3[2];
- return o.copyFrom(i.absolutePosition).subtractInPlace(n.absolutePosition).normalize(),
- a.copyFrom(t.absolutePosition).subtractInPlace(i.absolutePosition).normalize(),
- x.CrossToRef(o, a, a),
- x.CrossToRef(a, o, s),
- C.FromLookDirectionLHToRef(a, o, r.quaternion),
- r
- }
- }
- return null
- }
- ,
- e.prototype.init = function() {}
- ,
- e.prototype.attach = function(e) {
- var t = this;
- this._node = e,
- this._scene = e.getScene(),
- this._node.rotationQuaternion || (this._node.rotationQuaternion = C.RotationYawPitchRoll(this._node.rotation.y, this._node.rotation.x, this._node.rotation.z));
- var i = Date.now();
- this._sceneRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
- var e = t._getHandPose();
- if (t._node.reservedDataStore = t._node.reservedDataStore || {},
- t._node.reservedDataStore.nearInteraction = t._node.reservedDataStore.nearInteraction || {},
- t._node.reservedDataStore.nearInteraction.excludedControllerId = null,
- e) {
- var n = I.Vector3[0]
- , r = t._scene.activeCamera;
- n.copyFrom(t._zoneAxis[t.targetZone]);
- var o = I.Quaternion[0];
- if (r && (t.zoneOrientationMode === Eo.LOOK_AT_CAMERA || t.nodeOrientationMode === Eo.LOOK_AT_CAMERA)) {
- var a = I.Vector3[1];
- a.copyFrom(r.position).subtractInPlace(e.position).normalize(),
- t._scene.useRightHandedSystem ? C.FromLookDirectionRHToRef(a, x.UpReadOnly, o) : C.FromLookDirectionLHToRef(a, x.UpReadOnly, o)
- }
- t.zoneOrientationMode === Eo.HAND_ROTATION ? e.quaternion.toRotationMatrix(I.Matrix[0]) : o.toRotationMatrix(I.Matrix[0]),
- x.TransformNormalToRef(n, I.Matrix[0], n),
- n.scaleInPlace(t.targetOffset);
- var s = I.Vector3[2]
- , l = I.Quaternion[1];
- s.copyFrom(e.position).addInPlace(n),
- t.nodeOrientationMode === Eo.HAND_ROTATION ? l.copyFrom(e.quaternion) : l.copyFrom(o);
- var c = Date.now() - i;
- x.SmoothToRef(t._node.position, s, c, t.lerpTime, t._node.position),
- C.SmoothToRef(t._node.rotationQuaternion, l, c, t.lerpTime, t._node.rotationQuaternion),
- t._node.reservedDataStore.nearInteraction.excludedControllerId = e.id
- }
- t._setVisibility(e),
- i = Date.now()
- }
- ))
- }
- ,
- e.prototype._setVisibility = function(e) {
- var t = !0
- , i = !0
- , n = this._scene.activeCamera;
- if (n) {
- var r = n.getForwardRay();
- if (this.handConstraintVisibility === So.GAZE_FOCUS || this.handConstraintVisibility === So.PALM_AND_GAZE) {
- i = !1;
- var o = void 0;
- this._eyeTracking && (o = this._eyeTracking.getEyeGaze()),
- o = o || r;
- var a = I.Vector3[0];
- e ? e.position.subtractToRef(o.origin, a) : this._node.getAbsolutePosition().subtractToRef(o.origin, a);
- var s = x.Dot(a, o.direction)
- , l = s * s;
- s > 0 && a.lengthSquared() - l < this.gazeProximityRadius * this.gazeProximityRadius && (i = !0)
- }
- if ((this.handConstraintVisibility === So.PALM_UP || this.handConstraintVisibility === So.PALM_AND_GAZE) && (t = !1,
- e)) {
- var c = I.Vector3[0];
- x.LeftHandedForwardReadOnly.rotateByQuaternionToRef(e.quaternion, c),
- x.Dot(c, r.direction) > 2 * this.palmUpStrictness - 1 && (t = !0)
- }
- }
- this._node.setEnabled(t && i)
- }
- ,
- e.prototype.detach = function() {
- this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver)
- }
- ,
- e.prototype.linkToXRExperience = function(e) {
- try {
- this._eyeTracking = e.featuresManager.getEnabledFeature(Io.EYE_TRACKING)
- } catch (e) {}
- try {
- this._handTracking = e.featuresManager.getEnabledFeature(Io.HAND_TRACKING)
- } catch (e) {
- alert("Hand tracking must be enabled for the Hand Menu to work")
- }
- }
- ,
- e
- }()
- , No = function() {
- function e(e, t, i) {
- if (this.targetPosition = x.Zero(),
- this.poleTargetPosition = x.Zero(),
- this.poleTargetLocalOffset = x.Zero(),
- this.poleAngle = 0,
- this.slerpAmount = 1,
- this._bone1Quat = C.Identity(),
- this._bone1Mat = P.Identity(),
- this._bone2Ang = Math.PI,
- this._maxAngle = Math.PI,
- this._rightHandedSystem = !1,
- this._bendAxis = x.Right(),
- this._slerping = !1,
- this._adjustRoll = 0,
- this._bone2 = t,
- this._bone1 = t.getParent(),
- this._bone1) {
- this.mesh = e;
- var n = t.getPosition();
- if (t.getAbsoluteTransform().determinant() > 0 && (this._rightHandedSystem = !0,
- this._bendAxis.x = 0,
- this._bendAxis.y = 0,
- this._bendAxis.z = -1,
- n.x > n.y && n.x > n.z && (this._adjustRoll = .5 * Math.PI,
- this._bendAxis.z = 1)),
- this._bone1.length) {
- var r = this._bone1.getScale()
- , o = this._bone2.getScale();
- this._bone1Length = this._bone1.length * r.y * this.mesh.scaling.y,
- this._bone2Length = this._bone2.length * o.y * this.mesh.scaling.y
- } else if (this._bone1.children[0]) {
- e.computeWorldMatrix(!0);
- var a = this._bone2.children[0].getAbsolutePosition(e)
- , s = this._bone2.getAbsolutePosition(e)
- , l = this._bone1.getAbsolutePosition(e);
- this._bone1Length = x.Distance(a, s),
- this._bone2Length = x.Distance(s, l)
- }
- this._bone1.getRotationMatrixToRef(Ji.WORLD, e, this._bone1Mat),
- this.maxAngle = Math.PI,
- i && (i.targetMesh && (this.targetMesh = i.targetMesh,
- this.targetMesh.computeWorldMatrix(!0)),
- i.poleTargetMesh ? (this.poleTargetMesh = i.poleTargetMesh,
- this.poleTargetMesh.computeWorldMatrix(!0)) : i.poleTargetBone ? this.poleTargetBone = i.poleTargetBone : this._bone1.getParent() && (this.poleTargetBone = this._bone1.getParent()),
- i.poleTargetLocalOffset && this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),
- i.poleAngle && (this.poleAngle = i.poleAngle),
- i.bendAxis && this._bendAxis.copyFrom(i.bendAxis),
- i.maxAngle && (this.maxAngle = i.maxAngle),
- i.slerpAmount && (this.slerpAmount = i.slerpAmount))
- }
- }
- return Object.defineProperty(e.prototype, "maxAngle", {
- get: function() {
- return this._maxAngle
- },
- set: function(e) {
- this._setMaxAngle(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._setMaxAngle = function(e) {
- e < 0 && (e = 0),
- (e > Math.PI || null == e) && (e = Math.PI),
- this._maxAngle = e;
- var t = this._bone1Length
- , i = this._bone2Length;
- this._maxReach = Math.sqrt(t * t + i * i - 2 * t * i * Math.cos(e))
- }
- ,
- e.prototype.update = function() {
- var t = this._bone1;
- if (t) {
- var i = this.targetPosition
- , n = this.poleTargetPosition
- , r = e._TmpMats[0]
- , o = e._TmpMats[1];
- this.targetMesh && i.copyFrom(this.targetMesh.getAbsolutePosition()),
- this.poleTargetBone ? this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, n) : this.poleTargetMesh && x.TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), n);
- var a = e._TmpVecs[0]
- , s = e._TmpVecs[1]
- , l = e._TmpVecs[2]
- , c = e._TmpVecs[3]
- , u = e._TmpVecs[4]
- , h = e._TmpQuat;
- t.getAbsolutePositionToRef(this.mesh, a),
- n.subtractToRef(a, u),
- 0 == u.x && 0 == u.y && 0 == u.z ? u.y = 1 : u.normalize(),
- i.subtractToRef(a, c),
- c.normalize(),
- x.CrossToRef(c, u, s),
- s.normalize(),
- x.CrossToRef(c, s, l),
- l.normalize(),
- P.FromXYZAxesToRef(l, c, s, r);
- var d = this._bone1Length
- , p = this._bone2Length
- , f = x.Distance(a, i);
- this._maxReach > 0 && (f = Math.min(this._maxReach, f));
- var _ = (p * p + f * f - d * d) / (2 * p * f)
- , m = (f * f + d * d - p * p) / (2 * f * d);
- _ > 1 && (_ = 1),
- m > 1 && (m = 1),
- _ < -1 && (_ = -1),
- m < -1 && (m = -1);
- var g = Math.acos(_)
- , v = Math.acos(m)
- , y = -g - v;
- if (this._rightHandedSystem)
- P.RotationYawPitchRollToRef(0, 0, this._adjustRoll, o),
- o.multiplyToRef(r, r),
- P.RotationAxisToRef(this._bendAxis, v, o),
- o.multiplyToRef(r, r);
- else {
- var b = e._TmpVecs[5];
- b.copyFrom(this._bendAxis),
- b.x *= -1,
- P.RotationAxisToRef(b, -v, o),
- o.multiplyToRef(r, r)
- }
- this.poleAngle && (P.RotationAxisToRef(c, this.poleAngle, o),
- r.multiplyToRef(o, r)),
- this._bone1 && (this.slerpAmount < 1 ? (this._slerping || C.FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat),
- C.FromRotationMatrixToRef(r, h),
- C.SlerpToRef(this._bone1Quat, h, this.slerpAmount, this._bone1Quat),
- y = this._bone2Ang * (1 - this.slerpAmount) + y * this.slerpAmount,
- this._bone1.setRotationQuaternion(this._bone1Quat, Ji.WORLD, this.mesh),
- this._slerping = !0) : (this._bone1.setRotationMatrix(r, Ji.WORLD, this.mesh),
- this._bone1Mat.copyFrom(r),
- this._slerping = !1),
- this._updateLinkedTransformRotation(this._bone1)),
- this._bone2.setAxisAngle(this._bendAxis, y, Ji.LOCAL),
- this._updateLinkedTransformRotation(this._bone2),
- this._bone2Ang = y
- }
- }
- ,
- e.prototype._updateLinkedTransformRotation = function(e) {
- e._linkedTransformNode && (e._linkedTransformNode.rotationQuaternion || (e._linkedTransformNode.rotationQuaternion = new C),
- e.getRotationQuaternionToRef(Ji.LOCAL, null, e._linkedTransformNode.rotationQuaternion))
- }
- ,
- e._TmpVecs = [x.Zero(), x.Zero(), x.Zero(), x.Zero(), x.Zero(), x.Zero()],
- e._TmpQuat = C.Identity(),
- e._TmpMats = [P.Identity(), P.Identity()],
- e
- }()
- , Lo = function() {
- function e(e, t, i, n) {
- if (this.upAxis = x.Up(),
- this.upAxisSpace = Ji.LOCAL,
- this.adjustYaw = 0,
- this.adjustPitch = 0,
- this.adjustRoll = 0,
- this.slerpAmount = 1,
- this._boneQuat = C.Identity(),
- this._slerping = !1,
- this._firstFrameSkipped = !1,
- this._fowardAxis = x.Forward(),
- this.mesh = e,
- this.bone = t,
- this.target = i,
- n && (n.adjustYaw && (this.adjustYaw = n.adjustYaw),
- n.adjustPitch && (this.adjustPitch = n.adjustPitch),
- n.adjustRoll && (this.adjustRoll = n.adjustRoll),
- null != n.maxYaw ? this.maxYaw = n.maxYaw : this.maxYaw = Math.PI,
- null != n.minYaw ? this.minYaw = n.minYaw : this.minYaw = -Math.PI,
- null != n.maxPitch ? this.maxPitch = n.maxPitch : this.maxPitch = Math.PI,
- null != n.minPitch ? this.minPitch = n.minPitch : this.minPitch = -Math.PI,
- null != n.slerpAmount && (this.slerpAmount = n.slerpAmount),
- null != n.upAxis && (this.upAxis = n.upAxis),
- null != n.upAxisSpace && (this.upAxisSpace = n.upAxisSpace),
- null != n.yawAxis || null != n.pitchAxis)) {
- var r = vn.Y
- , o = vn.X;
- null != n.yawAxis && (r = n.yawAxis.clone()).normalize(),
- null != n.pitchAxis && (o = n.pitchAxis.clone()).normalize();
- var a = x.Cross(o, r);
- this._transformYawPitch = P.Identity(),
- P.FromXYZAxesToRef(o, r, a, this._transformYawPitch),
- this._transformYawPitchInv = this._transformYawPitch.clone(),
- this._transformYawPitch.invert()
- }
- t.getParent() || this.upAxisSpace != Ji.BONE || (this.upAxisSpace = Ji.LOCAL)
- }
- return Object.defineProperty(e.prototype, "minYaw", {
- get: function() {
- return this._minYaw
- },
- set: function(e) {
- this._minYaw = e,
- this._minYawSin = Math.sin(e),
- this._minYawCos = Math.cos(e),
- null != this._maxYaw && (this._midYawConstraint = .5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw,
- this._yawRange = this._maxYaw - this._minYaw)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "maxYaw", {
- get: function() {
- return this._maxYaw
- },
- set: function(e) {
- this._maxYaw = e,
- this._maxYawSin = Math.sin(e),
- this._maxYawCos = Math.cos(e),
- null != this._minYaw && (this._midYawConstraint = .5 * this._getAngleDiff(this._minYaw, this._maxYaw) + this._minYaw,
- this._yawRange = this._maxYaw - this._minYaw)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "minPitch", {
- get: function() {
- return this._minPitch
- },
- set: function(e) {
- this._minPitch = e,
- this._minPitchTan = Math.tan(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "maxPitch", {
- get: function() {
- return this._maxPitch
- },
- set: function(e) {
- this._maxPitch = e,
- this._maxPitchTan = Math.tan(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function() {
- if (this.slerpAmount < 1 && !this._firstFrameSkipped)
- this._firstFrameSkipped = !0;
- else {
- var t = this.bone
- , i = e._TmpVecs[0];
- t.getAbsolutePositionToRef(this.mesh, i);
- var n = this.target
- , r = e._TmpMats[0]
- , o = e._TmpMats[1]
- , a = this.mesh
- , s = t.getParent()
- , l = e._TmpVecs[1];
- l.copyFrom(this.upAxis),
- this.upAxisSpace == Ji.BONE && s ? (this._transformYawPitch && x.TransformCoordinatesToRef(l, this._transformYawPitchInv, l),
- s.getDirectionToRef(l, this.mesh, l)) : this.upAxisSpace == Ji.LOCAL && (a.getDirectionToRef(l, l),
- 1 == a.scaling.x && 1 == a.scaling.y && 1 == a.scaling.z || l.normalize());
- var c = !1
- , u = !1;
- if (this._maxYaw == Math.PI && this._minYaw == -Math.PI || (c = !0),
- this._maxPitch == Math.PI && this._minPitch == -Math.PI || (u = !0),
- c || u) {
- var h = e._TmpMats[2]
- , d = e._TmpMats[3];
- if (this.upAxisSpace == Ji.BONE && 1 == l.y && s)
- s.getRotationMatrixToRef(Ji.WORLD, this.mesh, h);
- else if (this.upAxisSpace != Ji.LOCAL || 1 != l.y || s) {
- var p = e._TmpVecs[2];
- p.copyFrom(this._fowardAxis),
- this._transformYawPitch && x.TransformCoordinatesToRef(p, this._transformYawPitchInv, p),
- s ? s.getDirectionToRef(p, this.mesh, p) : a.getDirectionToRef(p, p);
- var f = x.Cross(l, p);
- f.normalize(),
- p = x.Cross(f, l),
- P.FromXYZAxesToRef(f, l, p, h)
- } else
- h.copyFrom(a.getWorldMatrix());
- h.invertToRef(d);
- var _ = null;
- if (u) {
- var m = e._TmpVecs[3];
- n.subtractToRef(i, m),
- x.TransformCoordinatesToRef(m, d, m),
- _ = Math.sqrt(m.x * m.x + m.z * m.z);
- var g = Math.atan2(m.y, _)
- , v = g;
- g > this._maxPitch ? (m.y = this._maxPitchTan * _,
- v = this._maxPitch) : g < this._minPitch && (m.y = this._minPitchTan * _,
- v = this._minPitch),
- g != v && (x.TransformCoordinatesToRef(m, h, m),
- m.addInPlace(i),
- n = m)
- }
- if (c) {
- m = e._TmpVecs[4],
- n.subtractToRef(i, m),
- x.TransformCoordinatesToRef(m, d, m);
- var y = Math.atan2(m.x, m.z)
- , b = y;
- if ((y > this._maxYaw || y < this._minYaw) && (null == _ && (_ = Math.sqrt(m.x * m.x + m.z * m.z)),
- this._yawRange > Math.PI ? this._isAngleBetween(y, this._maxYaw, this._midYawConstraint) ? (m.z = this._maxYawCos * _,
- m.x = this._maxYawSin * _,
- b = this._maxYaw) : this._isAngleBetween(y, this._midYawConstraint, this._minYaw) && (m.z = this._minYawCos * _,
- m.x = this._minYawSin * _,
- b = this._minYaw) : y > this._maxYaw ? (m.z = this._maxYawCos * _,
- m.x = this._maxYawSin * _,
- b = this._maxYaw) : y < this._minYaw && (m.z = this._minYawCos * _,
- m.x = this._minYawSin * _,
- b = this._minYaw)),
- this._slerping && this._yawRange > Math.PI) {
- var T = e._TmpVecs[8];
- T.copyFrom(vn.Z),
- this._transformYawPitch && x.TransformCoordinatesToRef(T, this._transformYawPitchInv, T);
- var E = e._TmpMats[4];
- this._boneQuat.toRotationMatrix(E),
- this.mesh.getWorldMatrix().multiplyToRef(E, E),
- x.TransformCoordinatesToRef(T, E, T),
- x.TransformCoordinatesToRef(T, d, T);
- var S = Math.atan2(T.x, T.z);
- if (this._getAngleBetween(S, y) > this._getAngleBetween(S, this._midYawConstraint)) {
- null == _ && (_ = Math.sqrt(m.x * m.x + m.z * m.z));
- var A = this._getAngleBetween(S, this._maxYaw);
- this._getAngleBetween(S, this._minYaw) < A ? (b = S + .75 * Math.PI,
- m.z = Math.cos(b) * _,
- m.x = Math.sin(b) * _) : (b = S - .75 * Math.PI,
- m.z = Math.cos(b) * _,
- m.x = Math.sin(b) * _)
- }
- }
- y != b && (x.TransformCoordinatesToRef(m, h, m),
- m.addInPlace(i),
- n = m)
- }
- }
- var R = e._TmpVecs[5]
- , M = e._TmpVecs[6]
- , I = e._TmpVecs[7]
- , O = e._TmpQuat;
- n.subtractToRef(i, R),
- R.normalize(),
- x.CrossToRef(l, R, M),
- M.normalize(),
- x.CrossToRef(R, M, I),
- I.normalize(),
- P.FromXYZAxesToRef(M, I, R, r),
- 0 === M.x && 0 === M.y && 0 === M.z || 0 === I.x && 0 === I.y && 0 === I.z || 0 === R.x && 0 === R.y && 0 === R.z || ((this.adjustYaw || this.adjustPitch || this.adjustRoll) && (P.RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, o),
- o.multiplyToRef(r, r)),
- this.slerpAmount < 1 ? (this._slerping || this.bone.getRotationQuaternionToRef(Ji.WORLD, this.mesh, this._boneQuat),
- this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r),
- C.FromRotationMatrixToRef(r, O),
- C.SlerpToRef(this._boneQuat, O, this.slerpAmount, this._boneQuat),
- this.bone.setRotationQuaternion(this._boneQuat, Ji.WORLD, this.mesh),
- this._slerping = !0) : (this._transformYawPitch && this._transformYawPitch.multiplyToRef(r, r),
- this.bone.setRotationMatrix(r, Ji.WORLD, this.mesh),
- this._slerping = !1),
- this._updateLinkedTransformRotation())
- }
- }
- ,
- e.prototype._getAngleDiff = function(e, t) {
- var i = t - e;
- return (i %= 2 * Math.PI) > Math.PI ? i -= 2 * Math.PI : i < -Math.PI && (i += 2 * Math.PI),
- i
- }
- ,
- e.prototype._getAngleBetween = function(e, t) {
- var i = 0;
- return (i = (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e) < (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t) ? t - e : e - t) > Math.PI && (i = 2 * Math.PI - i),
- i
- }
- ,
- e.prototype._isAngleBetween = function(e, t, i) {
- if (e = (e %= 2 * Math.PI) < 0 ? e + 2 * Math.PI : e,
- (t = (t %= 2 * Math.PI) < 0 ? t + 2 * Math.PI : t) < (i = (i %= 2 * Math.PI) < 0 ? i + 2 * Math.PI : i)) {
- if (e > t && e < i)
- return !0
- } else if (e > i && e < t)
- return !0;
- return !1
- }
- ,
- e.prototype._updateLinkedTransformRotation = function() {
- var e = this.bone;
- e._linkedTransformNode && (e._linkedTransformNode.rotationQuaternion || (e._linkedTransformNode.rotationQuaternion = new C),
- e.getRotationQuaternionToRef(Ji.LOCAL, null, e._linkedTransformNode.rotationQuaternion))
- }
- ,
- e._TmpVecs = g.BuildArray(10, x.Zero),
- e._TmpQuat = C.Identity(),
- e._TmpMats = g.BuildArray(5, P.Identity),
- e
- }()
- , Fo = function() {
- function e(e, t, i) {
- this.name = e,
- this.id = t,
- this.bones = new Array,
- this.needInitialSkinMatrix = !1,
- this._isDirty = !0,
- this._meshesWithPoseMatrix = new Array,
- this._identity = P.Identity(),
- this._ranges = {},
- this._lastAbsoluteTransformsUpdateId = -1,
- this._canUseTextureForBones = !1,
- this._uniqueId = 0,
- this._numBonesWithLinkedTransformNode = 0,
- this._hasWaitingData = null,
- this._parentContainer = null,
- this.doNotSerialize = !1,
- this._useTextureToStoreBoneMatrices = !0,
- this._animationPropertiesOverride = null,
- this.onBeforeComputeObservable = new h,
- this.bones = [],
- this._scene = i || E.LastCreatedScene,
- this._uniqueId = this._scene.getUniqueId(),
- this._scene.addSkeleton(this),
- this._isDirty = !0;
- var n = this._scene.getEngine().getCaps();
- this._canUseTextureForBones = n.textureFloat && n.maxVertexTextureImageUnits > 0
- }
- return Object.defineProperty(e.prototype, "useTextureToStoreBoneMatrices", {
- get: function() {
- return this._useTextureToStoreBoneMatrices
- },
- set: function(e) {
- this._useTextureToStoreBoneMatrices = e,
- this._markAsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
- },
- set: function(e) {
- this._animationPropertiesOverride = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isUsingTextureForMatrices", {
- get: function() {
- return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "Skeleton"
- }
- ,
- e.prototype.getChildren = function() {
- return this.bones.filter((function(e) {
- return !e.getParent()
- }
- ))
- }
- ,
- e.prototype.getTransformMatrices = function(e) {
- return this.needInitialSkinMatrix ? (e._bonesTransformMatrices || this.prepare(),
- e._bonesTransformMatrices) : (this._transformMatrices || this.prepare(),
- this._transformMatrices)
- }
- ,
- e.prototype.getTransformMatrixTexture = function(e) {
- return this.needInitialSkinMatrix && e._transformMatrixTexture ? e._transformMatrixTexture : this._transformMatrixTexture
- }
- ,
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype.toString = function(e) {
- var t = "Name: ".concat(this.name, ", nBones: ").concat(this.bones.length);
- if (t += ", nAnimationRanges: ".concat(this._ranges ? Object.keys(this._ranges).length : "none"),
- e) {
- t += ", Ranges: {";
- var i = !0;
- for (var n in this._ranges)
- i && (t += ", ",
- i = !1),
- t += n;
- t += "}"
- }
- return t
- }
- ,
- e.prototype.getBoneIndexByName = function(e) {
- for (var t = 0, i = this.bones.length; t < i; t++)
- if (this.bones[t].name === e)
- return t;
- return -1
- }
- ,
- e.prototype.createAnimationRange = function(e, t, i) {
- if (!this._ranges[e]) {
- this._ranges[e] = new We(e,t,i);
- for (var n = 0, r = this.bones.length; n < r; n++)
- this.bones[n].animations[0] && this.bones[n].animations[0].createRange(e, t, i)
- }
- }
- ,
- e.prototype.deleteAnimationRange = function(e, t) {
- void 0 === t && (t = !0);
- for (var i = 0, n = this.bones.length; i < n; i++)
- this.bones[i].animations[0] && this.bones[i].animations[0].deleteRange(e, t);
- this._ranges[e] = null
- }
- ,
- e.prototype.getAnimationRange = function(e) {
- return this._ranges[e] || null
- }
- ,
- e.prototype.getAnimationRanges = function() {
- var e, t = [];
- for (e in this._ranges)
- t.push(this._ranges[e]);
- return t
- }
- ,
- e.prototype.copyAnimationRange = function(e, t, i) {
- if (void 0 === i && (i = !1),
- this._ranges[t] || !e.getAnimationRange(t))
- return !1;
- var n, r, o = !0, a = this._getHighestAnimationFrame() + 1, s = {}, l = e.bones;
- for (r = 0,
- n = l.length; r < n; r++)
- s[l[r].name] = l[r];
- this.bones.length !== l.length && (K.Warn("copyAnimationRange: this rig has ".concat(this.bones.length, " bones, while source as ").concat(l.length)),
- o = !1);
- var c = i && this.dimensionsAtRest && e.dimensionsAtRest ? this.dimensionsAtRest.divide(e.dimensionsAtRest) : null;
- for (r = 0,
- n = this.bones.length; r < n; r++) {
- var u = this.bones[r].name
- , h = s[u];
- h ? o = o && this.bones[r].copyAnimationRange(h, t, a, i, c) : (K.Warn("copyAnimationRange: not same rig, missing source bone " + u),
- o = !1)
- }
- var d = e.getAnimationRange(t);
- return d && (this._ranges[t] = new We(t,d.from + a,d.to + a)),
- o
- }
- ,
- e.prototype.returnToRest = function() {
- for (var e = 0, t = this.bones; e < t.length; e++) {
- var i = t[e];
- -1 !== i._index && i.returnToRest()
- }
- }
- ,
- e.prototype._getHighestAnimationFrame = function() {
- for (var e = 0, t = 0, i = this.bones.length; t < i; t++)
- if (this.bones[t].animations[0]) {
- var n = this.bones[t].animations[0].getHighestFrame();
- e < n && (e = n)
- }
- return e
- }
- ,
- e.prototype.beginAnimation = function(e, t, i, n) {
- var r = this.getAnimationRange(e);
- return r ? this._scene.beginAnimation(this, r.from, r.to, t, i, n) : null
- }
- ,
- e.MakeAnimationAdditive = function(e, t, i) {
- void 0 === t && (t = 0);
- var n = e.getAnimationRange(i);
- if (!n)
- return null;
- for (var r = e._scene.getAllAnimatablesByTarget(e), o = null, a = 0; a < r.length; a++) {
- var s = r[a];
- if (s.fromFrame === (null == n ? void 0 : n.from) && s.toFrame === (null == n ? void 0 : n.to)) {
- o = s;
- break
- }
- }
- var l = e.getAnimatables();
- for (a = 0; a < l.length; a++) {
- var c = l[a].animations;
- if (c)
- for (var u = 0; u < c.length; u++)
- Qe.MakeAnimationAdditive(c[u], t, i)
- }
- return o && (o.isAdditive = !0),
- e
- }
- ,
- e.prototype._markAsDirty = function() {
- this._isDirty = !0
- }
- ,
- e.prototype._registerMeshWithPoseMatrix = function(e) {
- this._meshesWithPoseMatrix.push(e)
- }
- ,
- e.prototype._unregisterMeshWithPoseMatrix = function(e) {
- var t = this._meshesWithPoseMatrix.indexOf(e);
- t > -1 && this._meshesWithPoseMatrix.splice(t, 1)
- }
- ,
- e.prototype._computeTransformMatrices = function(e, t) {
- this.onBeforeComputeObservable.notifyObservers(this);
- for (var i = 0; i < this.bones.length; i++) {
- var n = this.bones[i];
- n._childUpdateId++;
- var r = n.getParent();
- if (r ? n.getLocalMatrix().multiplyToRef(r.getWorldMatrix(), n.getWorldMatrix()) : t ? n.getLocalMatrix().multiplyToRef(t, n.getWorldMatrix()) : n.getWorldMatrix().copyFrom(n.getLocalMatrix()),
- -1 !== n._index) {
- var o = null === n._index ? i : n._index;
- n.getInvertedAbsoluteTransform().multiplyToArray(n.getWorldMatrix(), e, 16 * o)
- }
- }
- this._identity.copyToArray(e, 16 * this.bones.length)
- }
- ,
- e.prototype.prepare = function() {
- if (this._numBonesWithLinkedTransformNode > 0)
- for (var e = 0, t = this.bones; e < t.length; e++)
- (u = t[e])._linkedTransformNode && (u._linkedTransformNode.computeWorldMatrix(),
- u._matrix = u._linkedTransformNode._localMatrix);
- if (this.needInitialSkinMatrix)
- for (var i = 0, n = this._meshesWithPoseMatrix; i < n.length; i++) {
- var r = n[i]
- , o = r.getPoseMatrix()
- , s = this._isDirty;
- if (r._bonesTransformMatrices && r._bonesTransformMatrices.length === 16 * (this.bones.length + 1) || (r._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1)),
- s = !0),
- s) {
- if (this._synchronizedWithMesh !== r) {
- this._synchronizedWithMesh = r;
- for (var l = 0, c = this.bones; l < c.length; l++) {
- var u;
- (u = c[l]).getParent() || (u.getBaseMatrix().multiplyToRef(o, I.Matrix[1]),
- u._updateDifferenceMatrix(I.Matrix[1]))
- }
- if (this.isUsingTextureForMatrices) {
- var h = 4 * (this.bones.length + 1);
- r._transformMatrixTexture && r._transformMatrixTexture.getSize().width === h || (r._transformMatrixTexture && r._transformMatrixTexture.dispose(),
- r._transformMatrixTexture = ao.CreateRGBATexture(r._bonesTransformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT))
- }
- }
- this._computeTransformMatrices(r._bonesTransformMatrices, o),
- this.isUsingTextureForMatrices && r._transformMatrixTexture && r._transformMatrixTexture.update(r._bonesTransformMatrices)
- }
- }
- else {
- if (!this._isDirty)
- return;
- 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 = ao.CreateRGBATexture(this._transformMatrices, 4 * (this.bones.length + 1), 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT))),
- this._computeTransformMatrices(this._transformMatrices, null),
- this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices)
- }
- this._isDirty = !1
- }
- ,
- e.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
- }
- ,
- e.prototype.clone = function(t, i) {
- var n = new e(t,i || t,this._scene);
- n.needInitialSkinMatrix = this.needInitialSkinMatrix;
- for (var r = 0; r < this.bones.length; r++) {
- var o = this.bones[r]
- , a = null
- , s = o.getParent();
- if (s) {
- var l = this.bones.indexOf(s);
- a = n.bones[l]
- }
- var c = new yn(o.name,n,a,o.getBaseMatrix().clone(),o.getRestPose().clone());
- c._index = o._index,
- o._linkedTransformNode && c.linkTransformNode(o._linkedTransformNode),
- fe.DeepCopy(o.animations, c.animations)
- }
- if (this._ranges)
- for (var u in n._ranges = {},
- this._ranges) {
- var h = this._ranges[u];
- h && (n._ranges[u] = h.clone())
- }
- return this._isDirty = !0,
- n
- }
- ,
- e.prototype.enableBlending = function(e) {
- void 0 === e && (e = .01),
- this.bones.forEach((function(t) {
- t.animations.forEach((function(t) {
- t.enableBlending = !0,
- t.blendingSpeed = e
- }
- ))
- }
- ))
- }
- ,
- e.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)
- }
- ,
- e.prototype.serialize = function() {
- var e, t = {};
- t.name = this.name,
- t.id = this.id,
- this.dimensionsAtRest && (t.dimensionsAtRest = this.dimensionsAtRest.asArray()),
- t.bones = [],
- t.needInitialSkinMatrix = this.needInitialSkinMatrix;
- for (var i = 0; i < this.bones.length; i++) {
- var n = this.bones[i]
- , r = n.getParent()
- , o = {
- parentBoneIndex: r ? this.bones.indexOf(r) : -1,
- index: n.getIndex(),
- name: n.name,
- id: n.id,
- matrix: n.getBaseMatrix().toArray(),
- rest: n.getRestPose().toArray(),
- linkedTransformNodeId: null === (e = n.getTransformNode()) || void 0 === e ? void 0 : e.id
- };
- for (var a in t.bones.push(o),
- n.length && (o.length = n.length),
- n.metadata && (o.metadata = n.metadata),
- n.animations && n.animations.length > 0 && (o.animation = n.animations[0].serialize()),
- t.ranges = [],
- this._ranges) {
- var s = this._ranges[a];
- if (s) {
- var l = {};
- l.name = a,
- l.from = s.from,
- l.to = s.to,
- t.ranges.push(l)
- }
- }
- }
- return t
- }
- ,
- e.Parse = function(t, i) {
- var n, r = new e(t.name,t.id,i);
- for (t.dimensionsAtRest && (r.dimensionsAtRest = x.FromArray(t.dimensionsAtRest)),
- r.needInitialSkinMatrix = t.needInitialSkinMatrix,
- n = 0; n < t.bones.length; n++) {
- var o = t.bones[n]
- , a = t.bones[n].index
- , s = null;
- o.parentBoneIndex > -1 && (s = r.bones[o.parentBoneIndex]);
- var l = o.rest ? P.FromArray(o.rest) : null
- , c = new yn(o.name,r,s,P.FromArray(o.matrix),l,null,a);
- void 0 !== o.id && null !== o.id && (c.id = o.id),
- o.length && (c.length = o.length),
- o.metadata && (c.metadata = o.metadata),
- o.animation && c.animations.push(Qe.Parse(o.animation)),
- void 0 !== o.linkedTransformNodeId && null !== o.linkedTransformNodeId && (r._hasWaitingData = !0,
- c._waitingTransformNodeId = o.linkedTransformNodeId)
- }
- if (t.ranges)
- for (n = 0; n < t.ranges.length; n++) {
- var u = t.ranges[n];
- r.createAnimationRange(u.name, u.from, u.to)
- }
- return r
- }
- ,
- e.prototype.computeAbsoluteTransforms = function(e) {
- void 0 === e && (e = !1);
- var t = this._scene.getRenderId();
- (this._lastAbsoluteTransformsUpdateId != t || e) && (this.bones[0].computeAbsoluteTransforms(),
- this._lastAbsoluteTransformsUpdateId = t)
- }
- ,
- e.prototype.getPoseMatrix = function() {
- var e = null;
- return this._meshesWithPoseMatrix.length > 0 && (e = this._meshesWithPoseMatrix[0].getPoseMatrix()),
- e
- }
- ,
- e.prototype.sortBones = function() {
- for (var e = new Array, t = new Array(this.bones.length), i = 0; i < this.bones.length; i++)
- this._sortBones(i, e, t);
- this.bones = e
- }
- ,
- e.prototype._sortBones = function(e, t, i) {
- if (!i[e]) {
- i[e] = !0;
- var n = this.bones[e];
- void 0 === n._index && (n._index = e);
- var r = n.getParent();
- r && this._sortBones(this.bones.indexOf(r), t, i),
- t.push(n)
- }
- }
- ,
- e.prototype.setCurrentPoseAsRest = function() {
- this.bones.forEach((function(e) {
- e.setCurrentPoseAsRest()
- }
- ))
- }
- ,
- e
- }()
- , wo = function() {
- function e(e, t, i) {
- void 0 === i && (i = a.BUFFER_CREATIONFLAG_READWRITE),
- this._engine = e,
- this._engine._storageBuffers.push(this),
- this._create(t, i)
- }
- return e.prototype._create = function(e, t) {
- this._bufferSize = e,
- this._creationFlags = t,
- this._buffer = this._engine.createStorageBuffer(e, t)
- }
- ,
- e.prototype._rebuild = function() {
- this._create(this._bufferSize, this._creationFlags)
- }
- ,
- e.prototype.getBuffer = function() {
- return this._buffer
- }
- ,
- e.prototype.update = function(e, t, i) {
- this._buffer && this._engine.updateStorageBuffer(this._buffer, e, t, i)
- }
- ,
- e.prototype.read = function(e, t, i) {
- return this._engine.readFromStorageBuffer(this._buffer, e, t, i)
- }
- ,
- e.prototype.dispose = function() {
- var e = this._engine._storageBuffers
- , t = e.indexOf(this);
- -1 !== t && (e[t] = e[e.length - 1],
- e.pop()),
- this._engine._releaseBuffer(this._buffer),
- this._buffer = null
- }
- ,
- e
- }()
- , Bo = function() {
- function e() {
- this.wheelPrecisionX = 3,
- this.wheelPrecisionY = 3,
- this.wheelPrecisionZ = 3,
- this.onChangedObservable = new h,
- this._wheelDeltaX = 0,
- this._wheelDeltaY = 0,
- this._wheelDeltaZ = 0,
- this._ffMultiplier = 12,
- this._normalize = 120
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._wheel = function(i) {
- if (i.type === Xi.POINTERWHEEL) {
- var n = i.event
- , r = n.deltaMode === $i.DOM_DELTA_LINE ? t._ffMultiplier : 1;
- void 0 !== n.deltaY ? (t._wheelDeltaX += t.wheelPrecisionX * r * n.deltaX / t._normalize,
- t._wheelDeltaY -= t.wheelPrecisionY * r * n.deltaY / t._normalize,
- t._wheelDeltaZ += t.wheelPrecisionZ * r * n.deltaZ / t._normalize) : void 0 !== n.wheelDeltaY ? (t._wheelDeltaX += t.wheelPrecisionX * r * n.wheelDeltaX / t._normalize,
- t._wheelDeltaY -= t.wheelPrecisionY * r * n.wheelDeltaY / t._normalize,
- t._wheelDeltaZ += t.wheelPrecisionZ * r * n.wheelDeltaZ / t._normalize) : n.wheelDelta && (t._wheelDeltaY -= t.wheelPrecisionY * n.wheelDelta / t._normalize),
- n.preventDefault && (e || n.preventDefault())
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL)
- }
- ,
- e.prototype.detachControl = function() {
- this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this._wheel = null),
- this.onChangedObservable && this.onChangedObservable.clear()
- }
- ,
- e.prototype.checkInputs = function() {
- this.onChangedObservable.notifyObservers({
- wheelDeltaX: this._wheelDeltaX,
- wheelDeltaY: this._wheelDeltaY,
- wheelDeltaZ: this._wheelDeltaZ
- }),
- this._wheelDeltaX = 0,
- this._wheelDeltaY = 0,
- this._wheelDeltaZ = 0
- }
- ,
- e.prototype.getClassName = function() {
- return "BaseCameraMouseWheelInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "mousewheel"
- }
- ,
- k([Ce()], e.prototype, "wheelPrecisionX", void 0),
- k([Ce()], e.prototype, "wheelPrecisionY", void 0),
- k([Ce()], e.prototype, "wheelPrecisionZ", void 0),
- e
- }()
- , Uo = function() {
- function e() {
- this._currentActiveButton = -1,
- this.buttons = [0, 1, 2]
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments);
- var i = this.camera.getEngine()
- , n = i.getInputElement()
- , r = 0
- , o = 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(a) {
- var s = a.event
- , l = "touch" === s.pointerType;
- if (!i.isInVRExclusivePointerMode && (a.type === Xi.POINTERMOVE || -1 !== t.buttons.indexOf(s.button))) {
- var c = s.srcElement || s.target;
- if (t._altKey = s.altKey,
- t._ctrlKey = s.ctrlKey,
- t._metaKey = s.metaKey,
- t._shiftKey = s.shiftKey,
- t._buttonsPressed = s.buttons,
- i.isPointerLock) {
- var u = s.movementX || s.mozMovementX || s.webkitMovementX || s.msMovementX || 0
- , h = s.movementY || s.mozMovementY || s.webkitMovementY || s.msMovementY || 0;
- t.onTouch(null, u, h),
- t._pointA = null,
- t._pointB = null
- } else if (a.type !== Xi.POINTERDOWN || -1 !== t._currentActiveButton && !l)
- if (a.type === Xi.POINTERDOUBLETAP)
- t.onDoubleTap(s.pointerType);
- else if (a.type !== Xi.POINTERUP || t._currentActiveButton !== s.button && !l) {
- if (a.type === Xi.POINTERMOVE)
- if (e || s.preventDefault(),
- t._pointA && null === t._pointB)
- u = s.clientX - t._pointA.x,
- h = s.clientY - t._pointA.y,
- t.onTouch(t._pointA, u, h),
- t._pointA.x = s.clientX,
- t._pointA.y = s.clientY;
- else if (t._pointA && t._pointB) {
- var d = t._pointA.pointerId === s.pointerId ? t._pointA : t._pointB;
- d.x = s.clientX,
- d.y = s.clientY;
- var p = t._pointA.x - t._pointB.x
- , f = t._pointA.y - t._pointB.y
- , _ = p * p + f * f
- , m = {
- x: (t._pointA.x + t._pointB.x) / 2,
- y: (t._pointA.y + t._pointB.y) / 2,
- pointerId: s.pointerId,
- type: a.type
- };
- t.onMultiTouch(t._pointA, t._pointB, r, _, o, m),
- o = m,
- r = _
- }
- } else {
- try {
- null == c || c.releasePointerCapture(s.pointerId)
- } catch (e) {}
- l || (t._pointB = null),
- i._badOS ? t._pointA = t._pointB = null : t._pointB && t._pointA && t._pointA.pointerId == s.pointerId ? (t._pointA = t._pointB,
- t._pointB = null) : t._pointA && t._pointB && t._pointB.pointerId == s.pointerId ? t._pointB = null : t._pointA = t._pointB = null,
- (0 !== r || o) && (t.onMultiTouch(t._pointA, t._pointB, r, 0, o, null),
- r = 0,
- o = null),
- t._currentActiveButton = -1,
- t.onButtonUp(s),
- e || s.preventDefault()
- }
- else {
- try {
- null == c || c.setPointerCapture(s.pointerId)
- } catch (e) {}
- null === t._pointA ? t._pointA = {
- x: s.clientX,
- y: s.clientY,
- pointerId: s.pointerId,
- type: s.pointerType
- } : null === t._pointB && (t._pointB = {
- x: s.clientX,
- y: s.clientY,
- pointerId: s.pointerId,
- type: s.pointerType
- }),
- -1 !== t._currentActiveButton || l || (t._currentActiveButton = s.button),
- t.onButtonDown(s),
- e || (s.preventDefault(),
- n && n.focus())
- }
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE | Xi.POINTERDOUBLETAP),
- this._onLostFocus = function() {
- t._pointA = t._pointB = null,
- r = 0,
- o = null,
- t.onLostFocus()
- }
- ,
- this._contextMenuBind = this.onContextMenu.bind(this),
- n && n.addEventListener("contextmenu", this._contextMenuBind, !1);
- var a = this.camera.getScene().getEngine().getHostWindow();
- a && gi.RegisterTopRootEvents(a, [{
- name: "blur",
- handler: this._onLostFocus
- }])
- }
- ,
- e.prototype.detachControl = function() {
- if (this._onLostFocus) {
- var e = this.camera.getScene().getEngine().getHostWindow();
- e && gi.UnregisterTopRootEvents(e, [{
- name: "blur",
- handler: this._onLostFocus
- }])
- }
- if (this._observer) {
- if (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this._contextMenuBind) {
- var t = this.camera.getScene().getEngine().getInputElement();
- t && t.removeEventListener("contextmenu", this._contextMenuBind)
- }
- this._onLostFocus = null
- }
- this._altKey = !1,
- this._ctrlKey = !1,
- this._metaKey = !1,
- this._shiftKey = !1,
- this._buttonsPressed = 0
- }
- ,
- e.prototype.getClassName = function() {
- return "BaseCameraPointersInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "pointers"
- }
- ,
- e.prototype.onDoubleTap = function(e) {}
- ,
- e.prototype.onTouch = function(e, t, i) {}
- ,
- e.prototype.onMultiTouch = function(e, t, i, n, r, o) {}
- ,
- e.prototype.onContextMenu = function(e) {
- e.preventDefault()
- }
- ,
- e.prototype.onButtonDown = function(e) {}
- ,
- e.prototype.onButtonUp = function(e) {}
- ,
- e.prototype.onLostFocus = function() {}
- ,
- k([Ce()], e.prototype, "buttons", void 0),
- e
- }()
- , Vo = {}
- , ko = function() {
- function e(e) {
- this.attachedToElement = !1,
- this.attached = {},
- this.camera = e,
- this.checkInputs = function() {}
- }
- return e.prototype.add = function(e) {
- var t = e.getSimpleName();
- this.attached[t] ? K.Warn("camera input of type " + t + " already exists on camera") : (this.attached[t] = e,
- e.camera = this.camera,
- e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e))),
- this.attachedToElement && e.attachControl())
- }
- ,
- e.prototype.remove = function(e) {
- for (var t in this.attached) {
- var i = this.attached[t];
- i === e && (i.detachControl(),
- i.camera = null,
- delete this.attached[t],
- this.rebuildInputCheck())
- }
- }
- ,
- e.prototype.removeByType = function(e) {
- for (var t in this.attached) {
- var i = this.attached[t];
- i.getClassName() === e && (i.detachControl(),
- i.camera = null,
- delete this.attached[t],
- this.rebuildInputCheck())
- }
- }
- ,
- e.prototype._addCheckInputs = function(e) {
- var t = this.checkInputs;
- return function() {
- t(),
- e()
- }
- }
- ,
- e.prototype.attachInput = function(e) {
- this.attachedToElement && e.attachControl(this.noPreventDefault)
- }
- ,
- e.prototype.attachElement = function(e) {
- if (void 0 === e && (e = !1),
- !this.attachedToElement)
- for (var t in e = !Rr.ForceAttachControlToAlwaysPreventDefault && e,
- this.attachedToElement = !0,
- this.noPreventDefault = e,
- this.attached)
- this.attached[t].attachControl(e)
- }
- ,
- e.prototype.detachElement = function(e) {
- for (var t in void 0 === e && (e = !1),
- this.attached)
- this.attached[t].detachControl(),
- e && (this.attached[t].camera = null);
- this.attachedToElement = !1
- }
- ,
- e.prototype.rebuildInputCheck = function() {
- for (var e in this.checkInputs = function() {}
- ,
- this.attached) {
- var t = this.attached[e];
- t.checkInputs && (this.checkInputs = this._addCheckInputs(t.checkInputs.bind(t)))
- }
- }
- ,
- e.prototype.clear = function() {
- this.attachedToElement && this.detachElement(!0),
- this.attached = {},
- this.attachedToElement = !1,
- this.checkInputs = function() {}
- }
- ,
- e.prototype.serialize = function(e) {
- var t = {};
- for (var i in this.attached) {
- var n = this.attached[i]
- , r = Ge.Serialize(n);
- t[n.getClassName()] = r
- }
- e.inputsmgr = t
- }
- ,
- e.prototype.parse = function(e) {
- var t = e.inputsmgr;
- if (t) {
- this.clear();
- var i = function(e) {
- var i = Vo[e];
- if (i) {
- var r = t[e]
- , o = Ge.Parse((function() {
- return new i
- }
- ), r, null);
- n.add(o)
- }
- }
- , n = this;
- for (var r in t)
- i(r)
- } else {
- var o = function(t) {
- var i = Vo[a.attached[t].getClassName()];
- if (i) {
- var n = Ge.Parse((function() {
- return new i
- }
- ), e, null);
- a.remove(a.attached[t]),
- a.add(n)
- }
- }
- , a = this;
- for (var r in this.attached)
- o(r)
- }
- }
- ,
- e
- }()
- , Go = function(e, t) {
- this.x = e,
- this.y = t
- }
- , zo = function() {
- function e(t, i, n, r, o, a, s) {
- void 0 === r && (r = 0),
- void 0 === o && (o = 1),
- void 0 === a && (a = 2),
- void 0 === s && (s = 3),
- this.id = t,
- this.index = i,
- this.browserGamepad = n,
- this._leftStick = {
- x: 0,
- y: 0
- },
- this._rightStick = {
- x: 0,
- y: 0
- },
- this._isConnected = !0,
- this._invertLeftStickY = !1,
- this.type = e.GAMEPAD,
- this._leftStickAxisX = r,
- this._leftStickAxisY = o,
- this._rightStickAxisX = a,
- this._rightStickAxisY = s,
- 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(e.prototype, "isConnected", {
- get: function() {
- return this._isConnected
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.onleftstickchanged = function(e) {
- this._onleftstickchanged = e
- }
- ,
- e.prototype.onrightstickchanged = function(e) {
- this._onrightstickchanged = e
- }
- ,
- Object.defineProperty(e.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(e.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
- }),
- e.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]
- })
- }
- ,
- e.prototype.dispose = function() {}
- ,
- e.GAMEPAD = 0,
- e.GENERIC = 1,
- e.XBOX = 2,
- e.POSE_ENABLED = 3,
- e.DUALSHOCK = 4,
- e
- }()
- , Wo = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i, n) || this;
- return r.onButtonDownObservable = new h,
- r.onButtonUpObservable = new h,
- r.type = zo.GENERIC,
- r._buttons = new Array(n.buttons.length),
- r
- }
- return U(t, e),
- t.prototype.onbuttondown = function(e) {
- this._onbuttondown = e
- }
- ,
- t.prototype.onbuttonup = function(e) {
- this._onbuttonup = e
- }
- ,
- t.prototype._setButtonValue = function(e, t, i) {
- return e !== t && (1 === e && (this._onbuttondown && this._onbuttondown(i),
- this.onButtonDownObservable.notifyObservers(i)),
- 0 === e && (this._onbuttonup && this._onbuttonup(i),
- this.onButtonUpObservable.notifyObservers(i))),
- e
- }
- ,
- t.prototype.update = function() {
- e.prototype.update.call(this);
- for (var t = 0; t < this._buttons.length; t++)
- this._buttons[t] = this._setButtonValue(this.browserGamepad.buttons[t].value, this._buttons[t], t)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onButtonDownObservable.clear(),
- this.onButtonUpObservable.clear()
- }
- ,
- t
- }(zo)
- , Ho = function() {
- function e() {
- this.gamepadRotationSensibility = 80,
- this.gamepadMoveSensibility = 40,
- this._yAxisScale = 1
- }
- return Object.defineProperty(e.prototype, "invertYAxis", {
- get: function() {
- return 1 !== this._yAxisScale
- },
- set: function(e) {
- this._yAxisScale = e ? -1 : 1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attachControl = function() {
- var e = this
- , t = this.camera.getScene().gamepadManager;
- this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
- t.type !== zo.POSE_ENABLED && (e.gamepad && t.type !== zo.XBOX || (e.gamepad = t))
- }
- )),
- this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
- e.gamepad === t && (e.gamepad = null)
- }
- )),
- this.gamepad = t.getGamepadByType(zo.XBOX)
- }
- ,
- e.prototype.detachControl = function() {
- this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
- this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
- this.gamepad = null
- }
- ,
- e.prototype.checkInputs = function() {
- if (this.gamepad) {
- var e = this.camera
- , t = this.gamepad.rightStick;
- if (t) {
- if (0 != t.x) {
- var i = t.x / this.gamepadRotationSensibility;
- 0 != i && Math.abs(i) > .005 && (e.inertialAlphaOffset += i)
- }
- if (0 != t.y) {
- var n = t.y / this.gamepadRotationSensibility * this._yAxisScale;
- 0 != n && Math.abs(n) > .005 && (e.inertialBetaOffset += n)
- }
- }
- var r = this.gamepad.leftStick;
- if (r && 0 != r.y) {
- var o = r.y / this.gamepadMoveSensibility;
- 0 != o && Math.abs(o) > .005 && (this.camera.inertialRadiusOffset -= o)
- }
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "ArcRotateCameraGamepadInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "gamepad"
- }
- ,
- k([Ce()], e.prototype, "gamepadRotationSensibility", void 0),
- k([Ce()], e.prototype, "gamepadMoveSensibility", void 0),
- e
- }();
- Vo.ArcRotateCameraGamepadInput = Ho;
- var Xo = function() {
- function e() {
- 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 e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
- this._engine = this._scene.getEngine(),
- this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
- t._keys = []
- }
- )),
- this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
- var n, r = i.event;
- r.metaKey || (i.type === Qi.KEYDOWN ? (t._ctrlPressed = r.ctrlKey,
- t._altPressed = r.altKey,
- (-1 !== t.keysUp.indexOf(r.keyCode) || -1 !== t.keysDown.indexOf(r.keyCode) || -1 !== t.keysLeft.indexOf(r.keyCode) || -1 !== t.keysRight.indexOf(r.keyCode) || -1 !== t.keysReset.indexOf(r.keyCode)) && (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
- r.preventDefault && (e || r.preventDefault()))) : -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysReset.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
- r.preventDefault && (e || r.preventDefault())))
- }
- )))
- }
- ,
- e.prototype.detachControl = function() {
- 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 = []
- }
- ,
- e.prototype.checkInputs = function() {
- if (this._onKeyboardObserver)
- for (var e = this.camera, t = 0; t < this._keys.length; t++) {
- var i = this._keys[t];
- -1 !== this.keysLeft.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX -= 1 / this.panningSensibility : e.inertialAlphaOffset -= this.angularSpeed : -1 !== this.keysUp.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY += 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset += 1 / this.zoomingSensibility : e.inertialBetaOffset -= this.angularSpeed : -1 !== this.keysRight.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningX += 1 / this.panningSensibility : e.inertialAlphaOffset += this.angularSpeed : -1 !== this.keysDown.indexOf(i) ? this._ctrlPressed && this.camera._useCtrlForPanning ? e.inertialPanningY -= 1 / this.panningSensibility : this._altPressed && this.useAltToZoom ? e.inertialRadiusOffset -= 1 / this.zoomingSensibility : e.inertialBetaOffset += this.angularSpeed : -1 !== this.keysReset.indexOf(i) && e.useInputToRestoreState && e.restoreState()
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "ArcRotateCameraKeyboardMoveInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "keyboard"
- }
- ,
- k([Ce()], e.prototype, "keysUp", void 0),
- k([Ce()], e.prototype, "keysDown", void 0),
- k([Ce()], e.prototype, "keysLeft", void 0),
- k([Ce()], e.prototype, "keysRight", void 0),
- k([Ce()], e.prototype, "keysReset", void 0),
- k([Ce()], e.prototype, "panningSensibility", void 0),
- k([Ce()], e.prototype, "zoomingSensibility", void 0),
- k([Ce()], e.prototype, "useAltToZoom", void 0),
- k([Ce()], e.prototype, "angularSpeed", void 0),
- e
- }();
- Vo.ArcRotateCameraKeyboardMoveInput = Xo;
- var jo = function() {
- function e() {
- this.wheelPrecision = 3,
- this.zoomToMouseLocation = !1,
- this.wheelDeltaPercentage = 0,
- this.customComputeDeltaFromMouseWheel = null,
- this._inertialPanning = x.Zero()
- }
- return e.prototype._computeDeltaFromMouseWheelLegacyEvent = function(e, t) {
- var i = .01 * e * this.wheelDeltaPercentage * t;
- return e > 0 ? i / (1 + this.wheelDeltaPercentage) : i * (1 + this.wheelDeltaPercentage)
- }
- ,
- e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._wheel = function(i) {
- if (i.type === Xi.POINTERWHEEL) {
- var n, r = i.event, o = 0, a = r, s = r.deltaMode === $i.DOM_DELTA_LINE ? 40 : 1;
- if (n = void 0 !== r.deltaY ? -r.deltaY * s : void 0 !== r.wheelDeltaY ? -r.wheelDeltaY * s : a.wheelDelta,
- t.customComputeDeltaFromMouseWheel)
- o = t.customComputeDeltaFromMouseWheel(n, t, r);
- else if (t.wheelDeltaPercentage) {
- if ((o = t._computeDeltaFromMouseWheelLegacyEvent(n, t.camera.radius)) > 0) {
- for (var l = t.camera.radius, c = t.camera.inertialRadiusOffset + o, u = 0; u < 20 && Math.abs(c) > .001; u++)
- l -= c,
- c *= t.camera.inertia;
- l = d.Clamp(l, 0, Number.MAX_VALUE),
- o = t._computeDeltaFromMouseWheelLegacyEvent(n, l)
- }
- } else
- o = n / (40 * t.wheelPrecision);
- o && (t.zoomToMouseLocation && t._hitPlane ? t._zoomToMouse(o) : t.camera.inertialRadiusOffset += o),
- r.preventDefault && (e || r.preventDefault())
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL),
- this.zoomToMouseLocation && this._inertialPanning.setAll(0)
- }
- ,
- e.prototype.detachControl = function() {
- this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this._wheel = null)
- }
- ,
- e.prototype.checkInputs = function() {
- if (this.zoomToMouseLocation) {
- var e = this.camera;
- 0 + e.inertialAlphaOffset + e.inertialBetaOffset + e.inertialRadiusOffset && (this._updateHitPlane(),
- e.target.addInPlace(this._inertialPanning),
- this._inertialPanning.scaleInPlace(e.inertia),
- this._zeroIfClose(this._inertialPanning))
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "ArcRotateCameraMouseWheelInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "mousewheel"
- }
- ,
- e.prototype._updateHitPlane = function() {
- var e = this.camera
- , t = e.target.subtract(e.position);
- this._hitPlane = hn.FromPositionAndNormal(e.target, t)
- }
- ,
- e.prototype._getPosition = function() {
- var e, t = this.camera, i = t.getScene(), n = i.createPickingRay(i.pointerX, i.pointerY, P.Identity(), t, !1), r = 0;
- return this._hitPlane && (r = null !== (e = n.intersectsPlane(this._hitPlane)) && void 0 !== e ? e : 0),
- n.origin.addInPlace(n.direction.scaleInPlace(r))
- }
- ,
- e.prototype._zoomToMouse = function(e) {
- var t, i, n = this.camera, r = 1 - n.inertia;
- if (n.lowerRadiusLimit) {
- var o = null !== (t = n.lowerRadiusLimit) && void 0 !== t ? t : 0;
- n.radius - (n.inertialRadiusOffset + e) / r < o && (e = (n.radius - o) * r - n.inertialRadiusOffset)
- }
- if (n.upperRadiusLimit) {
- var a = null !== (i = n.upperRadiusLimit) && void 0 !== i ? i : 0;
- n.radius - (n.inertialRadiusOffset + e) / r > a && (e = (n.radius - a) * r - n.inertialRadiusOffset)
- }
- var s = e / r / n.radius
- , l = this._getPosition()
- , c = I.Vector3[6];
- l.subtractToRef(n.target, c),
- c.scaleInPlace(s),
- c.scaleInPlace(r),
- this._inertialPanning.addInPlace(c),
- n.inertialRadiusOffset += e
- }
- ,
- e.prototype._zeroIfClose = function(e) {
- Math.abs(e.x) < m && (e.x = 0),
- Math.abs(e.y) < m && (e.y = 0),
- Math.abs(e.z) < m && (e.z = 0)
- }
- ,
- k([Ce()], e.prototype, "wheelPrecision", void 0),
- k([Ce()], e.prototype, "zoomToMouseLocation", void 0),
- k([Ce()], e.prototype, "wheelDeltaPercentage", void 0),
- e
- }();
- Vo.ArcRotateCameraMouseWheelInput = jo;
- var Yo = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.buttons = [0, 1, 2],
- t.angularSensibilityX = 1e3,
- t.angularSensibilityY = 1e3,
- t.pinchPrecision = 12,
- t.pinchDeltaPercentage = 0,
- t.useNaturalPinchZoom = !1,
- t.pinchZoom = !0,
- t.panningSensibility = 1e3,
- t.multiTouchPanning = !0,
- t.multiTouchPanAndZoom = !0,
- t.pinchInwards = !0,
- t._isPanClick = !1,
- t._twoFingerActivityCount = 0,
- t._isPinching = !1,
- t
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ArcRotateCameraPointersInput"
- }
- ,
- t.prototype._computeMultiTouchPanning = function(e, t) {
- if (0 !== this.panningSensibility && e && t) {
- var i = t.x - e.x
- , n = t.y - e.y;
- this.camera.inertialPanningX += -i / this.panningSensibility,
- this.camera.inertialPanningY += n / this.panningSensibility
- }
- }
- ,
- t.prototype._computePinchZoom = function(e, i) {
- var n = this.camera.radius || t.MinimumRadiusForPinch;
- this.useNaturalPinchZoom ? this.camera.radius = n * Math.sqrt(e) / Math.sqrt(i) : this.pinchDeltaPercentage ? this.camera.inertialRadiusOffset += .001 * (i - e) * n * this.pinchDeltaPercentage : this.camera.inertialRadiusOffset += (i - e) / (this.pinchPrecision * (this.pinchInwards ? 1 : -1) * (this.angularSensibilityX + this.angularSensibilityY) / 2)
- }
- ,
- t.prototype.onTouch = function(e, t, i) {
- 0 !== this.panningSensibility && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -t / this.panningSensibility,
- this.camera.inertialPanningY += i / this.panningSensibility) : (this.camera.inertialAlphaOffset -= t / this.angularSensibilityX,
- this.camera.inertialBetaOffset -= i / this.angularSensibilityY)
- }
- ,
- t.prototype.onDoubleTap = function() {
- this.camera.useInputToRestoreState && this.camera.restoreState()
- }
- ,
- t.prototype.onMultiTouch = function(e, t, i, n, r, o) {
- 0 === i && null === r || 0 === n && null === o || (this.multiTouchPanAndZoom ? (this._computePinchZoom(i, n),
- this._computeMultiTouchPanning(r, o)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++,
- this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(n) - Math.sqrt(i)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(i, n),
- this._isPinching = !0) : this._computeMultiTouchPanning(r, o)) : this.multiTouchPanning ? this._computeMultiTouchPanning(r, o) : this.pinchZoom && this._computePinchZoom(i, n))
- }
- ,
- t.prototype.onButtonDown = function(e) {
- this._isPanClick = e.button === this.camera._panningMouseButton
- }
- ,
- t.prototype.onButtonUp = function() {
- this._twoFingerActivityCount = 0,
- this._isPinching = !1
- }
- ,
- t.prototype.onLostFocus = function() {
- this._isPanClick = !1,
- this._twoFingerActivityCount = 0,
- this._isPinching = !1
- }
- ,
- t.MinimumRadiusForPinch = .001,
- k([Ce()], t.prototype, "buttons", void 0),
- k([Ce()], t.prototype, "angularSensibilityX", void 0),
- k([Ce()], t.prototype, "angularSensibilityY", void 0),
- k([Ce()], t.prototype, "pinchPrecision", void 0),
- k([Ce()], t.prototype, "pinchDeltaPercentage", void 0),
- k([Ce()], t.prototype, "useNaturalPinchZoom", void 0),
- k([Ce()], t.prototype, "pinchZoom", void 0),
- k([Ce()], t.prototype, "panningSensibility", void 0),
- k([Ce()], t.prototype, "multiTouchPanning", void 0),
- k([Ce()], t.prototype, "multiTouchPanAndZoom", void 0),
- t
- }(Uo);
- Vo.ArcRotateCameraPointersInput = Yo;
- var Ko = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- t.prototype.addMouseWheel = function() {
- return this.add(new jo),
- this
- }
- ,
- t.prototype.addPointers = function() {
- return this.add(new Yo),
- this
- }
- ,
- t.prototype.addKeyboard = function() {
- return this.add(new Xo),
- this
- }
- ,
- t
- }(ko);
- Ko.prototype.addVRDeviceOrientation = function() {
- return this.add(new Qo),
- this
- }
- ;
- var Qo = function() {
- function e() {
- this.alphaCorrection = 1,
- this.gammaCorrection = 1,
- this._alpha = 0,
- this._gamma = 0,
- this._dirty = !1,
- this._deviceOrientationHandler = this._onOrientationEvent.bind(this)
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this.camera.attachControl(e);
- var i = this.camera.getScene().getEngine().getHostWindow();
- i && ("undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
- "granted" === e ? i.addEventListener("deviceorientation", t._deviceOrientationHandler) : gi.Warn("Permission not granted.")
- }
- )).catch((function(e) {
- gi.Error(e)
- }
- )) : i.addEventListener("deviceorientation", this._deviceOrientationHandler))
- }
- ,
- e.prototype._onOrientationEvent = function(e) {
- null !== e.alpha && (this._alpha = (0 | +e.alpha) * this.alphaCorrection),
- null !== e.gamma && (this._gamma = (0 | +e.gamma) * this.gammaCorrection),
- this._dirty = !0
- }
- ,
- e.prototype.checkInputs = function() {
- this._dirty && (this._dirty = !1,
- this._gamma < 0 && (this._gamma = 180 + this._gamma),
- this.camera.alpha = -this._alpha / 180 * Math.PI % Math.PI * 2,
- this.camera.beta = this._gamma / 180 * Math.PI)
- }
- ,
- e.prototype.detachControl = function() {
- window.removeEventListener("deviceorientation", this._deviceOrientationHandler)
- }
- ,
- e.prototype.getClassName = function() {
- return "ArcRotateCameraVRDeviceOrientationInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "VRDeviceOrientation"
- }
- ,
- e
- }();
- Vo.ArcRotateCameraVRDeviceOrientationInput = Qo;
- var qo = function() {
- function e() {
- this.keysForward = [87],
- this.keysBackward = [83],
- this.keysUp = [69],
- this.keysDown = [81],
- this.keysRight = [68],
- this.keysLeft = [65],
- this._keys = new Array
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
- this._engine = this._scene.getEngine(),
- this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
- t._keys = []
- }
- )),
- this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
- var n, r = i.event;
- i.type === Qi.KEYDOWN ? -1 === t.keysForward.indexOf(r.keyCode) && -1 === t.keysBackward.indexOf(r.keyCode) && -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) || (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
- e || r.preventDefault()) : -1 === t.keysForward.indexOf(r.keyCode) && -1 === t.keysBackward.indexOf(r.keyCode) && -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
- e || r.preventDefault())
- }
- )))
- }
- ,
- e.prototype.detachControl = function() {
- 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 = []
- }
- ,
- e.prototype.getClassName = function() {
- return "FlyCameraKeyboardInput"
- }
- ,
- e.prototype._onLostFocus = function() {
- this._keys = []
- }
- ,
- e.prototype.getSimpleName = function() {
- return "keyboard"
- }
- ,
- e.prototype.checkInputs = function() {
- if (this._onKeyboardObserver)
- for (var e = this.camera, t = 0; t < this._keys.length; t++) {
- var i = this._keys[t]
- , n = e._computeLocalCameraSpeed();
- -1 !== this.keysForward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, n) : -1 !== this.keysBackward.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -n) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, n, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, -n, 0) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(n, 0, 0) : -1 !== this.keysLeft.indexOf(i) && e._localDirection.copyFromFloats(-n, 0, 0),
- e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
- e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
- x.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
- e.cameraDirection.addInPlace(e._transformedDirection)
- }
- }
- ,
- k([Ce()], e.prototype, "keysForward", void 0),
- k([Ce()], e.prototype, "keysBackward", void 0),
- k([Ce()], e.prototype, "keysUp", void 0),
- k([Ce()], e.prototype, "keysDown", void 0),
- k([Ce()], e.prototype, "keysRight", void 0),
- k([Ce()], e.prototype, "keysLeft", void 0),
- e
- }();
- Vo.FlyCameraKeyboardInput = qo;
- var Zo = function() {
- function e() {
- this.buttons = [0, 1, 2],
- this.buttonsYaw = [-1, 0, 1],
- this.buttonsPitch = [-1, 0, 1],
- this.buttonsRoll = [2],
- this.activeButton = -1,
- this.angularSensibility = 1e3,
- this._previousPosition = null
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._noPreventDefault = e,
- this._observer = this.camera.getScene().onPointerObservable.add((function(e) {
- t._pointerInput(e)
- }
- ), Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
- this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add((function() {
- t.camera.rollCorrect && t.camera.restoreRoll(t.camera.rollCorrect)
- }
- ))
- }
- ,
- e.prototype.detachControl = function() {
- this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver),
- this._observer = null,
- this._rollObserver = null,
- this._previousPosition = null,
- this._noPreventDefault = void 0)
- }
- ,
- e.prototype.getClassName = function() {
- return "FlyCameraMouseInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "mouse"
- }
- ,
- e.prototype._pointerInput = function(e) {
- var t = e.event
- , i = this.camera.getEngine();
- if (!i.isInVRExclusivePointerMode && (this.touchEnabled || "touch" !== t.pointerType) && (e.type === Xi.POINTERMOVE || -1 !== this.buttons.indexOf(t.button))) {
- var n = t.srcElement || t.target;
- if (e.type === Xi.POINTERDOWN) {
- try {
- null == n || n.setPointerCapture(t.pointerId)
- } catch (t) {}
- this._previousPosition = {
- x: t.clientX,
- y: t.clientY
- },
- this.activeButton = t.button,
- this._noPreventDefault || (t.preventDefault(),
- this._element.focus()),
- i.isPointerLock && this._onMouseMove(e.event)
- } else if (e.type === Xi.POINTERUP) {
- try {
- null == n || n.releasePointerCapture(t.pointerId)
- } catch (t) {}
- this.activeButton = -1,
- this._previousPosition = null,
- this._noPreventDefault || t.preventDefault()
- } else if (e.type === Xi.POINTERMOVE) {
- if (!this._previousPosition)
- return void (i.isPointerLock && this._onMouseMove(e.event));
- var r = t.clientX - this._previousPosition.x
- , o = t.clientY - this._previousPosition.y;
- this._rotateCamera(r, o),
- this._previousPosition = {
- x: t.clientX,
- y: t.clientY
- },
- this._noPreventDefault || t.preventDefault()
- }
- }
- }
- ,
- e.prototype._onMouseMove = function(e) {
- var t = this.camera.getEngine();
- if (t.isPointerLock && !t.isInVRExclusivePointerMode) {
- var i = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0
- , n = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
- this._rotateCamera(i, n),
- this._previousPosition = null,
- this._noPreventDefault || e.preventDefault()
- }
- }
- ,
- e.prototype._rotateCamera = function(e, t) {
- var i = this
- , n = this.camera;
- this.camera.getScene().useRightHandedSystem && (e *= -1),
- n.parent && n.parent._getWorldMatrixDeterminant() < 0 && (e *= -1);
- var r, o = e / this.angularSensibility, a = t / this.angularSensibility, s = C.RotationYawPitchRoll(n.rotation.y, n.rotation.x, n.rotation.z);
- if (this.buttonsPitch.some((function(e) {
- return e === i.activeButton
- }
- )) && (r = C.RotationAxis(vn.X, a),
- s.multiplyInPlace(r)),
- this.buttonsYaw.some((function(e) {
- return e === i.activeButton
- }
- ))) {
- r = C.RotationAxis(vn.Y, o),
- s.multiplyInPlace(r);
- var l = n.bankedTurnLimit + n._trackRoll;
- if (n.bankedTurn && -l < n.rotation.z && n.rotation.z < l) {
- var c = n.bankedTurnMultiplier * -o;
- r = C.RotationAxis(vn.Z, c),
- s.multiplyInPlace(r)
- }
- }
- this.buttonsRoll.some((function(e) {
- return e === i.activeButton
- }
- )) && (r = C.RotationAxis(vn.Z, -o),
- n._trackRoll -= o,
- s.multiplyInPlace(r)),
- s.toEulerAnglesToRef(n.rotation)
- }
- ,
- k([Ce()], e.prototype, "buttons", void 0),
- k([Ce()], e.prototype, "angularSensibility", void 0),
- e
- }();
- Vo.FlyCameraMouseInput = Zo;
- var Jo = function() {
- function e() {
- this.keysHeightOffsetIncr = [38],
- this.keysHeightOffsetDecr = [40],
- this.keysHeightOffsetModifierAlt = !1,
- this.keysHeightOffsetModifierCtrl = !1,
- this.keysHeightOffsetModifierShift = !1,
- this.keysRotationOffsetIncr = [37],
- this.keysRotationOffsetDecr = [39],
- this.keysRotationOffsetModifierAlt = !1,
- this.keysRotationOffsetModifierCtrl = !1,
- this.keysRotationOffsetModifierShift = !1,
- this.keysRadiusIncr = [40],
- this.keysRadiusDecr = [38],
- this.keysRadiusModifierAlt = !0,
- this.keysRadiusModifierCtrl = !1,
- this.keysRadiusModifierShift = !1,
- this.heightSensibility = 1,
- this.rotationSensibility = 1,
- this.radiusSensibility = 1,
- this._keys = new Array
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
- this._engine = this._scene.getEngine(),
- this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
- t._keys = []
- }
- )),
- this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
- var n, r = i.event;
- r.metaKey || (i.type === Qi.KEYDOWN ? (t._ctrlPressed = r.ctrlKey,
- t._altPressed = r.altKey,
- t._shiftPressed = r.shiftKey,
- (-1 !== t.keysHeightOffsetIncr.indexOf(r.keyCode) || -1 !== t.keysHeightOffsetDecr.indexOf(r.keyCode) || -1 !== t.keysRotationOffsetIncr.indexOf(r.keyCode) || -1 !== t.keysRotationOffsetDecr.indexOf(r.keyCode) || -1 !== t.keysRadiusIncr.indexOf(r.keyCode) || -1 !== t.keysRadiusDecr.indexOf(r.keyCode)) && (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
- r.preventDefault && (e || r.preventDefault()))) : -1 === t.keysHeightOffsetIncr.indexOf(r.keyCode) && -1 === t.keysHeightOffsetDecr.indexOf(r.keyCode) && -1 === t.keysRotationOffsetIncr.indexOf(r.keyCode) && -1 === t.keysRotationOffsetDecr.indexOf(r.keyCode) && -1 === t.keysRadiusIncr.indexOf(r.keyCode) && -1 === t.keysRadiusDecr.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
- r.preventDefault && (e || r.preventDefault())))
- }
- )))
- }
- ,
- e.prototype.detachControl = function() {
- 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 = []
- }
- ,
- e.prototype.checkInputs = function() {
- var e = this;
- this._onKeyboardObserver && this._keys.forEach((function(t) {
- -1 !== e.keysHeightOffsetIncr.indexOf(t) && e._modifierHeightOffset() ? e.camera.heightOffset += e.heightSensibility : -1 !== e.keysHeightOffsetDecr.indexOf(t) && e._modifierHeightOffset() ? e.camera.heightOffset -= e.heightSensibility : -1 !== e.keysRotationOffsetIncr.indexOf(t) && e._modifierRotationOffset() ? (e.camera.rotationOffset += e.rotationSensibility,
- e.camera.rotationOffset %= 360) : -1 !== e.keysRotationOffsetDecr.indexOf(t) && e._modifierRotationOffset() ? (e.camera.rotationOffset -= e.rotationSensibility,
- e.camera.rotationOffset %= 360) : -1 !== e.keysRadiusIncr.indexOf(t) && e._modifierRadius() ? e.camera.radius += e.radiusSensibility : -1 !== e.keysRadiusDecr.indexOf(t) && e._modifierRadius() && (e.camera.radius -= e.radiusSensibility)
- }
- ))
- }
- ,
- e.prototype.getClassName = function() {
- return "FollowCameraKeyboardMoveInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "keyboard"
- }
- ,
- e.prototype._modifierHeightOffset = function() {
- return this.keysHeightOffsetModifierAlt === this._altPressed && this.keysHeightOffsetModifierCtrl === this._ctrlPressed && this.keysHeightOffsetModifierShift === this._shiftPressed
- }
- ,
- e.prototype._modifierRotationOffset = function() {
- return this.keysRotationOffsetModifierAlt === this._altPressed && this.keysRotationOffsetModifierCtrl === this._ctrlPressed && this.keysRotationOffsetModifierShift === this._shiftPressed
- }
- ,
- e.prototype._modifierRadius = function() {
- return this.keysRadiusModifierAlt === this._altPressed && this.keysRadiusModifierCtrl === this._ctrlPressed && this.keysRadiusModifierShift === this._shiftPressed
- }
- ,
- k([Ce()], e.prototype, "keysHeightOffsetIncr", void 0),
- k([Ce()], e.prototype, "keysHeightOffsetDecr", void 0),
- k([Ce()], e.prototype, "keysHeightOffsetModifierAlt", void 0),
- k([Ce()], e.prototype, "keysHeightOffsetModifierCtrl", void 0),
- k([Ce()], e.prototype, "keysHeightOffsetModifierShift", void 0),
- k([Ce()], e.prototype, "keysRotationOffsetIncr", void 0),
- k([Ce()], e.prototype, "keysRotationOffsetDecr", void 0),
- k([Ce()], e.prototype, "keysRotationOffsetModifierAlt", void 0),
- k([Ce()], e.prototype, "keysRotationOffsetModifierCtrl", void 0),
- k([Ce()], e.prototype, "keysRotationOffsetModifierShift", void 0),
- k([Ce()], e.prototype, "keysRadiusIncr", void 0),
- k([Ce()], e.prototype, "keysRadiusDecr", void 0),
- k([Ce()], e.prototype, "keysRadiusModifierAlt", void 0),
- k([Ce()], e.prototype, "keysRadiusModifierCtrl", void 0),
- k([Ce()], e.prototype, "keysRadiusModifierShift", void 0),
- k([Ce()], e.prototype, "heightSensibility", void 0),
- k([Ce()], e.prototype, "rotationSensibility", void 0),
- k([Ce()], e.prototype, "radiusSensibility", void 0),
- e
- }();
- Vo.FollowCameraKeyboardMoveInput = Jo;
- var $o = function() {
- function e() {
- this.axisControlRadius = !0,
- this.axisControlHeight = !1,
- this.axisControlRotation = !1,
- this.wheelPrecision = 3,
- this.wheelDeltaPercentage = 0
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._wheel = function(i) {
- if (i.type === Xi.POINTERWHEEL) {
- var n = i.event
- , r = 0
- , o = Math.max(-1, Math.min(1, n.deltaY || n.wheelDelta || -n.detail));
- t.wheelDeltaPercentage ? (console.assert(t.axisControlRadius + t.axisControlHeight + t.axisControlRotation <= 1, "wheelDeltaPercentage only usable when mouse wheel controls ONE axis. Currently enabled: axisControlRadius: " + t.axisControlRadius + ", axisControlHeightOffset: " + t.axisControlHeight + ", axisControlRotationOffset: " + t.axisControlRotation),
- t.axisControlRadius ? r = .01 * o * t.wheelDeltaPercentage * t.camera.radius : t.axisControlHeight ? r = .01 * o * t.wheelDeltaPercentage * t.camera.heightOffset : t.axisControlRotation && (r = .01 * o * t.wheelDeltaPercentage * t.camera.rotationOffset)) : r = o * t.wheelPrecision,
- r && (t.axisControlRadius ? t.camera.radius += r : t.axisControlHeight ? t.camera.heightOffset -= r : t.axisControlRotation && (t.camera.rotationOffset -= r)),
- n.preventDefault && (e || n.preventDefault())
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, Xi.POINTERWHEEL)
- }
- ,
- e.prototype.detachControl = function() {
- this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this._wheel = null)
- }
- ,
- e.prototype.getClassName = function() {
- return "ArcRotateCameraMouseWheelInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "mousewheel"
- }
- ,
- k([Ce()], e.prototype, "axisControlRadius", void 0),
- k([Ce()], e.prototype, "axisControlHeight", void 0),
- k([Ce()], e.prototype, "axisControlRotation", void 0),
- k([Ce()], e.prototype, "wheelPrecision", void 0),
- k([Ce()], e.prototype, "wheelDeltaPercentage", void 0),
- e
- }();
- Vo.FollowCameraMouseWheelInput = $o;
- var ea = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.angularSensibilityX = 1,
- t.angularSensibilityY = 1,
- t.pinchPrecision = 1e4,
- t.pinchDeltaPercentage = 0,
- t.axisXControlRadius = !1,
- t.axisXControlHeight = !1,
- t.axisXControlRotation = !0,
- t.axisYControlRadius = !1,
- t.axisYControlHeight = !0,
- t.axisYControlRotation = !1,
- t.axisPinchControlRadius = !0,
- t.axisPinchControlHeight = !1,
- t.axisPinchControlRotation = !1,
- t.warningEnable = !0,
- t._warningCounter = 0,
- t
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FollowCameraPointersInput"
- }
- ,
- t.prototype.onTouch = function(e, t, i) {
- this._warning(),
- this.axisXControlRotation ? this.camera.rotationOffset += t / this.angularSensibilityX : this.axisYControlRotation && (this.camera.rotationOffset += i / this.angularSensibilityX),
- this.axisXControlHeight ? this.camera.heightOffset += t / this.angularSensibilityY : this.axisYControlHeight && (this.camera.heightOffset += i / this.angularSensibilityY),
- this.axisXControlRadius ? this.camera.radius -= t / this.angularSensibilityY : this.axisYControlRadius && (this.camera.radius -= i / this.angularSensibilityY)
- }
- ,
- t.prototype.onMultiTouch = function(e, t, i, n, r, o) {
- if (!(0 === i && null === r || 0 === n && null === o)) {
- var a = (n - i) / (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
- this.pinchDeltaPercentage ? (a *= .01 * this.pinchDeltaPercentage,
- this.axisPinchControlRotation && (this.camera.rotationOffset += a * this.camera.rotationOffset),
- this.axisPinchControlHeight && (this.camera.heightOffset += a * this.camera.heightOffset),
- this.axisPinchControlRadius && (this.camera.radius -= a * this.camera.radius)) : (this.axisPinchControlRotation && (this.camera.rotationOffset += a),
- this.axisPinchControlHeight && (this.camera.heightOffset += a),
- this.axisPinchControlRadius && (this.camera.radius -= a))
- }
- }
- ,
- t.prototype._warning = function() {
- if (this.warningEnable && this._warningCounter++ % 100 == 0) {
- var e = "It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";
- console.assert(this.axisXControlRotation + this.axisXControlHeight + this.axisXControlRadius <= 1, e + "axisXControlRotation: " + this.axisXControlRotation + ", axisXControlHeight: " + this.axisXControlHeight + ", axisXControlRadius: " + this.axisXControlRadius),
- console.assert(this.axisYControlRotation + this.axisYControlHeight + this.axisYControlRadius <= 1, e + "axisYControlRotation: " + this.axisYControlRotation + ", axisYControlHeight: " + this.axisYControlHeight + ", axisYControlRadius: " + this.axisYControlRadius),
- console.assert(this.axisPinchControlRotation + this.axisPinchControlHeight + this.axisPinchControlRadius <= 1, e + "axisPinchControlRotation: " + this.axisPinchControlRotation + ", axisPinchControlHeight: " + this.axisPinchControlHeight + ", axisPinchControlRadius: " + this.axisPinchControlRadius)
- }
- }
- ,
- k([Ce()], t.prototype, "angularSensibilityX", void 0),
- k([Ce()], t.prototype, "angularSensibilityY", void 0),
- k([Ce()], t.prototype, "pinchPrecision", void 0),
- k([Ce()], t.prototype, "pinchDeltaPercentage", void 0),
- k([Ce()], t.prototype, "axisXControlRadius", void 0),
- k([Ce()], t.prototype, "axisXControlHeight", void 0),
- k([Ce()], t.prototype, "axisXControlRotation", void 0),
- k([Ce()], t.prototype, "axisYControlRadius", void 0),
- k([Ce()], t.prototype, "axisYControlHeight", void 0),
- k([Ce()], t.prototype, "axisYControlRotation", void 0),
- k([Ce()], t.prototype, "axisPinchControlRadius", void 0),
- k([Ce()], t.prototype, "axisPinchControlHeight", void 0),
- k([Ce()], t.prototype, "axisPinchControlRotation", void 0),
- t
- }(Uo);
- Vo.FollowCameraPointersInput = ea;
- var ta = function() {
- function e() {
- 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 e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments),
- this._onCanvasBlurObserver || (this._scene = this.camera.getScene(),
- this._engine = this._scene.getEngine(),
- this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add((function() {
- t._keys = []
- }
- )),
- this._onKeyboardObserver = this._scene.onKeyboardObservable.add((function(i) {
- var n, r = i.event;
- r.metaKey || (i.type === Qi.KEYDOWN ? -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysUpward.indexOf(r.keyCode) && -1 === t.keysDownward.indexOf(r.keyCode) && -1 === t.keysRotateLeft.indexOf(r.keyCode) && -1 === t.keysRotateRight.indexOf(r.keyCode) || (-1 === (n = t._keys.indexOf(r.keyCode)) && t._keys.push(r.keyCode),
- e || r.preventDefault()) : -1 === t.keysUp.indexOf(r.keyCode) && -1 === t.keysDown.indexOf(r.keyCode) && -1 === t.keysLeft.indexOf(r.keyCode) && -1 === t.keysRight.indexOf(r.keyCode) && -1 === t.keysUpward.indexOf(r.keyCode) && -1 === t.keysDownward.indexOf(r.keyCode) && -1 === t.keysRotateLeft.indexOf(r.keyCode) && -1 === t.keysRotateRight.indexOf(r.keyCode) || ((n = t._keys.indexOf(r.keyCode)) >= 0 && t._keys.splice(n, 1),
- e || r.preventDefault()))
- }
- )))
- }
- ,
- e.prototype.detachControl = function() {
- 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 = []
- }
- ,
- e.prototype.checkInputs = function() {
- if (this._onKeyboardObserver)
- for (var e = this.camera, t = 0; t < this._keys.length; t++) {
- var i = this._keys[t]
- , n = e._computeLocalCameraSpeed();
- -1 !== this.keysLeft.indexOf(i) ? e._localDirection.copyFromFloats(-n, 0, 0) : -1 !== this.keysUp.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, n) : -1 !== this.keysRight.indexOf(i) ? e._localDirection.copyFromFloats(n, 0, 0) : -1 !== this.keysDown.indexOf(i) ? e._localDirection.copyFromFloats(0, 0, -n) : -1 !== this.keysUpward.indexOf(i) ? e._localDirection.copyFromFloats(0, n, 0) : -1 !== this.keysDownward.indexOf(i) ? e._localDirection.copyFromFloats(0, -n, 0) : -1 !== this.keysRotateLeft.indexOf(i) ? (e._localDirection.copyFromFloats(0, 0, 0),
- e.cameraRotation.y -= this._getLocalRotation()) : -1 !== this.keysRotateRight.indexOf(i) && (e._localDirection.copyFromFloats(0, 0, 0),
- e.cameraRotation.y += this._getLocalRotation()),
- e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
- e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
- x.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
- e.cameraDirection.addInPlace(e._transformedDirection)
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCameraKeyboardMoveInput"
- }
- ,
- e.prototype._onLostFocus = function() {
- this._keys = []
- }
- ,
- e.prototype.getSimpleName = function() {
- return "keyboard"
- }
- ,
- e.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
- }
- ,
- k([Ce()], e.prototype, "keysUp", void 0),
- k([Ce()], e.prototype, "keysUpward", void 0),
- k([Ce()], e.prototype, "keysDown", void 0),
- k([Ce()], e.prototype, "keysDownward", void 0),
- k([Ce()], e.prototype, "keysLeft", void 0),
- k([Ce()], e.prototype, "keysRight", void 0),
- k([Ce()], e.prototype, "rotationSpeed", void 0),
- k([Ce()], e.prototype, "keysRotateLeft", void 0),
- k([Ce()], e.prototype, "keysRotateRight", void 0),
- e
- }();
- Vo.FreeCameraKeyboardMoveInput = ta;
- var ia, na = function() {
- function e(e) {
- void 0 === e && (e = !0),
- this.touchEnabled = e,
- this.buttons = [0, 1, 2],
- this.angularSensibility = 2e3,
- this._previousPosition = null,
- this.onPointerMovedObservable = new h,
- this._allowCameraRotation = !0,
- this._currentActiveButton = -1
- }
- return e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments);
- var i = this.camera.getEngine()
- , n = i.getInputElement();
- this._pointerInput || (this._pointerInput = function(r) {
- var o = r.event
- , a = "touch" === o.pointerType;
- if (!i.isInVRExclusivePointerMode && (t.touchEnabled || !a) && (r.type === Xi.POINTERMOVE || -1 !== t.buttons.indexOf(o.button))) {
- var s = o.srcElement || o.target;
- if (r.type !== Xi.POINTERDOWN || -1 !== t._currentActiveButton && !a)
- if (r.type !== Xi.POINTERUP || t._currentActiveButton !== o.button && !a) {
- if (r.type === Xi.POINTERMOVE)
- if (i.isPointerLock && t._onMouseMove)
- t._onMouseMove(r.event);
- else if (t._previousPosition) {
- var l = o.clientX - t._previousPosition.x
- , c = o.clientY - t._previousPosition.y;
- t.camera.getScene().useRightHandedSystem && (l *= -1),
- t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (l *= -1),
- t._allowCameraRotation && (t.camera.cameraRotation.y += l / t.angularSensibility,
- t.camera.cameraRotation.x += c / t.angularSensibility),
- t.onPointerMovedObservable.notifyObservers({
- offsetX: l,
- offsetY: c
- }),
- t._previousPosition = {
- x: o.clientX,
- y: o.clientY
- },
- e || o.preventDefault()
- }
- } else {
- try {
- null == s || s.releasePointerCapture(o.pointerId)
- } catch (e) {}
- t._currentActiveButton = -1,
- t._previousPosition = null,
- e || o.preventDefault()
- }
- else {
- try {
- null == s || s.setPointerCapture(o.pointerId)
- } catch (e) {}
- -1 === t._currentActiveButton && (t._currentActiveButton = o.button),
- t._previousPosition = {
- x: o.clientX,
- y: o.clientY
- },
- e || (o.preventDefault(),
- n && n.focus()),
- i.isPointerLock && t._onMouseMove && t._onMouseMove(r.event)
- }
- }
- }
- ),
- this._onMouseMove = function(n) {
- if (i.isPointerLock && !i.isInVRExclusivePointerMode) {
- var r = n.movementX || n.mozMovementX || n.webkitMovementX || n.msMovementX || 0;
- t.camera.getScene().useRightHandedSystem && (r *= -1),
- t.camera.parent && t.camera.parent._getWorldMatrixDeterminant() < 0 && (r *= -1),
- t.camera.cameraRotation.y += r / t.angularSensibility;
- var o = n.movementY || n.mozMovementY || n.webkitMovementY || n.msMovementY || 0;
- t.camera.cameraRotation.x += o / t.angularSensibility,
- t._previousPosition = null,
- e || n.preventDefault()
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
- n && (this._contextMenuBind = this.onContextMenu.bind(this),
- n.addEventListener("contextmenu", this._contextMenuBind, !1))
- }
- ,
- e.prototype.onContextMenu = function(e) {
- e.preventDefault()
- }
- ,
- e.prototype.detachControl = function() {
- if (this._observer) {
- if (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._contextMenuBind) {
- var e = this.camera.getEngine().getInputElement();
- e && e.removeEventListener("contextmenu", this._contextMenuBind)
- }
- this.onPointerMovedObservable && this.onPointerMovedObservable.clear(),
- this._observer = null,
- this._onMouseMove = null,
- this._previousPosition = null
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCameraMouseInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "mouse"
- }
- ,
- k([Ce()], e.prototype, "buttons", void 0),
- k([Ce()], e.prototype, "angularSensibility", void 0),
- e
- }();
- Vo.FreeCameraMouseInput = na,
- function(e) {
- e[e.MoveRelative = 0] = "MoveRelative",
- e[e.RotateRelative = 1] = "RotateRelative",
- e[e.MoveScene = 2] = "MoveScene"
- }(ia || (ia = {}));
- var ra = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t._moveRelative = x.Zero(),
- t._rotateRelative = x.Zero(),
- t._moveScene = x.Zero(),
- t._wheelXAction = ia.MoveRelative,
- t._wheelXActionCoordinate = gn.X,
- t._wheelYAction = ia.MoveRelative,
- t._wheelYActionCoordinate = gn.Z,
- t._wheelZAction = null,
- t._wheelZActionCoordinate = null,
- t
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FreeCameraMouseWheelInput"
- }
- ,
- Object.defineProperty(t.prototype, "wheelXMoveRelative", {
- get: function() {
- return this._wheelXAction !== ia.MoveRelative ? null : this._wheelXActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelXAction !== ia.MoveRelative || (this._wheelXAction = ia.MoveRelative,
- this._wheelXActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelYMoveRelative", {
- get: function() {
- return this._wheelYAction !== ia.MoveRelative ? null : this._wheelYActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelYAction !== ia.MoveRelative || (this._wheelYAction = ia.MoveRelative,
- this._wheelYActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelZMoveRelative", {
- get: function() {
- return this._wheelZAction !== ia.MoveRelative ? null : this._wheelZActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelZAction !== ia.MoveRelative || (this._wheelZAction = ia.MoveRelative,
- this._wheelZActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelXRotateRelative", {
- get: function() {
- return this._wheelXAction !== ia.RotateRelative ? null : this._wheelXActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelXAction !== ia.RotateRelative || (this._wheelXAction = ia.RotateRelative,
- this._wheelXActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelYRotateRelative", {
- get: function() {
- return this._wheelYAction !== ia.RotateRelative ? null : this._wheelYActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelYAction !== ia.RotateRelative || (this._wheelYAction = ia.RotateRelative,
- this._wheelYActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelZRotateRelative", {
- get: function() {
- return this._wheelZAction !== ia.RotateRelative ? null : this._wheelZActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelZAction !== ia.RotateRelative || (this._wheelZAction = ia.RotateRelative,
- this._wheelZActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelXMoveScene", {
- get: function() {
- return this._wheelXAction !== ia.MoveScene ? null : this._wheelXActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelXAction !== ia.MoveScene || (this._wheelXAction = ia.MoveScene,
- this._wheelXActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelYMoveScene", {
- get: function() {
- return this._wheelYAction !== ia.MoveScene ? null : this._wheelYActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelYAction !== ia.MoveScene || (this._wheelYAction = ia.MoveScene,
- this._wheelYActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelZMoveScene", {
- get: function() {
- return this._wheelZAction !== ia.MoveScene ? null : this._wheelZActionCoordinate
- },
- set: function(e) {
- null === e && this._wheelZAction !== ia.MoveScene || (this._wheelZAction = ia.MoveScene,
- this._wheelZActionCoordinate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.checkInputs = function() {
- if (0 !== this._wheelDeltaX || 0 !== this._wheelDeltaY || 0 != this._wheelDeltaZ) {
- this._moveRelative.setAll(0),
- this._rotateRelative.setAll(0),
- this._moveScene.setAll(0),
- this._updateCamera(),
- this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
- var t = P.Zero();
- this.camera.getViewMatrix().invertToRef(t);
- var i = x.Zero();
- x.TransformNormalToRef(this._moveRelative, t, i),
- this.camera.cameraRotation.x += this._rotateRelative.x / 200,
- this.camera.cameraRotation.y += this._rotateRelative.y / 200,
- this.camera.cameraDirection.addInPlace(i),
- this.camera.cameraDirection.addInPlace(this._moveScene),
- e.prototype.checkInputs.call(this)
- }
- }
- ,
- t.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)
- }
- ,
- t.prototype._updateCameraProperty = function(e, t, i) {
- if (0 !== e && null !== t && null !== i) {
- var n = null;
- switch (t) {
- case ia.MoveRelative:
- n = this._moveRelative;
- break;
- case ia.RotateRelative:
- n = this._rotateRelative;
- break;
- case ia.MoveScene:
- n = this._moveScene
- }
- switch (i) {
- case gn.X:
- n.set(e, 0, 0);
- break;
- case gn.Y:
- n.set(0, e, 0);
- break;
- case gn.Z:
- n.set(0, 0, e)
- }
- }
- }
- ,
- k([Ce()], t.prototype, "wheelXMoveRelative", null),
- k([Ce()], t.prototype, "wheelYMoveRelative", null),
- k([Ce()], t.prototype, "wheelZMoveRelative", null),
- k([Ce()], t.prototype, "wheelXRotateRelative", null),
- k([Ce()], t.prototype, "wheelYRotateRelative", null),
- k([Ce()], t.prototype, "wheelZRotateRelative", null),
- k([Ce()], t.prototype, "wheelXMoveScene", null),
- k([Ce()], t.prototype, "wheelYMoveScene", null),
- k([Ce()], t.prototype, "wheelZMoveScene", null),
- t
- }(Bo);
- Vo.FreeCameraMouseWheelInput = ra;
- var oa = function() {
- function e(e) {
- void 0 === e && (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 e.prototype.attachControl = function(e) {
- var t = this;
- e = gi.BackCompatCameraNoPreventDefault(arguments);
- var i = null;
- if (void 0 === this._pointerInput && (this._onLostFocus = function() {
- t._offsetX = null,
- t._offsetY = null
- }
- ,
- this._pointerInput = function(n) {
- var r = n.event
- , o = !t.camera.getEngine().hostInformation.isMobile && r instanceof MouseEvent;
- if (t.allowMouse || "mouse" !== r.pointerType && !o)
- if (n.type === Xi.POINTERDOWN) {
- if (e || r.preventDefault(),
- t._pointerPressed.push(r.pointerId),
- 1 !== t._pointerPressed.length)
- return;
- i = {
- x: r.clientX,
- y: r.clientY
- }
- } else if (n.type === Xi.POINTERUP) {
- if (e || r.preventDefault(),
- -1 === (a = t._pointerPressed.indexOf(r.pointerId)))
- return;
- if (t._pointerPressed.splice(a, 1),
- 0 != a)
- return;
- i = null,
- t._offsetX = null,
- t._offsetY = null
- } else if (n.type === Xi.POINTERMOVE) {
- if (e || r.preventDefault(),
- !i)
- return;
- var a;
- if (0 != (a = t._pointerPressed.indexOf(r.pointerId)))
- return;
- t._offsetX = r.clientX - i.x,
- t._offsetY = -(r.clientY - i.y)
- }
- }
- ),
- this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, Xi.POINTERDOWN | Xi.POINTERUP | Xi.POINTERMOVE),
- this._onLostFocus) {
- var n = this.camera.getEngine()
- , r = n.getInputElement();
- r && r.addEventListener("blur", this._onLostFocus)
- }
- }
- ,
- e.prototype.detachControl = function() {
- if (this._pointerInput) {
- if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null),
- this._onLostFocus) {
- var e = this.camera.getEngine().getInputElement();
- e && e.removeEventListener("blur", this._onLostFocus),
- this._onLostFocus = null
- }
- this._pointerPressed = [],
- this._offsetX = null,
- this._offsetY = null
- }
- }
- ,
- e.prototype.checkInputs = function() {
- if (null !== this._offsetX && null !== this._offsetY && (0 !== this._offsetX || 0 !== this._offsetY)) {
- var e = this.camera;
- if (e.cameraRotation.y = this._offsetX / this.touchAngularSensibility,
- this.singleFingerRotate && 1 === this._pointerPressed.length || !this.singleFingerRotate && this._pointerPressed.length > 1)
- e.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
- else {
- var t = e._computeLocalCameraSpeed()
- , i = new x(0,0,t * this._offsetY / this.touchMoveSensibility);
- P.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix),
- e.cameraDirection.addInPlace(x.TransformCoordinates(i, e._cameraRotationMatrix))
- }
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCameraTouchInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "touch"
- }
- ,
- k([Ce()], e.prototype, "touchAngularSensibility", void 0),
- k([Ce()], e.prototype, "touchMoveSensibility", void 0),
- e
- }();
- Vo.FreeCameraTouchInput = oa;
- var aa = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i._mouseInput = null,
- i._mouseWheelInput = null,
- i
- }
- return U(t, e),
- t.prototype.addKeyboard = function() {
- return this.add(new ta),
- this
- }
- ,
- t.prototype.addMouse = function(e) {
- return void 0 === e && (e = !0),
- this._mouseInput || (this._mouseInput = new na(e),
- this.add(this._mouseInput)),
- this
- }
- ,
- t.prototype.removeMouse = function() {
- return this._mouseInput && this.remove(this._mouseInput),
- this
- }
- ,
- t.prototype.addMouseWheel = function() {
- return this._mouseWheelInput || (this._mouseWheelInput = new ra,
- this.add(this._mouseWheelInput)),
- this
- }
- ,
- t.prototype.removeMouseWheel = function() {
- return this._mouseWheelInput && this.remove(this._mouseWheelInput),
- this
- }
- ,
- t.prototype.addTouch = function() {
- return this.add(new oa),
- this
- }
- ,
- t.prototype.clear = function() {
- e.prototype.clear.call(this),
- this._mouseInput = null
- }
- ,
- t
- }(ko);
- aa.prototype.addDeviceOrientation = function() {
- return this._deviceOrientationInput || (this._deviceOrientationInput = new sa,
- this.add(this._deviceOrientationInput)),
- this
- }
- ;
- var sa = function() {
- function e() {
- var e = this;
- this._screenOrientationAngle = 0,
- this._screenQuaternion = new C,
- this._alpha = 0,
- this._beta = 0,
- this._gamma = 0,
- this._onDeviceOrientationChangedObservable = new h,
- this._orientationChanged = function() {
- e._screenOrientationAngle = void 0 !== window.orientation ? +window.orientation : window.screen.orientation && window.screen.orientation.angle ? window.screen.orientation.angle : 0,
- e._screenOrientationAngle = -gi.ToRadians(e._screenOrientationAngle / 2),
- e._screenQuaternion.copyFromFloats(0, Math.sin(e._screenOrientationAngle), 0, Math.cos(e._screenOrientationAngle))
- }
- ,
- this._deviceOrientation = function(t) {
- e._alpha = null !== t.alpha ? t.alpha : 0,
- e._beta = null !== t.beta ? t.beta : 0,
- e._gamma = null !== t.gamma ? t.gamma : 0,
- null !== t.alpha && e._onDeviceOrientationChangedObservable.notifyObservers()
- }
- ,
- this._constantTranform = new C(-Math.sqrt(.5),0,0,Math.sqrt(.5)),
- this._orientationChanged()
- }
- return e.WaitForOrientationChangeAsync = function(e) {
- return new Promise((function(t, i) {
- var n = !1
- , r = function() {
- window.removeEventListener("deviceorientation", r),
- n = !0,
- t()
- };
- e && setTimeout((function() {
- n || (window.removeEventListener("deviceorientation", r),
- i("WaitForOrientationChangeAsync timed out"))
- }
- ), e),
- "undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
- "granted" == e ? window.addEventListener("deviceorientation", r) : gi.Warn("Permission not granted.")
- }
- )).catch((function(e) {
- gi.Error(e)
- }
- )) : window.addEventListener("deviceorientation", r)
- }
- ))
- }
- ,
- Object.defineProperty(e.prototype, "camera", {
- get: function() {
- return this._camera
- },
- set: function(e) {
- var t = this;
- this._camera = e,
- null == this._camera || this._camera.rotationQuaternion || (this._camera.rotationQuaternion = new C),
- this._camera && this._camera.onDisposeObservable.add((function() {
- t._onDeviceOrientationChangedObservable.clear()
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attachControl = function() {
- var e = this
- , t = this.camera.getScene().getEngine().getHostWindow();
- if (t) {
- var i = function() {
- t.addEventListener("orientationchange", e._orientationChanged),
- t.addEventListener("deviceorientation", e._deviceOrientation),
- e._orientationChanged()
- };
- "undefined" != typeof DeviceOrientationEvent && "function" == typeof DeviceOrientationEvent.requestPermission ? DeviceOrientationEvent.requestPermission().then((function(e) {
- "granted" === e ? i() : gi.Warn("Permission not granted.")
- }
- )).catch((function(e) {
- gi.Error(e)
- }
- )) : i()
- }
- }
- ,
- e.prototype.detachControl = function() {
- window.removeEventListener("orientationchange", this._orientationChanged),
- window.removeEventListener("deviceorientation", this._deviceOrientation),
- this._alpha = 0
- }
- ,
- e.prototype.checkInputs = function() {
- this._alpha && (C.RotationYawPitchRollToRef(gi.ToRadians(this._alpha), gi.ToRadians(this._beta), -gi.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)
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCameraDeviceOrientationInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "deviceOrientation"
- }
- ,
- e
- }();
- Vo.FreeCameraDeviceOrientationInput = sa;
- var la, ca = function() {
- function e() {
- this.gamepadAngularSensibility = 200,
- this.gamepadMoveSensibility = 40,
- this.deadzoneDelta = .1,
- this._yAxisScale = 1,
- this._cameraTransform = P.Identity(),
- this._deltaTransform = x.Zero(),
- this._vector3 = x.Zero(),
- this._vector2 = A.Zero()
- }
- return Object.defineProperty(e.prototype, "invertYAxis", {
- get: function() {
- return 1 !== this._yAxisScale
- },
- set: function(e) {
- this._yAxisScale = e ? -1 : 1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attachControl = function() {
- var e = this
- , t = this.camera.getScene().gamepadManager;
- this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
- t.type !== zo.POSE_ENABLED && (e.gamepad && t.type !== zo.XBOX || (e.gamepad = t))
- }
- )),
- this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
- e.gamepad === t && (e.gamepad = null)
- }
- )),
- this.gamepad = t.getGamepadByType(zo.XBOX),
- !this.gamepad && t.gamepads.length && (this.gamepad = t.gamepads[0])
- }
- ,
- e.prototype.detachControl = function() {
- this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
- this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
- this.gamepad = null
- }
- ,
- e.prototype.checkInputs = function() {
- if (this.gamepad && this.gamepad.leftStick) {
- var e = this.camera
- , t = this.gamepad.leftStick;
- 0 !== this.gamepadMoveSensibility && (t.x = Math.abs(t.x) > this.deadzoneDelta ? t.x / this.gamepadMoveSensibility : 0,
- t.y = Math.abs(t.y) > this.deadzoneDelta ? t.y / this.gamepadMoveSensibility : 0);
- var i = this.gamepad.rightStick;
- i && 0 !== this.gamepadAngularSensibility ? (i.x = Math.abs(i.x) > this.deadzoneDelta ? i.x / this.gamepadAngularSensibility : 0,
- i.y = (Math.abs(i.y) > this.deadzoneDelta ? i.y / this.gamepadAngularSensibility : 0) * this._yAxisScale) : i = {
- x: 0,
- y: 0
- },
- e.rotationQuaternion ? e.rotationQuaternion.toRotationMatrix(this._cameraTransform) : P.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, this._cameraTransform);
- var n = 50 * e._computeLocalCameraSpeed();
- this._vector3.copyFromFloats(t.x * n, 0, -t.y * n),
- x.TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform),
- e.cameraDirection.addInPlace(this._deltaTransform),
- this._vector2.copyFromFloats(i.y, i.x),
- e.cameraRotation.addInPlace(this._vector2)
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCameraGamepadInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "gamepad"
- }
- ,
- k([Ce()], e.prototype, "gamepadAngularSensibility", void 0),
- k([Ce()], e.prototype, "gamepadMoveSensibility", void 0),
- e
- }();
- Vo.FreeCameraGamepadInput = ca,
- function(e) {
- e[e.X = 0] = "X",
- e[e.Y = 1] = "Y",
- e[e.Z = 2] = "Z"
- }(la || (la = {}));
- var ua = function() {
- function e(t, i) {
- var n = this
- , r = V(V({}, e._GetDefaultOptions()), i);
- if (this._leftJoystick = !!t,
- e._GlobalJoystickIndex++,
- this._axisTargetedByLeftAndRight = la.X,
- this._axisTargetedByUpAndDown = la.Y,
- this.reverseLeftRight = !1,
- this.reverseUpDown = !1,
- this._touches = new Ei,
- this.deltaPosition = x.Zero(),
- this._joystickSensibility = 25,
- this._inversedSensibility = 1 / (this._joystickSensibility / 1e3),
- this._onResize = function() {
- e._VJCanvasWidth = window.innerWidth,
- e._VJCanvasHeight = window.innerHeight,
- e.Canvas && (e.Canvas.width = e._VJCanvasWidth,
- e.Canvas.height = e._VJCanvasHeight),
- e._HalfWidth = e._VJCanvasWidth / 2
- }
- ,
- !e.Canvas) {
- window.addEventListener("resize", this._onResize, !1),
- e.Canvas = document.createElement("canvas"),
- e._VJCanvasWidth = window.innerWidth,
- e._VJCanvasHeight = window.innerHeight,
- e.Canvas.width = window.innerWidth,
- e.Canvas.height = window.innerHeight,
- e.Canvas.style.width = "100%",
- e.Canvas.style.height = "100%",
- e.Canvas.style.position = "absolute",
- e.Canvas.style.backgroundColor = "transparent",
- e.Canvas.style.top = "0px",
- e.Canvas.style.left = "0px",
- e.Canvas.style.zIndex = "5",
- e.Canvas.style.msTouchAction = "none",
- e.Canvas.style.touchAction = "none",
- e.Canvas.setAttribute("touch-action", "none");
- var o = e.Canvas.getContext("2d");
- if (!o)
- throw new Error("Unable to create canvas for virtual joystick");
- e._VJCanvasContext = o,
- e._VJCanvasContext.strokeStyle = "#ffffff",
- e._VJCanvasContext.lineWidth = 2,
- document.body.appendChild(e.Canvas)
- }
- e._HalfWidth = e.Canvas.width / 2,
- this.pressed = !1,
- this.limitToContainer = r.limitToContainer,
- this._joystickColor = r.color,
- this.containerSize = r.containerSize,
- this.puckSize = r.puckSize,
- r.position && this.setPosition(r.position.x, r.position.y),
- r.puckImage && this.setPuckImage(r.puckImage),
- r.containerImage && this.setContainerImage(r.containerImage),
- r.alwaysVisible && e._AlwaysVisibleSticks++,
- this.alwaysVisible = r.alwaysVisible,
- this._joystickPointerId = -1,
- this._joystickPointerPos = new A(0,0),
- this._joystickPreviousPointerPos = new A(0,0),
- this._joystickPointerStartPos = new A(0,0),
- this._deltaJoystickVector = new A(0,0),
- this._onPointerDownHandlerRef = function(e) {
- n._onPointerDown(e)
- }
- ,
- this._onPointerMoveHandlerRef = function(e) {
- n._onPointerMove(e)
- }
- ,
- this._onPointerUpHandlerRef = function(e) {
- n._onPointerUp(e)
- }
- ,
- e.Canvas.addEventListener("pointerdown", this._onPointerDownHandlerRef, !1),
- e.Canvas.addEventListener("pointermove", this._onPointerMoveHandlerRef, !1),
- e.Canvas.addEventListener("pointerup", this._onPointerUpHandlerRef, !1),
- e.Canvas.addEventListener("pointerout", this._onPointerUpHandlerRef, !1),
- e.Canvas.addEventListener("contextmenu", (function(e) {
- e.preventDefault()
- }
- ), !1),
- requestAnimationFrame((function() {
- n._drawVirtualJoystick()
- }
- ))
- }
- return e._GetDefaultOptions = function() {
- return {
- puckSize: 40,
- containerSize: 60,
- color: "cyan",
- puckImage: void 0,
- containerImage: void 0,
- position: void 0,
- alwaysVisible: !1,
- limitToContainer: !1
- }
- }
- ,
- e.prototype.setJoystickSensibility = function(e) {
- this._joystickSensibility = e,
- this._inversedSensibility = 1 / (this._joystickSensibility / 1e3)
- }
- ,
- e.prototype._onPointerDown = function(t) {
- t.preventDefault(),
- (!0 === this._leftJoystick ? t.clientX < e._HalfWidth : t.clientX > e._HalfWidth) && this._joystickPointerId < 0 ? (this._joystickPointerId = t.pointerId,
- this._joystickPosition ? (this._joystickPointerStartPos = this._joystickPosition.clone(),
- this._joystickPointerPos = this._joystickPosition.clone(),
- this._joystickPreviousPointerPos = this._joystickPosition.clone(),
- this._onPointerMove(t)) : (this._joystickPointerStartPos.x = t.clientX,
- this._joystickPointerStartPos.y = t.clientY,
- this._joystickPointerPos = this._joystickPointerStartPos.clone(),
- this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone()),
- this._deltaJoystickVector.x = 0,
- this._deltaJoystickVector.y = 0,
- this.pressed = !0,
- this._touches.add(t.pointerId.toString(), t)) : e._GlobalJoystickIndex < 2 && this._action && (this._action(),
- this._touches.add(t.pointerId.toString(), {
- x: t.clientX,
- y: t.clientY,
- prevX: t.clientX,
- prevY: t.clientY
- }))
- }
- ,
- e.prototype._onPointerMove = function(t) {
- if (this._joystickPointerId == t.pointerId) {
- if (this.limitToContainer) {
- var i = new A(t.clientX - this._joystickPointerStartPos.x,t.clientY - this._joystickPointerStartPos.y)
- , n = i.length();
- n > this.containerSize && i.scaleInPlace(this.containerSize / n),
- this._joystickPointerPos.x = this._joystickPointerStartPos.x + i.x,
- this._joystickPointerPos.y = this._joystickPointerStartPos.y + i.y
- } else
- this._joystickPointerPos.x = t.clientX,
- this._joystickPointerPos.y = t.clientY;
- this._deltaJoystickVector = this._joystickPointerPos.clone(),
- this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos),
- 0 < e._AlwaysVisibleSticks && (this._leftJoystick ? this._joystickPointerPos.x = Math.min(e._HalfWidth, this._joystickPointerPos.x) : this._joystickPointerPos.x = Math.max(e._HalfWidth, this._joystickPointerPos.x));
- var r = (this.reverseLeftRight ? -1 : 1) * this._deltaJoystickVector.x / this._inversedSensibility;
- switch (this._axisTargetedByLeftAndRight) {
- case la.X:
- this.deltaPosition.x = Math.min(1, Math.max(-1, r));
- break;
- case la.Y:
- this.deltaPosition.y = Math.min(1, Math.max(-1, r));
- break;
- case la.Z:
- this.deltaPosition.z = Math.min(1, Math.max(-1, r))
- }
- var o = (this.reverseUpDown ? 1 : -1) * this._deltaJoystickVector.y / this._inversedSensibility;
- switch (this._axisTargetedByUpAndDown) {
- case la.X:
- this.deltaPosition.x = Math.min(1, Math.max(-1, o));
- break;
- case la.Y:
- this.deltaPosition.y = Math.min(1, Math.max(-1, o));
- break;
- case la.Z:
- this.deltaPosition.z = Math.min(1, Math.max(-1, o))
- }
- } else {
- var a = this._touches.get(t.pointerId.toString());
- a && (a.x = t.clientX,
- a.y = t.clientY)
- }
- }
- ,
- e.prototype._onPointerUp = function(t) {
- if (this._joystickPointerId == t.pointerId)
- this._clearPreviousDraw(),
- this._joystickPointerId = -1,
- this.pressed = !1;
- else {
- var i = this._touches.get(t.pointerId.toString());
- i && e._VJCanvasContext.clearRect(i.prevX - 44, i.prevY - 44, 88, 88)
- }
- this._deltaJoystickVector.x = 0,
- this._deltaJoystickVector.y = 0,
- this._touches.remove(t.pointerId.toString())
- }
- ,
- e.prototype.setJoystickColor = function(e) {
- this._joystickColor = e
- }
- ,
- Object.defineProperty(e.prototype, "containerSize", {
- get: function() {
- return this._joystickContainerSize
- },
- set: function(e) {
- this._joystickContainerSize = e,
- this._clearContainerSize = ~~(2.1 * this._joystickContainerSize),
- this._clearContainerSizeOffset = ~~(this._clearContainerSize / 2)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "puckSize", {
- get: function() {
- return this._joystickPuckSize
- },
- set: function(e) {
- this._joystickPuckSize = e,
- this._clearPuckSize = ~~(2.1 * this._joystickPuckSize),
- this._clearPuckSizeOffset = ~~(this._clearPuckSize / 2)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.clearPosition = function() {
- this.alwaysVisible = !1,
- this._joystickPosition = null
- }
- ,
- Object.defineProperty(e.prototype, "alwaysVisible", {
- get: function() {
- return this._alwaysVisible
- },
- set: function(t) {
- this._alwaysVisible !== t && (t && this._joystickPosition ? (e._AlwaysVisibleSticks++,
- this._alwaysVisible = !0) : (e._AlwaysVisibleSticks--,
- this._alwaysVisible = !1))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setPosition = function(e, t) {
- this._joystickPointerStartPos && this._clearPreviousDraw(),
- this._joystickPosition = new A(e,t)
- }
- ,
- e.prototype.setActionOnTouch = function(e) {
- this._action = e
- }
- ,
- e.prototype.setAxisForLeftRight = function(e) {
- switch (e) {
- case la.X:
- case la.Y:
- case la.Z:
- this._axisTargetedByLeftAndRight = e;
- break;
- default:
- this._axisTargetedByLeftAndRight = la.X
- }
- }
- ,
- e.prototype.setAxisForUpDown = function(e) {
- switch (e) {
- case la.X:
- case la.Y:
- case la.Z:
- this._axisTargetedByUpAndDown = e;
- break;
- default:
- this._axisTargetedByUpAndDown = la.Y
- }
- }
- ,
- e.prototype._clearPreviousDraw = function() {
- var t = this._joystickPosition || this._joystickPointerStartPos;
- e._VJCanvasContext.clearRect(t.x - this._clearContainerSizeOffset, t.y - this._clearContainerSizeOffset, this._clearContainerSize, this._clearContainerSize),
- e._VJCanvasContext.clearRect(this._joystickPreviousPointerPos.x - this._clearPuckSizeOffset, this._joystickPreviousPointerPos.y - this._clearPuckSizeOffset, this._clearPuckSize, this._clearPuckSize)
- }
- ,
- e.prototype.setContainerImage = function(e) {
- var t = this
- , i = new Image;
- i.src = e,
- i.onload = function() {
- return t._containerImage = i
- }
- }
- ,
- e.prototype.setPuckImage = function(e) {
- var t = this
- , i = new Image;
- i.src = e,
- i.onload = function() {
- return t._puckImage = i
- }
- }
- ,
- e.prototype._drawContainer = function() {
- var t = this._joystickPosition || this._joystickPointerStartPos;
- this._clearPreviousDraw(),
- this._containerImage ? e._VJCanvasContext.drawImage(this._containerImage, t.x - this.containerSize, t.y - this.containerSize, 2 * this.containerSize, 2 * this.containerSize) : (e._VJCanvasContext.beginPath(),
- e._VJCanvasContext.strokeStyle = this._joystickColor,
- e._VJCanvasContext.lineWidth = 2,
- e._VJCanvasContext.arc(t.x, t.y, this.containerSize, 0, 2 * Math.PI, !0),
- e._VJCanvasContext.stroke(),
- e._VJCanvasContext.closePath(),
- e._VJCanvasContext.beginPath(),
- e._VJCanvasContext.lineWidth = 6,
- e._VJCanvasContext.strokeStyle = this._joystickColor,
- e._VJCanvasContext.arc(t.x, t.y, this.puckSize, 0, 2 * Math.PI, !0),
- e._VJCanvasContext.stroke(),
- e._VJCanvasContext.closePath())
- }
- ,
- e.prototype._drawPuck = function() {
- this._puckImage ? e._VJCanvasContext.drawImage(this._puckImage, this._joystickPointerPos.x - this.puckSize, this._joystickPointerPos.y - this.puckSize, 2 * this.puckSize, 2 * this.puckSize) : (e._VJCanvasContext.beginPath(),
- e._VJCanvasContext.strokeStyle = this._joystickColor,
- e._VJCanvasContext.lineWidth = 2,
- e._VJCanvasContext.arc(this._joystickPointerPos.x, this._joystickPointerPos.y, this.puckSize, 0, 2 * Math.PI, !0),
- e._VJCanvasContext.stroke(),
- e._VJCanvasContext.closePath())
- }
- ,
- e.prototype._drawVirtualJoystick = function() {
- var t = this;
- this.alwaysVisible && this._drawContainer(),
- this.pressed && this._touches.forEach((function(i, n) {
- n.pointerId === t._joystickPointerId ? (t.alwaysVisible || t._drawContainer(),
- t._drawPuck(),
- t._joystickPreviousPointerPos = t._joystickPointerPos.clone()) : (e._VJCanvasContext.clearRect(n.prevX - 44, n.prevY - 44, 88, 88),
- e._VJCanvasContext.beginPath(),
- e._VJCanvasContext.fillStyle = "white",
- e._VJCanvasContext.beginPath(),
- e._VJCanvasContext.strokeStyle = "red",
- e._VJCanvasContext.lineWidth = 6,
- e._VJCanvasContext.arc(n.x, n.y, 40, 0, 2 * Math.PI, !0),
- e._VJCanvasContext.stroke(),
- e._VJCanvasContext.closePath(),
- n.prevX = n.x,
- n.prevY = n.y)
- }
- )),
- requestAnimationFrame((function() {
- t._drawVirtualJoystick()
- }
- ))
- }
- ,
- e.prototype.releaseCanvas = function() {
- e.Canvas && (e.Canvas.removeEventListener("pointerdown", this._onPointerDownHandlerRef),
- e.Canvas.removeEventListener("pointermove", this._onPointerMoveHandlerRef),
- e.Canvas.removeEventListener("pointerup", this._onPointerUpHandlerRef),
- e.Canvas.removeEventListener("pointerout", this._onPointerUpHandlerRef),
- window.removeEventListener("resize", this._onResize),
- document.body.removeChild(e.Canvas),
- e.Canvas = null)
- }
- ,
- e._GlobalJoystickIndex = 0,
- e._AlwaysVisibleSticks = 0,
- e
- }();
- aa.prototype.addVirtualJoystick = function() {
- return this.add(new ha),
- this
- }
- ;
- var ha = function() {
- function e() {}
- return e.prototype.getLeftJoystick = function() {
- return this._leftjoystick
- }
- ,
- e.prototype.getRightJoystick = function() {
- return this._rightjoystick
- }
- ,
- e.prototype.checkInputs = function() {
- if (this._leftjoystick) {
- var e = this.camera
- , t = 50 * e._computeLocalCameraSpeed()
- , i = P.RotationYawPitchRoll(e.rotation.y, e.rotation.x, 0)
- , n = x.TransformCoordinates(new x(this._leftjoystick.deltaPosition.x * t,this._leftjoystick.deltaPosition.y * t,this._leftjoystick.deltaPosition.z * t), i);
- e.cameraDirection = e.cameraDirection.add(n),
- e.cameraRotation = e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),
- this._leftjoystick.pressed || (this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(.9)),
- this._rightjoystick.pressed || (this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(.9))
- }
- }
- ,
- e.prototype.attachControl = function() {
- this._leftjoystick = new ua(!0),
- this._leftjoystick.setAxisForUpDown(la.Z),
- this._leftjoystick.setAxisForLeftRight(la.X),
- this._leftjoystick.setJoystickSensibility(.15),
- this._rightjoystick = new ua(!1),
- this._rightjoystick.setAxisForUpDown(la.X),
- this._rightjoystick.setAxisForLeftRight(la.Y),
- this._rightjoystick.reverseUpDown = !0,
- this._rightjoystick.setJoystickSensibility(.05),
- this._rightjoystick.setJoystickColor("yellow")
- }
- ,
- e.prototype.detachControl = function() {
- this._leftjoystick.releaseCanvas(),
- this._rightjoystick.releaseCanvas()
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCameraVirtualJoystickInput"
- }
- ,
- e.prototype.getSimpleName = function() {
- return "virtualJoystick"
- }
- ,
- e
- }();
- Vo.FreeCameraVirtualJoystickInput = ha;
- var da = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = !0);
- var o = e.call(this, t, i, n, r) || this;
- return o._tmpUpVector = x.Zero(),
- o._tmpTargetVector = x.Zero(),
- o.cameraDirection = new x(0,0,0),
- o.cameraRotation = new A(0,0),
- o.ignoreParentScaling = !1,
- o.updateUpVectorFromRotation = !1,
- o._tmpQuaternion = new C,
- o.rotation = new x(0,0,0),
- o.speed = 2,
- o.noRotationConstraint = !1,
- o.invertRotation = !1,
- o.inverseRotationSpeed = .2,
- o.lockedTarget = null,
- o._currentTarget = x.Zero(),
- o._initialFocalDistance = 1,
- o._viewMatrix = P.Zero(),
- o._camMatrix = P.Zero(),
- o._cameraTransformMatrix = P.Zero(),
- o._cameraRotationMatrix = P.Zero(),
- o._referencePoint = new x(0,0,1),
- o._transformedReferencePoint = x.Zero(),
- o._defaultUp = x.Up(),
- o._cachedRotationZ = 0,
- o._cachedQuaternionRotationZ = 0,
- o
- }
- return U(t, e),
- t.prototype.getFrontPosition = function(e) {
- this.getWorldMatrix();
- var t = this.getTarget().subtract(this.position);
- return t.normalize(),
- t.scaleInPlace(e),
- this.globalPosition.add(t)
- }
- ,
- t.prototype._getLockedTargetPosition = function() {
- return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(),
- this.lockedTarget.absolutePosition || this.lockedTarget) : null
- }
- ,
- t.prototype.storeState = function() {
- return this._storedPosition = this.position.clone(),
- this._storedRotation = this.rotation.clone(),
- this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()),
- e.prototype.storeState.call(this)
- }
- ,
- t.prototype._restoreStateValues = function() {
- return !!e.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)
- }
- ,
- t.prototype._initCache = function() {
- e.prototype._initCache.call(this),
- this._cache.lockedTarget = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.rotation = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.rotationQuaternion = new C(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- }
- ,
- t.prototype._updateCache = function(t) {
- t || e.prototype._updateCache.call(this);
- var i = this._getLockedTargetPosition();
- i ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(i) : this._cache.lockedTarget = i.clone() : this._cache.lockedTarget = null,
- this._cache.rotation.copyFrom(this.rotation),
- this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)
- }
- ,
- t.prototype._isSynchronizedViewMatrix = function() {
- if (!e.prototype._isSynchronizedViewMatrix.call(this))
- return !1;
- var t = this._getLockedTargetPosition();
- return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(t) : !t) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation))
- }
- ,
- t.prototype._computeLocalCameraSpeed = function() {
- var e = this.getEngine();
- return this.speed * Math.sqrt(e.getDeltaTime() / (100 * e.getFps()))
- }
- ,
- t.prototype.setTarget = function(e) {
- this.upVector.normalize(),
- this._initialFocalDistance = e.subtract(this.position).length(),
- this.position.z === e.z && (this.position.z += m),
- this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),
- P.LookAtLHToRef(this.position, e, this._defaultUp, this._camMatrix),
- this._camMatrix.invert(),
- this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
- var t = e.subtract(this.position);
- t.x >= 0 ? this.rotation.y = -Math.atan(t.z / t.x) + Math.PI / 2 : this.rotation.y = -Math.atan(t.z / t.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 && C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
- }
- ,
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- return this.getTarget()
- },
- set: function(e) {
- this.setTarget(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getTarget = function() {
- return this._currentTarget
- }
- ,
- t.prototype._decideIfNeedsToMove = function() {
- return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
- }
- ,
- t.prototype._updatePosition = function() {
- if (this.parent)
- return this.parent.getWorldMatrix().invertToRef(I.Matrix[0]),
- x.TransformNormalToRef(this.cameraDirection, I.Matrix[0], I.Vector3[0]),
- void this.position.addInPlace(I.Vector3[0]);
- this.position.addInPlace(this.cameraDirection)
- }
- ,
- t.prototype._checkInputs = function() {
- var t = this.invertRotation ? -this.inverseRotationSpeed : 1
- , i = this._decideIfNeedsToMove()
- , n = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
- if (i && this._updatePosition(),
- n) {
- if (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this.rotation),
- this.rotation.x += this.cameraRotation.x * t,
- this.rotation.y += this.cameraRotation.y * t,
- !this.noRotationConstraint) {
- var r = 1.570796;
- this.rotation.x > r && (this.rotation.x = r),
- this.rotation.x < -r && (this.rotation.x = -r)
- }
- this.rotationQuaternion && this.rotation.lengthSquared() && C.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
- }
- i && (Math.abs(this.cameraDirection.x) < this.speed * m && (this.cameraDirection.x = 0),
- Math.abs(this.cameraDirection.y) < this.speed * m && (this.cameraDirection.y = 0),
- Math.abs(this.cameraDirection.z) < this.speed * m && (this.cameraDirection.z = 0),
- this.cameraDirection.scaleInPlace(this.inertia)),
- n && (Math.abs(this.cameraRotation.x) < this.speed * m && (this.cameraRotation.x = 0),
- Math.abs(this.cameraRotation.y) < this.speed * m && (this.cameraRotation.y = 0),
- this.cameraRotation.scaleInPlace(this.inertia)),
- e.prototype._checkInputs.call(this)
- }
- ,
- t.prototype._updateCameraRotationMatrix = function() {
- this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : P.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix)
- }
- ,
- t.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
- return x.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector),
- this
- }
- ,
- t.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),
- x.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
- this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
- this.updateUpVectorFromRotation && (this.rotationQuaternion ? vn.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (C.FromEulerVectorToRef(this.rotation, this._tmpQuaternion),
- vn.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))),
- this._computeViewMatrix(this.position, this._currentTarget, this.upVector),
- this._viewMatrix
- }
- ,
- t.prototype._computeViewMatrix = function(e, t, i) {
- if (this.ignoreParentScaling) {
- if (this.parent) {
- var n = this.parent.getWorldMatrix();
- x.TransformCoordinatesToRef(e, n, this._globalPosition),
- x.TransformCoordinatesToRef(t, n, this._tmpTargetVector),
- x.TransformNormalToRef(i, n, this._tmpUpVector),
- this._markSyncedWithParent()
- } else
- this._globalPosition.copyFrom(e),
- this._tmpTargetVector.copyFrom(t),
- this._tmpUpVector.copyFrom(i);
- this.getScene().useRightHandedSystem ? P.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : P.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix)
- } else
- this.getScene().useRightHandedSystem ? P.LookAtRHToRef(e, t, i, this._viewMatrix) : P.LookAtLHToRef(e, t, i, this._viewMatrix),
- this.parent ? (n = this.parent.getWorldMatrix(),
- this._viewMatrix.invert(),
- this._viewMatrix.multiplyToRef(n, this._viewMatrix),
- this._viewMatrix.getTranslationToRef(this._globalPosition),
- this._viewMatrix.invert(),
- this._markSyncedWithParent()) : this._globalPosition.copyFrom(e)
- }
- ,
- t.prototype.createRigCamera = function(e, i) {
- if (this.cameraRigMode !== Rr.RIG_MODE_NONE) {
- var n = new t(e,this.position.clone(),this.getScene());
- return n.isRigCamera = !0,
- n.rigParent = this,
- this.cameraRigMode !== Rr.RIG_MODE_VR && this.cameraRigMode !== Rr.RIG_MODE_WEBVR || (this.rotationQuaternion || (this.rotationQuaternion = new C),
- n._cameraRigParams = {},
- n.rotationQuaternion = new C),
- n
- }
- return null
- }
- ,
- t.prototype._updateRigCameras = function() {
- var t = this._rigCameras[0]
- , i = this._rigCameras[1];
- switch (this.computeWorldMatrix(),
- this.cameraRigMode) {
- case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
- case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
- case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
- case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
- case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
- var n = this.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1
- , r = this.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
- this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * n, t),
- this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * r, i);
- break;
- case Rr.RIG_MODE_VR:
- t.rotationQuaternion ? (t.rotationQuaternion.copyFrom(this.rotationQuaternion),
- i.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (t.rotation.copyFrom(this.rotation),
- i.rotation.copyFrom(this.rotation)),
- t.position.copyFrom(this.position),
- i.position.copyFrom(this.position)
- }
- e.prototype._updateRigCameras.call(this)
- }
- ,
- t.prototype._getRigCamPositionAndTarget = function(e, i) {
- this.getTarget().subtractToRef(this.position, t._TargetFocalPoint),
- t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
- var n = t._TargetFocalPoint.addInPlace(this.position);
- P.TranslationToRef(-n.x, -n.y, -n.z, t._TargetTransformMatrix),
- t._TargetTransformMatrix.multiplyToRef(P.RotationAxis(i.upVector, e), t._RigCamTransformMatrix),
- P.TranslationToRef(n.x, n.y, n.z, t._TargetTransformMatrix),
- t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix, t._RigCamTransformMatrix),
- x.TransformCoordinatesToRef(this.position, t._RigCamTransformMatrix, i.position),
- i.setTarget(n)
- }
- ,
- t.prototype.getClassName = function() {
- return "TargetCamera"
- }
- ,
- t._RigCamTransformMatrix = new P,
- t._TargetTransformMatrix = new P,
- t._TargetFocalPoint = new x,
- k([De()], t.prototype, "rotation", void 0),
- k([Ce()], t.prototype, "speed", void 0),
- k([Ne("lockedTargetId")], t.prototype, "lockedTarget", void 0),
- t
- }(Rr)
- , pa = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = !0);
- var o = e.call(this, t, i, n, r) || this;
- return o.ellipsoid = new x(.5,1,.5),
- o.ellipsoidOffset = new x(0,0,0),
- o.checkCollisions = !1,
- o.applyGravity = !1,
- o._needMoveForGravity = !1,
- o._oldPosition = x.Zero(),
- o._diffPosition = x.Zero(),
- o._newPosition = x.Zero(),
- o._collisionMask = -1,
- o._onCollisionPositionChange = function(e, t, i) {
- var n;
- void 0 === i && (i = null),
- n = t,
- o._newPosition.copyFrom(n),
- o._newPosition.subtractToRef(o._oldPosition, o._diffPosition),
- o._diffPosition.length() > vr.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition),
- o.onCollide && i && o.onCollide(i))
- }
- ,
- o.inputs = new aa(o),
- o.inputs.addKeyboard().addMouse(),
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "angularSensibility", {
- get: function() {
- var e = this.inputs.attached.mouse;
- return e ? e.angularSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.mouse;
- t && (t.angularSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysUp", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysUp : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysUp = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysUpward", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysUpward : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysUpward = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysDown", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysDown : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysDown = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysDownward", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysDownward : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysDownward = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysLeft", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysLeft : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysLeft = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysRight", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysRight : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysRight = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysRotateLeft", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysRotateLeft : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysRotateLeft = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysRotateRight", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysRotateRight : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysRotateRight = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.attachControl = function(e, t) {
- t = gi.BackCompatCameraNoPreventDefault(arguments),
- this.inputs.attachElement(t)
- }
- ,
- t.prototype.detachControl = function() {
- this.inputs.detachElement(),
- this.cameraDirection = new x(0,0,0),
- this.cameraRotation = new A(0,0)
- }
- ,
- Object.defineProperty(t.prototype, "collisionMask", {
- get: function() {
- return this._collisionMask
- },
- set: function(e) {
- this._collisionMask = isNaN(e) ? -1 : e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._collideWithWorld = function(e) {
- (this.parent ? x.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
- this._oldPosition.addInPlace(this.ellipsoidOffset);
- var t = this.getScene().collisionCoordinator;
- this._collider || (this._collider = t.createCollider()),
- this._collider._radius = this.ellipsoid,
- this._collider.collisionMask = this._collisionMask;
- var i = e;
- this.applyGravity && (i = e.add(this.getScene().gravity)),
- t.getNewPosition(this._oldPosition, i, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
- }
- ,
- t.prototype._checkInputs = function() {
- this._localDirection || (this._localDirection = x.Zero(),
- this._transformedDirection = x.Zero()),
- this.inputs.checkInputs(),
- e.prototype._checkInputs.call(this)
- }
- ,
- t.prototype._decideIfNeedsToMove = function() {
- return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
- }
- ,
- t.prototype._updatePosition = function() {
- this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : e.prototype._updatePosition.call(this)
- }
- ,
- t.prototype.dispose = function() {
- this.inputs.clear(),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.getClassName = function() {
- return "FreeCamera"
- }
- ,
- k([De()], t.prototype, "ellipsoid", void 0),
- k([De()], t.prototype, "ellipsoidOffset", void 0),
- k([Ce()], t.prototype, "checkCollisions", void 0),
- k([Ce()], t.prototype, "applyGravity", void 0),
- t
- }(da);
- Xe.AddNodeConstructor("TouchCamera", (function(e, t) {
- return function() {
- return new fa(e,x.Zero(),t)
- }
- }
- ));
- var fa = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i, n) || this;
- return r.inputs.addTouch(),
- r._setupInputs(),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "touchAngularSensibility", {
- get: function() {
- var e = this.inputs.attached.touch;
- return e ? e.touchAngularSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.touch;
- t && (t.touchAngularSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "touchMoveSensibility", {
- get: function() {
- var e = this.inputs.attached.touch;
- return e ? e.touchMoveSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.touch;
- t && (t.touchMoveSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "TouchCamera"
- }
- ,
- t.prototype._setupInputs = function() {
- var e = this.inputs.attached.touch
- , t = this.inputs.attached.mouse;
- t ? t.touchEnabled = !1 : e.allowMouse = !0
- }
- ,
- t
- }(pa);
- Xe.AddNodeConstructor("ArcRotateCamera", (function(e, t) {
- return function() {
- return new _a(e,0,0,1,x.Zero(),t)
- }
- }
- ));
- var _a = function(e) {
- function t(t, i, n, r, o, a, s) {
- void 0 === s && (s = !0);
- var l = e.call(this, t, x.Zero(), a, s) || this;
- return l.inertialAlphaOffset = 0,
- l.inertialBetaOffset = 0,
- l.inertialRadiusOffset = 0,
- l.lowerAlphaLimit = null,
- l.upperAlphaLimit = null,
- l.lowerBetaLimit = .01,
- l.upperBetaLimit = Math.PI - .01,
- l.lowerRadiusLimit = null,
- l.upperRadiusLimit = null,
- l.inertialPanningX = 0,
- l.inertialPanningY = 0,
- l.pinchToPanMaxDistance = 20,
- l.panningDistanceLimit = null,
- l.panningOriginTarget = x.Zero(),
- l.panningInertia = .9,
- l.zoomOnFactor = 1,
- l.targetScreenOffset = A.Zero(),
- l.allowUpsideDown = !0,
- l.useInputToRestoreState = !0,
- l._viewMatrix = new P,
- l.panningAxis = new x(1,1,0),
- l._transformedDirection = new x,
- l.mapPanning = !1,
- l.onMeshTargetChangedObservable = new h,
- l.checkCollisions = !1,
- l.collisionRadius = new x(.5,.5,.5),
- l._previousPosition = x.Zero(),
- l._collisionVelocity = x.Zero(),
- l._newPosition = x.Zero(),
- l._computationVector = x.Zero(),
- l._onCollisionPositionChange = function(e, t, i) {
- void 0 === i && (i = null),
- i ? (l.setPosition(t),
- l.onCollide && l.onCollide(i)) : l._previousPosition.copyFrom(l._position);
- var n = Math.cos(l.alpha)
- , r = Math.sin(l.alpha)
- , o = Math.cos(l.beta)
- , a = Math.sin(l.beta);
- 0 === a && (a = 1e-4);
- var s = l._getTargetPosition();
- l._computationVector.copyFromFloats(l.radius * n * a, l.radius * o, l.radius * r * a),
- s.addToRef(l._computationVector, l._newPosition),
- l._position.copyFrom(l._newPosition);
- var c = l.upVector;
- l.allowUpsideDown && l.beta < 0 && (c = (c = c.clone()).negate()),
- l._computeViewMatrix(l._position, s, c),
- l._viewMatrix.addAtIndex(12, l.targetScreenOffset.x),
- l._viewMatrix.addAtIndex(13, l.targetScreenOffset.y),
- l._collisionTriggered = !1
- }
- ,
- l._target = x.Zero(),
- o && l.setTarget(o),
- l.alpha = i,
- l.beta = n,
- l.radius = r,
- l.getViewMatrix(),
- l.inputs = new Ko(l),
- l.inputs.addKeyboard().addMouseWheel().addPointers(),
- l
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- return this._target
- },
- set: function(e) {
- this.setTarget(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "targetHost", {
- get: function() {
- return this._targetHost
- },
- set: function(e) {
- e && this.setTarget(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getTarget = function() {
- return this.target
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(e) {
- this.setPosition(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "upVector", {
- get: function() {
- return this._upVector
- },
- set: function(e) {
- this._upToYMatrix || (this._yToUpMatrix = new P,
- this._upToYMatrix = new P,
- this._upVector = x.Zero()),
- e.normalize(),
- this._upVector.copyFrom(e),
- this.setMatUp()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setMatUp = function() {
- P.RotationAlignToRef(x.UpReadOnly, this._upVector, this._yToUpMatrix),
- P.RotationAlignToRef(this._upVector, x.UpReadOnly, this._upToYMatrix)
- }
- ,
- Object.defineProperty(t.prototype, "angularSensibilityX", {
- get: function() {
- var e = this.inputs.attached.pointers;
- return e ? e.angularSensibilityX : 0
- },
- set: function(e) {
- var t = this.inputs.attached.pointers;
- t && (t.angularSensibilityX = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "angularSensibilityY", {
- get: function() {
- var e = this.inputs.attached.pointers;
- return e ? e.angularSensibilityY : 0
- },
- set: function(e) {
- var t = this.inputs.attached.pointers;
- t && (t.angularSensibilityY = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "pinchPrecision", {
- get: function() {
- var e = this.inputs.attached.pointers;
- return e ? e.pinchPrecision : 0
- },
- set: function(e) {
- var t = this.inputs.attached.pointers;
- t && (t.pinchPrecision = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "pinchDeltaPercentage", {
- get: function() {
- var e = this.inputs.attached.pointers;
- return e ? e.pinchDeltaPercentage : 0
- },
- set: function(e) {
- var t = this.inputs.attached.pointers;
- t && (t.pinchDeltaPercentage = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useNaturalPinchZoom", {
- get: function() {
- var e = this.inputs.attached.pointers;
- return !!e && e.useNaturalPinchZoom
- },
- set: function(e) {
- var t = this.inputs.attached.pointers;
- t && (t.useNaturalPinchZoom = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "panningSensibility", {
- get: function() {
- var e = this.inputs.attached.pointers;
- return e ? e.panningSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.pointers;
- t && (t.panningSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysUp", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysUp : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysUp = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysDown", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysDown : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysDown = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysLeft", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysLeft : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysLeft = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysRight", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysRight : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysRight = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelPrecision", {
- get: function() {
- var e = this.inputs.attached.mousewheel;
- return e ? e.wheelPrecision : 0
- },
- set: function(e) {
- var t = this.inputs.attached.mousewheel;
- t && (t.wheelPrecision = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "zoomToMouseLocation", {
- get: function() {
- var e = this.inputs.attached.mousewheel;
- return !!e && e.zoomToMouseLocation
- },
- set: function(e) {
- var t = this.inputs.attached.mousewheel;
- t && (t.zoomToMouseLocation = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wheelDeltaPercentage", {
- get: function() {
- var e = this.inputs.attached.mousewheel;
- return e ? e.wheelDeltaPercentage : 0
- },
- set: function(e) {
- var t = this.inputs.attached.mousewheel;
- t && (t.wheelDeltaPercentage = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bouncingBehavior", {
- get: function() {
- return this._bouncingBehavior
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useBouncingBehavior", {
- get: function() {
- return null != this._bouncingBehavior
- },
- set: function(e) {
- e !== this.useBouncingBehavior && (e ? (this._bouncingBehavior = new co,
- this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior),
- this._bouncingBehavior = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "framingBehavior", {
- get: function() {
- return this._framingBehavior
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useFramingBehavior", {
- get: function() {
- return null != this._framingBehavior
- },
- set: function(e) {
- e !== this.useFramingBehavior && (e ? (this._framingBehavior = new uo,
- this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior),
- this._framingBehavior = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "autoRotationBehavior", {
- get: function() {
- return this._autoRotationBehavior
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useAutoRotationBehavior", {
- get: function() {
- return null != this._autoRotationBehavior
- },
- set: function(e) {
- e !== this.useAutoRotationBehavior && (e ? (this._autoRotationBehavior = new lo,
- this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior),
- this._autoRotationBehavior = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._initCache = function() {
- e.prototype._initCache.call(this),
- this._cache._target = new x(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 = A.Zero()
- }
- ,
- t.prototype._updateCache = function(t) {
- t || e.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)
- }
- ,
- t.prototype._getTargetPosition = function() {
- if (this._targetHost && this._targetHost.getAbsolutePosition) {
- var e = this._targetHost.getAbsolutePosition();
- this._targetBoundingCenter ? e.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(e)
- }
- return this._getLockedTargetPosition() || this._target
- }
- ,
- t.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(),
- e.prototype.storeState.call(this)
- }
- ,
- t.prototype._restoreStateValues = function() {
- return !!e.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)
- }
- ,
- t.prototype._isSynchronizedViewMatrix = function() {
- return !!e.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)
- }
- ,
- t.prototype.attachControl = function(e, t, i, n) {
- var r = this;
- void 0 === i && (i = !0),
- void 0 === n && (n = 2);
- var o = arguments;
- t = gi.BackCompatCameraNoPreventDefault(o),
- this._useCtrlForPanning = i,
- this._panningMouseButton = n,
- "boolean" == typeof o[0] && (o.length > 1 && (this._useCtrlForPanning = o[1]),
- o.length > 2 && (this._panningMouseButton = o[2])),
- this.inputs.attachElement(t),
- this._reset = function() {
- r.inertialAlphaOffset = 0,
- r.inertialBetaOffset = 0,
- r.inertialRadiusOffset = 0,
- r.inertialPanningX = 0,
- r.inertialPanningY = 0
- }
- }
- ,
- t.prototype.detachControl = function() {
- this.inputs.detachElement(),
- this._reset && this._reset()
- }
- ,
- t.prototype._checkInputs = function() {
- if (!this._collisionTriggered) {
- if (this.inputs.checkInputs(),
- 0 !== this.inertialAlphaOffset || 0 !== this.inertialBetaOffset || 0 !== this.inertialRadiusOffset) {
- var t = this.inertialAlphaOffset;
- this.beta <= 0 && (t *= -1),
- this.getScene().useRightHandedSystem && (t *= -1),
- this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (t *= -1),
- this.alpha += t,
- this.beta += this.inertialBetaOffset,
- this.radius -= this.inertialRadiusOffset,
- this.inertialAlphaOffset *= this.inertia,
- this.inertialBetaOffset *= this.inertia,
- this.inertialRadiusOffset *= this.inertia,
- Math.abs(this.inertialAlphaOffset) < m && (this.inertialAlphaOffset = 0),
- Math.abs(this.inertialBetaOffset) < m && (this.inertialBetaOffset = 0),
- Math.abs(this.inertialRadiusOffset) < this.speed * m && (this.inertialRadiusOffset = 0)
- }
- if (0 !== this.inertialPanningX || 0 !== this.inertialPanningY) {
- var i = new x(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);
- this._viewMatrix.invertToRef(this._cameraTransformMatrix),
- i.multiplyInPlace(this.panningAxis),
- x.TransformNormalToRef(i, this._cameraTransformMatrix, this._transformedDirection),
- !this.mapPanning && this.panningAxis.y || (this._transformedDirection.y = 0),
- this._targetHost || (this.panningDistanceLimit ? (this._transformedDirection.addInPlace(this._target),
- x.DistanceSquared(this._transformedDirection, this.panningOriginTarget) <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)) : this._target.addInPlace(this._transformedDirection)),
- this.inertialPanningX *= this.panningInertia,
- this.inertialPanningY *= this.panningInertia,
- Math.abs(this.inertialPanningX) < this.speed * m && (this.inertialPanningX = 0),
- Math.abs(this.inertialPanningY) < this.speed * m && (this.inertialPanningY = 0)
- }
- this._checkLimits(),
- e.prototype._checkInputs.call(this)
- }
- }
- ,
- t.prototype._checkLimits = function() {
- null === this.lowerBetaLimit || void 0 === this.lowerBetaLimit ? this.allowUpsideDown && this.beta > Math.PI && (this.beta = this.beta - 2 * Math.PI) : this.beta < this.lowerBetaLimit && (this.beta = this.lowerBetaLimit),
- null === this.upperBetaLimit || void 0 === this.upperBetaLimit ? this.allowUpsideDown && this.beta < -Math.PI && (this.beta = this.beta + 2 * Math.PI) : this.beta > this.upperBetaLimit && (this.beta = this.upperBetaLimit),
- null !== this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit),
- null !== this.upperAlphaLimit && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit),
- null !== this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit,
- this.inertialRadiusOffset = 0),
- null !== this.upperRadiusLimit && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit,
- this.inertialRadiusOffset = 0)
- }
- ,
- t.prototype.rebuildAnglesAndRadius = function() {
- this._position.subtractToRef(this._getTargetPosition(), this._computationVector),
- 0 === this._upVector.x && 1 === this._upVector.y && 0 === this._upVector.z || x.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector),
- this.radius = this._computationVector.length(),
- 0 === this.radius && (this.radius = 1e-4);
- var e = this.alpha;
- 0 === this._computationVector.x && 0 === this._computationVector.z ? 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 t = Math.round((e - this.alpha) / (2 * Math.PI));
- this.alpha += 2 * t * Math.PI,
- this.beta = Math.acos(this._computationVector.y / this.radius),
- this._checkLimits()
- }
- ,
- t.prototype.setPosition = function(e) {
- this._position.equals(e) || (this._position.copyFrom(e),
- this.rebuildAnglesAndRadius())
- }
- ,
- t.prototype.setTarget = function(e, t, i, n) {
- if (void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- void 0 === n && (n = !1),
- e.getBoundingInfo)
- this._targetBoundingCenter = t ? e.getBoundingInfo().boundingBox.centerWorld.clone() : null,
- e.computeWorldMatrix(),
- this._targetHost = e,
- this._target = this._getTargetPosition(),
- this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
- else {
- var r = e
- , o = this._getTargetPosition();
- if (o && !i && o.equals(r))
- return;
- this._targetHost = null,
- this._target = r,
- this._targetBoundingCenter = null,
- this.onMeshTargetChangedObservable.notifyObservers(null)
- }
- n || this.rebuildAnglesAndRadius()
- }
- ,
- t.prototype._getViewMatrix = function() {
- var e = Math.cos(this.alpha)
- , t = Math.sin(this.alpha)
- , i = Math.cos(this.beta)
- , n = Math.sin(this.beta);
- 0 === n && (n = 1e-4),
- 0 === this.radius && (this.radius = 1e-4);
- var r = this._getTargetPosition();
- if (this._computationVector.copyFromFloats(this.radius * e * n, this.radius * i, this.radius * t * n),
- 0 === this._upVector.x && 1 === this._upVector.y && 0 === this._upVector.z || x.TransformCoordinatesToRef(this._computationVector, this._yToUpMatrix, this._computationVector),
- r.addToRef(this._computationVector, this._newPosition),
- this.getScene().collisionsEnabled && this.checkCollisions) {
- var o = this.getScene().collisionCoordinator;
- this._collider || (this._collider = o.createCollider()),
- this._collider._radius = this.collisionRadius,
- this._newPosition.subtractToRef(this._position, this._collisionVelocity),
- this._collisionTriggered = !0,
- o.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
- } else {
- this._position.copyFrom(this._newPosition);
- var a = this.upVector;
- this.allowUpsideDown && n < 0 && (a = a.negate()),
- this._computeViewMatrix(this._position, r, a),
- this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x),
- this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y)
- }
- return this._currentTarget = r,
- this._viewMatrix
- }
- ,
- t.prototype.zoomOn = function(e, t) {
- void 0 === t && (t = !1),
- e = e || this.getScene().meshes;
- var i = Vr.MinMax(e)
- , n = x.Distance(i.min, i.max);
- this.radius = n * this.zoomOnFactor,
- this.focusOn({
- min: i.min,
- max: i.max,
- distance: n
- }, t)
- }
- ,
- t.prototype.focusOn = function(e, t) {
- var i, n;
- if (void 0 === t && (t = !1),
- void 0 === e.min) {
- var r = e || this.getScene().meshes;
- i = Vr.MinMax(r),
- n = x.Distance(i.min, i.max)
- } else
- i = e,
- n = e.distance;
- this._target = Vr.Center(i),
- t || (this.maxZ = 2 * n)
- }
- ,
- t.prototype.createRigCamera = function(e, i) {
- var n = 0;
- switch (this.cameraRigMode) {
- case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
- case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
- case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
- case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
- case Rr.RIG_MODE_VR:
- n = this._cameraRigParams.stereoHalfAngle * (0 === i ? 1 : -1);
- break;
- case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
- n = this._cameraRigParams.stereoHalfAngle * (0 === i ? -1 : 1)
- }
- var r = new t(e,this.alpha + n,this.beta,this.radius,this._target,this.getScene());
- return r._cameraRigParams = {},
- r.isRigCamera = !0,
- r.rigParent = this,
- r.upVector = this.upVector,
- r
- }
- ,
- t.prototype._updateRigCameras = function() {
- var t = this._rigCameras[0]
- , i = this._rigCameras[1];
- switch (t.beta = i.beta = this.beta,
- this.cameraRigMode) {
- case Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
- case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
- case Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER:
- case Rr.RIG_MODE_STEREOSCOPIC_INTERLACED:
- case Rr.RIG_MODE_VR:
- t.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle,
- i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
- break;
- case Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
- t.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle,
- i.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle
- }
- e.prototype._updateRigCameras.call(this)
- }
- ,
- t.prototype.dispose = function() {
- this.inputs.clear(),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.getClassName = function() {
- return "ArcRotateCamera"
- }
- ,
- k([Ce()], t.prototype, "alpha", void 0),
- k([Ce()], t.prototype, "beta", void 0),
- k([Ce()], t.prototype, "radius", void 0),
- k([De("target")], t.prototype, "_target", void 0),
- k([Ne("targetHost")], t.prototype, "_targetHost", void 0),
- k([Ce()], t.prototype, "inertialAlphaOffset", void 0),
- k([Ce()], t.prototype, "inertialBetaOffset", void 0),
- k([Ce()], t.prototype, "inertialRadiusOffset", void 0),
- k([Ce()], t.prototype, "lowerAlphaLimit", void 0),
- k([Ce()], t.prototype, "upperAlphaLimit", void 0),
- k([Ce()], t.prototype, "lowerBetaLimit", void 0),
- k([Ce()], t.prototype, "upperBetaLimit", void 0),
- k([Ce()], t.prototype, "lowerRadiusLimit", void 0),
- k([Ce()], t.prototype, "upperRadiusLimit", void 0),
- k([Ce()], t.prototype, "inertialPanningX", void 0),
- k([Ce()], t.prototype, "inertialPanningY", void 0),
- k([Ce()], t.prototype, "pinchToPanMaxDistance", void 0),
- k([Ce()], t.prototype, "panningDistanceLimit", void 0),
- k([De()], t.prototype, "panningOriginTarget", void 0),
- k([Ce()], t.prototype, "panningInertia", void 0),
- k([Ce()], t.prototype, "zoomToMouseLocation", null),
- k([Ce()], t.prototype, "zoomOnFactor", void 0),
- k([Oe()], t.prototype, "targetScreenOffset", void 0),
- k([Ce()], t.prototype, "allowUpsideDown", void 0),
- k([Ce()], t.prototype, "useInputToRestoreState", void 0),
- t
- }(da);
- Xe.AddNodeConstructor("DeviceOrientationCamera", (function(e, t) {
- return function() {
- return new ma(e,x.Zero(),t)
- }
- }
- ));
- var ma = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i, n) || this;
- return r._tmpDragQuaternion = new C,
- r._disablePointerInputWhenUsingDeviceOrientation = !0,
- r._dragFactor = 0,
- r._quaternionCache = new C,
- r.inputs.addDeviceOrientation(),
- r.inputs._deviceOrientationInput && r.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function() {
- r._disablePointerInputWhenUsingDeviceOrientation && r.inputs._mouseInput && (r.inputs._mouseInput._allowCameraRotation = !1,
- r.inputs._mouseInput.onPointerMovedObservable.add((function(e) {
- 0 != r._dragFactor && (r._initialQuaternion || (r._initialQuaternion = new C),
- C.FromEulerAnglesToRef(0, e.offsetX * r._dragFactor, 0, r._tmpDragQuaternion),
- r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion, r._initialQuaternion))
- }
- )))
- }
- )),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "disablePointerInputWhenUsingDeviceOrientation", {
- get: function() {
- return this._disablePointerInputWhenUsingDeviceOrientation
- },
- set: function(e) {
- this._disablePointerInputWhenUsingDeviceOrientation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.enableHorizontalDragging = function(e) {
- void 0 === e && (e = 1 / 300),
- this._dragFactor = e
- }
- ,
- t.prototype.getClassName = function() {
- return "DeviceOrientationCamera"
- }
- ,
- t.prototype._checkInputs = function() {
- e.prototype._checkInputs.call(this),
- this._quaternionCache.copyFrom(this.rotationQuaternion),
- this._initialQuaternion && this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
- }
- ,
- t.prototype.resetToCurrentRotation = function(e) {
- var t = this;
- void 0 === e && (e = vn.Y),
- this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new C),
- this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion),
- ["x", "y", "z"].forEach((function(i) {
- e[i] ? t._initialQuaternion[i] *= -1 : t._initialQuaternion[i] = 0
- }
- )),
- this._initialQuaternion.normalize(),
- this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion))
- }
- ,
- t
- }(pa)
- , ga = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- t.prototype.addKeyboard = function() {
- return this.add(new qo),
- this
- }
- ,
- t.prototype.addMouse = function() {
- return this.add(new Zo),
- this
- }
- ,
- t
- }(ko)
- , va = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = !0);
- var o = e.call(this, t, i, n, r) || this;
- return o.ellipsoid = new x(1,1,1),
- o.ellipsoidOffset = new x(0,0,0),
- o.checkCollisions = !1,
- o.applyGravity = !1,
- o.cameraDirection = x.Zero(),
- o._trackRoll = 0,
- o.rollCorrect = 100,
- o.bankedTurn = !1,
- o.bankedTurnLimit = Math.PI / 2,
- o.bankedTurnMultiplier = 1,
- o._needMoveForGravity = !1,
- o._oldPosition = x.Zero(),
- o._diffPosition = x.Zero(),
- o._newPosition = x.Zero(),
- o._collisionMask = -1,
- o._onCollisionPositionChange = function(e, t, i) {
- var n;
- void 0 === i && (i = null),
- n = t,
- o._newPosition.copyFrom(n),
- o._newPosition.subtractToRef(o._oldPosition, o._diffPosition),
- o._diffPosition.length() > vr.CollisionsEpsilon && (o.position.addInPlace(o._diffPosition),
- o.onCollide && i && o.onCollide(i))
- }
- ,
- o.inputs = new ga(o),
- o.inputs.addKeyboard().addMouse(),
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "angularSensibility", {
- get: function() {
- var e = this.inputs.attached.mouse;
- return e ? e.angularSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.mouse;
- t && (t.angularSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysForward", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysForward : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysForward = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysBackward", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysBackward : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysBackward = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysUp", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysUp : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysUp = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysDown", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysDown : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysDown = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysLeft", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysLeft : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysLeft = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "keysRight", {
- get: function() {
- var e = this.inputs.attached.keyboard;
- return e ? e.keysRight : []
- },
- set: function(e) {
- var t = this.inputs.attached.keyboard;
- t && (t.keysRight = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.attachControl = function(e, t) {
- t = gi.BackCompatCameraNoPreventDefault(arguments),
- this.inputs.attachElement(t)
- }
- ,
- t.prototype.detachControl = function() {
- this.inputs.detachElement(),
- this.cameraDirection = new x(0,0,0)
- }
- ,
- Object.defineProperty(t.prototype, "collisionMask", {
- get: function() {
- return this._collisionMask
- },
- set: function(e) {
- this._collisionMask = isNaN(e) ? -1 : e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._collideWithWorld = function(e) {
- (this.parent ? x.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : this.position).subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
- this._oldPosition.addInPlace(this.ellipsoidOffset);
- var t = this.getScene().collisionCoordinator;
- this._collider || (this._collider = t.createCollider()),
- this._collider._radius = this.ellipsoid,
- this._collider.collisionMask = this._collisionMask;
- var i = e;
- this.applyGravity && (i = e.add(this.getScene().gravity)),
- t.getNewPosition(this._oldPosition, i, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
- }
- ,
- t.prototype._checkInputs = function() {
- this._localDirection || (this._localDirection = x.Zero(),
- this._transformedDirection = x.Zero()),
- this.inputs.checkInputs(),
- e.prototype._checkInputs.call(this)
- }
- ,
- t.prototype._decideIfNeedsToMove = function() {
- return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
- }
- ,
- t.prototype._updatePosition = function() {
- this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : e.prototype._updatePosition.call(this)
- }
- ,
- t.prototype.restoreRoll = function(e) {
- var t = this._trackRoll
- , i = t - this.rotation.z;
- Math.abs(i) >= .001 && (this.rotation.z += i / e,
- Math.abs(t - this.rotation.z) <= .001 && (this.rotation.z = t))
- }
- ,
- t.prototype.dispose = function() {
- this.inputs.clear(),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.getClassName = function() {
- return "FlyCamera"
- }
- ,
- k([De()], t.prototype, "ellipsoid", void 0),
- k([De()], t.prototype, "ellipsoidOffset", void 0),
- k([Ce()], t.prototype, "checkCollisions", void 0),
- k([Ce()], t.prototype, "applyGravity", void 0),
- t
- }(da)
- , ya = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- t.prototype.addKeyboard = function() {
- return this.add(new Jo),
- this
- }
- ,
- t.prototype.addMouseWheel = function() {
- return this.add(new $o),
- this
- }
- ,
- t.prototype.addPointers = function() {
- return this.add(new ea),
- this
- }
- ,
- t.prototype.addVRDeviceOrientation = function() {
- return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),
- this
- }
- ,
- t
- }(ko);
- Xe.AddNodeConstructor("FollowCamera", (function(e, t) {
- return function() {
- return new Ta(e,x.Zero(),t)
- }
- }
- )),
- Xe.AddNodeConstructor("ArcFollowCamera", (function(e, t) {
- return function() {
- return new Ea(e,0,0,1,null,t)
- }
- }
- ));
- var ba, Ta = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = null);
- var o = e.call(this, t, i, n) || this;
- return o.radius = 12,
- o.lowerRadiusLimit = null,
- o.upperRadiusLimit = null,
- o.rotationOffset = 0,
- o.lowerRotationOffsetLimit = null,
- o.upperRotationOffsetLimit = null,
- o.heightOffset = 4,
- o.lowerHeightOffsetLimit = null,
- o.upperHeightOffsetLimit = null,
- o.cameraAcceleration = .05,
- o.maxCameraSpeed = 20,
- o.lockedTarget = r,
- o.inputs = new ya(o),
- o.inputs.addKeyboard().addMouseWheel().addPointers(),
- o
- }
- return U(t, e),
- t.prototype._follow = function(e) {
- if (e) {
- var t = I.Matrix[0];
- e.absoluteRotationQuaternion.toRotationMatrix(t);
- var i = Math.atan2(t.m[8], t.m[10])
- , n = gi.ToRadians(this.rotationOffset) + i
- , r = e.getAbsolutePosition()
- , o = r.x + Math.sin(n) * this.radius
- , a = r.z + Math.cos(n) * this.radius
- , s = o - this.position.x
- , l = r.y + this.heightOffset - this.position.y
- , c = a - this.position.z
- , u = s * this.cameraAcceleration * 2
- , h = l * this.cameraAcceleration
- , d = c * this.cameraAcceleration * 2;
- (u > this.maxCameraSpeed || u < -this.maxCameraSpeed) && (u = u < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed),
- (h > this.maxCameraSpeed || h < -this.maxCameraSpeed) && (h = h < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed),
- (d > this.maxCameraSpeed || d < -this.maxCameraSpeed) && (d = d < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed),
- this.position = new x(this.position.x + u,this.position.y + h,this.position.z + d),
- this.setTarget(r)
- }
- }
- ,
- t.prototype.attachControl = function(e, t) {
- t = gi.BackCompatCameraNoPreventDefault(arguments),
- this.inputs.attachElement(t),
- this._reset = function() {}
- }
- ,
- t.prototype.detachControl = function() {
- this.inputs.detachElement(),
- this._reset && this._reset()
- }
- ,
- t.prototype._checkInputs = function() {
- this.inputs.checkInputs(),
- this._checkLimits(),
- e.prototype._checkInputs.call(this),
- this.lockedTarget && this._follow(this.lockedTarget)
- }
- ,
- t.prototype._checkLimits = function() {
- null !== this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit),
- null !== this.upperRadiusLimit && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit),
- null !== this.lowerHeightOffsetLimit && this.heightOffset < this.lowerHeightOffsetLimit && (this.heightOffset = this.lowerHeightOffsetLimit),
- null !== this.upperHeightOffsetLimit && this.heightOffset > this.upperHeightOffsetLimit && (this.heightOffset = this.upperHeightOffsetLimit),
- null !== this.lowerRotationOffsetLimit && this.rotationOffset < this.lowerRotationOffsetLimit && (this.rotationOffset = this.lowerRotationOffsetLimit),
- null !== this.upperRotationOffsetLimit && this.rotationOffset > this.upperRotationOffsetLimit && (this.rotationOffset = this.upperRotationOffsetLimit)
- }
- ,
- t.prototype.getClassName = function() {
- return "FollowCamera"
- }
- ,
- k([Ce()], t.prototype, "radius", void 0),
- k([Ce()], t.prototype, "lowerRadiusLimit", void 0),
- k([Ce()], t.prototype, "upperRadiusLimit", void 0),
- k([Ce()], t.prototype, "rotationOffset", void 0),
- k([Ce()], t.prototype, "lowerRotationOffsetLimit", void 0),
- k([Ce()], t.prototype, "upperRotationOffsetLimit", void 0),
- k([Ce()], t.prototype, "heightOffset", void 0),
- k([Ce()], t.prototype, "lowerHeightOffsetLimit", void 0),
- k([Ce()], t.prototype, "upperHeightOffsetLimit", void 0),
- k([Ce()], t.prototype, "cameraAcceleration", void 0),
- k([Ce()], t.prototype, "maxCameraSpeed", void 0),
- k([Ne("lockedTargetId")], t.prototype, "lockedTarget", void 0),
- t
- }(da), Ea = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, x.Zero(), a) || this;
- return s.alpha = i,
- s.beta = n,
- s.radius = r,
- s._cartesianCoordinates = x.Zero(),
- s.setMeshTarget(o),
- s
- }
- return U(t, e),
- t.prototype.setMeshTarget = function(e) {
- this._meshTarget = e,
- this._follow()
- }
- ,
- t.prototype._follow = function() {
- if (this._meshTarget) {
- this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta),
- this._cartesianCoordinates.y = this.radius * Math.sin(this.beta),
- this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
- var e = this._meshTarget.getAbsolutePosition();
- this.position = e.add(this._cartesianCoordinates),
- this.setTarget(e)
- }
- }
- ,
- t.prototype._checkInputs = function() {
- e.prototype._checkInputs.call(this),
- this._follow()
- }
- ,
- t.prototype.getClassName = function() {
- return "ArcFollowCamera"
- }
- ,
- t
- }(da);
- !function(e) {
- e[e.VIVE = 0] = "VIVE",
- e[e.OCULUS = 1] = "OCULUS",
- e[e.WINDOWS = 2] = "WINDOWS",
- e[e.GEAR_VR = 3] = "GEAR_VR",
- e[e.DAYDREAM = 4] = "DAYDREAM",
- e[e.GENERIC = 5] = "GENERIC"
- }(ba || (ba = {}));
- var Sa, Aa, xa = function() {
- function e() {}
- return e.InitiateController = function(e) {
- for (var t = 0, i = this._ControllerFactories; t < i.length; t++) {
- var n = i[t];
- if (n.canCreate(e))
- return n.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."
- }
- ,
- e._ControllerFactories = [],
- e._DefaultControllerFactory = null,
- e
- }(), Ra = function(e) {
- function t(t) {
- var i = e.call(this, t.id, t.index, t) || this;
- return i.isXR = !1,
- i._deviceRoomPosition = x.Zero(),
- i._deviceRoomRotationQuaternion = new C,
- i.devicePosition = x.Zero(),
- i.deviceRotationQuaternion = new C,
- i.deviceScaleFactor = 1,
- i._trackPosition = !0,
- i._maxRotationDistFromHeadset = Math.PI / 5,
- i._draggedRoomRotation = 0,
- i._leftHandSystemQuaternion = new C,
- i._deviceToWorld = P.Identity(),
- i._pointingPoseNode = null,
- i._workingMatrix = P.Identity(),
- i._meshAttachedObservable = new h,
- i.type = zo.POSE_ENABLED,
- i.controllerType = ba.GENERIC,
- i.position = x.Zero(),
- i.rotationQuaternion = new C,
- i._calculatedPosition = x.Zero(),
- i._calculatedRotation = new C,
- C.RotationYawPitchRollToRef(Math.PI, 0, 0, i._leftHandSystemQuaternion),
- i
- }
- return U(t, e),
- t.prototype._disableTrackPosition = function(e) {
- this._trackPosition && (this._calculatedPosition.copyFrom(e),
- this._trackPosition = !1)
- }
- ,
- t.prototype.update = function() {
- e.prototype.update.call(this),
- this._updatePoseAndMesh()
- }
- ,
- t.prototype._updatePoseAndMesh = function() {
- if (!this.isXR) {
- var e = this.browserGamepad.pose;
- if (this.updateFromDevice(e),
- !this._trackPosition && E.LastCreatedScene && E.LastCreatedScene.activeCamera && E.LastCreatedScene.activeCamera.devicePosition) {
- var t = E.LastCreatedScene.activeCamera;
- if (t._computeDevicePosition(),
- this._deviceToWorld.setTranslation(t.devicePosition),
- t.deviceRotationQuaternion) {
- t._deviceRoomRotationQuaternion.toEulerAnglesToRef(I.Vector3[0]);
- var i = Math.atan2(Math.sin(I.Vector3[0].y - this._draggedRoomRotation), Math.cos(I.Vector3[0].y - this._draggedRoomRotation));
- if (Math.abs(i) > this._maxRotationDistFromHeadset) {
- var n = i - (i < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
- this._draggedRoomRotation += n;
- var r = Math.sin(-n)
- , o = Math.cos(-n);
- this._calculatedPosition.x = this._calculatedPosition.x * o - this._calculatedPosition.z * r,
- this._calculatedPosition.z = this._calculatedPosition.x * r + this._calculatedPosition.z * o
- }
- }
- }
- x.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition),
- this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),
- C.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))
- }
- }
- ,
- t.prototype.updateFromDevice = function(e) {
- if (!this.isXR && e) {
- this.rawPose = e,
- e.position && (this._deviceRoomPosition.copyFromFloats(e.position[0], e.position[1], -e.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 t = this.rawPose;
- e.orientation && t.orientation && 4 === t.orientation.length && (this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0], t.orientation[1], -t.orientation[2], -t.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))
- }
- }
- ,
- t.prototype.attachToMesh = function(e) {
- if (this._mesh && (this._mesh.parent = null),
- this._mesh = e,
- this._poseControlledCamera && (this._mesh.parent = this._poseControlledCamera),
- this._mesh.rotationQuaternion || (this._mesh.rotationQuaternion = new C),
- !this.isXR && (this._updatePoseAndMesh(),
- this._pointingPoseNode)) {
- for (var t = [], i = this._pointingPoseNode; i.parent; )
- t.push(i.parent),
- i = i.parent;
- t.reverse().forEach((function(e) {
- e.computeWorldMatrix(!0)
- }
- ))
- }
- this._meshAttachedObservable.notifyObservers(e)
- }
- ,
- t.prototype.attachToPoseControlledCamera = function(e) {
- this._poseControlledCamera = e,
- this._mesh && (this._mesh.parent = this._poseControlledCamera)
- }
- ,
- t.prototype.dispose = function() {
- this._mesh && this._mesh.dispose(),
- this._mesh = null,
- e.prototype.dispose.call(this)
- }
- ,
- Object.defineProperty(t.prototype, "mesh", {
- get: function() {
- return this._mesh
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getForwardRay = function(e) {
- if (void 0 === e && (e = 100),
- !this.mesh)
- return new _o(x.Zero(),new x(0,0,1),e);
- var t = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix()
- , i = t.getTranslation()
- , n = new x(0,0,-1)
- , r = x.TransformNormal(n, t)
- , o = x.Normalize(r);
- return new _o(i,o,e)
- }
- ,
- t.POINTING_POSE = "POINTING_POSE",
- t
- }(zo);
- !function(e) {
- e[e.A = 0] = "A",
- e[e.B = 1] = "B",
- e[e.X = 2] = "X",
- e[e.Y = 3] = "Y",
- e[e.LB = 4] = "LB",
- e[e.RB = 5] = "RB",
- e[e.Back = 8] = "Back",
- e[e.Start = 9] = "Start",
- e[e.LeftStick = 10] = "LeftStick",
- e[e.RightStick = 11] = "RightStick"
- }(Sa || (Sa = {})),
- function(e) {
- e[e.Up = 12] = "Up",
- e[e.Down = 13] = "Down",
- e[e.Left = 14] = "Left",
- e[e.Right = 15] = "Right"
- }(Aa || (Aa = {}));
- var Ca, Pa, Ma = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = !1);
- var o = e.call(this, t, i, n, 0, 1, 2, 3) || this;
- return o._leftTrigger = 0,
- o._rightTrigger = 0,
- o.onButtonDownObservable = new h,
- o.onButtonUpObservable = new h,
- o.onPadDownObservable = new h,
- o.onPadUpObservable = new h,
- o._buttonA = 0,
- o._buttonB = 0,
- o._buttonX = 0,
- o._buttonY = 0,
- o._buttonBack = 0,
- o._buttonStart = 0,
- o._buttonLB = 0,
- o._buttonRB = 0,
- o._buttonLeftStick = 0,
- o._buttonRightStick = 0,
- o._dPadUp = 0,
- o._dPadDown = 0,
- o._dPadLeft = 0,
- o._dPadRight = 0,
- o._isXboxOnePad = !1,
- o.type = zo.XBOX,
- o._isXboxOnePad = r,
- o
- }
- return U(t, e),
- t.prototype.onlefttriggerchanged = function(e) {
- this._onlefttriggerchanged = e
- }
- ,
- t.prototype.onrighttriggerchanged = function(e) {
- this._onrighttriggerchanged = e
- }
- ,
- Object.defineProperty(t.prototype, "leftTrigger", {
- get: function() {
- return this._leftTrigger
- },
- set: function(e) {
- this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e),
- this._leftTrigger = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rightTrigger", {
- get: function() {
- return this._rightTrigger
- },
- set: function(e) {
- this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e),
- this._rightTrigger = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.onbuttondown = function(e) {
- this._onbuttondown = e
- }
- ,
- t.prototype.onbuttonup = function(e) {
- this._onbuttonup = e
- }
- ,
- t.prototype.ondpaddown = function(e) {
- this._ondpaddown = e
- }
- ,
- t.prototype.ondpadup = function(e) {
- this._ondpadup = e
- }
- ,
- t.prototype._setButtonValue = function(e, t, i) {
- return e !== t && (1 === e && (this._onbuttondown && this._onbuttondown(i),
- this.onButtonDownObservable.notifyObservers(i)),
- 0 === e && (this._onbuttonup && this._onbuttonup(i),
- this.onButtonUpObservable.notifyObservers(i))),
- e
- }
- ,
- t.prototype._setDPadValue = function(e, t, i) {
- return e !== t && (1 === e && (this._ondpaddown && this._ondpaddown(i),
- this.onPadDownObservable.notifyObservers(i)),
- 0 === e && (this._ondpadup && this._ondpadup(i),
- this.onPadUpObservable.notifyObservers(i))),
- e
- }
- ,
- Object.defineProperty(t.prototype, "buttonA", {
- get: function() {
- return this._buttonA
- },
- set: function(e) {
- this._buttonA = this._setButtonValue(e, this._buttonA, Sa.A)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonB", {
- get: function() {
- return this._buttonB
- },
- set: function(e) {
- this._buttonB = this._setButtonValue(e, this._buttonB, Sa.B)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonX", {
- get: function() {
- return this._buttonX
- },
- set: function(e) {
- this._buttonX = this._setButtonValue(e, this._buttonX, Sa.X)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonY", {
- get: function() {
- return this._buttonY
- },
- set: function(e) {
- this._buttonY = this._setButtonValue(e, this._buttonY, Sa.Y)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonStart", {
- get: function() {
- return this._buttonStart
- },
- set: function(e) {
- this._buttonStart = this._setButtonValue(e, this._buttonStart, Sa.Start)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonBack", {
- get: function() {
- return this._buttonBack
- },
- set: function(e) {
- this._buttonBack = this._setButtonValue(e, this._buttonBack, Sa.Back)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonLB", {
- get: function() {
- return this._buttonLB
- },
- set: function(e) {
- this._buttonLB = this._setButtonValue(e, this._buttonLB, Sa.LB)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonRB", {
- get: function() {
- return this._buttonRB
- },
- set: function(e) {
- this._buttonRB = this._setButtonValue(e, this._buttonRB, Sa.RB)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonLeftStick", {
- get: function() {
- return this._buttonLeftStick
- },
- set: function(e) {
- this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, Sa.LeftStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonRightStick", {
- get: function() {
- return this._buttonRightStick
- },
- set: function(e) {
- this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, Sa.RightStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadUp", {
- get: function() {
- return this._dPadUp
- },
- set: function(e) {
- this._dPadUp = this._setDPadValue(e, this._dPadUp, Aa.Up)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadDown", {
- get: function() {
- return this._dPadDown
- },
- set: function(e) {
- this._dPadDown = this._setDPadValue(e, this._dPadDown, Aa.Down)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadLeft", {
- get: function() {
- return this._dPadLeft
- },
- set: function(e) {
- this._dPadLeft = this._setDPadValue(e, this._dPadLeft, Aa.Left)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadRight", {
- get: function() {
- return this._dPadRight
- },
- set: function(e) {
- this._dPadRight = this._setDPadValue(e, this._dPadRight, Aa.Right)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.update = function() {
- e.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
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onButtonDownObservable.clear(),
- this.onButtonUpObservable.clear(),
- this.onPadDownObservable.clear(),
- this.onPadUpObservable.clear()
- }
- ,
- t
- }(zo);
- !function(e) {
- e[e.Cross = 0] = "Cross",
- e[e.Circle = 1] = "Circle",
- e[e.Square = 2] = "Square",
- e[e.Triangle = 3] = "Triangle",
- e[e.L1 = 4] = "L1",
- e[e.R1 = 5] = "R1",
- e[e.Share = 8] = "Share",
- e[e.Options = 9] = "Options",
- e[e.LeftStick = 10] = "LeftStick",
- e[e.RightStick = 11] = "RightStick"
- }(Ca || (Ca = {})),
- function(e) {
- e[e.Up = 12] = "Up",
- e[e.Down = 13] = "Down",
- e[e.Left = 14] = "Left",
- e[e.Right = 15] = "Right"
- }(Pa || (Pa = {}));
- var Ia = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), i, n, 0, 1, 2, 3) || this;
- return r._leftTrigger = 0,
- r._rightTrigger = 0,
- r.onButtonDownObservable = new h,
- r.onButtonUpObservable = new h,
- r.onPadDownObservable = new h,
- r.onPadUpObservable = new h,
- r._buttonCross = 0,
- r._buttonCircle = 0,
- r._buttonSquare = 0,
- r._buttonTriangle = 0,
- r._buttonShare = 0,
- r._buttonOptions = 0,
- r._buttonL1 = 0,
- r._buttonR1 = 0,
- r._buttonLeftStick = 0,
- r._buttonRightStick = 0,
- r._dPadUp = 0,
- r._dPadDown = 0,
- r._dPadLeft = 0,
- r._dPadRight = 0,
- r.type = zo.DUALSHOCK,
- r
- }
- return U(t, e),
- t.prototype.onlefttriggerchanged = function(e) {
- this._onlefttriggerchanged = e
- }
- ,
- t.prototype.onrighttriggerchanged = function(e) {
- this._onrighttriggerchanged = e
- }
- ,
- Object.defineProperty(t.prototype, "leftTrigger", {
- get: function() {
- return this._leftTrigger
- },
- set: function(e) {
- this._onlefttriggerchanged && this._leftTrigger !== e && this._onlefttriggerchanged(e),
- this._leftTrigger = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rightTrigger", {
- get: function() {
- return this._rightTrigger
- },
- set: function(e) {
- this._onrighttriggerchanged && this._rightTrigger !== e && this._onrighttriggerchanged(e),
- this._rightTrigger = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.onbuttondown = function(e) {
- this._onbuttondown = e
- }
- ,
- t.prototype.onbuttonup = function(e) {
- this._onbuttonup = e
- }
- ,
- t.prototype.ondpaddown = function(e) {
- this._ondpaddown = e
- }
- ,
- t.prototype.ondpadup = function(e) {
- this._ondpadup = e
- }
- ,
- t.prototype._setButtonValue = function(e, t, i) {
- return e !== t && (1 === e && (this._onbuttondown && this._onbuttondown(i),
- this.onButtonDownObservable.notifyObservers(i)),
- 0 === e && (this._onbuttonup && this._onbuttonup(i),
- this.onButtonUpObservable.notifyObservers(i))),
- e
- }
- ,
- t.prototype._setDPadValue = function(e, t, i) {
- return e !== t && (1 === e && (this._ondpaddown && this._ondpaddown(i),
- this.onPadDownObservable.notifyObservers(i)),
- 0 === e && (this._ondpadup && this._ondpadup(i),
- this.onPadUpObservable.notifyObservers(i))),
- e
- }
- ,
- Object.defineProperty(t.prototype, "buttonCross", {
- get: function() {
- return this._buttonCross
- },
- set: function(e) {
- this._buttonCross = this._setButtonValue(e, this._buttonCross, Ca.Cross)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonCircle", {
- get: function() {
- return this._buttonCircle
- },
- set: function(e) {
- this._buttonCircle = this._setButtonValue(e, this._buttonCircle, Ca.Circle)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonSquare", {
- get: function() {
- return this._buttonSquare
- },
- set: function(e) {
- this._buttonSquare = this._setButtonValue(e, this._buttonSquare, Ca.Square)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonTriangle", {
- get: function() {
- return this._buttonTriangle
- },
- set: function(e) {
- this._buttonTriangle = this._setButtonValue(e, this._buttonTriangle, Ca.Triangle)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonOptions", {
- get: function() {
- return this._buttonOptions
- },
- set: function(e) {
- this._buttonOptions = this._setButtonValue(e, this._buttonOptions, Ca.Options)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonShare", {
- get: function() {
- return this._buttonShare
- },
- set: function(e) {
- this._buttonShare = this._setButtonValue(e, this._buttonShare, Ca.Share)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonL1", {
- get: function() {
- return this._buttonL1
- },
- set: function(e) {
- this._buttonL1 = this._setButtonValue(e, this._buttonL1, Ca.L1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonR1", {
- get: function() {
- return this._buttonR1
- },
- set: function(e) {
- this._buttonR1 = this._setButtonValue(e, this._buttonR1, Ca.R1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonLeftStick", {
- get: function() {
- return this._buttonLeftStick
- },
- set: function(e) {
- this._buttonLeftStick = this._setButtonValue(e, this._buttonLeftStick, Ca.LeftStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buttonRightStick", {
- get: function() {
- return this._buttonRightStick
- },
- set: function(e) {
- this._buttonRightStick = this._setButtonValue(e, this._buttonRightStick, Ca.RightStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadUp", {
- get: function() {
- return this._dPadUp
- },
- set: function(e) {
- this._dPadUp = this._setDPadValue(e, this._dPadUp, Pa.Up)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadDown", {
- get: function() {
- return this._dPadDown
- },
- set: function(e) {
- this._dPadDown = this._setDPadValue(e, this._dPadDown, Pa.Down)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadLeft", {
- get: function() {
- return this._dPadLeft
- },
- set: function(e) {
- this._dPadLeft = this._setDPadValue(e, this._dPadLeft, Pa.Left)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dPadRight", {
- get: function() {
- return this._dPadRight
- },
- set: function(e) {
- this._dPadRight = this._setDPadValue(e, this._dPadRight, Pa.Right)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.update = function() {
- e.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
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onButtonDownObservable.clear(),
- this.onButtonUpObservable.clear(),
- this.onPadDownObservable.clear(),
- this.onPadUpObservable.clear()
- }
- ,
- t
- }(zo)
- , Oa = function() {
- function e(e) {
- var t = this;
- if (this._scene = e,
- this._babylonGamepads = [],
- this._oneGamepadConnected = !1,
- this._isMonitoring = !1,
- this.onGamepadDisconnectedObservable = new h,
- nt() ? (this._gamepadEventSupported = "GamepadEvent"in window,
- this._gamepadSupport = navigator && (navigator.getGamepads || navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads)) : this._gamepadEventSupported = !1,
- this.onGamepadConnectedObservable = new h((function(e) {
- for (var i in t._babylonGamepads) {
- var n = t._babylonGamepads[i];
- n && n._isConnected && t.onGamepadConnectedObservable.notifyObserver(e, n)
- }
- }
- )),
- this._onGamepadConnectedEvent = function(e) {
- var i, n = e.gamepad;
- n.index in t._babylonGamepads && t._babylonGamepads[n.index].isConnected || (t._babylonGamepads[n.index] ? ((i = t._babylonGamepads[n.index]).browserGamepad = n,
- i._isConnected = !0) : i = t._addNewGamepad(n),
- t.onGamepadConnectedObservable.notifyObservers(i),
- t._startMonitoringGamepads())
- }
- ,
- this._onGamepadDisconnectedEvent = function(e) {
- var i = e.gamepad;
- for (var n in t._babylonGamepads)
- if (t._babylonGamepads[n].index === i.index) {
- var r = t._babylonGamepads[n];
- r._isConnected = !1,
- t.onGamepadDisconnectedObservable.notifyObservers(r),
- r.dispose && r.dispose();
- break
- }
- }
- ,
- this._gamepadSupport)
- if (this._updateGamepadObjects(),
- this._babylonGamepads.length && this._startMonitoringGamepads(),
- this._gamepadEventSupported) {
- var i = this._scene ? this._scene.getEngine().getHostWindow() : window;
- i && (i.addEventListener("gamepadconnected", this._onGamepadConnectedEvent, !1),
- i.addEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent, !1))
- } else
- this._startMonitoringGamepads()
- }
- return Object.defineProperty(e.prototype, "gamepads", {
- get: function() {
- return this._babylonGamepads
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getGamepadByType = function(e) {
- void 0 === e && (e = zo.XBOX);
- for (var t = 0, i = this._babylonGamepads; t < i.length; t++) {
- var n = i[t];
- if (n && n.type === e)
- return n
- }
- return null
- }
- ,
- e.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 = []
- }
- ,
- e.prototype._addNewGamepad = function(e) {
- var t;
- this._oneGamepadConnected || (this._oneGamepadConnected = !0);
- var i = -1 !== e.id.search("054c") && -1 === e.id.search("0ce6")
- , n = -1 !== e.id.search("Xbox One");
- return t = n || -1 !== e.id.search("Xbox 360") || -1 !== e.id.search("xinput") || -1 !== e.id.search("045e") && -1 === e.id.search("Surface Dock") ? new Ma(e.id,e.index,e,n) : i ? new Ia(e.id,e.index,e) : e.pose ? xa.InitiateController(e) : new Wo(e.id,e.index,e),
- this._babylonGamepads[t.index] = t,
- t
- }
- ,
- e.prototype._startMonitoringGamepads = function() {
- this._isMonitoring || (this._isMonitoring = !0,
- this._scene || this._checkGamepadsStatus())
- }
- ,
- e.prototype._stopMonitoringGamepads = function() {
- this._isMonitoring = !1
- }
- ,
- e.prototype._checkGamepadsStatus = function() {
- var e = this;
- for (var t in this._updateGamepadObjects(),
- this._babylonGamepads) {
- var i = this._babylonGamepads[t];
- if (i && i.isConnected)
- try {
- i.update()
- } catch (e) {
- -1 === this._loggedErrors.indexOf(i.index) && (gi.Warn("Error updating gamepad ".concat(i.id)),
- this._loggedErrors.push(i.index))
- }
- }
- this._isMonitoring && !this._scene && vr.QueueNewFrame((function() {
- e._checkGamepadsStatus()
- }
- ))
- }
- ,
- e.prototype._updateGamepadObjects = function() {
- for (var e = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [], t = 0; t < e.length; t++) {
- var i = e[t];
- if (i)
- if (this._babylonGamepads[i.index])
- this._babylonGamepads[t].browserGamepad = i,
- this._babylonGamepads[t].isConnected || (this._babylonGamepads[t]._isConnected = !0,
- this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t]));
- else {
- var n = this._addNewGamepad(i);
- this.onGamepadConnectedObservable.notifyObservers(n)
- }
- }
- }
- ,
- e
- }();
- Object.defineProperty(mn.prototype, "gamepadManager", {
- get: function() {
- if (!this._gamepadManager) {
- this._gamepadManager = new Oa(this);
- var e = this._getComponent(Wi.NAME_GAMEPAD);
- e || (e = new Da(this),
- this._addComponent(e))
- }
- return this._gamepadManager
- },
- enumerable: !0,
- configurable: !0
- }),
- aa.prototype.addGamepad = function() {
- return this.add(new ca),
- this
- }
- ,
- Ko.prototype.addGamepad = function() {
- return this.add(new Ho),
- this
- }
- ;
- var Da = function() {
- function e(e) {
- this.name = Wi.NAME_GAMEPAD,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._beforeCameraUpdateStage.registerStep(Wi.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {
- var e = this.scene._gamepadManager;
- e && (e.dispose(),
- this.scene._gamepadManager = null)
- }
- ,
- e.prototype._beforeCameraUpdate = function() {
- var e = this.scene._gamepadManager;
- e && e._isMonitoring && e._checkGamepadsStatus()
- }
- ,
- e
- }();
- Xe.AddNodeConstructor("FreeCamera", (function(e, t) {
- return function() {
- return new Na(e,x.Zero(),t)
- }
- }
- ));
- var Na = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i, n) || this;
- return r.inputs.addGamepad(),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "gamepadAngularSensibility", {
- get: function() {
- var e = this.inputs.attached.gamepad;
- return e ? e.gamepadAngularSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.gamepad;
- t && (t.gamepadAngularSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "gamepadMoveSensibility", {
- get: function() {
- var e = this.inputs.attached.gamepad;
- return e ? e.gamepadMoveSensibility : 0
- },
- set: function(e) {
- var t = this.inputs.attached.gamepad;
- t && (t.gamepadMoveSensibility = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "UniversalCamera"
- }
- ,
- t
- }(fa);
- Rr._CreateDefaultParsedCamera = function(e, t) {
- return new Na(e,x.Zero(),t)
- }
- ,
- Xe.AddNodeConstructor("GamepadCamera", (function(e, t) {
- return function() {
- return new La(e,x.Zero(),t)
- }
- }
- ));
- var La = function(e) {
- function t(t, i, n) {
- return e.call(this, t, i, n) || this
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "GamepadCamera"
- }
- ,
- t
- }(Na);
- Pt.ShadersStore.postprocessVertexShader = "attribute vec2 position;\nuniform vec2 scale;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var Fa = function() {
- function e(e, t, i, n) {
- this._textures = null,
- this._attachments = null,
- this._generateStencilBuffer = !1,
- this._generateDepthBuffer = !1,
- this._depthStencilTextureWithStencil = !1,
- this._isMulti = e,
- this._isCube = t,
- this._size = i,
- this._engine = n,
- this._depthStencilTexture = null
- }
- return Object.defineProperty(e.prototype, "depthStencilTexture", {
- get: function() {
- return this._depthStencilTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthStencilTextureWithStencil", {
- get: function() {
- return this._depthStencilTextureWithStencil
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isCube", {
- get: function() {
- return this._isCube
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isMulti", {
- get: function() {
- return this._isMulti
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "is2DArray", {
- get: function() {
- return this.layers > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "size", {
- get: function() {
- return this.width
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "width", {
- get: function() {
- return this._size.width || this._size
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "height", {
- get: function() {
- return this._size.height || this._size
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "layers", {
- get: function() {
- return this._size.layers || 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "texture", {
- get: function() {
- var e, t;
- return null !== (t = null === (e = this._textures) || void 0 === e ? void 0 : e[0]) && void 0 !== t ? t : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "textures", {
- get: function() {
- return this._textures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "samples", {
- get: function() {
- var e, t;
- return null !== (t = null === (e = this.texture) || void 0 === e ? void 0 : e.samples) && void 0 !== t ? t : 1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setSamples = function(e, t, i) {
- return void 0 === t && (t = !0),
- void 0 === i && (i = !1),
- this.samples !== e || i ? this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, e, t) : this._engine.updateRenderTargetTextureSampleCount(this, e) : e
- }
- ,
- e.prototype.setTextures = function(e) {
- Array.isArray(e) ? this._textures = e : this._textures = e ? [e] : null
- }
- ,
- e.prototype.setTexture = function(e, t, i) {
- void 0 === t && (t = 0),
- void 0 === i && (i = !0),
- this._textures || (this._textures = []),
- this._textures[t] && i && this._textures[t].dispose(),
- this._textures[t] = e
- }
- ,
- e.prototype.createDepthStencilTexture = function(e, t, i, n, r) {
- var o;
- return void 0 === e && (e = 0),
- void 0 === t && (t = !0),
- void 0 === i && (i = !1),
- void 0 === n && (n = 1),
- void 0 === r && (r = a.TEXTUREFORMAT_DEPTH32_FLOAT),
- null === (o = this._depthStencilTexture) || void 0 === o || o.dispose(),
- this._depthStencilTextureWithStencil = i,
- this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, {
- bilinearFiltering: t,
- comparisonFunction: e,
- generateStencil: i,
- isCube: this._isCube,
- samples: n,
- depthTextureFormat: r
- }, this),
- this._depthStencilTexture
- }
- ,
- e.prototype._shareDepth = function(e) {
- this._depthStencilTexture && (e._depthStencilTexture && e._depthStencilTexture.dispose(),
- e._depthStencilTexture = this._depthStencilTexture,
- this._depthStencilTexture.incrementReferences())
- }
- ,
- e.prototype._swapAndDie = function(e) {
- this.texture && this.texture._swapAndDie(e),
- this._textures = null,
- this.dispose(!0)
- }
- ,
- e.prototype._cloneRenderTargetWrapper = function() {
- var e, t, i, n, r, o, a = null;
- if (this._isMulti) {
- var s = this.textures;
- if (s && s.length > 0) {
- var l = !1
- , c = s.length
- , u = s[s.length - 1]._source;
- u !== At.Depth && u !== At.DepthStencil || (l = !0,
- c--);
- for (var h = [], d = [], p = 0; p < c; ++p) {
- var f = s[p];
- h.push(f.samplingMode),
- d.push(f.type)
- }
- var _ = {
- samplingModes: h,
- generateMipMaps: s[0].generateMipMaps,
- generateDepthBuffer: this._generateDepthBuffer,
- generateStencilBuffer: this._generateStencilBuffer,
- generateDepthTexture: l,
- types: d,
- textureCount: c
- }
- , m = {
- width: this.width,
- height: this.height
- };
- a = this._engine.createMultipleRenderTarget(m, _)
- }
- } else {
- var g = {};
- g.generateDepthBuffer = this._generateDepthBuffer,
- g.generateMipMaps = null !== (t = null === (e = this.texture) || void 0 === e ? void 0 : e.generateMipMaps) && void 0 !== t && t,
- g.generateStencilBuffer = this._generateStencilBuffer,
- g.samplingMode = null === (i = this.texture) || void 0 === i ? void 0 : i.samplingMode,
- g.type = null === (n = this.texture) || void 0 === n ? void 0 : n.type,
- g.format = null === (r = this.texture) || void 0 === r ? void 0 : r.format,
- this.isCube ? a = this._engine.createRenderTargetCubeTexture(this.width, g) : (m = {
- width: this.width,
- height: this.height,
- layers: this.is2DArray ? null === (o = this.texture) || void 0 === o ? void 0 : o.depth : void 0
- },
- a = this._engine.createRenderTargetTexture(m, g)),
- a.texture.isReady = !0
- }
- return a
- }
- ,
- e.prototype._swapRenderTargetWrapper = function(e) {
- if (this._textures && e._textures)
- for (var t = 0; t < this._textures.length; ++t)
- this._textures[t]._swapAndDie(e._textures[t], !1),
- e._textures[t].isReady = !0;
- this._depthStencilTexture && e._depthStencilTexture && (this._depthStencilTexture._swapAndDie(e._depthStencilTexture),
- e._depthStencilTexture.isReady = !0),
- this._textures = null,
- this._depthStencilTexture = null
- }
- ,
- e.prototype._rebuild = function() {
- var e = this._cloneRenderTargetWrapper();
- if (e) {
- if (this._depthStencilTexture) {
- var t = this._depthStencilTexture.samplingMode
- , i = t === a.TEXTURE_BILINEAR_SAMPLINGMODE || t === a.TEXTURE_TRILINEAR_SAMPLINGMODE || t === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
- e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, i, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples)
- }
- this.samples > 1 && e.setSamples(this.samples),
- e._swapRenderTargetWrapper(this),
- e.dispose()
- }
- }
- ,
- e.prototype.releaseTextures = function() {
- var e, t;
- if (this._textures)
- for (var i = 0; null !== (t = i < (null === (e = this._textures) || void 0 === e ? void 0 : e.length)) && void 0 !== t && t; ++i)
- this._textures[i].dispose();
- this._textures = null
- }
- ,
- e.prototype.dispose = function(e) {
- var t;
- void 0 === e && (e = !1),
- e || (null === (t = this._depthStencilTexture) || void 0 === t || t.dispose(),
- this._depthStencilTexture = null,
- this.releaseTextures()),
- this._engine._releaseRenderTargetWrapper(this)
- }
- ,
- e
- }()
- , wa = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, i, n, r) || this;
- return a._framebuffer = null,
- a._depthStencilBuffer = null,
- a._MSAAFramebuffer = null,
- a._colorTextureArray = null,
- a._depthStencilTextureArray = null,
- a._context = o,
- a
- }
- return U(t, e),
- t.prototype._cloneRenderTargetWrapper = function() {
- var t = null;
- return this._colorTextureArray && this._depthStencilTextureArray ? (t = this._engine.createMultiviewRenderTargetTexture(this.width, this.height)).texture.isReady = !0 : t = e.prototype._cloneRenderTargetWrapper.call(this),
- t
- }
- ,
- t.prototype._swapRenderTargetWrapper = function(t) {
- e.prototype._swapRenderTargetWrapper.call(this, t),
- t._framebuffer = this._framebuffer,
- t._depthStencilBuffer = this._depthStencilBuffer,
- t._MSAAFramebuffer = this._MSAAFramebuffer,
- t._colorTextureArray = this._colorTextureArray,
- t._depthStencilTextureArray = this._depthStencilTextureArray,
- this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null
- }
- ,
- t.prototype._shareDepth = function(t) {
- e.prototype._shareDepth.call(this, t);
- var i = this._context
- , n = this._depthStencilBuffer
- , r = t._framebuffer;
- t._depthStencilBuffer && i.deleteRenderbuffer(t._depthStencilBuffer),
- t._depthStencilBuffer = this._depthStencilBuffer,
- this._engine._bindUnboundFramebuffer(r),
- i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, n),
- this._engine._bindUnboundFramebuffer(null)
- }
- ,
- t.prototype._bindTextureRenderTarget = function(e, t, i, n) {
- if (void 0 === t && (t = 0),
- void 0 === i && (i = -1),
- void 0 === n && (n = 0),
- e._hardwareTexture) {
- var r = this._context
- , o = this._framebuffer
- , a = this._engine._currentFramebuffer;
- this._engine._bindUnboundFramebuffer(o);
- var s = r[this._engine.webGLVersion > 1 ? "COLOR_ATTACHMENT" + t : "COLOR_ATTACHMENT" + t + "_WEBGL"]
- , l = -1 !== i ? r.TEXTURE_CUBE_MAP_POSITIVE_X + i : r.TEXTURE_2D;
- r.framebufferTexture2D(r.FRAMEBUFFER, s, l, e._hardwareTexture.underlyingResource, n),
- this._engine._bindUnboundFramebuffer(a)
- }
- }
- ,
- t.prototype.setTexture = function(t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = !0),
- e.prototype.setTexture.call(this, t, i, n),
- this._bindTextureRenderTarget(t, i)
- }
- ,
- t.prototype.dispose = function(t) {
- void 0 === t && (t = !1);
- var i = this._context;
- t || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray),
- this._colorTextureArray = null),
- this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray),
- this._depthStencilTextureArray = null)),
- this._framebuffer && (i.deleteFramebuffer(this._framebuffer),
- this._framebuffer = null),
- this._depthStencilBuffer && (i.deleteRenderbuffer(this._depthStencilBuffer),
- this._depthStencilBuffer = null),
- this._MSAAFramebuffer && (i.deleteFramebuffer(this._MSAAFramebuffer),
- this._MSAAFramebuffer = null),
- e.prototype.dispose.call(this, t)
- }
- ,
- t
- }(Fa);
- Ht.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
- var n = new wa(e,t,i,this,this._gl);
- return this._renderTargetWrapperCache.push(n),
- n
- }
- ,
- Ht.prototype.createRenderTargetTexture = function(e, t) {
- var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
- , n = {};
- void 0 !== t && "object" == typeof t ? (n.generateDepthBuffer = !!t.generateDepthBuffer,
- n.generateStencilBuffer = !!t.generateStencilBuffer) : (n.generateDepthBuffer = !0,
- n.generateStencilBuffer = !1);
- var r = this._createInternalTexture(e, t, !0, At.RenderTarget)
- , o = e.width || e
- , a = e.height || e
- , s = this._currentFramebuffer
- , l = this._gl
- , c = l.createFramebuffer();
- return this._bindUnboundFramebuffer(c),
- i._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!n.generateStencilBuffer, n.generateDepthBuffer, o, a),
- r.is2DArray || l.framebufferTexture2D(l.FRAMEBUFFER, l.COLOR_ATTACHMENT0, l.TEXTURE_2D, r._hardwareTexture.underlyingResource, 0),
- this._bindUnboundFramebuffer(s),
- i._framebuffer = c,
- i._generateDepthBuffer = n.generateDepthBuffer,
- i._generateStencilBuffer = !!n.generateStencilBuffer,
- i.setTextures(r),
- i
- }
- ,
- Ht.prototype.createDepthStencilTexture = function(e, t, i) {
- if (t.isCube) {
- var n = e.width || e;
- return this._createDepthStencilCubeTexture(n, t, i)
- }
- return this._createDepthStencilTexture(e, t, i)
- }
- ,
- Ht.prototype._createDepthStencilTexture = function(e, t, i) {
- var n = this._gl
- , r = e.layers || 0
- , o = 0 !== r ? n.TEXTURE_2D_ARRAY : n.TEXTURE_2D
- , s = new Lt(this,At.DepthStencil);
- if (!this._caps.depthTextureExtension)
- return K.Error("Depth texture is not supported by your browser or hardware."),
- s;
- var l = V({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1
- }, t);
- this._bindTextureDirectly(o, s, !0),
- this._setupDepthStencilTexture(s, e, l.generateStencil, 0 !== l.comparisonFunction && l.bilinearFiltering, l.comparisonFunction),
- s.format = l.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH24,
- i._depthStencilTexture = s,
- i._depthStencilTextureWithStencil = l.generateStencil;
- var c = l.generateStencil ? n.UNSIGNED_INT_24_8 : n.UNSIGNED_INT
- , u = l.generateStencil ? n.DEPTH_STENCIL : n.DEPTH_COMPONENT
- , h = u;
- return this.webGLVersion > 1 && (h = l.generateStencil ? n.DEPTH24_STENCIL8 : n.DEPTH_COMPONENT24),
- s.is2DArray ? n.texImage3D(o, 0, h, s.width, s.height, r, 0, u, c, null) : n.texImage2D(o, 0, h, s.width, s.height, 0, u, c, null),
- this._bindTextureDirectly(o, null),
- this._internalTexturesCache.push(s),
- s
- }
- ,
- Ht.prototype.updateRenderTargetTextureSampleCount = function(e, t) {
- if (this.webGLVersion < 2 || !e || !e.texture)
- return 1;
- if (e.samples === t)
- return t;
- var i = this._gl;
- t = Math.min(t, this.getCaps().maxMSAASamples),
- e._depthStencilBuffer && (i.deleteRenderbuffer(e._depthStencilBuffer),
- e._depthStencilBuffer = null),
- e._MSAAFramebuffer && (i.deleteFramebuffer(e._MSAAFramebuffer),
- e._MSAAFramebuffer = null);
- var n = e.texture._hardwareTexture;
- if (n._MSAARenderBuffer && (i.deleteRenderbuffer(n._MSAARenderBuffer),
- n._MSAARenderBuffer = null),
- t > 1 && i.renderbufferStorageMultisample) {
- var r = i.createFramebuffer();
- if (!r)
- throw new Error("Unable to create multi sampled framebuffer");
- e._MSAAFramebuffer = r,
- this._bindUnboundFramebuffer(e._MSAAFramebuffer);
- var o = this._createRenderBuffer(e.texture.width, e.texture.height, t, -1, this._getRGBAMultiSampleBufferFormat(e.texture.type), i.COLOR_ATTACHMENT0, !1);
- if (!o)
- throw new Error("Unable to create multi sampled framebuffer");
- n._MSAARenderBuffer = o
- } else
- this._bindUnboundFramebuffer(e._framebuffer);
- return e.texture.samples = t,
- e._depthStencilBuffer = this._setupFramebufferDepthAttachments(e._generateStencilBuffer, e._generateDepthBuffer, e.texture.width, e.texture.height, t),
- this._bindUnboundFramebuffer(null),
- t
- }
- ;
- var Ba = function() {
- function e(e, t, i, n, r, o, s, l, c, u, d, p, f, _, m) {
- void 0 === s && (s = a.TEXTURE_NEAREST_SAMPLINGMODE),
- void 0 === u && (u = null),
- void 0 === d && (d = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === p && (p = "postprocess"),
- void 0 === _ && (_ = !1),
- void 0 === m && (m = a.TEXTUREFORMAT_RGBA),
- this._parentContainer = null,
- this.width = -1,
- this.height = -1,
- this.nodeMaterialSource = null,
- this._outputTexture = null,
- this.autoClear = !0,
- this.alphaMode = a.ALPHA_DISABLE,
- this.animations = new Array,
- this.enablePixelPerfectMode = !1,
- this.forceFullscreenViewport = !0,
- this.scaleMode = a.SCALEMODE_FLOOR,
- this.alwaysForcePOT = !1,
- this._samples = 1,
- this.adaptScaleToCurrentViewport = !1,
- this._reusable = !1,
- this._renderId = 0,
- this.externalTextureSamplerBinding = !1,
- this._textures = new bi(2),
- this._textureCache = [],
- this._currentRenderTextureInd = 0,
- this._scaleRatio = new A(1,1),
- this._texelSize = A.Zero(),
- this.onActivateObservable = new h,
- this.onSizeChangedObservable = new h,
- this.onApplyObservable = new h,
- this.onBeforeRenderObservable = new h,
- this.onAfterRenderObservable = new h,
- this.name = e,
- null != o ? (this._camera = o,
- this._scene = o.getScene(),
- o.attachPostProcess(this),
- this._engine = this._scene.getEngine(),
- this._scene.postProcesses.push(this),
- this.uniqueId = this._scene.getUniqueId()) : l && (this._engine = l,
- this._engine.postProcesses.push(this)),
- this._options = r,
- this.renderTargetSamplingMode = s || a.TEXTURE_NEAREST_SAMPLINGMODE,
- this._reusable = c || !1,
- this._textureType = d,
- this._textureFormat = m,
- this._samplers = n || [],
- this._samplers.push("textureSampler"),
- this._fragmentUrl = t,
- this._vertexUrl = p,
- this._parameters = i || [],
- this._parameters.push("scale"),
- this._indexParameters = f,
- this._drawWrapper = new Gt(this._engine),
- _ || this.updateEffect(u)
- }
- return Object.defineProperty(e.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(e) {
- var t = this;
- this._samples = Math.min(e, this._engine.getCaps().maxMSAASamples),
- this._textures.forEach((function(e) {
- e.samples !== t._samples && t._engine.updateRenderTargetTextureSampleCount(e, t._samples)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getEffectName = function() {
- return this._fragmentUrl
- }
- ,
- Object.defineProperty(e.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(e.prototype, "onSizeChanged", {
- set: function(e) {
- this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver),
- this._onSizeChangedObserver = this.onSizeChangedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onApply", {
- set: function(e) {
- this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver),
- this._onApplyObserver = this.onApplyObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeRender", {
- set: function(e) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onAfterRender", {
- set: function(e) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "inputTexture", {
- get: function() {
- return this._textures.data[this._currentRenderTextureInd]
- },
- set: function(e) {
- this._forcedOutputTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.restoreDefaultInputTexture = function() {
- this._forcedOutputTexture && (this._forcedOutputTexture = null,
- this.markTextureDirty())
- }
- ,
- e.prototype.getCamera = function() {
- return this._camera
- }
- ,
- Object.defineProperty(e.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
- }),
- e.prototype.getClassName = function() {
- return "PostProcess"
- }
- ,
- e.prototype.getEngine = function() {
- return this._engine
- }
- ,
- e.prototype.getEffect = function() {
- return this._drawWrapper.effect
- }
- ,
- e.prototype.shareOutputWith = function(e) {
- return this._disposeTextures(),
- this._shareOutputWithPostProcess = e,
- this
- }
- ,
- e.prototype.useOwnOutput = function() {
- 0 == this._textures.length && (this._textures = new bi(2)),
- this._shareOutputWithPostProcess = null
- }
- ,
- e.prototype.updateEffect = function(e, t, i, n, r, o, a, s) {
- void 0 === e && (e = null),
- void 0 === t && (t = null),
- void 0 === i && (i = null),
- this._postProcessDefines = e,
- this._drawWrapper.effect = this._engine.createEffect({
- vertex: null != a ? a : this._vertexUrl,
- fragment: null != s ? s : this._fragmentUrl
- }, ["position"], t || this._parameters, i || this._samplers, null !== e ? e : "", void 0, r, o, n || this._indexParameters)
- }
- ,
- e.prototype.isReusable = function() {
- return this._reusable
- }
- ,
- e.prototype.markTextureDirty = function() {
- this.width = -1
- }
- ,
- e.prototype._createRenderTargetTexture = function(e, t, i) {
- void 0 === i && (i = 0);
- for (var n = 0; n < this._textureCache.length; n++)
- if (this._textureCache[n].texture.width === e.width && this._textureCache[n].texture.height === e.height && this._textureCache[n].postProcessChannel === i && this._textureCache[n].texture._generateDepthBuffer === t.generateDepthBuffer)
- return this._textureCache[n].texture;
- var r = this._engine.createRenderTargetTexture(e, t);
- return this._textureCache.push({
- texture: r,
- postProcessChannel: i,
- lastUsedRenderId: -1
- }),
- r
- }
- ,
- e.prototype._flushTextureCache = function() {
- for (var e = this._renderId, t = this._textureCache.length - 1; t >= 0; t--)
- if (e - this._textureCache[t].lastUsedRenderId > 100) {
- for (var i = !1, n = 0; n < this._textures.length; n++)
- if (this._textures.data[n] === this._textureCache[t].texture) {
- i = !0;
- break
- }
- i || (this._textureCache[t].texture.dispose(),
- this._textureCache.splice(t, 1))
- }
- }
- ,
- e.prototype._resize = function(e, t, i, n, r) {
- this._textures.length > 0 && this._textures.reset(),
- this.width = e,
- this.height = t;
- for (var o = null, a = 0; a < i._postProcesses.length; a++)
- if (null !== i._postProcesses[a]) {
- o = i._postProcesses[a];
- break
- }
- var s = {
- width: this.width,
- height: this.height
- }
- , l = {
- generateMipMaps: n,
- generateDepthBuffer: r || o === this,
- generateStencilBuffer: (r || o === this) && this._engine.isStencilEnable,
- samplingMode: this.renderTargetSamplingMode,
- type: this._textureType,
- format: this._textureFormat
- };
- this._textures.push(this._createRenderTargetTexture(s, l, 0)),
- this._reusable && this._textures.push(this._createRenderTargetTexture(s, l, 1)),
- this._texelSize.copyFromFloats(1 / this.width, 1 / this.height),
- this.onSizeChangedObservable.notifyObservers(this)
- }
- ,
- e.prototype.activate = function(e, t, i) {
- var n, r, o = this;
- void 0 === t && (t = null);
- var s = (e = e || this._camera).getScene()
- , l = s.getEngine()
- , c = l.getCaps().maxTextureSize
- , u = (t ? t.width : this._engine.getRenderWidth(!0)) * this._options | 0
- , h = (t ? t.height : this._engine.getRenderHeight(!0)) * this._options | 0
- , d = e.parent;
- !d || d.leftCamera != e && d.rightCamera != e || (u /= 2);
- var p, f = this._options.width || u, _ = this._options.height || h, m = this.renderTargetSamplingMode !== a.TEXTURE_NEAREST_LINEAR && this.renderTargetSamplingMode !== a.TEXTURE_NEAREST_NEAREST && this.renderTargetSamplingMode !== a.TEXTURE_LINEAR_LINEAR;
- if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
- if (this.adaptScaleToCurrentViewport) {
- var g = l.currentViewport;
- g && (f *= g.width,
- _ *= g.height)
- }
- (m || this.alwaysForcePOT) && (this._options.width || (f = l.needPOTTextures ? vr.GetExponentOfTwo(f, c, this.scaleMode) : f),
- this._options.height || (_ = l.needPOTTextures ? vr.GetExponentOfTwo(_, c, this.scaleMode) : _)),
- this.width === f && this.height === _ || this._resize(f, _, e, m, i),
- this._textures.forEach((function(e) {
- e.samples !== o.samples && o._engine.updateRenderTargetTextureSampleCount(e, o.samples)
- }
- )),
- this._flushTextureCache(),
- this._renderId++
- }
- if (this._shareOutputWithPostProcess)
- p = this._shareOutputWithPostProcess.inputTexture;
- else if (this._forcedOutputTexture)
- p = this._forcedOutputTexture,
- this.width = this._forcedOutputTexture.width,
- this.height = this._forcedOutputTexture.height;
- else {
- p = this.inputTexture;
- for (var v = void 0, y = 0; y < this._textureCache.length; y++)
- if (this._textureCache[y].texture === p) {
- v = this._textureCache[y];
- break
- }
- v && (v.lastUsedRenderId = this._renderId)
- }
- return this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(u / f, h / _),
- this._engine.bindFramebuffer(p, 0, u, h, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1),
- this._engine.bindFramebuffer(p, 0, void 0, void 0, this.forceFullscreenViewport)),
- null === (r = (n = this._engine)._debugInsertMarker) || void 0 === r || r.call(n, "post process ".concat(this.name, " input")),
- this.onActivateObservable.notifyObservers(e),
- this.autoClear && this.alphaMode === a.ALPHA_DISABLE && this._engine.clear(this.clearColor ? this.clearColor : s.clearColor, s._allowPostProcessClearColor, !0, !0),
- this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2),
- p
- }
- ,
- Object.defineProperty(e.prototype, "isSupported", {
- get: function() {
- return this._drawWrapper.effect.isSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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
- }),
- e.prototype.isReady = function() {
- var e, t;
- return null !== (t = null === (e = this._drawWrapper.effect) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t
- }
- ,
- e.prototype.apply = function() {
- var e, t;
- return (null === (e = this._drawWrapper.effect) || void 0 === e ? void 0 : e.isReady()) ? (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),
- t = this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? this._forcedOutputTexture : this.inputTexture,
- this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", null == t ? void 0 : t.texture),
- this._drawWrapper.effect.setVector2("scale", this._scaleRatio),
- this.onApplyObservable.notifyObservers(this._drawWrapper.effect),
- this._drawWrapper.effect) : null
- }
- ,
- e.prototype._disposeTextures = function() {
- this._shareOutputWithPostProcess || this._forcedOutputTexture ? this._disposeTextureCache() : (this._disposeTextureCache(),
- this._textures.dispose())
- }
- ,
- e.prototype._disposeTextureCache = function() {
- for (var e = this._textureCache.length - 1; e >= 0; e--)
- this._textureCache[e].texture.dispose();
- this._textureCache.length = 0
- }
- ,
- e.prototype.setPrePassRenderer = function(e) {
- return !!this._prePassEffectConfiguration && (this._prePassEffectConfiguration = e.addEffectConfiguration(this._prePassEffectConfiguration),
- this._prePassEffectConfiguration.enabled = !0,
- !0)
- }
- ,
- e.prototype.dispose = function(e) {
- var t;
- if (e = e || this._camera,
- this._disposeTextures(),
- this._scene && -1 !== (t = this._scene.postProcesses.indexOf(this)) && this._scene.postProcesses.splice(t, 1),
- this._parentContainer) {
- var i = this._parentContainer.postProcesses.indexOf(this);
- i > -1 && this._parentContainer.postProcesses.splice(i, 1),
- this._parentContainer = null
- }
- if (-1 !== (t = this._engine.postProcesses.indexOf(this)) && this._engine.postProcesses.splice(t, 1),
- e) {
- if (e.detachPostProcess(this),
- 0 === (t = e._postProcesses.indexOf(this)) && e._postProcesses.length > 0) {
- var n = this._camera._getFirstPostProcess();
- n && n.markTextureDirty()
- }
- this.onActivateObservable.clear(),
- this.onAfterRenderObservable.clear(),
- this.onApplyObservable.clear(),
- this.onBeforeRenderObservable.clear(),
- this.onSizeChangedObservable.clear()
- }
- }
- ,
- e.prototype.serialize = function() {
- var e = Ge.Serialize(this)
- , t = this.getCamera() || this._scene && this._scene.activeCamera;
- return e.customType = "BABYLON." + this.getClassName(),
- e.cameraId = t ? t.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
- }
- ,
- e.prototype.clone = function() {
- var t = this.serialize();
- t._engine = this._engine,
- t.cameraId = null;
- var i = e.Parse(t, 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
- }
- ,
- e.Parse = function(e, t, i) {
- var n = b(e.customType);
- if (!n || !n._Parse)
- return null;
- var r = t ? t.getCameraById(e.cameraId) : null;
- return n._Parse(e, r, t, i)
- }
- ,
- e._Parse = function(t, i, n, r) {
- return Ge.Parse((function() {
- return new e(t.name,t.fragmentUrl,t.parameters,t.samplers,t.options,i,t.renderTargetSamplingMode,t._engine,t.reusable,t.defines,t.textureType,t.vertexUrl,t.indexParameters,!1,t.textureFormat)
- }
- ), t, n, r)
- }
- ,
- k([Ce()], e.prototype, "uniqueId", void 0),
- k([Ce()], e.prototype, "name", void 0),
- k([Ce()], e.prototype, "width", void 0),
- k([Ce()], e.prototype, "height", void 0),
- k([Ce()], e.prototype, "renderTargetSamplingMode", void 0),
- k([Fe()], e.prototype, "clearColor", void 0),
- k([Ce()], e.prototype, "autoClear", void 0),
- k([Ce()], e.prototype, "alphaMode", void 0),
- k([Ce()], e.prototype, "alphaConstants", void 0),
- k([Ce()], e.prototype, "enablePixelPerfectMode", void 0),
- k([Ce()], e.prototype, "forceFullscreenViewport", void 0),
- k([Ce()], e.prototype, "scaleMode", void 0),
- k([Ce()], e.prototype, "alwaysForcePOT", void 0),
- k([Ce("samples")], e.prototype, "_samples", void 0),
- k([Ce()], e.prototype, "adaptScaleToCurrentViewport", void 0),
- e
- }();
- y("BABYLON.PostProcess", Ba);
- Pt.ShadersStore.passPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
- Pt.ShadersStore.passCubePixelShader = "varying vec2 vUV;\nuniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";
- var Ua = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- return void 0 === n && (n = null),
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === c && (c = !1),
- e.call(this, t, "pass", null, null, i, n, r, o, s, void 0, l, void 0, null, c) || this
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "PassPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)
- }
- ), e, n, r)
- }
- ,
- t
- }(Ba);
- y("BABYLON.PassPostProcess", Ua);
- var Va = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === n && (n = null),
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === c && (c = !1);
- var u = e.call(this, t, "passCube", null, null, i, n, r, o, s, "#define POSITIVEX", l, void 0, null, c) || this;
- return u._face = 0,
- u
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "face", {
- get: function() {
- return this._face
- },
- set: function(e) {
- if (!(e < 0 || e > 5))
- switch (this._face = e,
- 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")
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "PassCubePostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,e._engine,e.reusable)
- }
- ), e, n, r)
- }
- ,
- t
- }(Ba);
- vr._RescalePostProcessFactory = function(e) {
- return new Ua("rescale",1,null,a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,a.TEXTURETYPE_UNSIGNED_INT)
- }
- ;
- Pt.ShadersStore.anaglyphPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}";
- var ka = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, "anaglyph", null, ["leftSampler"], i, n[1], r, o, a) || this;
- return s._passedProcess = n[0]._rigPostProcess,
- s.onApplyObservable.add((function(e) {
- e.setTextureFromPostProcess("leftSampler", s._passedProcess)
- }
- )),
- s
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "AnaglyphPostProcess"
- }
- ,
- t
- }(Ba);
- function Ga(e) {
- e._rigCameras[0]._rigPostProcess = new Ua(e.name + "_passthru",1,e._rigCameras[0]),
- e._rigCameras[1]._rigPostProcess = new ka(e.name + "_anaglyph",1,e._rigCameras)
- }
- y("BABYLON.AnaglyphPostProcess", ka),
- Xe.AddNodeConstructor("AnaglyphArcRotateCamera", (function(e, t, i) {
- return function() {
- return new za(e,0,0,1,x.Zero(),i.interaxial_distance,t)
- }
- }
- ));
- var za = function(e) {
- function t(t, i, n, r, o, a, s) {
- var l = e.call(this, t, i, n, r, o, s) || this;
- return l._setRigMode = Ga.bind(null, l),
- l.interaxialDistance = a,
- l.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
- interaxialDistance: a
- }),
- l
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "AnaglyphArcRotateCamera"
- }
- ,
- t
- }(_a);
- Xe.AddNodeConstructor("AnaglyphFreeCamera", (function(e, t, i) {
- return function() {
- return new Wa(e,x.Zero(),i.interaxial_distance,t)
- }
- }
- ));
- var Wa = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, i, r) || this;
- return o._setRigMode = Ga.bind(null, o),
- o.interaxialDistance = n,
- o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
- interaxialDistance: n
- }),
- o
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "AnaglyphFreeCamera"
- }
- ,
- t
- }(pa);
- Xe.AddNodeConstructor("AnaglyphGamepadCamera", (function(e, t, i) {
- return function() {
- return new Ha(e,x.Zero(),i.interaxial_distance,t)
- }
- }
- ));
- var Ha = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, i, r) || this;
- return o._setRigMode = Ga.bind(null, o),
- o.interaxialDistance = n,
- o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
- interaxialDistance: n
- }),
- o
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "AnaglyphGamepadCamera"
- }
- ,
- t
- }(La);
- Xe.AddNodeConstructor("AnaglyphUniversalCamera", (function(e, t, i) {
- return function() {
- return new Xa(e,x.Zero(),i.interaxial_distance,t)
- }
- }
- ));
- var Xa = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, i, r) || this;
- return o._setRigMode = Ga.bind(null, o),
- o.interaxialDistance = n,
- o.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_ANAGLYPH, {
- interaxialDistance: n
- }),
- o
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "AnaglyphUniversalCamera"
- }
- ,
- t
- }(Na);
- Pt.ShadersStore.stereoscopicInterlacePixelShader = "const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nbool useCamA;\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);\nuseCamA=mod(rowNum,2.0)==1.0;\nuseCamB=mod(rowNum,2.0)==0.0;\ntexCoord1=vec2(vUV.x,vUV.y);\ntexCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\nuseCamA=!useCamB;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n#endif\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else if (useCamA){\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}else {\ndiscard;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}\n";
- var ja = function(e) {
- function t(t, i, n, r, o, a, s) {
- var l = e.call(this, t, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], o, a, s, r ? "#define IS_STEREOSCOPIC_INTERLACED 1" : n ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
- return l._passedProcess = i[0]._rigPostProcess,
- l._stepSize = new A(1 / l.width,1 / l.height),
- l.onSizeChangedObservable.add((function() {
- l._stepSize = new A(1 / l.width,1 / l.height)
- }
- )),
- l.onApplyObservable.add((function(e) {
- e.setTextureFromPostProcess("camASampler", l._passedProcess),
- e.setFloat2("stepSize", l._stepSize.x, l._stepSize.y)
- }
- )),
- l
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StereoscopicInterlacePostProcessI"
- }
- ,
- t
- }(Ba)
- , Ya = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, "stereoscopicInterlace", ["stepSize"], ["camASampler"], 1, i[1], r, o, a, n ? "#define IS_STEREOSCOPIC_HORIZ 1" : void 0) || this;
- return s._passedProcess = i[0]._rigPostProcess,
- s._stepSize = new A(1 / s.width,1 / s.height),
- s.onSizeChangedObservable.add((function() {
- s._stepSize = new A(1 / s.width,1 / s.height)
- }
- )),
- s.onApplyObservable.add((function(e) {
- e.setTextureFromPostProcess("camASampler", s._passedProcess),
- e.setFloat2("stepSize", s._stepSize.x, s._stepSize.y)
- }
- )),
- s
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StereoscopicInterlacePostProcess"
- }
- ,
- t
- }(Ba);
- function Ka(e) {
- var t = e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED
- , i = e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
- e.cameraRigMode === Rr.RIG_MODE_STEREOSCOPIC_INTERLACED ? (e._rigCameras[0]._rigPostProcess = new Ua(e.name + "_passthru",1,e._rigCameras[0]),
- e._rigCameras[1]._rigPostProcess = new ja(e.name + "_stereoInterlace",e._rigCameras,!1,!0)) : (e._rigCameras[i ? 1 : 0].viewport = new xr(0,0,t ? .5 : 1,t ? 1 : .5),
- e._rigCameras[i ? 0 : 1].viewport = new xr(t ? .5 : 0,t ? 0 : .5,t ? .5 : 1,t ? 1 : .5))
- }
- Xe.AddNodeConstructor("StereoscopicArcRotateCamera", (function(e, t, i) {
- return function() {
- return new Qa(e,0,0,1,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
- }
- }
- ));
- var Qa = function(e) {
- function t(t, i, n, r, o, a, s, l) {
- var c = e.call(this, t, i, n, r, o, l) || this;
- return c._setRigMode = Ka.bind(null, c),
- c.interaxialDistance = a,
- c.isStereoscopicSideBySide = s,
- c.setCameraRigMode(s ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
- interaxialDistance: a
- }),
- c
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StereoscopicArcRotateCamera"
- }
- ,
- t
- }(_a);
- Xe.AddNodeConstructor("StereoscopicFreeCamera", (function(e, t, i) {
- return function() {
- return new qa(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
- }
- }
- ));
- var qa = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, i, o) || this;
- return a._setRigMode = Ka.bind(null, a),
- a.interaxialDistance = n,
- a.isStereoscopicSideBySide = r,
- a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
- interaxialDistance: n
- }),
- a
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StereoscopicFreeCamera"
- }
- ,
- t
- }(pa);
- Xe.AddNodeConstructor("StereoscopicGamepadCamera", (function(e, t, i) {
- return function() {
- return new Za(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
- }
- }
- ));
- var Za = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, i, o) || this;
- return a._setRigMode = Ka.bind(null, a),
- a.interaxialDistance = n,
- a.isStereoscopicSideBySide = r,
- a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
- interaxialDistance: n
- }),
- a
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StereoscopicGamepadCamera"
- }
- ,
- t
- }(La);
- Xe.AddNodeConstructor("StereoscopicFreeCamera", (function(e, t, i) {
- return function() {
- return new Ja(e,x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)
- }
- }
- ));
- var Ja = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, i, o) || this;
- return a._setRigMode = Ka.bind(null, a),
- a.interaxialDistance = n,
- a.isStereoscopicSideBySide = r,
- a.setCameraRigMode(r ? Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL : Rr.RIG_MODE_STEREOSCOPIC_OVERUNDER, {
- interaxialDistance: n
- }),
- a
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StereoscopicUniversalCamera"
- }
- ,
- t
- }(Na)
- , $a = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = 1),
- void 0 === o && (o = .065);
- var a = e.call(this, t, i, n) || this;
- return a._distanceBetweenEyes = o,
- a._distanceToProjectionPlane = r,
- a.setCameraRigMode(Rr.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, {
- stereoHalfAngle: 0
- }),
- a._cameraRigParams.stereoHalfAngle = 0,
- a._cameraRigParams.interaxialDistance = o,
- a
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "distanceBetweenEyes", {
- get: function() {
- return this._distanceBetweenEyes
- },
- set: function(e) {
- this._distanceBetweenEyes = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "distanceToProjectionPlane", {
- get: function() {
- return this._distanceToProjectionPlane
- },
- set: function(e) {
- this._distanceToProjectionPlane = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "StereoscopicUniversalCamera"
- }
- ,
- t.prototype.createRigCamera = function(e) {
- var t = new da(e,x.Zero(),this.getScene())
- , i = new yr("tm_" + e,this.getScene());
- return t.parent = i,
- i.setPivotMatrix(P.Identity(), !1),
- t.isRigCamera = !0,
- t.rigParent = this,
- t
- }
- ,
- t.prototype._updateRigCameras = function() {
- for (var e = 0; e < this._rigCameras.length; e++) {
- var t = this._rigCameras[e];
- t.minZ = this.minZ,
- t.maxZ = this.maxZ,
- t.fov = this.fov,
- t.upVector.copyFrom(this.upVector),
- t.rotationQuaternion ? t.rotationQuaternion.copyFrom(this.rotationQuaternion) : t.rotation.copyFrom(this.rotation),
- this._updateCamera(this._rigCameras[e], e)
- }
- }
- ,
- t.prototype._updateCamera = function(e, t) {
- var i = this.distanceBetweenEyes / 2
- , n = i / this.distanceToProjectionPlane;
- e.position.copyFrom(this.position),
- e.position.addInPlaceFromFloats(0 === t ? -i : i, 0, -this._distanceToProjectionPlane);
- var r = e.parent
- , o = r.getPivotMatrix();
- o.setTranslationFromFloats(0 === t ? i : -i, 0, 0),
- o.setRowFromFloats(2, 0 === t ? n : -n, 0, 1, 0),
- r.setPivotMatrix(o, !1)
- }
- ,
- t.prototype._setRigMode = function() {
- this._rigCameras[0].viewport = new xr(0,0,.5,1),
- this._rigCameras[1].viewport = new xr(.5,0,.5,1);
- for (var e = 0; e < this._rigCameras.length; e++)
- this._updateCamera(this._rigCameras[e], e)
- }
- ,
- t
- }(Na);
- Xe.AddNodeConstructor("VirtualJoysticksCamera", (function(e, t) {
- return function() {
- return new es(e,x.Zero(),t)
- }
- }
- ));
- var es = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i, n) || this;
- return r.inputs.addVirtualJoystick(),
- r
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VirtualJoysticksCamera"
- }
- ,
- t
- }(pa)
- , ts = function() {
- function e() {
- this.compensateDistortion = !0,
- this.multiviewEnabled = !1
- }
- return Object.defineProperty(e.prototype, "aspectRatio", {
- get: function() {
- return this.hResolution / (2 * this.vResolution)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "aspectRatioFov", {
- get: function() {
- return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "leftHMatrix", {
- get: function() {
- var e = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
- return P.Translation(e, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightHMatrix", {
- get: function() {
- var e = 4 * (this.hScreenSize / 4 - this.lensSeparationDistance / 2) / this.hScreenSize;
- return P.Translation(-e, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "leftPreViewMatrix", {
- get: function() {
- return P.Translation(.5 * this.interpupillaryDistance, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightPreViewMatrix", {
- get: function() {
- return P.Translation(-.5 * this.interpupillaryDistance, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.GetDefault = function() {
- var t = new e;
- return t.hResolution = 1280,
- t.vResolution = 800,
- t.hScreenSize = .149759993,
- t.vScreenSize = .0935999975,
- t.vScreenCenter = .0467999987,
- t.eyeToScreenDistance = .0410000011,
- t.lensSeparationDistance = .063500002,
- t.interpupillaryDistance = .064000003,
- t.distortionK = [1, .219999999, .239999995, 0],
- t.chromaAbCorrection = [.995999992, -.00400000019, 1.01400006, 0],
- t.postProcessScaleFactor = 1.714605507808412,
- t.lensCenterOffset = .151976421,
- t
- }
- ,
- e
- }();
- Pt.ShadersStore.vrDistortionCorrectionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";
- var is = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, r.postProcessScaleFactor, i, io.BILINEAR_SAMPLINGMODE) || this;
- return o._isRightEye = n,
- o._distortionFactors = r.distortionK,
- o._postProcessScaleFactor = r.postProcessScaleFactor,
- o._lensCenterOffset = r.lensCenterOffset,
- o.adaptScaleToCurrentViewport = !0,
- o.onSizeChangedObservable.add((function() {
- o._scaleIn = new A(2,2 / o.aspectRatio),
- o._scaleFactor = new A(1 / o._postProcessScaleFactor * .5,1 / o._postProcessScaleFactor * .5 * o.aspectRatio),
- o._lensCenter = new A(o._isRightEye ? .5 - .5 * o._lensCenterOffset : .5 + .5 * o._lensCenterOffset,.5)
- }
- )),
- o.onApplyObservable.add((function(e) {
- e.setFloat2("LensCenter", o._lensCenter.x, o._lensCenter.y),
- e.setFloat2("Scale", o._scaleFactor.x, o._scaleFactor.y),
- e.setFloat2("ScaleIn", o._scaleIn.x, o._scaleIn.y),
- e.setFloat4("HmdWarpParam", o._distortionFactors[0], o._distortionFactors[1], o._distortionFactors[2], o._distortionFactors[3])
- }
- )),
- o
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VRDistortionCorrectionPostProcess"
- }
- ,
- t
- }(Ba);
- Pt.ShadersStore.vrMultiviewToSingleviewPixelShader = "precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));\n}",
- Ht.prototype.createRenderTargetCubeTexture = function(e, t) {
- var i = this._createHardwareRenderTargetWrapper(!1, !0, e)
- , n = V({
- generateMipMaps: !0,
- generateDepthBuffer: !0,
- generateStencilBuffer: !1,
- type: a.TEXTURETYPE_UNSIGNED_INT,
- samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- format: a.TEXTUREFORMAT_RGBA
- }, t);
- n.generateStencilBuffer = n.generateDepthBuffer && n.generateStencilBuffer,
- (n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (n.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (n.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE);
- var r = this._gl
- , o = new Lt(this,At.RenderTarget);
- this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, o, !0);
- var s = this._getSamplingParameters(n.samplingMode, n.generateMipMaps);
- n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (n.type = a.TEXTURETYPE_UNSIGNED_INT,
- K.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),
- r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MAG_FILTER, s.mag),
- r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_MIN_FILTER, s.min),
- r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE),
- r.texParameteri(r.TEXTURE_CUBE_MAP, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE);
- for (var l = 0; l < 6; l++)
- r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X + l, 0, this._getRGBABufferInternalSizedFormat(n.type, n.format), e, e, 0, this._getInternalFormat(n.format), this._getWebGLTextureType(n.type), null);
- var c = r.createFramebuffer();
- return this._bindUnboundFramebuffer(c),
- i._depthStencilBuffer = this._setupFramebufferDepthAttachments(n.generateStencilBuffer, n.generateDepthBuffer, e, e),
- n.generateMipMaps && r.generateMipmap(r.TEXTURE_CUBE_MAP),
- this._bindTextureDirectly(r.TEXTURE_CUBE_MAP, null),
- this._bindUnboundFramebuffer(null),
- i._framebuffer = c,
- i._generateDepthBuffer = n.generateDepthBuffer,
- i._generateStencilBuffer = n.generateStencilBuffer,
- o.width = e,
- o.height = e,
- o.isReady = !0,
- o.isCube = !0,
- o.samples = 1,
- o.generateMipMaps = n.generateMipMaps,
- o.samplingMode = n.samplingMode,
- o.type = n.type,
- o.format = n.format,
- this._internalTexturesCache.push(o),
- i.setTextures(o),
- i
- }
- ;
- var ns = function(e) {
- function t(t, i, n, r, o, s, l, c, u, d, p, f, _, m, g) {
- void 0 === o && (o = !0),
- void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === l && (l = !1),
- void 0 === c && (c = io.TRILINEAR_SAMPLINGMODE),
- void 0 === u && (u = !0),
- void 0 === d && (d = !1),
- void 0 === p && (p = !1),
- void 0 === f && (f = a.TEXTUREFORMAT_RGBA),
- void 0 === _ && (_ = !1);
- var v, y = this;
- if ((y = e.call(this, null, n, !r, void 0, c, void 0, void 0, void 0, void 0, f) || this).renderParticles = !0,
- y.renderSprites = !1,
- y.ignoreCameraViewport = !1,
- y.onBeforeBindObservable = new h,
- y.onAfterUnbindObservable = new h,
- y.onBeforeRenderObservable = new h,
- y.onAfterRenderObservable = new h,
- y.onClearObservable = new h,
- y.onResizeObservable = new h,
- y._cleared = !1,
- y.skipInitialClear = !1,
- y._currentRefreshId = -1,
- y._refreshRate = 1,
- y._samples = 1,
- y._canRescale = !0,
- y._renderTarget = null,
- y.boundingBoxPosition = x.Zero(),
- !(n = y.getScene()))
- return y;
- var b = y.getScene().getEngine();
- return y._coordinatesMode = io.PROJECTION_MODE,
- y.renderList = new Array,
- y.name = t,
- y.isRenderTarget = !0,
- y._initialSizeParameter = i,
- y._renderPassIds = [],
- y._isCubeData = l,
- y._processSizeParameter(i),
- y.renderPassId = y._renderPassIds[0],
- y._resizeObserver = b.onResizeObservable.add((function() {}
- )),
- y._generateMipMaps = !!r,
- y._doNotChangeAspectRatio = o,
- y._renderingManager = new zi(n),
- y._renderingManager._useSceneAutoClearSetup = !0,
- p || (y._renderTargetOptions = {
- generateMipMaps: r,
- type: s,
- format: null !== (v = y._format) && void 0 !== v ? v : void 0,
- samplingMode: y.samplingMode,
- generateDepthBuffer: u,
- generateStencilBuffer: d,
- samples: m,
- creationFlags: g
- },
- y.samplingMode === io.NEAREST_SAMPLINGMODE && (y.wrapU = io.CLAMP_ADDRESSMODE,
- y.wrapV = io.CLAMP_ADDRESSMODE),
- _ || (l ? (y._renderTarget = n.getEngine().createRenderTargetCubeTexture(y.getRenderSize(), y._renderTargetOptions),
- y.coordinatesMode = io.INVCUBIC_MODE,
- y._textureMatrix = P.Identity()) : y._renderTarget = n.getEngine().createRenderTargetTexture(y._size, y._renderTargetOptions),
- y._texture = y._renderTarget.texture,
- void 0 !== m && (y.samples = m))),
- y
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "renderList", {
- get: function() {
- return this._renderList
- },
- set: function(e) {
- this._renderList = e,
- this._renderList && this._hookArray(this._renderList)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._hookArray = function(e) {
- var t = this
- , i = e.push;
- e.push = function() {
- for (var n, r = [], o = 0; o < arguments.length; o++)
- r[o] = arguments[o];
- var a = 0 === e.length
- , s = i.apply(e, r);
- return a && (null === (n = t.getScene()) || void 0 === n || n.meshes.forEach((function(e) {
- e._markSubMeshesAsLightDirty()
- }
- ))),
- s
- }
- ;
- var n = e.splice;
- e.splice = function(i, r) {
- var o, a = n.apply(e, [i, r]);
- return 0 === e.length && (null === (o = t.getScene()) || void 0 === o || o.meshes.forEach((function(e) {
- e._markSubMeshesAsLightDirty()
- }
- ))),
- a
- }
- }
- ,
- Object.defineProperty(t.prototype, "postProcesses", {
- get: function() {
- return this._postProcesses
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_prePassEnabled", {
- get: function() {
- return !!this._prePassRenderTarget && this._prePassRenderTarget.enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onAfterUnbind", {
- set: function(e) {
- this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
- this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBeforeRender", {
- set: function(e) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onAfterRender", {
- set: function(e) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onClear", {
- set: function(e) {
- this._onClearObserver && this.onClearObservable.remove(this._onClearObserver),
- this._onClearObserver = this.onClearObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "renderPassIds", {
- get: function() {
- return this._renderPassIds
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "currentRefreshId", {
- get: function() {
- return this._currentRefreshId
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setMaterialForRendering = function(e, t) {
- var i;
- i = Array.isArray(e) ? e : [e];
- for (var n = 0; n < i.length; ++n)
- for (var r = 0; r < this._renderPassIds.length; ++r)
- i[n].setMaterialForRenderPass(this._renderPassIds[r], void 0 !== t ? Array.isArray(t) ? t[r] : t : void 0)
- }
- ,
- Object.defineProperty(t.prototype, "renderTargetOptions", {
- get: function() {
- return this._renderTargetOptions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "renderTarget", {
- get: function() {
- return this._renderTarget
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._onRatioRescale = function() {
- this._sizeRatio && this.resize(this._initialSizeParameter)
- }
- ,
- Object.defineProperty(t.prototype, "boundingBoxSize", {
- get: function() {
- return this._boundingBoxSize
- },
- set: function(e) {
- if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
- this._boundingBoxSize = e;
- var t = this.getScene();
- t && t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthStencilTexture", {
- get: function() {
- var e, t;
- return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e._depthStencilTexture) && void 0 !== t ? t : null
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.createDepthStencilTexture = function(e, t, i, n, r) {
- var o;
- void 0 === e && (e = 0),
- void 0 === t && (t = !0),
- void 0 === i && (i = !1),
- void 0 === n && (n = 1),
- void 0 === r && (r = a.TEXTUREFORMAT_DEPTH32_FLOAT),
- null === (o = this._renderTarget) || void 0 === o || o.createDepthStencilTexture(e, t, i, n, r)
- }
- ,
- t.prototype._releaseRenderPassId = function() {
- if (this._scene)
- for (var e = this._scene.getEngine(), t = 0; t < this._renderPassIds.length; ++t)
- e.releaseRenderPassId(this._renderPassIds[t]);
- this._renderPassIds = []
- }
- ,
- t.prototype._createRenderPassId = function() {
- this._releaseRenderPassId();
- for (var e = this._scene.getEngine(), t = this._isCubeData ? 6 : this.getRenderLayers() || 1, i = 0; i < t; ++i)
- this._renderPassIds[i] = e.createRenderPassId("RenderTargetTexture - ".concat(this.name, "#").concat(i))
- }
- ,
- t.prototype._processSizeParameter = function(e) {
- if (e.ratio) {
- this._sizeRatio = e.ratio;
- var t = this._getEngine();
- this._size = {
- width: this._bestReflectionRenderTargetDimension(t.getRenderWidth(), this._sizeRatio),
- height: this._bestReflectionRenderTargetDimension(t.getRenderHeight(), this._sizeRatio)
- }
- } else
- this._size = e;
- this._createRenderPassId()
- }
- ,
- Object.defineProperty(t.prototype, "samples", {
- get: function() {
- var e, t;
- return null !== (t = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.samples) && void 0 !== t ? t : this._samples
- },
- set: function(e) {
- this._renderTarget && (this._samples = this._renderTarget.setSamples(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.resetRefreshCounter = function() {
- this._currentRefreshId = -1
- }
- ,
- Object.defineProperty(t.prototype, "refreshRate", {
- get: function() {
- return this._refreshRate
- },
- set: function(e) {
- this._refreshRate = e,
- this.resetRefreshCounter()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addPostProcess = function(e) {
- if (!this._postProcessManager) {
- var t = this.getScene();
- if (!t)
- return;
- this._postProcessManager = new Vi(t),
- this._postProcesses = new Array
- }
- this._postProcesses.push(e),
- this._postProcesses[0].autoClear = !1
- }
- ,
- t.prototype.clearPostProcesses = function(e) {
- if (void 0 === e && (e = !1),
- this._postProcesses) {
- if (e)
- for (var t = 0, i = this._postProcesses; t < i.length; t++)
- i[t].dispose();
- this._postProcesses = []
- }
- }
- ,
- t.prototype.removePostProcess = function(e) {
- if (this._postProcesses) {
- var t = this._postProcesses.indexOf(e);
- -1 !== t && (this._postProcesses.splice(t, 1),
- this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1))
- }
- }
- ,
- t.prototype._shouldRender = function() {
- return -1 === this._currentRefreshId || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
- !0) : (this._currentRefreshId++,
- !1)
- }
- ,
- t.prototype.getRenderSize = function() {
- return this.getRenderWidth()
- }
- ,
- t.prototype.getRenderWidth = function() {
- return this._size.width ? this._size.width : this._size
- }
- ,
- t.prototype.getRenderHeight = function() {
- return this._size.width ? this._size.height : this._size
- }
- ,
- t.prototype.getRenderLayers = function() {
- return this._size.layers || 0
- }
- ,
- t.prototype.disableRescaling = function() {
- this._canRescale = !1
- }
- ,
- Object.defineProperty(t.prototype, "canRescale", {
- get: function() {
- return this._canRescale
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.scale = function(e) {
- var t = Math.max(1, this.getRenderSize() * e);
- this.resize(t)
- }
- ,
- t.prototype.getReflectionTextureMatrix = function() {
- return this.isCube ? this._textureMatrix : e.prototype.getReflectionTextureMatrix.call(this)
- }
- ,
- t.prototype.resize = function(e) {
- var t, i = this.isCube;
- null === (t = this._renderTarget) || void 0 === t || t.dispose(),
- this._renderTarget = null;
- var n = this.getScene();
- n && (this._processSizeParameter(e),
- this._renderTarget = i ? n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : n.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions),
- this._texture = this._renderTarget.texture,
- void 0 !== this._renderTargetOptions.samples && (this.samples = this._renderTargetOptions.samples),
- this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this))
- }
- ,
- t.prototype.render = function(e, t) {
- void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- this._render(e, t)
- }
- ,
- t.prototype.isReadyForRendering = function() {
- return this._render(!1, !1, !0)
- }
- ,
- t.prototype._render = function(e, t, i) {
- var n;
- void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- void 0 === i && (i = !1);
- var r = this.getScene();
- if (!r)
- return i;
- var o = r.getEngine();
- if (void 0 !== this.useCameraPostProcesses && (e = this.useCameraPostProcesses),
- this._waitingRenderList) {
- this.renderList = [];
- for (var a = 0; a < this._waitingRenderList.length; a++) {
- var s = this._waitingRenderList[a];
- (u = r.getMeshById(s)) && this.renderList.push(u)
- }
- this._waitingRenderList = void 0
- }
- if (this.renderListPredicate) {
- this.renderList ? this.renderList.length = 0 : this.renderList = [];
- var l = this.getScene();
- if (!l)
- return i;
- var c = l.meshes;
- for (a = 0; a < c.length; a++) {
- var u = c[a];
- this.renderListPredicate(u) && this.renderList.push(u)
- }
- }
- var h = o.currentRenderPassId;
- this.onBeforeBindObservable.notifyObservers(this);
- var d = null !== (n = this.activeCamera) && void 0 !== n ? n : r.activeCamera;
- d && (d !== r.activeCamera && r.setTransformMatrix(d.getViewMatrix(), d.getProjectionMatrix(!0)),
- o.setViewport(d.viewport, this.getRenderWidth(), this.getRenderHeight())),
- this._defaultRenderListPrepared = !1;
- var p = i;
- if (i) {
- r.getViewMatrix() || r.updateTransformMatrix();
- var f = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1;
- for (y = 0; y < f && p; y++) {
- var _ = null
- , m = this.renderList ? this.renderList : r.getActiveMeshes().data
- , g = this.renderList ? this.renderList.length : r.getActiveMeshes().length;
- o.currentRenderPassId = this._renderPassIds[y],
- this.onBeforeRenderObservable.notifyObservers(y),
- this.getCustomRenderList && (_ = this.getCustomRenderList(y, m, g)),
- _ || (_ = m),
- this._doNotChangeAspectRatio || r.updateTransformMatrix(!0);
- for (var v = 0; v < _.length && p; ++v)
- if ((u = _[v]).isEnabled() && !u.isBlocked && u.isVisible && u.subMeshes)
- if (this.customIsReadyFunction) {
- if (!this.customIsReadyFunction(u, this.refreshRate)) {
- p = !1;
- break
- }
- } else if (!u.isReady(!0)) {
- p = !1;
- break
- }
- this.onAfterRenderObservable.notifyObservers(y)
- }
- } else if (this.is2DArray)
- for (var y = 0; y < this.getRenderLayers(); y++)
- this._renderToTarget(0, e, t, y, d),
- r.incrementRenderId(),
- r.resetCachedMaterial();
- else if (this.isCube)
- for (var b = 0; b < 6; b++)
- this._renderToTarget(b, e, t, void 0, d),
- r.incrementRenderId(),
- r.resetCachedMaterial();
- else
- this._renderToTarget(0, e, t, void 0, d);
- return this.onAfterUnbindObservable.notifyObservers(this),
- o.currentRenderPassId = h,
- r.activeCamera && ((r.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== r.activeCamera) && r.setTransformMatrix(r.activeCamera.getViewMatrix(), r.activeCamera.getProjectionMatrix(!0)),
- o.setViewport(r.activeCamera.viewport)),
- r.resetCachedMaterial(),
- p
- }
- ,
- t.prototype._bestReflectionRenderTargetDimension = function(e, t) {
- var i = e * t
- , n = vr.NearestPOT(i + 16384 / (128 + i));
- return Math.min(vr.FloorPOT(e), n)
- }
- ,
- t.prototype._prepareRenderingManager = function(e, t, i, n) {
- var r = this.getScene();
- if (r) {
- this._renderingManager.reset();
- for (var o = r.getRenderId(), a = 0; a < t; a++) {
- var s = e[a];
- if (s && !s.isBlocked) {
- if (this.customIsReadyFunction) {
- if (!this.customIsReadyFunction(s, this.refreshRate)) {
- this.resetRefreshCounter();
- continue
- }
- } else if (!s.isReady(0 === this.refreshRate)) {
- this.resetRefreshCounter();
- continue
- }
- if (!s._internalAbstractMeshDataInfo._currentLODIsUpToDate && r.activeCamera && (s._internalAbstractMeshDataInfo._currentLOD = r.customLODSelector ? r.customLODSelector(s, this.activeCamera || r.activeCamera) : s.getLOD(this.activeCamera || r.activeCamera),
- s._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0),
- !s._internalAbstractMeshDataInfo._currentLOD)
- continue;
- var l = s._internalAbstractMeshDataInfo._currentLOD;
- l._preActivateForIntermediateRendering(o);
- var c;
- if (c = !(!n || !i) && 0 == (s.layerMask & i.layerMask),
- s.isEnabled() && s.isVisible && s.subMeshes && !c && (l !== s && l._activate(o, !0),
- s._activate(o, !0) && s.subMeshes.length)) {
- s.isAnInstance ? s._internalAbstractMeshDataInfo._actAsRegularMesh && (l = s) : l._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1,
- l._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
- for (var u = 0; u < l.subMeshes.length; u++) {
- var h = l.subMeshes[u];
- this._renderingManager.dispatch(h, l)
- }
- }
- }
- }
- for (var d = 0; d < r.particleSystems.length; d++) {
- var p = r.particleSystems[d]
- , f = p.emitter;
- p.isStarted() && f && f.position && f.isEnabled() && e.indexOf(f) >= 0 && this._renderingManager.dispatchParticles(p)
- }
- }
- }
- ,
- t.prototype._bindFrameBuffer = function(e, t) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0);
- var i = this.getScene();
- if (i) {
- var n = i.getEngine();
- this._renderTarget && n.bindFramebuffer(this._renderTarget, this.isCube ? e : void 0, void 0, void 0, this.ignoreCameraViewport, 0, t)
- }
- }
- ,
- t.prototype._unbindFrameBuffer = function(e, t) {
- var i = this;
- this._renderTarget && e.unBindFramebuffer(this._renderTarget, this.isCube, (function() {
- i.onAfterRenderObservable.notifyObservers(t)
- }
- ))
- }
- ,
- t.prototype._prepareFrame = function(e, t, i, n) {
- this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : n && e.postProcessManager._prepareFrame(this._texture) || this._bindFrameBuffer(t, i)
- }
- ,
- t.prototype._renderToTarget = function(e, t, i, n, r) {
- var o, s, l, c;
- void 0 === n && (n = 0),
- void 0 === r && (r = null);
- var u = this.getScene();
- if (u) {
- var h = u.getEngine();
- if (this._texture) {
- if (null === (o = h._debugPushGroup) || void 0 === o || o.call(h, "render to face #".concat(e, " layer #").concat(n), 1),
- this._prepareFrame(u, e, n, t),
- this.is2DArray ? (h.currentRenderPassId = this._renderPassIds[n],
- this.onBeforeRenderObservable.notifyObservers(n)) : (h.currentRenderPassId = this._renderPassIds[e],
- this.onBeforeRenderObservable.notifyObservers(e)),
- h.snapshotRendering && h.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST)
- this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(h) : this.skipInitialClear || h.clear(this.clearColor || u.clearColor, !0, !0, !0);
- else {
- var d = null
- , p = this.renderList ? this.renderList : u.getActiveMeshes().data
- , f = this.renderList ? this.renderList.length : u.getActiveMeshes().length;
- this.getCustomRenderList && (d = this.getCustomRenderList(this.is2DArray ? n : e, p, f)),
- d ? this._prepareRenderingManager(d, d.length, r, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(p, f, r, !this.renderList),
- this._defaultRenderListPrepared = !0),
- d = p);
- for (var _ = 0, m = u._beforeRenderTargetClearStage; _ < m.length; _++)
- m[_].action(this, e, n);
- this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(h) : this.skipInitialClear || h.clear(this.clearColor || u.clearColor, !0, !0, !0),
- this._doNotChangeAspectRatio || u.updateTransformMatrix(!0);
- for (var g = 0, v = u._beforeRenderTargetDrawStage; g < v.length; g++)
- v[g].action(this, e, n);
- this._renderingManager.render(this.customRenderFunction, d, this.renderParticles, this.renderSprites);
- for (var y = 0, b = u._afterRenderTargetDrawStage; y < b.length; y++)
- b[y].action(this, e, n);
- var T = this._texture.generateMipMaps;
- this._texture.generateMipMaps = !1,
- this._postProcessManager ? this._postProcessManager._finalizeFrame(!1, null !== (s = this._renderTarget) && void 0 !== s ? s : void 0, e, this._postProcesses, this.ignoreCameraViewport) : t && u.postProcessManager._finalizeFrame(!1, null !== (l = this._renderTarget) && void 0 !== l ? l : void 0, e),
- this._texture.generateMipMaps = T,
- this._doNotChangeAspectRatio || u.updateTransformMatrix(!0),
- i && gi.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), h)
- }
- this._unbindFrameBuffer(h, e),
- this.isCube && 5 === e && h.generateMipMapsForCubemap(this._texture),
- null === (c = h._debugPopGroup) || void 0 === c || c.call(h, 1)
- }
- }
- }
- ,
- t.prototype.setRenderingOrder = function(e, t, i, n) {
- void 0 === t && (t = null),
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- this._renderingManager.setRenderingOrder(e, t, i, n)
- }
- ,
- t.prototype.setRenderingAutoClearDepthStencil = function(e, t) {
- this._renderingManager.setRenderingAutoClearDepthStencil(e, t),
- this._renderingManager._useSceneAutoClearSetup = !1
- }
- ,
- t.prototype.clone = function() {
- var e = this.getSize()
- , i = new t(this.name,e,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 i.hasAlpha = this.hasAlpha,
- i.level = this.level,
- i.coordinatesMode = this.coordinatesMode,
- this.renderList && (i.renderList = this.renderList.slice(0)),
- i
- }
- ,
- t.prototype.serialize = function() {
- if (!this.name)
- return null;
- var t = e.prototype.serialize.call(this);
- if (t.renderTargetSize = this.getRenderSize(),
- t.renderList = [],
- this.renderList)
- for (var i = 0; i < this.renderList.length; i++)
- t.renderList.push(this.renderList[i].id);
- return t
- }
- ,
- t.prototype.disposeFramebufferObjects = function() {
- var e;
- null === (e = this._renderTarget) || void 0 === e || e.dispose(!0)
- }
- ,
- t.prototype.releaseInternalTexture = function() {
- var e;
- null === (e = this._renderTarget) || void 0 === e || e.releaseTextures(),
- this._texture = null
- }
- ,
- t.prototype.dispose = function() {
- var t;
- 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 i = this.getScene();
- if (i) {
- var n = i.customRenderTargets.indexOf(this);
- n >= 0 && i.customRenderTargets.splice(n, 1);
- for (var r = 0, o = i.cameras; r < o.length; r++) {
- var a = o[r];
- (n = a.customRenderTargets.indexOf(this)) >= 0 && a.customRenderTargets.splice(n, 1)
- }
- null === (t = this._renderTarget) || void 0 === t || t.dispose(),
- this._renderTarget = null,
- this._texture = null,
- e.prototype.dispose.call(this)
- }
- }
- ,
- t.prototype._rebuild = function() {
- this.refreshRate === t.REFRESHRATE_RENDER_ONCE && (this.refreshRate = t.REFRESHRATE_RENDER_ONCE),
- this._postProcessManager && this._postProcessManager._rebuild()
- }
- ,
- t.prototype.freeRenderingGroups = function() {
- this._renderingManager && this._renderingManager.freeRenderingGroups()
- }
- ,
- t.prototype.getViewCount = function() {
- return 1
- }
- ,
- t.REFRESHRATE_RENDER_ONCE = 0,
- t.REFRESHRATE_RENDER_ONEVERYFRAME = 1,
- t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2,
- t
- }(io);
- io._CreateRenderTargetTexture = function(e, t, i, n, r) {
- return new ns(e,t,i,n)
- }
- ;
- var rs = function(e) {
- function t(t, i) {
- void 0 === i && (i = 512);
- var n = e.call(this, "multiview rtt", i, t, !1, !0, a.TEXTURETYPE_UNSIGNED_INT, !1, void 0, !1, !1, !0, void 0, !0) || this;
- return n._renderTarget = n.getScene().getEngine().createMultiviewRenderTargetTexture(n.getRenderWidth(), n.getRenderHeight()),
- n._texture = n._renderTarget.texture,
- n._texture.isMultiview = !0,
- n._texture.format = a.TEXTUREFORMAT_RGBA,
- n.samples = n._getEngine().getCaps().maxSamples || n.samples,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "samples", {
- set: function(e) {
- this._samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._bindFrameBuffer = function() {
- this._renderTarget && this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)
- }
- ,
- t.prototype.getViewCount = function() {
- return 2
- }
- ,
- t
- }(ns);
- function os(e, t) {
- var i = new Fi(e,void 0,!0,t);
- return i.addUniform("viewProjection", 16),
- i.addUniform("viewProjectionR", 16),
- i.addUniform("view", 16),
- i.addUniform("projection", 16),
- i.addUniform("vEyePosition", 4),
- i
- }
- vr.prototype.createMultiviewRenderTargetTexture = function(e, t) {
- var i = this._gl;
- if (!this.getCaps().multiview)
- throw "Multiview is not supported";
- var n = this._createHardwareRenderTargetWrapper(!1, !1, {
- width: e,
- height: t
- });
- n._framebuffer = i.createFramebuffer();
- var r = new Lt(this,At.Unknown,!0);
- return r.width = e,
- r.height = t,
- r.isMultiview = !0,
- n._colorTextureArray = i.createTexture(),
- i.bindTexture(i.TEXTURE_2D_ARRAY, n._colorTextureArray),
- i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.RGBA8, e, t, 2),
- n._depthStencilTextureArray = i.createTexture(),
- i.bindTexture(i.TEXTURE_2D_ARRAY, n._depthStencilTextureArray),
- i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.DEPTH24_STENCIL8, e, t, 2),
- r.isReady = !0,
- n.setTextures(r),
- n._depthStencilTexture = r,
- n
- }
- ,
- vr.prototype.bindMultiviewFramebuffer = function(e) {
- var t = e
- , i = this._gl
- , n = this.getCaps().oculusMultiview || this.getCaps().multiview;
- if (this.bindFramebuffer(t, void 0, void 0, void 0, !0),
- i.bindFramebuffer(i.DRAW_FRAMEBUFFER, t._framebuffer),
- !t._colorTextureArray || !t._depthStencilTextureArray)
- throw "Invalid multiview frame buffer";
- this.getCaps().oculusMultiview ? (n.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, t._colorTextureArray, 0, t.samples, 0, 2),
- n.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, t.samples, 0, 2)) : (n.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, t._colorTextureArray, 0, 0, 2),
- n.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, t._depthStencilTextureArray, 0, 0, 2))
- }
- ,
- Rr.prototype._useMultiviewToSingleView = !1,
- Rr.prototype._multiviewTexture = null,
- Rr.prototype._resizeOrCreateMultiviewTexture = function(e, t) {
- this._multiviewTexture ? this._multiviewTexture.getRenderWidth() == e && this._multiviewTexture.getRenderHeight() == t || (this._multiviewTexture.dispose(),
- this._multiviewTexture = new rs(this.getScene(),{
- width: e,
- height: t
- })) : this._multiviewTexture = new rs(this.getScene(),{
- width: e,
- height: t
- })
- }
- ;
- var as = mn.prototype.createSceneUniformBuffer;
- mn.prototype._transformMatrixR = P.Zero(),
- mn.prototype._multiviewSceneUbo = null,
- mn.prototype._createMultiviewUbo = function() {
- this._multiviewSceneUbo = os(this.getEngine(), "scene_multiview")
- }
- ,
- mn.prototype.createSceneUniformBuffer = function(e) {
- return this._multiviewSceneUbo ? os(this.getEngine(), e) : as.bind(this)(e)
- }
- ,
- mn.prototype._updateMultiviewUbo = function(e, t) {
- e && t && e.multiplyToRef(t, this._transformMatrixR),
- e && t && (e.multiplyToRef(t, I.Matrix[0]),
- dn.GetRightPlaneToRef(I.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))
- }
- ,
- mn.prototype._renderMultiviewToSingleView = function(e) {
- e._resizeOrCreateMultiviewTexture(e._rigPostProcess && e._rigPostProcess && e._rigPostProcess.width > 0 ? e._rigPostProcess.width : this.getEngine().getRenderWidth(!0), e._rigPostProcess && e._rigPostProcess && e._rigPostProcess.height > 0 ? e._rigPostProcess.height : this.getEngine().getRenderHeight(!0)),
- this._multiviewSceneUbo || this._createMultiviewUbo(),
- e.outputRenderTarget = e._multiviewTexture,
- this._renderForCamera(e),
- e.outputRenderTarget = null;
- for (var t = 0; t < e._rigCameras.length; t++) {
- var i = this.getEngine();
- this._activeCamera = e._rigCameras[t],
- i.setViewport(this._activeCamera.viewport),
- this.postProcessManager && (this.postProcessManager._prepareFrame(),
- this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))
- }
- }
- ;
- var ss = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], n, i, io.BILINEAR_SAMPLINGMODE) || this;
- return r.onSizeChangedObservable.add((function() {}
- )),
- r.onApplyObservable.add((function(e) {
- i._scene.activeCamera && i._scene.activeCamera.isLeftCamera ? e.setInt("imageIndex", 0) : e.setInt("imageIndex", 1),
- e.setTexture("multiviewSampler", i._multiviewTexture)
- }
- )),
- r
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VRMultiviewToSingleviewPostProcess"
- }
- ,
- t
- }(Ba);
- function ls(e, t) {
- var i = t.vrCameraMetrics || ts.GetDefault();
- e._rigCameras[0]._cameraRigParams.vrMetrics = i,
- e._rigCameras[0].viewport = new xr(0,0,.5,1),
- e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new P,
- e._rigCameras[0]._cameraRigParams.vrHMatrix = i.leftHMatrix,
- e._rigCameras[0]._cameraRigParams.vrPreViewMatrix = i.leftPreViewMatrix,
- e._rigCameras[0].getProjectionMatrix = e._rigCameras[0]._getVRProjectionMatrix,
- e._rigCameras[1]._cameraRigParams.vrMetrics = i,
- e._rigCameras[1].viewport = new xr(.5,0,.5,1),
- e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new P,
- e._rigCameras[1]._cameraRigParams.vrHMatrix = i.rightHMatrix,
- e._rigCameras[1]._cameraRigParams.vrPreViewMatrix = i.rightPreViewMatrix,
- e._rigCameras[1].getProjectionMatrix = e._rigCameras[1]._getVRProjectionMatrix,
- i.multiviewEnabled && (e.getScene().getEngine().getCaps().multiview ? (e._useMultiviewToSingleView = !0,
- e._rigPostProcess = new ss("VRMultiviewToSingleview",e,i.postProcessScaleFactor)) : (K.Warn("Multiview is not supported, falling back to standard rendering"),
- i.multiviewEnabled = !1)),
- i.compensateDistortion && (e._rigCameras[0]._rigPostProcess = new is("VR_Distort_Compensation_Left",e._rigCameras[0],!1,i),
- e._rigCameras[1]._rigPostProcess = new is("VR_Distort_Compensation_Right",e._rigCameras[1],!0,i))
- }
- Xe.AddNodeConstructor("VRDeviceOrientationArcRotateCamera", (function(e, t) {
- return function() {
- return new cs(e,0,0,1,x.Zero(),t)
- }
- }
- ));
- var cs = function(e) {
- function t(t, i, n, r, o, a, s, l) {
- void 0 === s && (s = !0),
- void 0 === l && (l = ts.GetDefault());
- var c = e.call(this, t, i, n, r, o, a) || this;
- return c._setRigMode = ls.bind(null, c),
- l.compensateDistortion = s,
- c.setCameraRigMode(Rr.RIG_MODE_VR, {
- vrCameraMetrics: l
- }),
- c.inputs.addVRDeviceOrientation(),
- c
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VRDeviceOrientationArcRotateCamera"
- }
- ,
- t
- }(_a);
- Xe.AddNodeConstructor("VRDeviceOrientationFreeCamera", (function(e, t) {
- return function() {
- return new us(e,x.Zero(),t)
- }
- }
- ));
- var us = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = !0),
- void 0 === o && (o = ts.GetDefault());
- var a = e.call(this, t, i, n) || this;
- return a._setRigMode = ls.bind(null, a),
- o.compensateDistortion = r,
- a.setCameraRigMode(Rr.RIG_MODE_VR, {
- vrCameraMetrics: o
- }),
- a
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VRDeviceOrientationFreeCamera"
- }
- ,
- t
- }(ma);
- Xe.AddNodeConstructor("VRDeviceOrientationGamepadCamera", (function(e, t) {
- return function() {
- return new hs(e,x.Zero(),t)
- }
- }
- ));
- var hs = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = !0),
- void 0 === o && (o = ts.GetDefault());
- var a = e.call(this, t, i, n, r, o) || this;
- return a._setRigMode = ls.bind(null, a),
- a.inputs.addGamepad(),
- a
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VRDeviceOrientationGamepadCamera"
- }
- ,
- t
- }(us);
- Xe.AddNodeConstructor("Light_Type_3", (function(e, t) {
- return function() {
- return new ds(e,x.Zero(),t)
- }
- }
- ));
- var ds = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r.groundColor = new D(0,0,0),
- r.direction = i || x.Up(),
- r
- }
- return U(t, e),
- t.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()
- }
- ,
- t.prototype.getClassName = function() {
- return "HemisphericLight"
- }
- ,
- t.prototype.setDirectionToTarget = function(e) {
- return this.direction = x.Normalize(e.subtract(x.Zero())),
- this.direction
- }
- ,
- t.prototype.getShadowGenerator = function() {
- return null
- }
- ,
- t.prototype.transferToEffect = function(e, t) {
- var i = x.Normalize(this.direction);
- return this._uniformBuffer.updateFloat4("vLightData", i.x, i.y, i.z, 0, t),
- this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), t),
- this
- }
- ,
- t.prototype.transferToNodeMaterialEffect = function(e, t) {
- var i = x.Normalize(this.direction);
- return e.setFloat3(t, i.x, i.y, i.z),
- this
- }
- ,
- t.prototype.computeWorldMatrix = function() {
- return this._worldMatrix || (this._worldMatrix = P.Identity()),
- this._worldMatrix
- }
- ,
- t.prototype.getTypeID = function() {
- return Cr.LIGHTTYPEID_HEMISPHERICLIGHT
- }
- ,
- t.prototype.prepareLightSpecificDefines = function(e, t) {
- e["HEMILIGHT" + t] = !0
- }
- ,
- k([Me()], t.prototype, "groundColor", void 0),
- k([De()], t.prototype, "direction", void 0),
- t
- }(Cr);
- function ps(e, t) {
- if (t.vrDisplay) {
- var i = t.vrDisplay.getEyeParameters("left")
- , n = t.vrDisplay.getEyeParameters("right");
- e._rigCameras[0].viewport = new xr(0,0,.5,1),
- e._rigCameras[0].setCameraRigParameter("left", !0),
- e._rigCameras[0].setCameraRigParameter("specs", t.specs),
- e._rigCameras[0].setCameraRigParameter("eyeParameters", i),
- e._rigCameras[0].setCameraRigParameter("frameData", t.frameData),
- e._rigCameras[0].setCameraRigParameter("parentCamera", t.parentCamera),
- e._rigCameras[0]._cameraRigParams.vrWorkMatrix = new P,
- e._rigCameras[0].getProjectionMatrix = e._getWebVRProjectionMatrix,
- e._rigCameras[0].parent = e,
- e._rigCameras[0]._getViewMatrix = e._getWebVRViewMatrix,
- e._rigCameras[1].viewport = new xr(.5,0,.5,1),
- e._rigCameras[1].setCameraRigParameter("eyeParameters", n),
- e._rigCameras[1].setCameraRigParameter("specs", t.specs),
- e._rigCameras[1].setCameraRigParameter("frameData", t.frameData),
- e._rigCameras[1].setCameraRigParameter("parentCamera", t.parentCamera),
- e._rigCameras[1]._cameraRigParams.vrWorkMatrix = new P,
- e._rigCameras[1].getProjectionMatrix = e._getWebVRProjectionMatrix,
- e._rigCameras[1].parent = e,
- e._rigCameras[1]._getViewMatrix = e._getWebVRViewMatrix
- }
- }
- Object.defineProperty(vr.prototype, "isInVRExclusivePointerMode", {
- get: function() {
- return this._vrExclusivePointerMode
- },
- enumerable: !0,
- configurable: !0
- }),
- vr.prototype._prepareVRComponent = function() {
- this._vrSupported = !1,
- this._vrExclusivePointerMode = !1,
- this.onVRDisplayChangedObservable = new h,
- this.onVRRequestPresentComplete = new h,
- this.onVRRequestPresentStart = new h
- }
- ,
- vr.prototype.isVRDevicePresent = function() {
- return !!this._vrDisplay
- }
- ,
- vr.prototype.getVRDevice = function() {
- return this._vrDisplay
- }
- ,
- vr.prototype.initWebVR = function() {
- return this.initWebVRAsync(),
- this.onVRDisplayChangedObservable
- }
- ,
- vr.prototype.initWebVRAsync = function() {
- var e = this
- , t = function() {
- var t = {
- vrDisplay: e._vrDisplay,
- vrSupported: e._vrSupported
- };
- e.onVRDisplayChangedObservable.notifyObservers(t),
- e._webVRInitPromise = new Promise((function(e) {
- e(t)
- }
- ))
- };
- if (!this._onVrDisplayConnect) {
- this._onVrDisplayConnect = function(i) {
- e._vrDisplay = i.display,
- t()
- }
- ,
- this._onVrDisplayDisconnect = function() {
- e._vrDisplay.cancelAnimationFrame(e._frameHandler),
- e._vrDisplay = void 0,
- e._frameHandler = vr.QueueNewFrame(e._boundRenderFunction),
- t()
- }
- ,
- this._onVrDisplayPresentChange = function() {
- e._vrExclusivePointerMode = e._vrDisplay && e._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(t),
- this._webVRInitPromise
- }
- ,
- vr.prototype._getVRDisplaysAsync = function() {
- var e = this;
- return new Promise((function(t) {
- navigator.getVRDisplays ? navigator.getVRDisplays().then((function(i) {
- e._vrSupported = !0,
- e._vrDisplay = i[0],
- t({
- vrDisplay: e._vrDisplay,
- vrSupported: e._vrSupported
- })
- }
- )) : (e._vrDisplay = void 0,
- e._vrSupported = !1,
- t({
- vrDisplay: e._vrDisplay,
- vrSupported: e._vrSupported
- }))
- }
- ))
- }
- ,
- vr.prototype.enableVR = function(e) {
- var t = this;
- if (this._vrDisplay && !this._vrDisplay.isPresenting) {
- this.onVRRequestPresentStart.notifyObservers(this);
- var i = {
- highRefreshRate: !!this.vrPresentationAttributes && this.vrPresentationAttributes.highRefreshRate,
- foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1,
- multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && e.useMultiview
- };
- this._vrDisplay.requestPresent([V({
- source: this.getRenderingCanvas(),
- attributes: i
- }, i)]).then((function() {
- t.onVRRequestPresentComplete.notifyObservers(!0),
- t._onVRFullScreenTriggered()
- }
- )).catch((function() {
- t.onVRRequestPresentComplete.notifyObservers(!1)
- }
- ))
- }
- }
- ,
- vr.prototype._onVRFullScreenTriggered = function() {
- if (this._vrDisplay && this._vrDisplay.isPresenting) {
- this._oldSize = new je(this.getRenderWidth(),this.getRenderHeight()),
- this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
- var e = this._vrDisplay.getEyeParameters("left");
- this.setHardwareScalingLevel(1),
- this.setSize(2 * e.renderWidth, e.renderHeight)
- } else
- this.setHardwareScalingLevel(this._oldHardwareScaleFactor),
- this.setSize(this._oldSize.width, this._oldSize.height)
- }
- ,
- vr.prototype.disableVR = function() {
- var e = this;
- this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then((function() {
- return e._onVRFullScreenTriggered()
- }
- )).catch((function() {
- return e._onVRFullScreenTriggered()
- }
- )),
- nt() && (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))
- }
- ,
- vr.prototype._connectVREvents = function(e, t) {
- var i = this;
- if (this._onVRDisplayPointerRestricted = function() {
- e && e.requestPointerLock()
- }
- ,
- this._onVRDisplayPointerUnrestricted = function() {
- if (t)
- t.exitPointerLock && t.exitPointerLock();
- else {
- var e = i.getHostWindow();
- e.document && e.document.exitPointerLock && e.document.exitPointerLock()
- }
- }
- ,
- nt()) {
- var n = this.getHostWindow();
- n.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1),
- n.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1)
- }
- }
- ,
- vr.prototype._submitVRFrame = function() {
- if (this._vrDisplay && this._vrDisplay.isPresenting)
- try {
- this._vrDisplay.submitFrame()
- } catch (e) {
- gi.Warn("webVR submitFrame has had an unexpected failure: " + e)
- }
- }
- ,
- vr.prototype.isVRPresenting = function() {
- return this._vrDisplay && this._vrDisplay.isPresenting
- }
- ,
- vr.prototype._requestVRFrame = function() {
- this._frameHandler = vr.QueueNewFrame(this._boundRenderFunction, this._vrDisplay)
- }
- ,
- Xe.AddNodeConstructor("WebVRFreeCamera", (function(e, t) {
- return function() {
- return new fs(e,x.Zero(),t)
- }
- }
- )),
- Xe.AddNodeConstructor("WebVRGamepadCamera", (function(e, t) {
- return function() {
- return new fs(e,x.Zero(),t)
- }
- }
- ));
- var fs = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = {});
- var o = e.call(this, t, i, n) || this;
- o._webVROptions = r,
- o._vrDevice = null,
- o.rawPose = null,
- o._specsVersion = "1.1",
- o._attached = !1,
- o._descendants = [],
- o._deviceRoomPosition = x.Zero(),
- o._deviceRoomRotationQuaternion = C.Identity(),
- o._standingMatrix = null,
- o.devicePosition = x.Zero(),
- o.deviceRotationQuaternion = C.Identity(),
- o.deviceScaleFactor = 1,
- o._deviceToWorld = P.Identity(),
- o._worldToDevice = P.Identity(),
- o.controllers = [],
- o.onControllersAttachedObservable = new h,
- o.onControllerMeshLoadedObservable = new h,
- o.onPoseUpdatedFromDeviceObservable = new h,
- o._poseSet = !1,
- o.rigParenting = !0,
- o._defaultHeight = void 0,
- o._setRigMode = ps.bind(null, o),
- o._detachIfAttached = function() {
- var e = o.getEngine().getVRDevice();
- e && !e.isPresenting && o.detachControl()
- }
- ,
- o._workingVector = x.Zero(),
- o._oneVector = x.One(),
- o._workingMatrix = P.Identity(),
- o._tmpMatrix = new P,
- o._cache.position = x.Zero(),
- r.defaultHeight && (o._defaultHeight = r.defaultHeight,
- o.position.y = o._defaultHeight),
- o.minZ = .1,
- 5 === arguments.length && (o._webVROptions = arguments[4]),
- null == o._webVROptions.trackPosition && (o._webVROptions.trackPosition = !0),
- null == o._webVROptions.controllerMeshes && (o._webVROptions.controllerMeshes = !0),
- null == o._webVROptions.defaultLightingOnControllers && (o._webVROptions.defaultLightingOnControllers = !0),
- o.rotationQuaternion = new C,
- o._webVROptions && o._webVROptions.positionScale && (o.deviceScaleFactor = o._webVROptions.positionScale);
- var a = o.getEngine();
- return o._onVREnabled = function(e) {
- e && o.initControllers()
- }
- ,
- a.onVRRequestPresentComplete.add(o._onVREnabled),
- a.initWebVR().add((function(e) {
- e.vrDisplay && o._vrDevice !== e.vrDisplay && (o._vrDevice = e.vrDisplay,
- o.setCameraRigMode(Rr.RIG_MODE_WEBVR, {
- parentCamera: o,
- vrDisplay: o._vrDevice,
- frameData: o._frameData,
- specs: o._specsVersion
- }),
- o._attached && o.getEngine().enableVR(o._webVROptions))
- }
- )),
- "undefined" != typeof VRFrameData && (o._frameData = new VRFrameData),
- r.useMultiview && (o.getScene().getEngine().getCaps().multiview ? (o._useMultiviewToSingleView = !0,
- o._rigPostProcess = new ss("VRMultiviewToSingleview",o,1)) : (K.Warn("Multiview is not supported, falling back to standard rendering"),
- o._useMultiviewToSingleView = !1)),
- o.getScene().onBeforeCameraRenderObservable.add((function(e) {
- e.parent === o && o.rigParenting && (o._descendants = o.getDescendants(!0, (function(e) {
- var t = o.controllers.some((function(t) {
- return t._mesh === e
- }
- ))
- , i = -1 !== o._rigCameras.indexOf(e);
- return !t && !i
- }
- )),
- o._descendants.forEach((function(t) {
- t.parent = e
- }
- )))
- }
- )),
- o.getScene().onAfterCameraRenderObservable.add((function(e) {
- e.parent === o && o.rigParenting && o._descendants.forEach((function(e) {
- e.parent = o
- }
- ))
- }
- )),
- o
- }
- return U(t, e),
- t.prototype.deviceDistanceToRoomGround = function() {
- return this._standingMatrix ? (this._standingMatrix.getTranslationToRef(this._workingVector),
- this._deviceRoomPosition.y + this._workingVector.y) : this._defaultHeight || 0
- }
- ,
- t.prototype.useStandingMatrix = function(e) {
- var t = this;
- void 0 === e && (e = function(e) {}
- ),
- this.getEngine().initWebVRAsync().then((function(i) {
- i.vrDisplay && i.vrDisplay.stageParameters && i.vrDisplay.stageParameters.sittingToStandingTransform && t._webVROptions.trackPosition ? (t._standingMatrix = new P,
- P.FromFloat32ArrayToRefScaled(i.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, t._standingMatrix),
- t.getScene().useRightHandedSystem || t._standingMatrix && t._standingMatrix.toggleModelMatrixHandInPlace(),
- e(!0)) : e(!1)
- }
- ))
- }
- ,
- t.prototype.useStandingMatrixAsync = function() {
- var e = this;
- return new Promise((function(t) {
- e.useStandingMatrix((function(e) {
- t(e)
- }
- ))
- }
- ))
- }
- ,
- t.prototype.dispose = function() {
- this._detachIfAttached(),
- this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),
- this._updateCacheWhenTrackingDisabledObserver && this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.getControllerByName = function(e) {
- for (var t = 0, i = this.controllers; t < i.length; t++) {
- var n = i[t];
- if (n.hand === e)
- return n
- }
- return null
- }
- ,
- Object.defineProperty(t.prototype, "leftController", {
- get: function() {
- return this._leftController || (this._leftController = this.getControllerByName("left")),
- this._leftController
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rightController", {
- get: function() {
- return this._rightController || (this._rightController = this.getControllerByName("right")),
- this._rightController
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getForwardRay = function(t) {
- return void 0 === t && (t = 100),
- this.leftCamera ? e.prototype.getForwardRay.call(this, t, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition) : e.prototype.getForwardRay.call(this, t)
- }
- ,
- t.prototype._checkInputs = function() {
- this._vrDevice && this._vrDevice.isPresenting && (this._vrDevice.getFrameData(this._frameData),
- this.updateFromDevice(this._frameData.pose)),
- e.prototype._checkInputs.call(this)
- }
- ,
- t.prototype.updateFromDevice = function(e) {
- e && e.orientation && 4 === e.orientation.length && (this.rawPose = e,
- this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0], e.orientation[1], -e.orientation[2], -e.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)
- }
- ,
- t.prototype.attachControl = function(t) {
- t = gi.BackCompatCameraNoPreventDefault(arguments),
- e.prototype.attachControl.call(this, t),
- this._attached = !0,
- t = !Rr.ForceAttachControlToAlwaysPreventDefault && t,
- this._vrDevice && this.getEngine().enableVR(this._webVROptions);
- var i = this._scene.getEngine().getHostWindow();
- i && i.addEventListener("vrdisplaypresentchange", this._detachIfAttached)
- }
- ,
- t.prototype.detachControl = function() {
- this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
- this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
- e.prototype.detachControl.call(this),
- this._attached = !1,
- this.getEngine().disableVR(),
- window.removeEventListener("vrdisplaypresentchange", this._detachIfAttached)
- }
- ,
- t.prototype.getClassName = function() {
- return "WebVRFreeCamera"
- }
- ,
- t.prototype.resetToCurrentRotation = function() {
- this._vrDevice.resetPose()
- }
- ,
- t.prototype._updateRigCameras = function() {
- var e = this._rigCameras[0]
- , t = this._rigCameras[1];
- e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
- t.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
- e.position.copyFrom(this._deviceRoomPosition),
- t.position.copyFrom(this._deviceRoomPosition)
- }
- ,
- t.prototype._correctPositionIfNotTrackPosition = function(e, t) {
- void 0 === t && (t = !1),
- this.rawPose && this.rawPose.position && !this._webVROptions.trackPosition && (P.TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix),
- t || this._tmpMatrix.invert(),
- this._tmpMatrix.multiplyToRef(e, e))
- }
- ,
- t.prototype._updateCache = function(t) {
- var i = 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),
- x.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector),
- this.devicePosition.subtractToRef(this._workingVector, this._workingVector),
- P.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(e) {
- e._deviceToWorld.copyFrom(i._deviceToWorld),
- i._correctPositionIfNotTrackPosition(e._deviceToWorld),
- e.update()
- }
- ))),
- t || e.prototype._updateCache.call(this),
- this._updateCacheCalled = !1
- }
- ,
- t.prototype._computeDevicePosition = function() {
- x.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition)
- }
- ,
- t.prototype.update = function() {
- this._computeDevicePosition(),
- P.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix),
- this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix),
- C.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
- this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),
- e.prototype.update.call(this)
- }
- ,
- t.prototype._getViewMatrix = function() {
- return P.Identity()
- }
- ,
- t.prototype._getWebVRViewMatrix = function() {
- var e = this._cameraRigParams.parentCamera;
- e._updateCache();
- var t = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftViewMatrix : this._cameraRigParams.frameData.rightViewMatrix;
- return P.FromArrayToRef(t, 0, this._webvrViewMatrix),
- this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(),
- this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),
- x.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
- this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
- 1 !== e.deviceScaleFactor && (this._webvrViewMatrix.invert(),
- e.deviceScaleFactor && (this._webvrViewMatrix.multiplyAtIndex(12, e.deviceScaleFactor),
- this._webvrViewMatrix.multiplyAtIndex(13, e.deviceScaleFactor),
- this._webvrViewMatrix.multiplyAtIndex(14, e.deviceScaleFactor)),
- this._webvrViewMatrix.invert()),
- e._correctPositionIfNotTrackPosition(this._webvrViewMatrix, !0),
- e._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix),
- this._workingMatrix = this._workingMatrix || P.Identity(),
- this._webvrViewMatrix.invertToRef(this._workingMatrix),
- this._workingMatrix.multiplyToRef(e.getWorldMatrix(), this._workingMatrix),
- this._workingMatrix.getTranslationToRef(this._globalPosition),
- this._markSyncedWithParent(),
- this._webvrViewMatrix
- }
- ,
- t.prototype._getWebVRProjectionMatrix = function() {
- var e = this.parent;
- e._vrDevice.depthNear = e.minZ,
- e._vrDevice.depthFar = e.maxZ;
- var t = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftProjectionMatrix : this._cameraRigParams.frameData.rightProjectionMatrix;
- return P.FromArrayToRef(t, 0, this._projectionMatrix),
- this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(),
- this._projectionMatrix
- }
- ,
- t.prototype.initControllers = function() {
- var e = this;
- this.controllers = [];
- var t = this.getScene().gamepadManager;
- this._onGamepadDisconnectedObserver = t.onGamepadDisconnectedObservable.add((function(t) {
- if (t.type === zo.POSE_ENABLED) {
- var i = t;
- i.defaultModel && i.defaultModel.setEnabled(!1),
- "right" === i.hand && (e._rightController = null),
- "left" === i.hand && (e._leftController = null);
- var n = e.controllers.indexOf(i);
- -1 !== n && e.controllers.splice(n, 1)
- }
- }
- )),
- this._onGamepadConnectedObserver = t.onGamepadConnectedObservable.add((function(t) {
- if (t.type === zo.POSE_ENABLED) {
- var i = t;
- if (e._webVROptions.trackPosition || (i._disableTrackPosition(new x("left" == i.hand ? -.15 : .15,-.5,.25)),
- e._updateCacheWhenTrackingDisabledObserver || (e._updateCacheWhenTrackingDisabledObserver = e._scene.onBeforeRenderObservable.add((function() {
- e._updateCache()
- }
- )))),
- i.deviceScaleFactor = e.deviceScaleFactor,
- i._deviceToWorld.copyFrom(e._deviceToWorld),
- e._correctPositionIfNotTrackPosition(i._deviceToWorld),
- e._webVROptions.controllerMeshes && (i.defaultModel ? i.defaultModel.setEnabled(!0) : i.initControllerMesh(e.getScene(), (function(t) {
- if (t.scaling.scaleInPlace(e.deviceScaleFactor),
- e.onControllerMeshLoadedObservable.notifyObservers(i),
- e._webVROptions.defaultLightingOnControllers) {
- e._lightOnControllers || (e._lightOnControllers = new ds("vrControllersLight",new x(0,1,0),e.getScene()));
- var n = function(e, t) {
- var i = e.getChildren();
- i && 0 !== i.length && i.forEach((function(e) {
- t.includedOnlyMeshes.push(e),
- n(e, t)
- }
- ))
- };
- e._lightOnControllers.includedOnlyMeshes.push(t),
- n(t, e._lightOnControllers)
- }
- }
- ))),
- i.attachToPoseControlledCamera(e),
- -1 === e.controllers.indexOf(i)) {
- e.controllers.push(i);
- for (var n = !1, r = 0; r < e.controllers.length; r++)
- e.controllers[r].controllerType === ba.VIVE && (n ? e.controllers[r].hand = "right" : (n = !0,
- e.controllers[r].hand = "left"));
- e.controllers.length >= 2 && e.onControllersAttachedObservable.notifyObservers(e.controllers)
- }
- }
- }
- ))
- }
- ,
- t
- }(pa)
- , _s = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i.onTriggerStateChangedObservable = new h,
- i.onMainButtonStateChangedObservable = new h,
- i.onSecondaryButtonStateChangedObservable = new h,
- i.onPadStateChangedObservable = new h,
- i.onPadValuesChangedObservable = new h,
- i.pad = {
- x: 0,
- y: 0
- },
- i._changes = {
- pressChanged: !1,
- touchChanged: !1,
- valueChanged: !1,
- changed: !1
- },
- i._buttons = new Array(t.buttons.length),
- i.hand = t.hand,
- i
- }
- return U(t, e),
- t.prototype.onButtonStateChange = function(e) {
- this._onButtonStateChange = e
- }
- ,
- Object.defineProperty(t.prototype, "defaultModel", {
- get: function() {
- return this._defaultModel
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.update = function() {
- e.prototype.update.call(this);
- for (var t = 0; t < this._buttons.length; t++)
- this._setButtonValue(this.browserGamepad.buttons[t], this._buttons[t], t);
- 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))
- }
- ,
- t.prototype._setButtonValue = function(e, t, i) {
- e || (e = {
- pressed: !1,
- touched: !1,
- value: 0
- }),
- t ? (this._checkChanges(e, t),
- this._changes.changed && (this._onButtonStateChange && this._onButtonStateChange(this.index, i, e),
- this._handleButtonChange(i, e, this._changes)),
- this._buttons[i].pressed = e.pressed,
- this._buttons[i].touched = e.touched,
- this._buttons[i].value = e.value < 1e-8 ? 0 : e.value) : this._buttons[i] = {
- pressed: e.pressed,
- touched: e.touched,
- value: e.value
- }
- }
- ,
- t.prototype._checkChanges = function(e, t) {
- return this._changes.pressChanged = e.pressed !== t.pressed,
- this._changes.touchChanged = e.touched !== t.touched,
- this._changes.valueChanged = e.value !== t.value,
- this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged,
- this._changes
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._defaultModel = null,
- this.onTriggerStateChangedObservable.clear(),
- this.onMainButtonStateChangedObservable.clear(),
- this.onSecondaryButtonStateChangedObservable.clear(),
- this.onPadStateChangedObservable.clear(),
- this.onPadValuesChangedObservable.clear()
- }
- ,
- t
- }(Ra)
- , ms = function() {
- function e() {
- this.previousWorldMatrices = {},
- this.previousBones = {}
- }
- return e.AddUniforms = function(e) {
- e.push("previousWorld", "previousViewProjection", "mPreviousBones")
- }
- ,
- e.AddSamplers = function(e) {}
- ,
- e.prototype.bindForSubMesh = function(e, t, i, n, r) {
- if (t.prePassRenderer && t.prePassRenderer.enabled && t.prePassRenderer.currentRTisSceneRT && -1 !== t.prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE)) {
- this.previousWorldMatrices[i.uniqueId] || (this.previousWorldMatrices[i.uniqueId] = n.clone()),
- this.previousViewProjection || (this.previousViewProjection = t.getTransformMatrix().clone(),
- this.currentViewProjection = t.getTransformMatrix().clone());
- var o = t.getEngine();
- this.currentViewProjection.updateFlag !== t.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = o.frameId,
- this.previousViewProjection.copyFrom(this.currentViewProjection),
- this.currentViewProjection.copyFrom(t.getTransformMatrix())) : this._lastUpdateFrameId !== o.frameId && (this._lastUpdateFrameId = o.frameId,
- this.previousViewProjection.copyFrom(this.currentViewProjection)),
- e.setMatrix("previousWorld", this.previousWorldMatrices[i.uniqueId]),
- e.setMatrix("previousViewProjection", this.previousViewProjection),
- this.previousWorldMatrices[i.uniqueId] = n.clone()
- }
- }
- ,
- e
- }()
- , gs = function(e) {
- function t(t, i, n) {
- void 0 === n && (n = !0);
- var r = e.call(this, t, i) || this;
- return r._normalMatrix = new P,
- r._storeEffectOnSubMeshes = n,
- r
- }
- return U(t, e),
- t.prototype.getEffect = function() {
- return this._storeEffectOnSubMeshes ? this._activeEffect : e.prototype.getEffect.call(this)
- }
- ,
- t.prototype.isReady = function(e, t) {
- return !!e && (!this._storeEffectOnSubMeshes || !e.subMeshes || 0 === e.subMeshes.length || this.isReadyForSubMesh(e, e.subMeshes[0], t))
- }
- ,
- t.prototype._isReadyForSubMesh = function(e) {
- var t = e.materialDefines;
- return !(this.checkReadyOnEveryCall || !e.effect || !t || t._renderId !== this.getScene().getRenderId())
- }
- ,
- t.prototype.bindOnlyWorldMatrix = function(e) {
- this._activeEffect.setMatrix("world", e)
- }
- ,
- t.prototype.bindOnlyNormalMatrix = function(e) {
- this._activeEffect.setMatrix("normalMatrix", e)
- }
- ,
- t.prototype.bind = function(e, t) {
- t && this.bindForSubMesh(e, t, t.subMeshes[0])
- }
- ,
- t.prototype._afterBind = function(t, i) {
- void 0 === i && (i = null),
- e.prototype._afterBind.call(this, t, i),
- this.getScene()._cachedEffect = i
- }
- ,
- t.prototype._mustRebind = function(e, t, i) {
- return void 0 === i && (i = 1),
- e.isCachedMaterialInvalid(this, t, i)
- }
- ,
- t
- }(Or)
- , vs = function() {
- function e() {}
- return Object.defineProperty(e, "DiffuseTextureEnabled", {
- get: function() {
- return this._DiffuseTextureEnabled
- },
- set: function(e) {
- this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "DetailTextureEnabled", {
- get: function() {
- return this._DetailTextureEnabled
- },
- set: function(e) {
- this._DetailTextureEnabled !== e && (this._DetailTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "AmbientTextureEnabled", {
- get: function() {
- return this._AmbientTextureEnabled
- },
- set: function(e) {
- this._AmbientTextureEnabled !== e && (this._AmbientTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "OpacityTextureEnabled", {
- get: function() {
- return this._OpacityTextureEnabled
- },
- set: function(e) {
- this._OpacityTextureEnabled !== e && (this._OpacityTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ReflectionTextureEnabled", {
- get: function() {
- return this._ReflectionTextureEnabled
- },
- set: function(e) {
- this._ReflectionTextureEnabled !== e && (this._ReflectionTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "EmissiveTextureEnabled", {
- get: function() {
- return this._EmissiveTextureEnabled
- },
- set: function(e) {
- this._EmissiveTextureEnabled !== e && (this._EmissiveTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "SpecularTextureEnabled", {
- get: function() {
- return this._SpecularTextureEnabled
- },
- set: function(e) {
- this._SpecularTextureEnabled !== e && (this._SpecularTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BumpTextureEnabled", {
- get: function() {
- return this._BumpTextureEnabled
- },
- set: function(e) {
- this._BumpTextureEnabled !== e && (this._BumpTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LightmapTextureEnabled", {
- get: function() {
- return this._LightmapTextureEnabled
- },
- set: function(e) {
- this._LightmapTextureEnabled !== e && (this._LightmapTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "RefractionTextureEnabled", {
- get: function() {
- return this._RefractionTextureEnabled
- },
- set: function(e) {
- this._RefractionTextureEnabled !== e && (this._RefractionTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ColorGradingTextureEnabled", {
- get: function() {
- return this._ColorGradingTextureEnabled
- },
- set: function(e) {
- this._ColorGradingTextureEnabled !== e && (this._ColorGradingTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "FresnelEnabled", {
- get: function() {
- return this._FresnelEnabled
- },
- set: function(e) {
- this._FresnelEnabled !== e && (this._FresnelEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ClearCoatTextureEnabled", {
- get: function() {
- return this._ClearCoatTextureEnabled
- },
- set: function(e) {
- this._ClearCoatTextureEnabled !== e && (this._ClearCoatTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ClearCoatBumpTextureEnabled", {
- get: function() {
- return this._ClearCoatBumpTextureEnabled
- },
- set: function(e) {
- this._ClearCoatBumpTextureEnabled !== e && (this._ClearCoatBumpTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ClearCoatTintTextureEnabled", {
- get: function() {
- return this._ClearCoatTintTextureEnabled
- },
- set: function(e) {
- this._ClearCoatTintTextureEnabled !== e && (this._ClearCoatTintTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "SheenTextureEnabled", {
- get: function() {
- return this._SheenTextureEnabled
- },
- set: function(e) {
- this._SheenTextureEnabled !== e && (this._SheenTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "AnisotropicTextureEnabled", {
- get: function() {
- return this._AnisotropicTextureEnabled
- },
- set: function(e) {
- this._AnisotropicTextureEnabled !== e && (this._AnisotropicTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ThicknessTextureEnabled", {
- get: function() {
- return this._ThicknessTextureEnabled
- },
- set: function(e) {
- this._ThicknessTextureEnabled !== e && (this._ThicknessTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "RefractionIntensityTextureEnabled", {
- get: function() {
- return this._ThicknessTextureEnabled
- },
- set: function(e) {
- this._RefractionIntensityTextureEnabled !== e && (this._RefractionIntensityTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "TranslucencyIntensityTextureEnabled", {
- get: function() {
- return this._ThicknessTextureEnabled
- },
- set: function(e) {
- this._TranslucencyIntensityTextureEnabled !== e && (this._TranslucencyIntensityTextureEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- e._DiffuseTextureEnabled = !0,
- e._DetailTextureEnabled = !0,
- e._AmbientTextureEnabled = !0,
- e._OpacityTextureEnabled = !0,
- e._ReflectionTextureEnabled = !0,
- e._EmissiveTextureEnabled = !0,
- e._SpecularTextureEnabled = !0,
- e._BumpTextureEnabled = !0,
- e._LightmapTextureEnabled = !0,
- e._RefractionTextureEnabled = !0,
- e._ColorGradingTextureEnabled = !0,
- e._FresnelEnabled = !0,
- e._ClearCoatTextureEnabled = !0,
- e._ClearCoatBumpTextureEnabled = !0,
- e._ClearCoatTintTextureEnabled = !0,
- e._SheenTextureEnabled = !0,
- e._AnisotropicTextureEnabled = !0,
- e._ThicknessTextureEnabled = !0,
- e._RefractionIntensityTextureEnabled = !0,
- e._TranslucencyIntensityTextureEnabled = !0,
- e
- }();
- Pt.IncludesShadersStore.defaultFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform vec3 vAmbientColor;\nuniform float visibility;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize; \n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";
- Pt.IncludesShadersStore.sceneUboDeclaration = "layout(std140,column_major) uniform;\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;\nmat4 projection;\nvec4 vEyePosition;\n};\n";
- Pt.IncludesShadersStore.meshUboDeclaration = "uniform mat4 world;\nuniform float visibility;\n#define WORLD_UBO\n";
- Pt.IncludesShadersStore.defaultUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nfloat alphaCutOff;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec3 vRefractionPosition;\nvec3 vRefractionSize;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nvec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n";
- Pt.IncludesShadersStore.prePassDeclaration = "#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;\n#ifdef PREPASS_DEPTH\nvarying highp vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nvarying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.oitDeclaration = "#ifdef ORDER_INDEPENDENT_TRANSPARENCY\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out vec2 depth; \nlayout(location=1) out vec4 frontColor;\nlayout(location=2) out vec4 backColor;\n#define MAX_DEPTH 99999.0\nhighp vec4 gl_FragColor;\nuniform sampler2D oitDepthSampler;\nuniform sampler2D oitFrontColorSampler;\n#endif\n";
- Pt.IncludesShadersStore.mainUVVaryingDeclaration = "#ifdef MAINUV{X}\nvarying vec2 vMainUV{X};\n#endif\n";
- Pt.IncludesShadersStore.helperFunctions = "const float PI=3.1415926535897932384626433832795;\nconst float HALF_MIN=5.96046448e-08; \nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat toLinearSpace(float color)\n{\nreturn pow(color,LinearEncodePowerApprox);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec4 toLinearSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nvec4 toGammaSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D =max(rgbdMaxRange/maxRGB,1.);\nD =clamp(floor(D)/255.0,0.,1.);\nvec3 rgb=color.rgb*D;\nrgb=toGammaSpace(rgb);\nreturn vec4(clamp(rgb,0.,1.),D); \n}\nvec3 fromRGBD(vec4 rgbd) {\nrgbd.rgb=toLinearSpace(rgbd.rgb);\nreturn rgbd.rgb/rgbd.a;\n}\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\nvec3 intersectPositionWS=vertexPos+origVec*distance;\nreturn intersectPositionWS-cubePos;\n}\n";
- Pt.IncludesShadersStore.lightFragmentDeclaration = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif\n";
- Pt.IncludesShadersStore.lightUboDeclaration = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X}; \n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.lightsFragmentFunctions = "struct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w==0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";
- Pt.IncludesShadersStore.shadowsFragmentFunctions = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\n#define inline\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nreturn depth>shadow ? darkness : 1.0;\n}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\n#define inline\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\n#define inline\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\n#if defined(WEBGL2) || defined(WEBGPU)\n#define inline\nfloat computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nvec3 uvLayer=vec3(uv.x,uv.y,layer);\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uvLayer));\n#else\nfloat shadow=texture2D(shadowSampler,uvLayer).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nelse\n{\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture2D(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n#define inline\nfloat 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)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\nfloat AAOffset=shadowMapSizeInverse*10.;\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);\nvec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec4 offset=vec4(poissonSamplers[i],0.);\noffset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);\nshadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\nshadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n#define inline\nfloat 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)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=ZINCLIP;\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture2D(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\nfloat AAOffset=shadowMapSizeInverse*10.;\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n}\n#define inline\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\n#define inline\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\n#define inline\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#define inline\nfloat 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)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat 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)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat 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)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStore.samplerFragmentDeclaration = "#ifdef _DEFINENAME_\n#if _DEFINENAME_DIRECTUV==1\n#define v_VARYINGNAME_UV vMainUV1\n#elif _DEFINENAME_DIRECTUV==2\n#define v_VARYINGNAME_UV vMainUV2\n#elif _DEFINENAME_DIRECTUV==3\n#define v_VARYINGNAME_UV vMainUV3\n#elif _DEFINENAME_DIRECTUV==4\n#define v_VARYINGNAME_UV vMainUV4\n#elif _DEFINENAME_DIRECTUV==5\n#define v_VARYINGNAME_UV vMainUV5\n#elif _DEFINENAME_DIRECTUV==6\n#define v_VARYINGNAME_UV vMainUV6\n#else\nvarying vec2 v_VARYINGNAME_UV;\n#endif\nuniform sampler2D _SAMPLERNAME_Sampler;\n#endif\n";
- Pt.IncludesShadersStore.fresnelFunction = "#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif\n";
- Pt.IncludesShadersStore.reflectionFunction = "vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0); \n}\nvec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(1.0-s,t,0); \n}\nvec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nr=vec3(reflectionMatrix*vec4(r,0));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n}\nvec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr=vec3(reflectionMatrix*vec4(r,0));\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n}\nvec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=worldPos.xyz-eyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n}\nvec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*(view*worldPos));\n}\nvec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*vec4(positionW,1.));\n}\n#ifdef REFLECTION\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nreturn computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nreturn computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nreturn computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_CUBIC\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nreturn computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);\n#else\nreturn computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn computeProjectionCoords(worldPos,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn computeSkyBoxCoords(vPositionUVW,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}\n#endif\n";
- Pt.IncludesShadersStore.imageProcessingDeclaration = "#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif\n";
- Pt.IncludesShadersStore.imageProcessingFunctions = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n/** \n* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.\n* sampler3dSetting.x=textureOffset (0.5/textureSize).\n* sampler3dSetting.y=textureSize.\n*/\n#define inline\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108, 1.10813,-0.07276),\nvec3(-0.07367,-0.00605, 1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\ncolor=saturate(color);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=saturate(result.rgb);\n#ifdef CONTRAST\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);\nif (contrast<1.0) {\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
- Pt.IncludesShadersStore.bumpFragmentMainFunctions = "#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)\n{\n#ifdef NORMALXYSCALE\nnormal=normalize(normal*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)\n{\nreturn perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);\n}\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\n{\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\ntangent*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n";
- Pt.IncludesShadersStore.bumpFragmentFunctions = "#if defined(BUMP)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)\n#endif\n#if defined(DETAIL)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)\n#endif\n#if defined(BUMP) && defined(PARALLAX)\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n";
- Pt.IncludesShadersStore.clipPlaneFragmentDeclaration = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif\n";
- Pt.IncludesShadersStore.logDepthDeclaration = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif\n";
- Pt.IncludesShadersStore.fogFragmentDeclaration = "#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR==vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP==vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2==vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif\n";
- Pt.IncludesShadersStore.oitFragment = "#ifdef ORDER_INDEPENDENT_TRANSPARENCY\nfloat fragDepth=gl_FragCoord.z; \n#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS\nuint halfFloat=packHalf2x16(vec2(fragDepth));\nvec2 full=unpackHalf2x16(halfFloat);\nfragDepth=full.x;\n#endif\nivec2 fragCoord=ivec2(gl_FragCoord.xy);\nvec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;\nvec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);\ndepth.rg=vec2(-MAX_DEPTH);\nfrontColor=lastFrontColor;\nbackColor=vec4(0.0);\n#ifdef USE_REVERSE_DEPTHBUFFER\nfloat furthestDepth=-lastDepth.x;\nfloat nearestDepth=lastDepth.y;\n#else\nfloat nearestDepth=-lastDepth.x;\nfloat furthestDepth=lastDepth.y;\n#endif\nfloat alphaMultiplier=1.0-lastFrontColor.a;\n#ifdef USE_REVERSE_DEPTHBUFFER\nif (fragDepth>nearestDepth || fragDepth<furthestDepth) {\n#else\nif (fragDepth<nearestDepth || fragDepth>furthestDepth) {\n#endif\nreturn;\n}\n#ifdef USE_REVERSE_DEPTHBUFFER\nif (fragDepth<nearestDepth && fragDepth>furthestDepth) {\n#else\nif (fragDepth>nearestDepth && fragDepth<furthestDepth) {\n#endif\ndepth.rg=vec2(-fragDepth,fragDepth);\nreturn;\n}\n#endif\n";
- Pt.IncludesShadersStore.clipPlaneFragment = "#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelse if (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelse if (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelse if (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelse if (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelse if (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif\n";
- Pt.IncludesShadersStore.bumpFragment = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#elif defined(BUMP)\nfloat normalScale=vBumpInfos.y;\n#else\nfloat normalScale=1.0;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#elif defined(BUMP)\nvec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);\n#else\nvec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nvec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;\nmat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef DETAIL\nvec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);\nvec2 detailNormalRG=detailColor.wy*2.0-1.0;\nfloat detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));\nvec3 detailNormal=vec3(detailNormalRG,detailNormalB);\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz *2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#elif !defined(DETAIL)\nnormalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);\n#else\nvec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;\n#if DETAIL_NORMALBLENDMETHOD==0 \ndetailNormal.xy*=vDetailInfos.z;\nvec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));\n#elif DETAIL_NORMALBLENDMETHOD==1 \ndetailNormal.xy*=vDetailInfos.z;\nbumpNormal+=vec3(0.0,0.0,1.0);\ndetailNormal*=vec3(-1.0,-1.0,1.0);\nvec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;\n#endif\nnormalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);\n#endif\n#elif defined(DETAIL)\ndetailNormal.xy*=vDetailInfos.z;\nnormalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);\n#endif\n";
- Pt.IncludesShadersStore.depthPrePass = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif\n";
- Pt.IncludesShadersStore.lightFragment = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\npreInfo.roughness=sheenOut.sheenIntensity;\n#else\n#ifdef HEMILIGHT{X}\npreInfo.roughness=sheenOut.sheenRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#ifdef CLEARCOAT\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearcoatOut.clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\nabsorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) \n{\n#ifdef SHADOWCSM_RIGHTHANDED{X}\ndiff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;\n#else\ndiff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;\n#endif\nif (diff{X}>=0.) {\nindex{X}=i;\nbreak;\n}\n}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nif (index{X}>=0)\n#endif\n{\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=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);\n#else\nshadow=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);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=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});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=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});\n#else\nshadow=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});\n#endif\n#else\nshadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];\n#endif\n#ifndef SHADOWCSMNOBLEND{X}\nfloat frustumLength=frustumLengths{X}[index{X}];\nfloat diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};\nif (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\n{\nindex{X}+=1;\nfloat nextShadow=0.;\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=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);\n#else\nnextShadow=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);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=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});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=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});\n#else\nnextShadow=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});\n#endif\n#else\nnextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\nshadow=mix(nextShadow,shadow,diffRatio);\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\n#endif\n}\n#endif\n}\n#elif defined(SHADOWCLOSEESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=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);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=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);\n#else\nshadow=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);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor.rgb*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\n#ifdef SHADOWCSMDEBUG{X}\ndiffuseBase+=info.diffuse*shadowDebug{X};\n#else \ndiffuseBase+=info.diffuse*shadow;\n#endif\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.logDepthFragment = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif\n";
- Pt.IncludesShadersStore.fogFragment = "#ifdef FOG\nfloat fog=CalcFogFactor();\n#ifdef PBR\nfog=toLinearSpace(fog);\n#endif\ncolor.rgb=mix(vFogColor,color.rgb,fog);\n#endif\n";
- Pt.ShadersStore.defaultPixelShader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\n#include<oitDeclaration>\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<mainUVVaryingDeclaration>[1..7]\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULARTERM)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)\n#endif\n#include<fresnelFunction>\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<oitFragment>\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef DETAIL\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec4 refractionColor=vec4(0.,0.,0.,1.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\n#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);\n#endif\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector);\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords);\n#endif\n#ifdef RGBDREFRACTION\nrefractionColor.rgb=fromRGBD(refractionColor);\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\n#endif\nrefractionColor.rgb*=vRefractionInfos.x;\n#endif\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nvReflectionUVW.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords);\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n#ifdef ALPHATEST\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\nif (alpha<alphaCutOff)\ndiscard;\n#endif\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);\n#endif\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor.rgb;\n#else\ncolor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\nfloat writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;\ngl_FragData[0]=color; \n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo); \n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularMapColor.rgb,specularMapColor.a*writeGeometryInfo);\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {\nfrontColor.rgb+=color.rgb*color.a*alphaMultiplier;\nfrontColor.a=1.0-alphaMultiplier*(1.0-color.a);\n} else {\nbackColor+=color;\n}\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
- Pt.IncludesShadersStore.defaultVertexDeclaration = "uniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n#endif\n#define ADDITIONAL_VERTEX_DECLARATION\n";
- Pt.IncludesShadersStore.uvAttributeDeclaration = "#ifdef UV{X}\nattribute vec2 uv{X};\n#endif\n";
- Pt.IncludesShadersStore.bonesDeclaration = "#if NUM_BONE_INFLUENCERS>0\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#ifdef BONES_VELOCITY_ENABLED\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\n#ifdef BONETEXTURE\n#define inline\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{\nfloat offset=index *4.0;\nfloat dx=1.0/boneTextureWidth;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.bakedVertexAnimationDeclaration = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform float bakedVertexAnimationTime;\nuniform vec2 bakedVertexAnimationTextureSizeInverted;\nuniform vec4 bakedVertexAnimationSettings;\nuniform sampler2D bakedVertexAnimationTexture;\n#ifdef INSTANCES\nattribute vec4 bakedVertexAnimationSettingsInstanced;\n#endif\n#define inline\nmat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)\n{\nfloat offset=index*4.0;\nfloat frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;\nfloat dx=bakedVertexAnimationTextureSizeInverted.x;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n";
- Pt.IncludesShadersStore.instancesDeclaration = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute vec4 previousWorld0;\nattribute vec4 previousWorld1;\nattribute vec4 previousWorld2;\nattribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform mat4 previousWorld;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.prePassVertexDeclaration = "#ifdef PREPASS\n#ifdef PREPASS_DEPTH\nvarying vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nuniform mat4 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.samplerVertexDeclaration = "#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n";
- Pt.IncludesShadersStore.bumpVertexDeclaration = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.clipPlaneVertexDeclaration = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nvarying float fClipDistance6;\n#endif\n";
- Pt.IncludesShadersStore.fogVertexDeclaration = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif\n";
- Pt.IncludesShadersStore.lightVxFragmentDeclaration = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#endif\n";
- Pt.IncludesShadersStore.lightVxUboDeclaration = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.morphTargetsVertexGlobalDeclaration = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#ifdef MORPHTARGETS_TEXTURE \nprecision mediump sampler2DArray; \nuniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];\nuniform vec3 morphTargetTextureInfo;\nuniform sampler2DArray morphTargets;\nvec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)\n{ \nfloat y=floor(vertexIndex/morphTargetTextureInfo.y);\nfloat x=vertexIndex-y*morphTargetTextureInfo.y;\nvec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);\nreturn texture(morphTargets,textureUV).xyz;\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStore.morphTargetsVertexDeclaration = "#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.morphTargetsVertexGlobal = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nfloat vertexID;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.morphTargetsVertex = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE \nvertexID=float(gl_VertexID)*morphTargetTextureInfo.x;\npositionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(readVector3FromRawSampler({X},vertexID) -normal)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#else\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.instancesVertex = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nmat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\nmat4 finalWorld=world;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nmat4 finalPreviousWorld=previousWorld;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.bonesVertex = "#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.bakedVertexAnimation = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\n#define BVASNAME bakedVertexAnimationSettingsInstanced\n#else\n#define BVASNAME bakedVertexAnimationSettings\n#endif\nfloat VATStartFrame=BVASNAME.x;\nfloat VATEndFrame=BVASNAME.y;\nfloat VATOffsetFrame=BVASNAME.z;\nfloat VATSpeed=BVASNAME.w;\nfloat totalFrames=VATEndFrame-VATStartFrame+1.0;\nfloat time=bakedVertexAnimationTime*VATSpeed/totalFrames;\nfloat frameCorrection=time<1.0 ? 0.0 : 1.0;\nfloat numOfFrames=totalFrames-frameCorrection;\nfloat VATFrameNum=fract(time)*numOfFrames;\nVATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum+=VATStartFrame+frameCorrection;\nmat4 VATInfluence;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif\n";
- Pt.IncludesShadersStore.prePassVertex = "#ifdef PREPASS_DEPTH\nvViewPos=(view*worldPos).rgb;\n#endif\n#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*worldPos;\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n";
- Pt.IncludesShadersStore.uvVariableDeclaration = "#if !defined(UV{X}) && defined(MAINUV{X})\nvec2 uv{X}=vec2(0.,0.);\n#endif\n#ifdef MAINUV{X}\nvMainUV{X}=uv{X};\n#endif\n";
- Pt.IncludesShadersStore.samplerVertexImplementation = "#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nif (v_INFONAME_==0.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));\n}\n#ifdef UV2\nelse if (v_INFONAME_==1.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef UV3\nelse if (v_INFONAME_==2.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));\n}\n#endif\n#ifdef UV4\nelse if (v_INFONAME_==3.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));\n}\n#endif\n#ifdef UV5\nelse if (v_INFONAME_==4.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));\n}\n#endif\n#ifdef UV6\nelse if (v_INFONAME_==5.)\n{\nv_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStore.bumpVertex = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif\n";
- Pt.IncludesShadersStore.clipPlaneVertex = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif\n";
- Pt.IncludesShadersStore.fogVertex = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif\n";
- Pt.IncludesShadersStore.shadowsVertex = "#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {\nvPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#else\nvDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#endif\n}\n#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#else\nvDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pointCloudVertex = "#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n";
- Pt.IncludesShadersStore.logDepthVertex = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif\n";
- Pt.ShadersStore.defaultVertexShader = "#include<__decl__defaultVertex>\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#include<uvAttributeDeclaration>[2..7]\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\n#include<prePassVertexDeclaration>\n#include<mainUVVaryingDeclaration>[1..7]\n#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)\n#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)\n#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)\n#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)\n#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)\n#if defined(SPECULARTERM)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)\n#endif\n#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n#ifndef UV1\nvec2 uvUpdated=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#include<uvVariableDeclaration>[2..7]\n#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)\n#if defined(SPECULARTERM)\n#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)\n#endif\n#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
- var ys = function() {
- function e() {
- this._defines = {},
- this._currentRank = 32,
- this._maxRank = -1,
- this._mesh = null
- }
- return e.prototype.unBindMesh = function() {
- this._mesh = null
- }
- ,
- e.prototype.addFallback = function(e, t) {
- this._defines[e] || (e < this._currentRank && (this._currentRank = e),
- e > this._maxRank && (this._maxRank = e),
- this._defines[e] = new Array),
- this._defines[e].push(t)
- }
- ,
- e.prototype.addCPUSkinningFallback = function(e, t) {
- this._mesh = t,
- e < this._currentRank && (this._currentRank = e),
- e > this._maxRank && (this._maxRank = e)
- }
- ,
- Object.defineProperty(e.prototype, "hasMoreFallbacks", {
- get: function() {
- return this._currentRank <= this._maxRank
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reduce = function(e, t) {
- 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"),
- t._bonesComputationForcedToCPU = !0;
- for (var i = this._mesh.getScene(), n = 0; n < i.meshes.length; n++) {
- var r = i.meshes[n];
- if (r.material) {
- if (r.computeBonesUsingShaders && 0 !== r.numBoneInfluencers)
- if (r.material.getEffect() === t)
- r.computeBonesUsingShaders = !1;
- else if (r.subMeshes)
- for (var o = 0, a = r.subMeshes; o < a.length; o++)
- if (a[o].effect === t) {
- r.computeBonesUsingShaders = !1;
- break
- }
- } else
- !this._mesh.material && r.computeBonesUsingShaders && r.numBoneInfluencers > 0 && (r.computeBonesUsingShaders = !1)
- }
- } else {
- var s = this._defines[this._currentRank];
- if (s)
- for (n = 0; n < s.length; n++)
- e = e.replace("#define " + s[n], "");
- this._currentRank++
- }
- return e
- }
- ,
- e
- }()
- , bs = function() {
- function e(e) {
- this._plugins = [],
- this._activePlugins = [],
- this._activePluginsForExtraEvents = [],
- this._material = e,
- this._scene = e.getScene(),
- this._engine = this._scene.getEngine()
- }
- return e.prototype._addPlugin = function(e) {
- for (var t = 0; t < this._plugins.length; ++t)
- if (this._plugins[t].name === e.name)
- throw 'Plugin "'.concat(e.name, '" already added to the material "').concat(this._material.name, '"!');
- if (this._material._uniformBufferLayoutBuilt)
- throw 'The plugin "'.concat(e.name, '" can\'t be added to the material "').concat(this._material.name, '" because this material has already been used for rendering! Please add plugins to materials before any rendering with this material occurs.');
- this._material._callbackPluginEventGeneric = this._handlePluginEvent.bind(this),
- this._plugins.push(e),
- this._plugins.sort((function(e, t) {
- return e.priority - t.priority
- }
- )),
- this._codeInjectionPoints = {};
- for (var i = {}, n = 0, r = this._plugins; n < r.length; n++) {
- var o = r[n];
- o.collectDefines(i),
- this._collectPointNames("vertex", o.getCustomCode("vertex")),
- this._collectPointNames("fragment", o.getCustomCode("fragment"))
- }
- Object.keys(i).length > 0 ? this._defineNamesFromPlugins = i : delete this._defineNamesFromPlugins
- }
- ,
- e.prototype._activatePlugin = function(e) {
- -1 === this._activePlugins.indexOf(e) && (this._activePlugins.push(e),
- this._activePlugins.sort((function(e, t) {
- return e.priority - t.priority
- }
- )),
- this._material._callbackPluginEventIsReadyForSubMesh = this._handlePluginEventIsReadyForSubMesh.bind(this),
- this._material._callbackPluginEventPrepareDefines = this._handlePluginEventPrepareDefines.bind(this),
- this._material._callbackPluginEventBindForSubMesh = this._handlePluginEventBindForSubMesh.bind(this),
- e.registerForExtraEvents && (this._activePluginsForExtraEvents.push(e),
- this._activePluginsForExtraEvents.sort((function(e, t) {
- return e.priority - t.priority
- }
- )),
- this._material._callbackPluginEventHasRenderTargetTextures = this._handlePluginEventHasRenderTargetTextures.bind(this),
- this._material._callbackPluginEventFillRenderTargetTextures = this._handlePluginEventFillRenderTargetTextures.bind(this),
- this._material._callbackPluginEventHardBindForSubMesh = this._handlePluginEventHardBindForSubMesh.bind(this)))
- }
- ,
- e.prototype.getPlugin = function(e) {
- for (var t = 0; t < this._plugins.length; ++t)
- if (this._plugins[t].name === e)
- return this._plugins[t];
- return null
- }
- ,
- e.prototype._handlePluginEventIsReadyForSubMesh = function(e) {
- for (var t = !0, i = 0, n = this._activePlugins; i < n.length; i++) {
- var r = n[i];
- t = t && r.isReadyForSubMesh(e.defines, this._scene, this._engine, e.subMesh)
- }
- e.isReadyForSubMesh = t
- }
- ,
- e.prototype._handlePluginEventPrepareDefines = function(e) {
- for (var t = 0, i = this._activePlugins; t < i.length; t++)
- i[t].prepareDefines(e.defines, this._scene, e.mesh)
- }
- ,
- e.prototype._handlePluginEventHardBindForSubMesh = function(e) {
- for (var t = 0, i = this._activePluginsForExtraEvents; t < i.length; t++)
- i[t].hardBindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, e.subMesh)
- }
- ,
- e.prototype._handlePluginEventBindForSubMesh = function(e) {
- for (var t = 0, i = this._activePlugins; t < i.length; t++)
- i[t].bindForSubMesh(this._material._uniformBuffer, this._scene, this._engine, e.subMesh)
- }
- ,
- e.prototype._handlePluginEventHasRenderTargetTextures = function(e) {
- for (var t = !1, i = 0, n = this._activePluginsForExtraEvents; i < n.length && !(t = n[i].hasRenderTargetTextures()); i++)
- ;
- e.hasRenderTargetTextures = t
- }
- ,
- e.prototype._handlePluginEventFillRenderTargetTextures = function(e) {
- for (var t = 0, i = this._activePluginsForExtraEvents; t < i.length; t++)
- i[t].fillRenderTargetTextures(e.renderTargets)
- }
- ,
- e.prototype._handlePluginEvent = function(e, t) {
- var i, n, r;
- switch (e) {
- case Ar.GetActiveTextures:
- for (var o = t, a = 0, s = this._activePlugins; a < s.length; a++)
- (g = s[a]).getActiveTextures(o.activeTextures);
- break;
- case Ar.GetAnimatables:
- o = t;
- for (var l = 0, c = this._activePlugins; l < c.length; l++)
- (g = c[l]).getAnimatables(o.animatables);
- break;
- case Ar.HasTexture:
- o = t;
- for (var u = !1, h = 0, d = this._activePlugins; h < d.length && !(u = (g = d[h]).hasTexture(o.texture)); h++)
- ;
- o.hasTexture = u;
- break;
- case Ar.Disposed:
- o = t;
- for (var p = 0, f = this._plugins; p < f.length; p++)
- (g = f[p]).dispose(o.forceDisposeTextures);
- break;
- case Ar.GetDefineNames:
- (o = t).defineNames = this._defineNamesFromPlugins;
- break;
- case Ar.PrepareEffect:
- o = t;
- for (var _ = 0, m = this._activePlugins; _ < m.length; _++) {
- var g = m[_];
- o.fallbackRank = g.addFallbacks(o.defines, o.fallbacks, o.fallbackRank)
- }
- this._uniformList.length > 0 && (i = o.uniforms).push.apply(i, this._uniformList),
- this._samplerList.length > 0 && (n = o.samplers).push.apply(n, this._samplerList),
- this._uboList.length > 0 && (r = o.uniformBuffersNames).push.apply(r, this._uboList),
- o.customCode = this._injectCustomCode(o.customCode);
- break;
- case Ar.PrepareUniformBuffer:
- o = t,
- this._uboDeclaration = "",
- this._vertexDeclaration = "",
- this._fragmentDeclaration = "",
- this._uniformList = [],
- this._samplerList = [],
- this._uboList = [];
- for (var v = 0, y = this._plugins; v < y.length; v++) {
- var b = (g = y[v]).getUniforms();
- if (b) {
- if (b.ubo)
- for (var T = 0, E = b.ubo; T < E.length; T++) {
- var S = E[T];
- o.ubo.addUniform(S.name, S.size),
- this._uboDeclaration += "".concat(S.type, " ").concat(S.name, ";\r\n"),
- this._uniformList.push(S.name)
- }
- b.vertex && (this._vertexDeclaration += b.vertex + "\r\n"),
- b.fragment && (this._fragmentDeclaration += b.fragment + "\r\n")
- }
- g.getSamplers(this._samplerList),
- g.getUniformBuffersNames(this._uboList)
- }
- }
- }
- ,
- e.prototype._collectPointNames = function(e, t) {
- if (t)
- for (var i in t)
- this._codeInjectionPoints[e] || (this._codeInjectionPoints[e] = {}),
- this._codeInjectionPoints[e][i] = !0
- }
- ,
- e.prototype._injectCustomCode = function(e) {
- var t = this;
- return function(i, n) {
- var r;
- e && (n = e(i, n)),
- t._uboDeclaration && (n = n.replace("#define ADDITIONAL_UBO_DECLARATION", t._uboDeclaration)),
- t._vertexDeclaration && (n = n.replace("#define ADDITIONAL_VERTEX_DECLARATION", t._vertexDeclaration)),
- t._fragmentDeclaration && (n = n.replace("#define ADDITIONAL_FRAGMENT_DECLARATION", t._fragmentDeclaration));
- var o = null === (r = t._codeInjectionPoints) || void 0 === r ? void 0 : r[i];
- if (!o)
- return n;
- for (var a in o) {
- for (var s = "", l = 0, c = t._activePlugins; l < c.length; l++) {
- var u = c[l].getCustomCode(i);
- (null == u ? void 0 : u[a]) && (s += u[a] + "\r\n")
- }
- if (s.length > 0)
- if ("!" === a.charAt(0))
- for (var h = new RegExp(a.substring(1),"g"), d = h.exec(n); null !== d; )
- n = n.replace(d[0], s),
- d = h.exec(n);
- else {
- var p = "#define " + a;
- n = n.replace(p, "\r\n" + s + "\r\n" + p)
- }
- }
- return n
- }
- }
- ,
- e
- }()
- , Ts = []
- , Es = !1;
- function Ss(e, t) {
- Es || (Or.OnEventObservable.add((function(e) {
- for (var t = 0, i = Ts; t < i.length; t++)
- (0,
- i[t][1])(e)
- }
- ), Ar.Created),
- Es = !0);
- var i = Ts.filter((function(t) {
- var i = t[0];
- return t[1],
- i === e
- }
- ));
- i.length > 0 ? i[0][1] = t : Ts.push([e, t])
- }
- function As(e) {
- for (var t = 0; t < Ts.length; ++t)
- if (Ts[t][0] === e)
- return Ts.splice(t, 1),
- !0;
- return !1
- }
- function xs() {
- Ts.length = 0
- }
- var Rs = function() {
- function e(e, t, i, n, r, o) {
- void 0 === r && (r = !0),
- void 0 === o && (o = !1),
- this.priority = 500,
- this.registerForExtraEvents = !1,
- this._material = e,
- this.name = t,
- this.priority = i,
- e.pluginManager || (e.pluginManager = new bs(e)),
- this._pluginDefineNames = n,
- this._pluginManager = e.pluginManager,
- r && this._pluginManager._addPlugin(this),
- o && this._enable(!0),
- this.markAllDefinesAsDirty = e._dirtyCallbacks[a.MATERIAL_AllDirtyFlag]
- }
- return e.prototype._enable = function(e) {
- e && this._pluginManager._activatePlugin(this)
- }
- ,
- e.prototype.getClassName = function() {
- return "MaterialPluginBase"
- }
- ,
- e.prototype.isReadyForSubMesh = function(e, t, i, n) {
- return !0
- }
- ,
- e.prototype.hardBindForSubMesh = function(e, t, i, n) {}
- ,
- e.prototype.bindForSubMesh = function(e, t, i, n) {}
- ,
- e.prototype.dispose = function(e) {}
- ,
- e.prototype.getCustomCode = function(e) {
- return null
- }
- ,
- e.prototype.collectDefines = function(e) {
- if (this._pluginDefineNames)
- for (var t = 0, i = Object.keys(this._pluginDefineNames); t < i.length; t++) {
- var n = i[t];
- if ("_" !== n[0]) {
- var r = typeof this._pluginDefineNames[n];
- e[n] = {
- type: "number" === r ? "number" : "string" === r ? "string" : "boolean" === r ? "boolean" : "object",
- default: this._pluginDefineNames[n]
- }
- }
- }
- }
- ,
- e.prototype.prepareDefines = function(e, t, i) {}
- ,
- e.prototype.hasTexture = function(e) {
- return !1
- }
- ,
- e.prototype.hasRenderTargetTextures = function() {
- return !1
- }
- ,
- e.prototype.fillRenderTargetTextures = function(e) {}
- ,
- e.prototype.getActiveTextures = function(e) {}
- ,
- e.prototype.getAnimatables = function(e) {}
- ,
- e.prototype.addFallbacks = function(e, t, i) {
- return i
- }
- ,
- e.prototype.getSamplers = function(e) {}
- ,
- e.prototype.getUniformBuffersNames = function(e) {}
- ,
- e.prototype.getUniforms = function() {
- return {}
- }
- ,
- e.prototype.copyTo = function(e) {
- Ge.Clone((function() {
- return e
- }
- ), this)
- }
- ,
- e.prototype.serialize = function() {
- return Ge.Serialize(this)
- }
- ,
- e.prototype.parse = function(e, t, i) {
- var n = this;
- Ge.Parse((function() {
- return n
- }
- ), e, t, i)
- }
- ,
- k([Ce()], e.prototype, "name", void 0),
- k([Ce()], e.prototype, "priority", void 0),
- k([Ce()], e.prototype, "registerForExtraEvents", void 0),
- e
- }()
- , Cs = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.DETAIL = !1,
- t.DETAILDIRECTUV = 0,
- t.DETAIL_NORMALBLENDMETHOD = 0,
- t
- }
- return U(t, e),
- t
- }(Si)
- , Ps = function(e) {
- function t(t, i) {
- void 0 === i && (i = !0);
- var n = e.call(this, t, "DetailMap", 140, new Cs, i) || this;
- return n._texture = null,
- n.diffuseBlendLevel = 1,
- n.roughnessBlendLevel = 1,
- n.bumpLevel = 1,
- n._normalBlendMethod = Or.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,
- n._isEnabled = !1,
- n.isEnabled = !1,
- n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
- n
- }
- return U(t, e),
- t.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._enable(this._isEnabled),
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- return !this._isEnabled || !(e._areTexturesDirty && t.texturesEnabled && i.getCaps().standardDerivatives && this._texture && vs.DetailTextureEnabled && !this._texture.isReady())
- }
- ,
- t.prototype.prepareDefines = function(e, t) {
- if (this._isEnabled) {
- e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
- var i = t.getEngine();
- e._areTexturesDirty && (i.getCaps().standardDerivatives && this._texture && vs.DetailTextureEnabled && this._isEnabled ? (Mr.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"),
- e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1)
- } else
- e.DETAIL = !1
- }
- ,
- t.prototype.bindForSubMesh = function(e, t) {
- if (this._isEnabled) {
- var i = this._material.isFrozen;
- e.useUbo && i && e.isSync || this._texture && vs.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel),
- Mr.BindTextureMatrix(this._texture, e, "detail")),
- t.texturesEnabled && this._texture && vs.DetailTextureEnabled && e.setTexture("detailSampler", this._texture)
- }
- }
- ,
- t.prototype.hasTexture = function(e) {
- return this._texture === e
- }
- ,
- t.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture)
- }
- ,
- t.prototype.getAnimatables = function(e) {
- this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
- }
- ,
- t.prototype.dispose = function(e) {
- var t;
- e && (null === (t = this._texture) || void 0 === t || t.dispose())
- }
- ,
- t.prototype.getClassName = function() {
- return "DetailMapConfiguration"
- }
- ,
- t.prototype.getSamplers = function(e) {
- e.push("detailSampler")
- }
- ,
- t.prototype.getUniforms = function() {
- return {
- ubo: [{
- name: "vDetailInfos",
- size: 4,
- type: "vec4"
- }, {
- name: "detailMatrix",
- size: 16,
- type: "mat4"
- }]
- }
- }
- ,
- k([Pe("detailTexture"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
- k([Ce()], t.prototype, "diffuseBlendLevel", void 0),
- k([Ce()], t.prototype, "roughnessBlendLevel", void 0),
- k([Ce()], t.prototype, "bumpLevel", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "normalBlendMethod", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
- t
- }(Rs)
- , Ms = {
- effect: null,
- subMesh: null
- }
- , Is = function(e) {
- function t(t) {
- var i = e.call(this, t) || 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.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.INSTANCESCOLOR = !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 U(t, e),
- t.prototype.setReflectionMode = function(e) {
- for (var t = 0, i = ["REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX", "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED", "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"]; t < i.length; t++) {
- var n = i[t];
- this[n] = n === e
- }
- }
- ,
- t
- }(Si)
- , Os = function(e) {
- function t(i, n) {
- var r = e.call(this, i, n) || this;
- return r._diffuseTexture = null,
- r._ambientTexture = null,
- r._opacityTexture = null,
- r._reflectionTexture = null,
- r._emissiveTexture = null,
- r._specularTexture = null,
- r._bumpTexture = null,
- r._lightmapTexture = null,
- r._refractionTexture = null,
- r.ambientColor = new D(0,0,0),
- r.diffuseColor = new D(1,1,1),
- r.specularColor = new D(1,1,1),
- r.emissiveColor = new D(0,0,0),
- r.specularPower = 64,
- r._useAlphaFromDiffuseTexture = !1,
- r._useEmissiveAsIllumination = !1,
- r._linkEmissiveWithDiffuse = !1,
- r._useSpecularOverAlpha = !1,
- r._useReflectionOverAlpha = !1,
- r._disableLighting = !1,
- r._useObjectSpaceNormalMap = !1,
- r._useParallax = !1,
- r._useParallaxOcclusion = !1,
- r.parallaxScaleBias = .05,
- r._roughness = 0,
- r.indexOfRefraction = .98,
- r.invertRefractionY = !0,
- r.alphaCutOff = .4,
- r._useLightmapAsShadowmap = !1,
- r._useReflectionFresnelFromSpecular = !1,
- r._useGlossinessFromSpecularMapAlpha = !1,
- r._maxSimultaneousLights = 4,
- r._invertNormalMapX = !1,
- r._invertNormalMapY = !1,
- r._twoSidedLighting = !1,
- r._renderTargets = new bi(16),
- r._worldViewProjectionMatrix = P.Zero(),
- r._globalAmbientColor = new D(0,0,0),
- r._cacheHasRenderTargetTextures = !1,
- r.detailMap = new Ps(r),
- r._attachImageProcessingConfiguration(null),
- r.prePassConfiguration = new ms,
- r.getRenderTargetTextures = function() {
- return r._renderTargets.reset(),
- t.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture),
- t.RefractionTextureEnabled && r._refractionTexture && r._refractionTexture.isRenderTarget && r._renderTargets.push(r._refractionTexture),
- r._eventInfo.renderTargets = r._renderTargets,
- r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),
- r._renderTargets
- }
- ,
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- this._attachImageProcessingConfiguration(e),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._attachImageProcessingConfiguration = function(e) {
- var t = this;
- e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
- t._markAllSubMeshesAsImageProcessingDirty()
- }
- ))))
- }
- ,
- Object.defineProperty(t.prototype, "isPrePassCapable", {
- get: function() {
- return !this.disableDepthWrite
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorCurvesEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorGradingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraToneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(e) {
- this._imageProcessingConfiguration.toneMappingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraExposure", {
- get: function() {
- return this._imageProcessingConfiguration.exposure
- },
- set: function(e) {
- this._imageProcessingConfiguration.exposure = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraContrast", {
- get: function() {
- return this._imageProcessingConfiguration.contrast
- },
- set: function(e) {
- this._imageProcessingConfiguration.contrast = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorGradingTexture", {
- get: function() {
- return this._imageProcessingConfiguration.colorGradingTexture
- },
- set: function(e) {
- this._imageProcessingConfiguration.colorGradingTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorCurves", {
- get: function() {
- return this._imageProcessingConfiguration.colorCurves
- },
- set: function(e) {
- this._imageProcessingConfiguration.colorCurves = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "canRenderToMRT", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasRenderTargetTextures", {
- get: function() {
- return !!(t.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || !!(t.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "StandardMaterial"
- }
- ,
- Object.defineProperty(t.prototype, "useLogarithmicDepth", {
- get: function() {
- return this._useLogarithmicDepth
- },
- set: function(e) {
- this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported,
- this._markAllSubMeshesAsMiscDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.needAlphaBlending = function() {
- return !this._disableAlphaBlending && (this.alpha < 1 || null != this._opacityTexture || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled)
- }
- ,
- t.prototype.needAlphaTesting = function() {
- return !!this._forceAlphaTest || this._hasAlphaChannel() && (null == this._transparencyMode || this._transparencyMode === Or.MATERIAL_ALPHATEST)
- }
- ,
- t.prototype._shouldUseAlphaFromDiffuseTexture = function() {
- return null != this._diffuseTexture && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Or.MATERIAL_OPAQUE
- }
- ,
- t.prototype._hasAlphaChannel = function() {
- return null != this._diffuseTexture && this._diffuseTexture.hasAlpha || null != this._opacityTexture
- }
- ,
- t.prototype.getAlphaTestTexture = function() {
- return this._diffuseTexture
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, i, n) {
- if (void 0 === n && (n = !1),
- this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
- i.effect && this.isFrozen && i.effect._wasPreviouslyReady)
- return !0;
- i.materialDefines || (this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo),
- i.materialDefines = new Is(this._eventInfo.defineNames));
- var r = this.getScene()
- , o = i.materialDefines;
- if (this._isReadyForSubMesh(i))
- return !0;
- var s = r.getEngine();
- o._needNormals = Mr.PrepareDefinesForLights(r, e, o, !0, this._maxSimultaneousLights, this._disableLighting),
- Mr.PrepareDefinesForMultiview(r, o);
- var l = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
- if (Mr.PrepareDefinesForPrePass(r, o, this.canRenderToMRT && !l),
- Mr.PrepareDefinesForOIT(r, o, l),
- o._areTexturesDirty) {
- this._eventInfo.hasRenderTargetTextures = !1,
- this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
- this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures,
- o._needUVs = !1;
- for (var c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)
- o["MAINUV" + c] = !1;
- if (r.texturesEnabled) {
- if (this._diffuseTexture && t.DiffuseTextureEnabled) {
- if (!this._diffuseTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._diffuseTexture, o, "DIFFUSE")
- } else
- o.DIFFUSE = !1;
- if (this._ambientTexture && t.AmbientTextureEnabled) {
- if (!this._ambientTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._ambientTexture, o, "AMBIENT")
- } else
- o.AMBIENT = !1;
- if (this._opacityTexture && t.OpacityTextureEnabled) {
- if (!this._opacityTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._opacityTexture, o, "OPACITY"),
- o.OPACITYRGB = this._opacityTexture.getAlphaFromRGB
- } else
- o.OPACITY = !1;
- if (this._reflectionTexture && t.ReflectionTextureEnabled) {
- if (!this._reflectionTexture.isReadyOrNotBlocking())
- return !1;
- switch (o._needNormals = !0,
- o.REFLECTION = !0,
- o.ROUGHNESS = this._roughness > 0,
- o.REFLECTIONOVERALPHA = this._useReflectionOverAlpha,
- o.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === io.INVCUBIC_MODE,
- o.REFLECTIONMAP_3D = this._reflectionTexture.isCube,
- o.RGBDREFLECTION = this._reflectionTexture.isRGBD,
- o.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ,
- this._reflectionTexture.coordinatesMode) {
- case io.EXPLICIT_MODE:
- o.setReflectionMode("REFLECTIONMAP_EXPLICIT");
- break;
- case io.PLANAR_MODE:
- o.setReflectionMode("REFLECTIONMAP_PLANAR");
- break;
- case io.PROJECTION_MODE:
- o.setReflectionMode("REFLECTIONMAP_PROJECTION");
- break;
- case io.SKYBOX_MODE:
- o.setReflectionMode("REFLECTIONMAP_SKYBOX");
- break;
- case io.SPHERICAL_MODE:
- o.setReflectionMode("REFLECTIONMAP_SPHERICAL");
- break;
- case io.EQUIRECTANGULAR_MODE:
- o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
- break;
- case io.FIXED_EQUIRECTANGULAR_MODE:
- o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
- break;
- case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
- o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
- break;
- case io.CUBIC_MODE:
- case io.INVCUBIC_MODE:
- default:
- o.setReflectionMode("REFLECTIONMAP_CUBIC")
- }
- o.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize
- } else
- o.REFLECTION = !1,
- o.REFLECTIONMAP_OPPOSITEZ = !1;
- if (this._emissiveTexture && t.EmissiveTextureEnabled) {
- if (!this._emissiveTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._emissiveTexture, o, "EMISSIVE")
- } else
- o.EMISSIVE = !1;
- if (this._lightmapTexture && t.LightmapTextureEnabled) {
- if (!this._lightmapTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._lightmapTexture, o, "LIGHTMAP"),
- o.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
- o.RGBDLIGHTMAP = this._lightmapTexture.isRGBD
- } else
- o.LIGHTMAP = !1;
- if (this._specularTexture && t.SpecularTextureEnabled) {
- if (!this._specularTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._specularTexture, o, "SPECULAR"),
- o.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha
- } else
- o.SPECULAR = !1;
- if (r.getEngine().getCaps().standardDerivatives && this._bumpTexture && t.BumpTextureEnabled) {
- if (!this._bumpTexture.isReady())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._bumpTexture, o, "BUMP"),
- o.PARALLAX = this._useParallax,
- o.PARALLAXOCCLUSION = this._useParallaxOcclusion,
- o.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap
- } else
- o.BUMP = !1;
- if (this._refractionTexture && t.RefractionTextureEnabled) {
- if (!this._refractionTexture.isReadyOrNotBlocking())
- return !1;
- o._needUVs = !0,
- o.REFRACTION = !0,
- o.REFRACTIONMAP_3D = this._refractionTexture.isCube,
- o.RGBDREFRACTION = this._refractionTexture.isRGBD,
- o.USE_LOCAL_REFRACTIONMAP_CUBIC = !!this._refractionTexture.boundingBoxSize
- } else
- o.REFRACTION = !1;
- o.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting
- } else
- o.DIFFUSE = !1,
- o.AMBIENT = !1,
- o.OPACITY = !1,
- o.REFLECTION = !1,
- o.EMISSIVE = !1,
- o.LIGHTMAP = !1,
- o.BUMP = !1,
- o.REFRACTION = !1;
- o.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(),
- o.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination,
- o.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse,
- o.SPECULAROVERALPHA = this._useSpecularOverAlpha,
- o.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
- o.ALPHATEST_AFTERALLALPHACOMPUTATIONS = null !== this.transparencyMode,
- o.ALPHABLEND = null === this.transparencyMode || this.needAlphaBlendingForMesh(e)
- }
- if (this._eventInfo.isReadyForSubMesh = !0,
- this._eventInfo.defines = o,
- this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
- !this._eventInfo.isReadyForSubMesh)
- return !1;
- if (o._areImageProcessingDirty && this._imageProcessingConfiguration) {
- if (!this._imageProcessingConfiguration.isReady())
- return !1;
- this._imageProcessingConfiguration.prepareDefines(o),
- o.IS_REFLECTION_LINEAR = null != this.reflectionTexture && !this.reflectionTexture.gammaSpace,
- o.IS_REFRACTION_LINEAR = null != this.refractionTexture && !this.refractionTexture.gammaSpace
- }
- if (o._areFresnelDirty && (t.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (o.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled,
- o.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled,
- o.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled,
- o.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular,
- o.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled,
- o.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled,
- o._needNormals = !0,
- o.FRESNEL = !0) : o.FRESNEL = !1),
- Mr.PrepareDefinesForMisc(e, r, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, o),
- Mr.PrepareDefinesForAttributes(e, o, !0, !0, !0),
- Mr.PrepareDefinesForFrameBoundValues(r, s, o, n, null, i.getRenderingMesh().hasThinInstances),
- this._eventInfo.defines = o,
- this._eventInfo.mesh = e,
- this._callbackPluginEventPrepareDefines(this._eventInfo),
- o.isDirty) {
- var u = o._areLightsDisposed;
- o.markAsProcessed();
- var h = new ys;
- o.REFLECTION && h.addFallback(0, "REFLECTION"),
- o.SPECULAR && h.addFallback(0, "SPECULAR"),
- o.BUMP && h.addFallback(0, "BUMP"),
- o.PARALLAX && h.addFallback(1, "PARALLAX"),
- o.PARALLAXOCCLUSION && h.addFallback(0, "PARALLAXOCCLUSION"),
- o.SPECULAROVERALPHA && h.addFallback(0, "SPECULAROVERALPHA"),
- o.FOG && h.addFallback(1, "FOG"),
- o.POINTSIZE && h.addFallback(0, "POINTSIZE"),
- o.LOGARITHMICDEPTH && h.addFallback(0, "LOGARITHMICDEPTH"),
- Mr.HandleFallbacksForShadows(o, h, this._maxSimultaneousLights),
- o.SPECULARTERM && h.addFallback(0, "SPECULARTERM"),
- o.DIFFUSEFRESNEL && h.addFallback(1, "DIFFUSEFRESNEL"),
- o.OPACITYFRESNEL && h.addFallback(2, "OPACITYFRESNEL"),
- o.REFLECTIONFRESNEL && h.addFallback(3, "REFLECTIONFRESNEL"),
- o.EMISSIVEFRESNEL && h.addFallback(4, "EMISSIVEFRESNEL"),
- o.FRESNEL && h.addFallback(4, "FRESNEL"),
- o.MULTIVIEW && h.addFallback(0, "MULTIVIEW");
- var d = [Bi.PositionKind];
- for (o.NORMAL && d.push(Bi.NormalKind),
- o.TANGENT && d.push(Bi.TangentKind),
- c = 1; c <= a.MAX_SUPPORTED_UV_SETS; ++c)
- o["UV" + c] && d.push("uv".concat(1 === c ? "" : c));
- o.VERTEXCOLOR && d.push(Bi.ColorKind),
- o.INSTANCESCOLOR && d.push(Bi.ColorInstanceKind),
- Mr.PrepareAttributesForBones(d, e, o, h),
- Mr.PrepareAttributesForInstances(d, o),
- Mr.PrepareAttributesForMorphTargets(d, e, o),
- Mr.PrepareAttributesForBakedVertexAnimation(d, e, o);
- var p = "default"
- , f = ["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"]
- , _ = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
- , m = ["Material", "Scene", "Mesh"];
- this._eventInfo.fallbacks = h,
- this._eventInfo.fallbackRank = 0,
- this._eventInfo.defines = o,
- this._eventInfo.uniforms = f,
- this._eventInfo.samplers = _,
- this._eventInfo.uniformBuffersNames = m,
- this._eventInfo.customCode = void 0,
- this._callbackPluginEventGeneric(Ar.PrepareEffect, this._eventInfo),
- ms.AddUniforms(f),
- ms.AddSamplers(_),
- Ri && (Ri.PrepareUniforms(f, o),
- Ri.PrepareSamplers(_, o)),
- Mr.PrepareUniformsAndSamplersList({
- uniformsNames: f,
- uniformBuffersNames: m,
- samplers: _,
- defines: o,
- maxSimultaneousLights: this._maxSimultaneousLights
- });
- var g = {};
- this.customShaderNameResolve && (p = this.customShaderNameResolve(p, f, m, _, o, d, g));
- var v = o.toString()
- , y = i.effect
- , b = r.getEngine().createEffect(p, {
- attributes: d,
- uniformsNames: f,
- uniformBuffersNames: m,
- samplers: _,
- defines: v,
- fallbacks: h,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousLights: this._maxSimultaneousLights,
- maxSimultaneousMorphTargets: o.NUM_MORPH_INFLUENCERS
- },
- processFinalCode: g.processFinalCode,
- processCodeAfterIncludes: this._eventInfo.customCode,
- multiTarget: o.PREPASS
- }, s);
- if (b)
- if (this._onEffectCreatedObservable && (Ms.effect = b,
- Ms.subMesh = i,
- this._onEffectCreatedObservable.notifyObservers(Ms)),
- this.allowShaderHotSwapping && y && !b.isReady()) {
- if (b = y,
- o.markAsUnprocessed(),
- u)
- return o._areLightsDisposed = !0,
- !1
- } else
- r.resetCachedMaterial(),
- i.setEffect(b, o, this._materialContext)
- }
- return !(!i.effect || !i.effect.isReady() || (o._renderId = r.getRenderId(),
- i.effect._wasPreviouslyReady = !0,
- 0))
- }
- ,
- t.prototype.buildUniformLayout = function() {
- var t = this._uniformBuffer;
- t.addUniform("diffuseLeftColor", 4),
- t.addUniform("diffuseRightColor", 4),
- t.addUniform("opacityParts", 4),
- t.addUniform("reflectionLeftColor", 4),
- t.addUniform("reflectionRightColor", 4),
- t.addUniform("refractionLeftColor", 4),
- t.addUniform("refractionRightColor", 4),
- t.addUniform("emissiveLeftColor", 4),
- t.addUniform("emissiveRightColor", 4),
- t.addUniform("vDiffuseInfos", 2),
- t.addUniform("vAmbientInfos", 2),
- t.addUniform("vOpacityInfos", 2),
- t.addUniform("vReflectionInfos", 2),
- t.addUniform("vReflectionPosition", 3),
- t.addUniform("vReflectionSize", 3),
- t.addUniform("vEmissiveInfos", 2),
- t.addUniform("vLightmapInfos", 2),
- t.addUniform("vSpecularInfos", 2),
- t.addUniform("vBumpInfos", 3),
- t.addUniform("diffuseMatrix", 16),
- t.addUniform("ambientMatrix", 16),
- t.addUniform("opacityMatrix", 16),
- t.addUniform("reflectionMatrix", 16),
- t.addUniform("emissiveMatrix", 16),
- t.addUniform("lightmapMatrix", 16),
- t.addUniform("specularMatrix", 16),
- t.addUniform("bumpMatrix", 16),
- t.addUniform("vTangentSpaceParams", 2),
- t.addUniform("pointSize", 1),
- t.addUniform("alphaCutOff", 1),
- t.addUniform("refractionMatrix", 16),
- t.addUniform("vRefractionInfos", 4),
- t.addUniform("vRefractionPosition", 3),
- t.addUniform("vRefractionSize", 3),
- t.addUniform("vSpecularColor", 4),
- t.addUniform("vEmissiveColor", 3),
- t.addUniform("vDiffuseColor", 4),
- t.addUniform("vAmbientColor", 3),
- e.prototype.buildUniformLayout.call(this)
- }
- ,
- t.prototype.bindForSubMesh = function(e, i, n) {
- var r, o = this.getScene(), a = n.materialDefines;
- if (a) {
- var s = n.effect;
- if (s) {
- this._activeEffect = s,
- i.getMeshUniformBuffer().bindToEffect(s, "Mesh"),
- i.transferToEffect(e),
- this._uniformBuffer.bindToEffect(s, "Material"),
- this.prePassConfiguration.bindForSubMesh(this._activeEffect, o, i, e, this.isFrozen),
- this._eventInfo.subMesh = n,
- this._callbackPluginEventHardBindForSubMesh(this._eventInfo),
- a.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix),
- this.bindOnlyNormalMatrix(this._normalMatrix));
- var l = this._mustRebind(o, s, i.visibility);
- Mr.BindBonesParameters(i, s);
- var c = this._uniformBuffer;
- if (l) {
- if (this.bindViewProjection(s),
- !c.useUbo || !this.isFrozen || !c.isSync) {
- if (t.FresnelEnabled && a.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (c.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power),
- c.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)),
- this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && c.updateColor4("opacityParts", new D(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power),
- this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (c.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power),
- c.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)),
- this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (c.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power),
- c.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)),
- this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (c.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power),
- c.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))),
- o.texturesEnabled) {
- if (this._diffuseTexture && t.DiffuseTextureEnabled && (c.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
- Mr.BindTextureMatrix(this._diffuseTexture, c, "diffuse")),
- this._ambientTexture && t.AmbientTextureEnabled && (c.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level),
- Mr.BindTextureMatrix(this._ambientTexture, c, "ambient")),
- this._opacityTexture && t.OpacityTextureEnabled && (c.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
- Mr.BindTextureMatrix(this._opacityTexture, c, "opacity")),
- this._hasAlphaChannel() && c.updateFloat("alphaCutOff", this.alphaCutOff),
- this._reflectionTexture && t.ReflectionTextureEnabled && (c.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness),
- c.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()),
- this._reflectionTexture.boundingBoxSize)) {
- var u = this._reflectionTexture;
- c.updateVector3("vReflectionPosition", u.boundingBoxPosition),
- c.updateVector3("vReflectionSize", u.boundingBoxSize)
- }
- if (this._emissiveTexture && t.EmissiveTextureEnabled && (c.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
- Mr.BindTextureMatrix(this._emissiveTexture, c, "emissive")),
- this._lightmapTexture && t.LightmapTextureEnabled && (c.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
- Mr.BindTextureMatrix(this._lightmapTexture, c, "lightmap")),
- this._specularTexture && t.SpecularTextureEnabled && (c.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level),
- Mr.BindTextureMatrix(this._specularTexture, c, "specular")),
- this._bumpTexture && o.getEngine().getCaps().standardDerivatives && t.BumpTextureEnabled && (c.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias),
- Mr.BindTextureMatrix(this._bumpTexture, c, "bump"),
- o._mirroredCameraPosition ? c.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : c.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)),
- this._refractionTexture && t.RefractionTextureEnabled) {
- var h = 1;
- this._refractionTexture.isCube || (c.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()),
- this._refractionTexture.depth && (h = this._refractionTexture.depth)),
- c.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, h, this.invertRefractionY ? -1 : 1),
- this._refractionTexture.boundingBoxSize && (u = this._refractionTexture,
- c.updateVector3("vRefractionPosition", u.boundingBoxPosition),
- c.updateVector3("vRefractionSize", u.boundingBoxSize))
- }
- }
- this.pointsCloud && c.updateFloat("pointSize", this.pointSize),
- a.SPECULARTERM && c.updateColor4("vSpecularColor", this.specularColor, this.specularPower),
- c.updateColor3("vEmissiveColor", t.EmissiveTextureEnabled ? this.emissiveColor : D.BlackReadOnly),
- c.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha),
- o.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor),
- c.updateColor3("vAmbientColor", this._globalAmbientColor)
- }
- o.texturesEnabled && (this._diffuseTexture && t.DiffuseTextureEnabled && s.setTexture("diffuseSampler", this._diffuseTexture),
- this._ambientTexture && t.AmbientTextureEnabled && s.setTexture("ambientSampler", this._ambientTexture),
- this._opacityTexture && t.OpacityTextureEnabled && s.setTexture("opacitySampler", this._opacityTexture),
- this._reflectionTexture && t.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? s.setTexture("reflectionCubeSampler", this._reflectionTexture) : s.setTexture("reflection2DSampler", this._reflectionTexture)),
- this._emissiveTexture && t.EmissiveTextureEnabled && s.setTexture("emissiveSampler", this._emissiveTexture),
- this._lightmapTexture && t.LightmapTextureEnabled && s.setTexture("lightmapSampler", this._lightmapTexture),
- this._specularTexture && t.SpecularTextureEnabled && s.setTexture("specularSampler", this._specularTexture),
- this._bumpTexture && o.getEngine().getCaps().standardDerivatives && t.BumpTextureEnabled && s.setTexture("bumpSampler", this._bumpTexture),
- this._refractionTexture && t.RefractionTextureEnabled && (this._refractionTexture.isCube ? s.setTexture("refractionCubeSampler", this._refractionTexture) : s.setTexture("refraction2DSampler", this._refractionTexture))),
- this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(i) && this.getScene().depthPeelingRenderer.bind(s),
- this._eventInfo.subMesh = n,
- this._callbackPluginEventBindForSubMesh(this._eventInfo),
- Mr.BindClipPlane(s, o),
- this.bindEyePosition(s)
- } else
- o.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
- !l && this.isFrozen || (o.lightsEnabled && !this._disableLighting && Mr.BindLights(o, i, s, a, this._maxSimultaneousLights),
- (o.fogEnabled && i.applyFog && o.fogMode !== mn.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || i.receiveShadows) && this.bindView(s),
- Mr.BindFogParameters(o, i, s),
- a.NUM_MORPH_INFLUENCERS && Mr.BindMorphTargetParameters(i, s),
- a.BAKED_VERTEX_ANIMATION_TEXTURE && (null === (r = i.bakedVertexAnimationManager) || void 0 === r || r.bind(s, a.INSTANCES)),
- this.useLogarithmicDepth && Mr.BindLogDepth(a, s, o),
- this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)),
- this._afterBind(i, this._activeEffect),
- c.update()
- }
- }
- }
- ,
- t.prototype.getAnimatables = function() {
- var t = e.prototype.getAnimatables.call(this);
- return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && t.push(this._diffuseTexture),
- this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && t.push(this._ambientTexture),
- this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && t.push(this._opacityTexture),
- this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && t.push(this._reflectionTexture),
- this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && t.push(this._emissiveTexture),
- this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && t.push(this._specularTexture),
- this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && t.push(this._bumpTexture),
- this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && t.push(this._lightmapTexture),
- this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && t.push(this._refractionTexture),
- t
- }
- ,
- t.prototype.getActiveTextures = function() {
- var t = e.prototype.getActiveTextures.call(this);
- return this._diffuseTexture && t.push(this._diffuseTexture),
- this._ambientTexture && t.push(this._ambientTexture),
- this._opacityTexture && t.push(this._opacityTexture),
- this._reflectionTexture && t.push(this._reflectionTexture),
- this._emissiveTexture && t.push(this._emissiveTexture),
- this._specularTexture && t.push(this._specularTexture),
- this._bumpTexture && t.push(this._bumpTexture),
- this._lightmapTexture && t.push(this._lightmapTexture),
- this._refractionTexture && t.push(this._refractionTexture),
- t
- }
- ,
- t.prototype.hasTexture = function(t) {
- return !!e.prototype.hasTexture.call(this, t) || this._diffuseTexture === t || this._ambientTexture === t || this._opacityTexture === t || this._reflectionTexture === t || this._emissiveTexture === t || this._specularTexture === t || this._bumpTexture === t || this._lightmapTexture === t || this._refractionTexture === t
- }
- ,
- t.prototype.dispose = function(t, i) {
- var n, r, o, a, s, l, c, u, h;
- i && (null === (n = this._diffuseTexture) || void 0 === n || n.dispose(),
- null === (r = this._ambientTexture) || void 0 === r || r.dispose(),
- null === (o = this._opacityTexture) || void 0 === o || o.dispose(),
- null === (a = this._reflectionTexture) || void 0 === a || a.dispose(),
- null === (s = this._emissiveTexture) || void 0 === s || s.dispose(),
- null === (l = this._specularTexture) || void 0 === l || l.dispose(),
- null === (c = this._bumpTexture) || void 0 === c || c.dispose(),
- null === (u = this._lightmapTexture) || void 0 === u || u.dispose(),
- null === (h = this._refractionTexture) || void 0 === h || h.dispose()),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.prototype.clone = function(e) {
- var i = this
- , n = Ge.Clone((function() {
- return new t(e,i.getScene())
- }
- ), this);
- return n.name = e,
- n.id = e,
- this.stencil.copyTo(n.stencil),
- n
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n);
- return e.stencil && r.stencil.parse(e.stencil, i, n),
- r
- }
- ,
- Object.defineProperty(t, "DiffuseTextureEnabled", {
- get: function() {
- return vs.DiffuseTextureEnabled
- },
- set: function(e) {
- vs.DiffuseTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "DetailTextureEnabled", {
- get: function() {
- return vs.DetailTextureEnabled
- },
- set: function(e) {
- vs.DetailTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "AmbientTextureEnabled", {
- get: function() {
- return vs.AmbientTextureEnabled
- },
- set: function(e) {
- vs.AmbientTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "OpacityTextureEnabled", {
- get: function() {
- return vs.OpacityTextureEnabled
- },
- set: function(e) {
- vs.OpacityTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "ReflectionTextureEnabled", {
- get: function() {
- return vs.ReflectionTextureEnabled
- },
- set: function(e) {
- vs.ReflectionTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "EmissiveTextureEnabled", {
- get: function() {
- return vs.EmissiveTextureEnabled
- },
- set: function(e) {
- vs.EmissiveTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "SpecularTextureEnabled", {
- get: function() {
- return vs.SpecularTextureEnabled
- },
- set: function(e) {
- vs.SpecularTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "BumpTextureEnabled", {
- get: function() {
- return vs.BumpTextureEnabled
- },
- set: function(e) {
- vs.BumpTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "LightmapTextureEnabled", {
- get: function() {
- return vs.LightmapTextureEnabled
- },
- set: function(e) {
- vs.LightmapTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "RefractionTextureEnabled", {
- get: function() {
- return vs.RefractionTextureEnabled
- },
- set: function(e) {
- vs.RefractionTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "ColorGradingTextureEnabled", {
- get: function() {
- return vs.ColorGradingTextureEnabled
- },
- set: function(e) {
- vs.ColorGradingTextureEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "FresnelEnabled", {
- get: function() {
- return vs.FresnelEnabled
- },
- set: function(e) {
- vs.FresnelEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- k([Pe("diffuseTexture")], t.prototype, "_diffuseTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "diffuseTexture", void 0),
- k([Pe("ambientTexture")], t.prototype, "_ambientTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0),
- k([Pe("opacityTexture")], t.prototype, "_opacityTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0),
- k([Pe("reflectionTexture")], t.prototype, "_reflectionTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
- k([Pe("emissiveTexture")], t.prototype, "_emissiveTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
- k([Pe("specularTexture")], t.prototype, "_specularTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularTexture", void 0),
- k([Pe("bumpTexture")], t.prototype, "_bumpTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
- k([Pe("lightmapTexture")], t.prototype, "_lightmapTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "lightmapTexture", void 0),
- k([Pe("refractionTexture")], t.prototype, "_refractionTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0),
- k([Me("ambient")], t.prototype, "ambientColor", void 0),
- k([Me("diffuse")], t.prototype, "diffuseColor", void 0),
- k([Me("specular")], t.prototype, "specularColor", void 0),
- k([Me("emissive")], t.prototype, "emissiveColor", void 0),
- k([Ce()], t.prototype, "specularPower", void 0),
- k([Ce("useAlphaFromDiffuseTexture")], t.prototype, "_useAlphaFromDiffuseTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromDiffuseTexture", void 0),
- k([Ce("useEmissiveAsIllumination")], t.prototype, "_useEmissiveAsIllumination", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useEmissiveAsIllumination", void 0),
- k([Ce("linkEmissiveWithDiffuse")], t.prototype, "_linkEmissiveWithDiffuse", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkEmissiveWithDiffuse", void 0),
- k([Ce("useSpecularOverAlpha")], t.prototype, "_useSpecularOverAlpha", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0),
- k([Ce("useReflectionOverAlpha")], t.prototype, "_useReflectionOverAlpha", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useReflectionOverAlpha", void 0),
- k([Ce("disableLighting")], t.prototype, "_disableLighting", void 0),
- k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
- k([Ce("useObjectSpaceNormalMap")], t.prototype, "_useObjectSpaceNormalMap", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0),
- k([Ce("useParallax")], t.prototype, "_useParallax", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0),
- k([Ce("useParallaxOcclusion")], t.prototype, "_useParallaxOcclusion", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0),
- k([Ce()], t.prototype, "parallaxScaleBias", void 0),
- k([Ce("roughness")], t.prototype, "_roughness", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
- k([Ce()], t.prototype, "indexOfRefraction", void 0),
- k([Ce()], t.prototype, "invertRefractionY", void 0),
- k([Ce()], t.prototype, "alphaCutOff", void 0),
- k([Ce("useLightmapAsShadowmap")], t.prototype, "_useLightmapAsShadowmap", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
- k([Ie("diffuseFresnelParameters")], t.prototype, "_diffuseFresnelParameters", void 0),
- k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "diffuseFresnelParameters", void 0),
- k([Ie("opacityFresnelParameters")], t.prototype, "_opacityFresnelParameters", void 0),
- k([Re("_markAllSubMeshesAsFresnelAndMiscDirty")], t.prototype, "opacityFresnelParameters", void 0),
- k([Ie("reflectionFresnelParameters")], t.prototype, "_reflectionFresnelParameters", void 0),
- k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "reflectionFresnelParameters", void 0),
- k([Ie("refractionFresnelParameters")], t.prototype, "_refractionFresnelParameters", void 0),
- k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "refractionFresnelParameters", void 0),
- k([Ie("emissiveFresnelParameters")], t.prototype, "_emissiveFresnelParameters", void 0),
- k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "emissiveFresnelParameters", void 0),
- k([Ce("useReflectionFresnelFromSpecular")], t.prototype, "_useReflectionFresnelFromSpecular", void 0),
- k([Re("_markAllSubMeshesAsFresnelDirty")], t.prototype, "useReflectionFresnelFromSpecular", void 0),
- k([Ce("useGlossinessFromSpecularMapAlpha")], t.prototype, "_useGlossinessFromSpecularMapAlpha", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGlossinessFromSpecularMapAlpha", void 0),
- k([Ce("maxSimultaneousLights")], t.prototype, "_maxSimultaneousLights", void 0),
- k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
- k([Ce("invertNormalMapX")], t.prototype, "_invertNormalMapX", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
- k([Ce("invertNormalMapY")], t.prototype, "_invertNormalMapY", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
- k([Ce("twoSidedLighting")], t.prototype, "_twoSidedLighting", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0),
- k([Ce()], t.prototype, "useLogarithmicDepth", null),
- t
- }(gs);
- y("BABYLON.StandardMaterial", Os),
- mn.DefaultMaterialFactory = function(e) {
- return new Os("default material",e)
- }
- ,
- Ht.prototype.createDynamicTexture = function(e, t, i, n) {
- var r = new Lt(this,At.Dynamic);
- return r.baseWidth = e,
- r.baseHeight = t,
- i && (e = this.needPOTTextures ? Ht.GetExponentOfTwo(e, this._caps.maxTextureSize) : e,
- t = this.needPOTTextures ? Ht.GetExponentOfTwo(t, this._caps.maxTextureSize) : t),
- r.width = e,
- r.height = t,
- r.isReady = !1,
- r.generateMipMaps = i,
- r.samplingMode = n,
- this.updateTextureSamplingMode(n, r),
- this._internalTexturesCache.push(r),
- r
- }
- ,
- Ht.prototype.updateDynamicTexture = function(e, t, i, n, r, o, a) {
- if (void 0 === n && (n = !1),
- void 0 === o && (o = !1),
- void 0 === a && (a = !1),
- e) {
- var s = this._gl
- , l = s.TEXTURE_2D
- , c = this._bindTextureDirectly(l, e, !0, o);
- this._unpackFlipY(void 0 === i ? e.invertY : i),
- n && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
- var u = this._getWebGLTextureType(e.type)
- , h = this._getInternalFormat(r || e.format)
- , d = this._getRGBABufferInternalSizedFormat(e.type, h);
- s.texImage2D(l, 0, d, h, u, t),
- e.generateMipMaps && s.generateMipmap(l),
- c || this._bindTextureDirectly(l, null),
- n && s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
- e.isReady = !0
- }
- }
- ;
- var Ds = function(e) {
- function t(t, i, n, r, o, s, l) {
- void 0 === n && (n = null),
- void 0 === r && (r = !1),
- void 0 === o && (o = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === s && (s = a.TEXTUREFORMAT_RGBA);
- var c = e.call(this, null, n, !r, l, o, void 0, void 0, void 0, void 0, s) || this;
- c.name = t,
- c.wrapU = io.CLAMP_ADDRESSMODE,
- c.wrapV = io.CLAMP_ADDRESSMODE,
- c._generateMipMaps = r;
- var u = c._getEngine();
- if (!u)
- return c;
- i.getContext ? (c._canvas = i,
- c._texture = u.createDynamicTexture(i.width, i.height, r, o)) : (c._canvas = u.createCanvas(1, 1),
- i.width || 0 === i.width ? c._texture = u.createDynamicTexture(i.width, i.height, r, o) : c._texture = u.createDynamicTexture(i, i, r, o));
- var h = c.getSize();
- return c._canvas.width !== h.width && (c._canvas.width = h.width),
- c._canvas.height !== h.height && (c._canvas.height = h.height),
- c._context = c._canvas.getContext("2d"),
- c
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DynamicTexture"
- }
- ,
- Object.defineProperty(t.prototype, "canRescale", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._recreate = function(e) {
- this._canvas.width = e.width,
- this._canvas.height = e.height,
- this.releaseInternalTexture(),
- this._texture = this._getEngine().createDynamicTexture(e.width, e.height, this._generateMipMaps, this.samplingMode)
- }
- ,
- t.prototype.scale = function(e) {
- var t = this.getSize();
- t.width *= e,
- t.height *= e,
- this._recreate(t)
- }
- ,
- t.prototype.scaleTo = function(e, t) {
- var i = this.getSize();
- i.width = e,
- i.height = t,
- this._recreate(i)
- }
- ,
- t.prototype.getContext = function() {
- return this._context
- }
- ,
- t.prototype.clear = function() {
- var e = this.getSize();
- this._context.fillRect(0, 0, e.width, e.height)
- }
- ,
- t.prototype.update = function(e, t, i) {
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- this._getEngine().updateDynamicTexture(this._texture, this._canvas, void 0 === e || e, t, this._format || void 0, void 0, i)
- }
- ,
- t.prototype.drawText = function(e, t, i, n, r, o, a, s) {
- void 0 === s && (s = !0);
- var l = this.getSize();
- if (o && (this._context.fillStyle = o,
- this._context.fillRect(0, 0, l.width, l.height)),
- this._context.font = n,
- null == t) {
- var c = this._context.measureText(e);
- t = (l.width - c.width) / 2
- }
- if (null == i) {
- var u = parseInt(n.replace(/\D/g, ""));
- i = l.height / 2 + u / 3.65
- }
- this._context.fillStyle = r || "",
- this._context.fillText(e, t, i),
- s && this.update(a)
- }
- ,
- t.prototype.clone = function() {
- var e = this.getScene();
- if (!e)
- return this;
- var i = this.getSize()
- , n = new t(this.name,i,e,this._generateMipMaps);
- return n.hasAlpha = this.hasAlpha,
- n.level = this.level,
- n.wrapU = this.wrapU,
- n.wrapV = this.wrapV,
- n
- }
- ,
- t.prototype.serialize = function() {
- var i = this.getScene();
- i && !i.isReady() && K.Warn("The scene must be ready before serializing the dynamic texture");
- var n = e.prototype.serialize.call(this);
- return t._IsCanvasElement(this._canvas) && (n.base64String = this._canvas.toDataURL()),
- n.invertY = this._invertY,
- n.samplingMode = this.samplingMode,
- n
- }
- ,
- t._IsCanvasElement = function(e) {
- return void 0 !== e.toDataURL
- }
- ,
- t.prototype._rebuild = function() {
- this.update()
- }
- ,
- t
- }(io);
- Pt.ShadersStore.imageProcessingPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}";
- var Ns, Ls, Fs = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === n && (n = null),
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
- var u = e.call(this, t, "imageProcessing", [], [], i, n, r, o, s, null, l, "postprocess", null, !0) || this;
- return u._fromLinearSpace = !0,
- u._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
- },
- c ? (c.applyByPostProcess = !0,
- u._attachImageProcessingConfiguration(c, !0),
- u._updateParameters()) : (u._attachImageProcessingConfiguration(null, !0),
- u.imageProcessingConfiguration.applyByPostProcess = !0),
- u.onApply = function(e) {
- u.imageProcessingConfiguration.bind(e, u.aspectRatio)
- }
- ,
- u
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- e.applyByPostProcess = !0,
- this._attachImageProcessingConfiguration(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._attachImageProcessingConfiguration = function(e, t) {
- var i = this;
- if (void 0 === t && (t = !1),
- e !== this._imageProcessingConfiguration) {
- if (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- e)
- this._imageProcessingConfiguration = e;
- else {
- var n = null
- , r = this.getEngine()
- , o = this.getCamera();
- if (o)
- n = o.getScene();
- else if (r && r.scenes) {
- var a = r.scenes;
- n = a[a.length - 1]
- } else
- n = E.LastCreatedScene;
- this._imageProcessingConfiguration = n ? n.imageProcessingConfiguration : new Ri
- }
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
- i._updateParameters()
- }
- ))),
- t || this._updateParameters()
- }
- }
- ,
- Object.defineProperty(t.prototype, "isSupported", {
- get: function() {
- var e = this.getEffect();
- return !e || e.isSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "colorCurves", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurves
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorCurves = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "colorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorCurvesEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "colorGradingTexture", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingTexture
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorGradingTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "colorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorGradingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "exposure", {
- get: function() {
- return this.imageProcessingConfiguration.exposure
- },
- set: function(e) {
- this.imageProcessingConfiguration.exposure = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "toneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(e) {
- this._imageProcessingConfiguration.toneMappingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "toneMappingType", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingType
- },
- set: function(e) {
- this._imageProcessingConfiguration.toneMappingType = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "contrast", {
- get: function() {
- return this.imageProcessingConfiguration.contrast
- },
- set: function(e) {
- this.imageProcessingConfiguration.contrast = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteStretch", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteStretch
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteStretch = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteCentreX", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteCentreX
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteCentreX = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteCentreY", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteCentreY
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteCentreY = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteWeight", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteWeight
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteWeight = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteColor", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteColor
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteColor = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteCameraFov", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteCameraFov
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteCameraFov = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteBlendMode", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteBlendMode
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteBlendMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vignetteEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.vignetteEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fromLinearSpace", {
- get: function() {
- return this._fromLinearSpace
- },
- set: function(e) {
- this._fromLinearSpace !== e && (this._fromLinearSpace = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "ImageProcessingPostProcess"
- }
- ,
- t.prototype._updateParameters = function() {
- this._defines.FROMLINEARSPACE = this._fromLinearSpace,
- this.imageProcessingConfiguration.prepareDefines(this._defines, !0);
- var e = "";
- for (var t in this._defines)
- this._defines[t] && (e += "#define ".concat(t, ";\r\n"));
- var i = ["textureSampler"]
- , n = ["scale"];
- Ri && (Ri.PrepareSamplers(i, this._defines),
- Ri.PrepareUniforms(n, this._defines)),
- this.updateEffect(e, n, i)
- }
- ,
- t.prototype.dispose = function(t) {
- e.prototype.dispose.call(this, t),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingConfiguration && (this.imageProcessingConfiguration.applyByPostProcess = !1)
- }
- ,
- k([Ce()], t.prototype, "_fromLinearSpace", void 0),
- t
- }(Ba), ws = function() {
- function e(e, t, i, n, r) {
- this.getWidth = e,
- this.getHeight = t,
- this.layer = i,
- this.layerType = n,
- this.createRenderTargetTextureProvider = r
- }
- return Object.defineProperty(e.prototype, "isFixedFoveationSupported", {
- get: function() {
- return "XRWebGLLayer" == this.layerType && "number" == typeof this.layer.fixedFoveation
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fixedFoveation", {
- get: function() {
- return this.isFixedFoveationSupported ? this.layer.fixedFoveation : null
- },
- set: function(e) {
- if (this.isFixedFoveationSupported) {
- var t = Math.max(0, Math.min(1, e || 0));
- this.layer.fixedFoveation = t
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(), Bs = function() {
- function e(e, t) {
- this._scene = e,
- this.layerWrapper = t,
- this._renderTargetTextures = new Array,
- this._engine = e.getEngine()
- }
- return e.prototype._createInternalTexture = function(e, t) {
- var i = new Lt(this._engine,At.Unknown,!0);
- return i.width = e.width,
- i.height = e.height,
- i._hardwareTexture = new kt(t,this._engine._gl),
- i.isReady = !0,
- i
- }
- ,
- e.prototype._createRenderTargetTexture = function(e, t, i, n, r, o) {
- if (!this._engine)
- throw new Error("Engine is disposed");
- var a = {
- width: e,
- height: t
- }
- , s = o ? new rs(this._scene,a) : new ns("XR renderTargetTexture",a,this._scene)
- , l = s.renderTarget;
- if (!i && n || (l._framebuffer = i),
- n)
- if (o)
- l._colorTextureArray = n;
- else {
- var c = this._createInternalTexture(a, n);
- l.setTexture(c, 0),
- s._texture = c
- }
- return r && (o ? l._depthStencilTextureArray = r : l._depthStencilTexture = this._createInternalTexture(a, r)),
- s.disableRescaling(),
- "undefined" != typeof XRWebGLBinding && (s.skipInitialClear = !0),
- this._renderTargetTextures.push(s),
- s
- }
- ,
- e.prototype._destroyRenderTargetTexture = function(e) {
- this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(e), 1),
- e.dispose()
- }
- ,
- e.prototype.getFramebufferDimensions = function() {
- return this._framebufferDimensions
- }
- ,
- e.prototype.dispose = function() {
- this._renderTargetTextures.forEach((function(e) {
- return e.dispose()
- }
- )),
- this._renderTargetTextures.length = 0
- }
- ,
- e
- }(), Us = function(e) {
- function t(t) {
- var i = e.call(this, (function() {
- return t.framebufferWidth
- }
- ), (function() {
- return t.framebufferHeight
- }
- ), t, "XRWebGLLayer", (function(e) {
- return new Vs(e.scene,i)
- }
- )) || this;
- return i.layer = t,
- i
- }
- return U(t, e),
- t
- }(ws), Vs = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n.layerWrapper = i,
- n._layer = i.layer,
- n._framebufferDimensions = {
- framebufferWidth: n._layer.framebufferWidth,
- framebufferHeight: n._layer.framebufferHeight
- },
- n
- }
- return U(t, e),
- t.prototype.trySetViewportForView = function(e, t) {
- var i = this._layer.getViewport(t)
- , n = this._framebufferDimensions.framebufferWidth
- , r = this._framebufferDimensions.framebufferHeight;
- return e.x = i.x / n,
- e.y = i.y / r,
- e.width = i.width / n,
- e.height = i.height / r,
- !0
- }
- ,
- t.prototype.getRenderTargetTextureForEye = function(e) {
- var t = this._layer.framebufferWidth
- , i = this._layer.framebufferHeight
- , n = this._layer.framebuffer;
- return this._rtt && t === this._framebufferDimensions.framebufferWidth && i === this._framebufferDimensions.framebufferHeight && n === this._framebuffer || (this._rtt = this._createRenderTargetTexture(t, i, n),
- this._framebufferDimensions.framebufferWidth = t,
- this._framebufferDimensions.framebufferHeight = i,
- this._framebuffer = n),
- this._rtt
- }
- ,
- t.prototype.getRenderTargetTextureForView = function(e) {
- return this.getRenderTargetTextureForEye(e.eye)
- }
- ,
- t
- }(Bs), ks = function() {
- function e() {}
- return e.GetDefaults = function(t) {
- var i = new e;
- return i.canvasOptions = {
- antialias: !0,
- depth: !0,
- stencil: !t || t.isStencilEnable,
- 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
- }
- ,
- e
- }(), Gs = function() {
- function e(e, t) {
- void 0 === t && (t = ks.GetDefaults());
- var i = this;
- if (this._options = t,
- this._canvas = null,
- this._engine = null,
- this.xrLayer = null,
- this._xrLayerWrapper = null,
- this.onXRLayerInitObservable = new h,
- this._engine = e.scene.getEngine(),
- this._engine.onDisposeObservable.addOnce((function() {
- i._engine = null
- }
- )),
- t.canvasElement)
- this._setManagedOutputCanvas(t.canvasElement);
- else {
- var n = document.createElement("canvas");
- n.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;",
- this._setManagedOutputCanvas(n)
- }
- e.onXRSessionInit.add((function() {
- i._addCanvas()
- }
- )),
- e.onXRSessionEnded.add((function() {
- i._removeCanvas()
- }
- ))
- }
- return e.prototype.dispose = function() {
- this._removeCanvas(),
- this._setManagedOutputCanvas(null)
- }
- ,
- e.prototype.initializeXRLayerAsync = function(e) {
- return G(this, void 0, void 0, (function() {
- var t, i = this;
- return z(this, (function(n) {
- return t = function() {
- return i.xrLayer = new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions),
- i._xrLayerWrapper = new Us(i.xrLayer),
- i.onXRLayerInitObservable.notifyObservers(i.xrLayer),
- i.xrLayer
- }
- ,
- this.canvasContext.makeXRCompatible ? [2, this.canvasContext.makeXRCompatible().then((function() {}
- ), (function() {
- gi.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")
- }
- )).then((function() {
- return t()
- }
- ))] : [2, Promise.resolve(t())]
- }
- ))
- }
- ))
- }
- ,
- e.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() {
- e._setCanvasSize(!0)
- }
- ))
- }
- ,
- e.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)
- }
- ,
- e.prototype._setCanvasSize = function(e, t) {
- void 0 === e && (e = !0),
- void 0 === t && (t = this._xrLayerWrapper),
- this._canvas && this._engine && (e ? t && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = t.getWidth() + "px",
- this._canvas.style.height = t.getHeight() + "px") : this._engine.setSize(t.getWidth(), t.getHeight())) : 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)))
- }
- ,
- e.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)
- }
- ,
- e
- }(), zs = function(e) {
- function t(t) {
- var i = e.call(this, (function() {
- return t.framebufferWidth
- }
- ), (function() {
- return t.framebufferHeight
- }
- ), t, "XRWebGLLayer", (function(e) {
- return new Ws(e,i)
- }
- )) || this;
- return i.layer = t,
- i
- }
- return U(t, e),
- t
- }(ws), Ws = function(e) {
- function t(t, i) {
- var n = e.call(this, t.scene, i) || this;
- return n.layerWrapper = i,
- n._nativeRTTProvider = navigator.xr.getNativeRenderTargetProvider(t.session, n._createRenderTargetTexture.bind(n), n._destroyRenderTargetTexture.bind(n)),
- n._nativeLayer = i.layer,
- n
- }
- return U(t, e),
- t.prototype.trySetViewportForView = function(e) {
- return e.x = 0,
- e.y = 0,
- e.width = 1,
- e.height = 1,
- !0
- }
- ,
- t.prototype.getRenderTargetTextureForEye = function(e) {
- return this._nativeRTTProvider.getRenderTargetForEye(e)
- }
- ,
- t.prototype.getRenderTargetTextureForView = function(e) {
- return this._nativeRTTProvider.getRenderTargetForEye(e.eye)
- }
- ,
- t.prototype.getFramebufferDimensions = function() {
- return {
- framebufferWidth: this._nativeLayer.framebufferWidth,
- framebufferHeight: this._nativeLayer.framebufferHeight
- }
- }
- ,
- t
- }(Bs), Hs = function() {
- function e(e) {
- this._nativeRenderTarget = navigator.xr.getWebXRRenderTarget(e.scene.getEngine())
- }
- return e.prototype.initializeXRLayerAsync = function(e) {
- return G(this, void 0, void 0, (function() {
- return z(this, (function(t) {
- switch (t.label) {
- case 0:
- return [4, this._nativeRenderTarget.initializeXRLayerAsync(e)];
- case 1:
- return t.sent(),
- this.xrLayer = this._nativeRenderTarget.xrLayer,
- [2, this.xrLayer]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype.dispose = function() {}
- ,
- e
- }(), Xs = function() {
- function e(e) {
- var t = this;
- this.scene = e,
- this.currentTimestamp = -1,
- this.defaultHeightCompensation = 1.7,
- this.onXRFrameObservable = new h,
- this.onXRReferenceSpaceChanged = new h,
- this.onXRSessionEnded = new h,
- this.onXRSessionInit = new h,
- this.inXRFrameLoop = !1,
- this.inXRSession = !1,
- this._engine = e.getEngine(),
- this._onEngineDisposedObserver = this._engine.onDisposeObservable.addOnce((function() {
- t._engine = null
- }
- )),
- e.onDisposeObservable.addOnce((function() {
- t.dispose()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "referenceSpace", {
- get: function() {
- return this._referenceSpace
- },
- set: function(e) {
- this._referenceSpace = e,
- this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sessionMode", {
- get: function() {
- return this._sessionMode
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- var e;
- this.inXRSession && this.exitXRAsync(),
- this.onXRFrameObservable.clear(),
- this.onXRSessionEnded.clear(),
- this.onXRReferenceSpaceChanged.clear(),
- this.onXRSessionInit.clear(),
- null === (e = this._engine) || void 0 === e || e.onDisposeObservable.remove(this._onEngineDisposedObserver),
- this._engine = null
- }
- ,
- e.prototype.exitXRAsync = function() {
- return this.session && this.inXRSession ? (this.inXRSession = !1,
- this.session.end().catch((function() {
- K.Warn("Could not end XR session.")
- }
- ))) : Promise.resolve()
- }
- ,
- e.prototype.trySetViewportForView = function(e, t) {
- var i;
- return (null === (i = this._baseLayerRTTProvider) || void 0 === i ? void 0 : i.trySetViewportForView(e, t)) || !1
- }
- ,
- e.prototype.getRenderTargetTextureForEye = function(e) {
- var t;
- return (null === (t = this._baseLayerRTTProvider) || void 0 === t ? void 0 : t.getRenderTargetTextureForEye(e)) || null
- }
- ,
- e.prototype.getRenderTargetTextureForView = function(e) {
- var t;
- return (null === (t = this._baseLayerRTTProvider) || void 0 === t ? void 0 : t.getRenderTargetTextureForView(e)) || null
- }
- ,
- e.prototype.getWebXRRenderTarget = function(e) {
- var t = this.scene.getEngine();
- return this._xrNavigator.xr.native ? new Hs(this) : ((e = e || ks.GetDefaults(t)).canvasElement = e.canvasElement || t.getRenderingCanvas() || void 0,
- new Gs(this,e))
- }
- ,
- e.prototype.initializeAsync = function() {
- return this._xrNavigator = navigator,
- this._xrNavigator.xr ? Promise.resolve() : Promise.reject("WebXR not available")
- }
- ,
- e.prototype.initializeSessionAsync = function(e, t) {
- var i = this;
- return void 0 === e && (e = "immersive-vr"),
- void 0 === t && (t = {}),
- this._xrNavigator.xr.requestSession(e, t).then((function(t) {
- return i.session = t,
- i._sessionMode = e,
- i.onXRSessionInit.notifyObservers(t),
- i.inXRSession = !0,
- i.session.addEventListener("end", (function() {
- var e;
- i.inXRSession = !1,
- i.onXRSessionEnded.notifyObservers(null),
- i._engine && (i._engine.framebufferDimensionsObject = null,
- i._engine.restoreDefaultFramebuffer(),
- i._engine.customAnimationFrameRequester = null,
- i._engine._renderLoop()),
- i.isNative && (null === (e = i._baseLayerRTTProvider) || void 0 === e || e.dispose()),
- i._baseLayerRTTProvider = null,
- i._baseLayerWrapper = null
- }
- ), {
- once: !0
- }),
- i.session
- }
- ))
- }
- ,
- e.prototype.isSessionSupportedAsync = function(t) {
- return e.IsSessionSupportedAsync(t)
- }
- ,
- e.prototype.resetReferenceSpace = function() {
- this.referenceSpace = this.baseReferenceSpace
- }
- ,
- e.prototype.runXRRenderLoop = function() {
- var e, t = this;
- this.inXRSession && this._engine && (this._engine.customAnimationFrameRequester = {
- requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),
- renderFunction: function(e, i) {
- var n;
- t.inXRSession && t._engine && (t.currentFrame = i,
- t.currentTimestamp = e,
- i && (t.inXRFrameLoop = !0,
- t._engine.framebufferDimensionsObject = (null === (n = t._baseLayerRTTProvider) || void 0 === n ? void 0 : n.getFramebufferDimensions()) || null,
- t.onXRFrameObservable.notifyObservers(i),
- t._engine._renderLoop(),
- t._engine.framebufferDimensionsObject = null,
- t.inXRFrameLoop = !1))
- }
- },
- this._engine.framebufferDimensionsObject = (null === (e = this._baseLayerRTTProvider) || void 0 === e ? void 0 : e.getFramebufferDimensions()) || null,
- "undefined" != typeof window && window.cancelAnimationFrame && window.cancelAnimationFrame(this._engine._frameHandler),
- this._engine._renderLoop())
- }
- ,
- e.prototype.setReferenceSpaceTypeAsync = function(e) {
- var t = this;
- return void 0 === e && (e = "local-floor"),
- this.session.requestReferenceSpace(e).then((function(e) {
- return e
- }
- ), (function(e) {
- return K.Error("XR.requestReferenceSpace failed for the following reason: "),
- K.Error(e),
- K.Log('Defaulting to universally-supported "viewer" reference space type.'),
- t.session.requestReferenceSpace("viewer").then((function(e) {
- var i = new XRRigidTransform({
- x: 0,
- y: -t.defaultHeightCompensation,
- z: 0
- });
- return e.getOffsetReferenceSpace(i)
- }
- ), (function(e) {
- throw K.Error(e),
- 'XR initialization failed: required "viewer" reference space type not supported.'
- }
- ))
- }
- )).then((function(e) {
- return t.session.requestReferenceSpace("viewer").then((function(i) {
- return t.viewerReferenceSpace = i,
- e
- }
- ))
- }
- )).then((function(e) {
- return t.referenceSpace = t.baseReferenceSpace = e,
- t.referenceSpace
- }
- ))
- }
- ,
- e.prototype.updateRenderStateAsync = function(e) {
- return Promise.resolve(this.session.updateRenderState(e))
- }
- ,
- e.prototype._setBaseLayerWrapper = function(e) {
- var t, i;
- this.isNative && (null === (t = this._baseLayerRTTProvider) || void 0 === t || t.dispose()),
- this._baseLayerWrapper = e,
- this._baseLayerRTTProvider = (null === (i = this._baseLayerWrapper) || void 0 === i ? void 0 : i.createRenderTargetTextureProvider(this)) || null
- }
- ,
- e.prototype.updateRenderState = function(e) {
- e.baseLayer && this._setBaseLayerWrapper(this.isNative ? new zs(e.baseLayer) : new Us(e.baseLayer)),
- this.session.updateRenderState(e)
- }
- ,
- e.IsSessionSupportedAsync = function(e) {
- if (!navigator.xr)
- return Promise.resolve(!1);
- var t = navigator.xr.isSessionSupported || navigator.xr.supportsSession;
- return t ? t.call(navigator.xr, e).then((function(e) {
- var t = void 0 === e || e;
- return Promise.resolve(t)
- }
- )).catch((function(e) {
- return K.Warn(e),
- Promise.resolve(!1)
- }
- )) : Promise.resolve(!1)
- }
- ,
- Object.defineProperty(e.prototype, "isNative", {
- get: function() {
- var e;
- return null !== (e = this._xrNavigator.xr.native) && void 0 !== e && e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentFrameRate", {
- get: function() {
- var e;
- return null === (e = this.session) || void 0 === e ? void 0 : e.frameRate
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportedFrameRates", {
- get: function() {
- var e;
- return null === (e = this.session) || void 0 === e ? void 0 : e.supportedFrameRates
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.updateTargetFrameRate = function(e) {
- return this.session.updateTargetFrameRate(e)
- }
- ,
- e.prototype.runInXRFrame = function(e, t) {
- void 0 === t && (t = !0),
- this.inXRFrameLoop ? e() : !this.inXRSession && t || this.onXRFrameObservable.addOnce(e)
- }
- ,
- Object.defineProperty(e.prototype, "isFixedFoveationSupported", {
- get: function() {
- var e;
- return (null === (e = this._baseLayerWrapper) || void 0 === e ? void 0 : e.isFixedFoveationSupported) || !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fixedFoveation", {
- get: function() {
- var e;
- return (null === (e = this._baseLayerWrapper) || void 0 === e ? void 0 : e.fixedFoveation) || null
- },
- set: function(e) {
- var t = Math.max(0, Math.min(1, e || 0));
- this._baseLayerWrapper && (this._baseLayerWrapper.fixedFoveation = t)
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }();
- function js(e) {
- var t = e.height || 2
- , i = 0 === e.diameterTop ? 0 : e.diameterTop || e.diameter || 1
- , n = 0 === e.diameterBottom ? 0 : e.diameterBottom || e.diameter || 1;
- i = i || 1e-5,
- n = n || 1e-5;
- var r, o = e.tessellation || 24, a = e.subdivisions || 1, s = !!e.hasRings, l = !!e.enclose, c = 0 === e.cap ? 0 : e.cap || Vr.CAP_ALL, u = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = e.faceUV || new Array(3), p = e.faceColors, f = 2 + (1 + (1 !== u && l ? 2 : 0)) * (s ? a : 1);
- for (r = 0; r < f; r++)
- p && void 0 === p[r] && (p[r] = new N(1,1,1,1));
- for (r = 0; r < f; r++)
- d && void 0 === d[r] && (d[r] = new R(0,0,1,1));
- var _, m, g, v, y, b, T = new Array, E = new Array, S = new Array, C = new Array, P = new Array, M = 2 * Math.PI * u / o, I = (n - i) / 2 / t, O = x.Zero(), D = x.Zero(), L = x.Zero(), F = x.Zero(), w = x.Zero(), B = vn.Y, U = 1, V = 1, k = 0, G = 0;
- for (v = 0; v <= a; v++)
- for (g = ((m = v / a) * (i - n) + n) / 2,
- U = s && 0 !== v && v !== a ? 2 : 1,
- b = 0; b < U; b++) {
- for (s && (V += b),
- l && (V += 2 * b),
- y = 0; y <= o; y++)
- _ = y * M,
- O.x = Math.cos(-_) * g,
- O.y = -t / 2 + m * t,
- O.z = Math.sin(-_) * g,
- 0 === i && v === a ? (D.x = S[S.length - 3 * (o + 1)],
- D.y = S[S.length - 3 * (o + 1) + 1],
- D.z = S[S.length - 3 * (o + 1) + 2]) : (D.x = O.x,
- D.z = O.z,
- D.y = Math.sqrt(D.x * D.x + D.z * D.z) * I,
- D.normalize()),
- 0 === y && (L.copyFrom(O),
- F.copyFrom(D)),
- E.push(O.x, O.y, O.z),
- S.push(D.x, D.y, D.z),
- G = s ? k !== V ? d[V].y : d[V].w : d[V].y + (d[V].w - d[V].y) * m,
- C.push(d[V].x + (d[V].z - d[V].x) * y / o, pr.UseOpenGLOrientationForUV ? 1 - G : G),
- p && P.push(p[V].r, p[V].g, p[V].b, p[V].a);
- 1 !== u && l && (E.push(O.x, O.y, O.z),
- E.push(0, O.y, 0),
- E.push(0, O.y, 0),
- E.push(L.x, L.y, L.z),
- x.CrossToRef(B, D, w),
- w.normalize(),
- S.push(w.x, w.y, w.z, w.x, w.y, w.z),
- x.CrossToRef(F, B, w),
- w.normalize(),
- S.push(w.x, w.y, w.z, w.x, w.y, w.z),
- G = s ? k !== V ? d[V + 1].y : d[V + 1].w : d[V + 1].y + (d[V + 1].w - d[V + 1].y) * m,
- C.push(d[V + 1].x, pr.UseOpenGLOrientationForUV ? 1 - G : G),
- C.push(d[V + 1].z, pr.UseOpenGLOrientationForUV ? 1 - G : G),
- G = s ? k !== V ? d[V + 2].y : d[V + 2].w : d[V + 2].y + (d[V + 2].w - d[V + 2].y) * m,
- C.push(d[V + 2].x, pr.UseOpenGLOrientationForUV ? 1 - G : G),
- C.push(d[V + 2].z, pr.UseOpenGLOrientationForUV ? 1 - G : G),
- p && (P.push(p[V + 1].r, p[V + 1].g, p[V + 1].b, p[V + 1].a),
- P.push(p[V + 1].r, p[V + 1].g, p[V + 1].b, p[V + 1].a),
- P.push(p[V + 2].r, p[V + 2].g, p[V + 2].b, p[V + 2].a),
- P.push(p[V + 2].r, p[V + 2].g, p[V + 2].b, p[V + 2].a))),
- k !== V && (k = V)
- }
- var z = 1 !== u && l ? o + 4 : o;
- for (v = 0,
- V = 0; V < a; V++) {
- var W = 0
- , H = 0
- , X = 0
- , j = 0;
- for (y = 0; y < o; y++)
- W = v * (z + 1) + y,
- H = (v + 1) * (z + 1) + y,
- X = v * (z + 1) + (y + 1),
- j = (v + 1) * (z + 1) + (y + 1),
- T.push(W, H, X),
- T.push(j, X, H);
- 1 !== u && l && (T.push(W + 2, H + 2, X + 2),
- T.push(j + 2, X + 2, H + 2),
- T.push(W + 4, H + 4, X + 4),
- T.push(j + 4, X + 4, H + 4)),
- v = s ? v + 2 : v + 1
- }
- var Y = function(e) {
- var r = e ? i / 2 : n / 2;
- if (0 !== r) {
- var a, s, l, c = e ? d[f - 1] : d[0], h = null;
- p && (h = e ? p[f - 1] : p[0]);
- var _ = E.length / 3
- , m = e ? t / 2 : -t / 2
- , g = new x(0,m,0);
- E.push(g.x, g.y, g.z),
- S.push(0, e ? 1 : -1, 0);
- var v = c.y + .5 * (c.w - c.y);
- C.push(c.x + .5 * (c.z - c.x), pr.UseOpenGLOrientationForUV ? 1 - v : v),
- h && P.push(h.r, h.g, h.b, h.a);
- var y = new A(.5,.5);
- for (l = 0; l <= o; l++) {
- a = 2 * Math.PI * l * u / o;
- var b = Math.cos(-a)
- , R = Math.sin(-a);
- s = new x(b * r,m,R * r);
- var M = new A(b * y.x + .5,R * y.y + .5);
- E.push(s.x, s.y, s.z),
- S.push(0, e ? 1 : -1, 0);
- var I = c.y + (c.w - c.y) * M.y;
- C.push(c.x + (c.z - c.x) * M.x, pr.UseOpenGLOrientationForUV ? 1 - I : I),
- h && P.push(h.r, h.g, h.b, h.a)
- }
- for (l = 0; l < o; l++)
- e ? (T.push(_),
- T.push(_ + (l + 2)),
- T.push(_ + (l + 1))) : (T.push(_),
- T.push(_ + (l + 1)),
- T.push(_ + (l + 2)))
- }
- };
- c !== Vr.CAP_START && c !== Vr.CAP_ALL || Y(!1),
- c !== Vr.CAP_END && c !== Vr.CAP_ALL || Y(!0),
- $n._ComputeSides(h, E, T, S, C, e.frontUVs, e.backUVs);
- var K = new $n;
- return K.indices = T,
- K.positions = E,
- K.normals = S,
- K.uvs = C,
- p && (K.colors = P),
- K
- }
- function Ys(e, t, i) {
- void 0 === t && (t = {});
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- js(t).applyToMesh(n, t.updatable),
- n
- }
- !function(e) {
- e[e.ENTERING_XR = 0] = "ENTERING_XR",
- e[e.EXITING_XR = 1] = "EXITING_XR",
- e[e.IN_XR = 2] = "IN_XR",
- e[e.NOT_IN_XR = 3] = "NOT_IN_XR"
- }(Ns || (Ns = {})),
- function(e) {
- e[e.NOT_TRACKING = 0] = "NOT_TRACKING",
- e[e.TRACKING_LOST = 1] = "TRACKING_LOST",
- e[e.TRACKING = 2] = "TRACKING"
- }(Ls || (Ls = {}));
- var Ks = {
- CreateCylinder: Ys
- };
- function Qs(e) {
- for (var t = [], i = [], n = [], r = [], o = e.diameter || 1, a = e.thickness || .5, s = e.tessellation || 16, l = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, c = s + 1, u = 0; u <= s; u++)
- for (var h = u / s, d = u * Math.PI * 2 / s - Math.PI / 2, p = P.Translation(o / 2, 0, 0).multiply(P.RotationY(d)), f = 0; f <= s; f++) {
- var _ = 1 - f / s
- , m = f * Math.PI * 2 / s + Math.PI
- , g = Math.cos(m)
- , v = Math.sin(m)
- , y = new x(g,v,0)
- , b = y.scale(a / 2)
- , T = new A(h,_);
- b = x.TransformCoordinates(b, p),
- y = x.TransformNormal(y, p),
- i.push(b.x, b.y, b.z),
- n.push(y.x, y.y, y.z),
- r.push(T.x, pr.UseOpenGLOrientationForUV ? 1 - T.y : T.y);
- var E = (u + 1) % c
- , S = (f + 1) % c;
- t.push(u * c + f),
- t.push(u * c + S),
- t.push(E * c + f),
- t.push(u * c + S),
- t.push(E * c + S),
- t.push(E * c + f)
- }
- $n._ComputeSides(l, i, t, n, r, e.frontUVs, e.backUVs);
- var R = new $n;
- return R.indices = t,
- R.positions = i,
- R.normals = n,
- R.uvs = r,
- R
- }
- function qs(e, t, i) {
- void 0 === t && (t = {});
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- Qs(t).applyToMesh(n, t.updatable),
- n
- }
- $n.CreateCylinder = js,
- Vr.CreateCylinder = function(e, t, i, n, r, o, a, s, l) {
- return void 0 !== a && a instanceof mn || (void 0 !== a && (l = s || Vr.DEFAULTSIDE,
- s = a),
- a = o,
- o = 1),
- Ys(e, {
- height: t,
- diameterTop: i,
- diameterBottom: n,
- tessellation: r,
- subdivisions: o,
- sideOrientation: l,
- updatable: s
- }, a)
- }
- ;
- var Zs = {
- CreateTorus: qs
- };
- $n.CreateTorus = Qs,
- Vr.CreateTorus = function(e, t, i, n, r, o, a) {
- return qs(e, {
- diameter: t,
- thickness: i,
- tessellation: n,
- sideOrientation: a,
- updatable: o
- }, r)
- }
- ,
- Vr._GroundMeshParser = function(e, t) {
- return Js.Parse(e, t)
- }
- ;
- var Js = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n.generateOctree = !1,
- n
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "GroundMesh"
- }
- ,
- Object.defineProperty(t.prototype, "subdivisions", {
- get: function() {
- return Math.min(this._subdivisionsX, this._subdivisionsY)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "subdivisionsX", {
- get: function() {
- return this._subdivisionsX
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "subdivisionsY", {
- get: function() {
- return this._subdivisionsY
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.optimize = function(e, t) {
- void 0 === t && (t = 32),
- this._subdivisionsX = e,
- this._subdivisionsY = e,
- this.subdivide(e),
- this.createOrUpdateSubmeshesOctree && this.createOrUpdateSubmeshesOctree(t)
- }
- ,
- t.prototype.getHeightAtCoordinates = function(e, t) {
- var i = this.getWorldMatrix()
- , n = I.Matrix[5];
- i.invertToRef(n);
- var r = I.Vector3[8];
- if (x.TransformCoordinatesFromFloatsToRef(e, 0, t, n, r),
- e = r.x,
- t = r.z,
- e < this._minX || e > this._maxX || t < this._minZ || t > this._maxZ)
- return this.position.y;
- this._heightQuads && 0 != this._heightQuads.length || (this._initHeightQuads(),
- this._computeHeightQuads());
- var o = this._getFacetAt(e, t)
- , a = -(o.x * e + o.z * t + o.w) / o.y;
- return x.TransformCoordinatesFromFloatsToRef(0, a, 0, i, r),
- r.y
- }
- ,
- t.prototype.getNormalAtCoordinates = function(e, t) {
- var i = new x(0,1,0);
- return this.getNormalAtCoordinatesToRef(e, t, i),
- i
- }
- ,
- t.prototype.getNormalAtCoordinatesToRef = function(e, t, i) {
- var n = this.getWorldMatrix()
- , r = I.Matrix[5];
- n.invertToRef(r);
- var o = I.Vector3[8];
- if (x.TransformCoordinatesFromFloatsToRef(e, 0, t, r, o),
- e = o.x,
- t = o.z,
- e < this._minX || e > this._maxX || t < this._minZ || t > this._maxZ)
- return this;
- this._heightQuads && 0 != this._heightQuads.length || (this._initHeightQuads(),
- this._computeHeightQuads());
- var a = this._getFacetAt(e, t);
- return x.TransformNormalFromFloatsToRef(a.x, a.y, a.z, n, i),
- this
- }
- ,
- t.prototype.updateCoordinateHeights = function() {
- return this._heightQuads && 0 != this._heightQuads.length || this._initHeightQuads(),
- this._computeHeightQuads(),
- this
- }
- ,
- t.prototype._getFacetAt = function(e, t) {
- var i = Math.floor((e + this._maxX) * this._subdivisionsX / this._width)
- , n = Math.floor(-(t + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY)
- , r = this._heightQuads[n * this._subdivisionsX + i];
- return t < r.slope.x * e + r.slope.y ? r.facet1 : r.facet2
- }
- ,
- t.prototype._initHeightQuads = function() {
- var e = this._subdivisionsX
- , t = this._subdivisionsY;
- this._heightQuads = new Array;
- for (var i = 0; i < t; i++)
- for (var n = 0; n < e; n++) {
- var r = {
- slope: A.Zero(),
- facet1: new R(0,0,0,0),
- facet2: new R(0,0,0,0)
- };
- this._heightQuads[i * e + n] = r
- }
- return this
- }
- ,
- t.prototype._computeHeightQuads = function() {
- var e = this.getVerticesData(Bi.PositionKind);
- if (!e)
- return this;
- for (var t = I.Vector3[3], i = I.Vector3[2], n = I.Vector3[1], r = I.Vector3[0], o = I.Vector3[4], a = I.Vector3[5], s = I.Vector3[6], l = I.Vector3[7], c = I.Vector3[8], u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0, m = 0, g = this._subdivisionsX, v = this._subdivisionsY, y = 0; y < v; y++)
- for (var b = 0; b < g; b++) {
- u = 3 * b,
- h = y * (g + 1) * 3,
- d = (y + 1) * (g + 1) * 3,
- t.x = e[h + u],
- t.y = e[h + u + 1],
- t.z = e[h + u + 2],
- i.x = e[h + u + 3],
- i.y = e[h + u + 4],
- i.z = e[h + u + 5],
- n.x = e[d + u],
- n.y = e[d + u + 1],
- n.z = e[d + u + 2],
- r.x = e[d + u + 3],
- r.y = e[d + u + 4],
- r.z = e[d + u + 5],
- p = (r.z - t.z) / (r.x - t.x),
- f = t.z - p * t.x,
- i.subtractToRef(t, o),
- n.subtractToRef(t, a),
- r.subtractToRef(t, s),
- x.CrossToRef(s, a, l),
- x.CrossToRef(o, s, c),
- l.normalize(),
- c.normalize(),
- _ = -(l.x * t.x + l.y * t.y + l.z * t.z),
- m = -(c.x * i.x + c.y * i.y + c.z * i.z);
- var T = this._heightQuads[y * g + b];
- T.slope.copyFromFloats(p, f),
- T.facet1.copyFromFloats(l.x, l.y, l.z, _),
- T.facet2.copyFromFloats(c.x, c.y, c.z, m)
- }
- return this
- }
- ,
- t.prototype.serialize = function(t) {
- e.prototype.serialize.call(this, t),
- t.subdivisionsX = this._subdivisionsX,
- t.subdivisionsY = this._subdivisionsY,
- t.minX = this._minX,
- t.maxX = this._maxX,
- t.minZ = this._minZ,
- t.maxZ = this._maxZ,
- t.width = this._width,
- t.height = this._height
- }
- ,
- t.Parse = function(e, i) {
- var n = new t(e.name,i);
- return n._subdivisionsX = e.subdivisionsX || 1,
- n._subdivisionsY = e.subdivisionsY || 1,
- n._minX = e.minX,
- n._maxX = e.maxX,
- n._minZ = e.minZ,
- n._maxZ = e.maxZ,
- n._width = e.width,
- n._height = e.height,
- n
- }
- ,
- t
- }(Vr);
- function $s(e) {
- var t, i, n = [], r = [], o = [], a = [], s = e.width || 1, l = e.height || 1, c = e.subdivisionsX || e.subdivisions || 1, u = e.subdivisionsY || e.subdivisions || 1;
- for (t = 0; t <= u; t++)
- for (i = 0; i <= c; i++) {
- var h = new x(i * s / c - s / 2,0,(u - t) * l / u - l / 2)
- , d = new x(0,1,0);
- r.push(h.x, h.y, h.z),
- o.push(d.x, d.y, d.z),
- a.push(i / c, pr.UseOpenGLOrientationForUV ? t / u : 1 - t / u)
- }
- for (t = 0; t < u; t++)
- for (i = 0; i < c; i++)
- n.push(i + 1 + (t + 1) * (c + 1)),
- n.push(i + 1 + t * (c + 1)),
- n.push(i + t * (c + 1)),
- n.push(i + (t + 1) * (c + 1)),
- n.push(i + 1 + (t + 1) * (c + 1)),
- n.push(i + t * (c + 1));
- var p = new $n;
- return p.indices = n,
- p.positions = r,
- p.normals = o,
- p.uvs = a,
- p
- }
- function el(e) {
- var t, i, n, r, o = void 0 !== e.xmin && null !== e.xmin ? e.xmin : -1, a = void 0 !== e.zmin && null !== e.zmin ? e.zmin : -1, s = void 0 !== e.xmax && null !== e.xmax ? e.xmax : 1, l = void 0 !== e.zmax && null !== e.zmax ? e.zmax : 1, c = e.subdivisions || {
- w: 1,
- h: 1
- }, u = e.precision || {
- w: 1,
- h: 1
- }, h = new Array, d = new Array, p = new Array, f = new Array;
- c.h = c.h < 1 ? 1 : c.h,
- c.w = c.w < 1 ? 1 : c.w,
- u.w = u.w < 1 ? 1 : u.w,
- u.h = u.h < 1 ? 1 : u.h;
- var _ = (s - o) / c.w
- , m = (l - a) / c.h;
- function g(e, n, r, o) {
- var a = d.length / 3
- , s = u.w + 1;
- for (t = 0; t < u.h; t++)
- for (i = 0; i < u.w; i++) {
- var l = [a + i + t * s, a + (i + 1) + t * s, a + (i + 1) + (t + 1) * s, a + i + (t + 1) * s];
- h.push(l[1]),
- h.push(l[2]),
- h.push(l[3]),
- h.push(l[0]),
- h.push(l[1]),
- h.push(l[3])
- }
- var c = x.Zero()
- , _ = new x(0,1,0);
- for (t = 0; t <= u.h; t++)
- for (c.z = t * (o - n) / u.h + n,
- i = 0; i <= u.w; i++)
- c.x = i * (r - e) / u.w + e,
- c.y = 0,
- d.push(c.x, c.y, c.z),
- p.push(_.x, _.y, _.z),
- f.push(i / u.w, t / u.h)
- }
- for (n = 0; n < c.h; n++)
- for (r = 0; r < c.w; r++)
- g(o + r * _, a + n * m, o + (r + 1) * _, a + (n + 1) * m);
- var v = new $n;
- return v.indices = h,
- v.positions = d,
- v.normals = p,
- v.uvs = f,
- v
- }
- function tl(e) {
- var t, i, n = [], r = [], o = [], a = [], s = e.colorFilter || new D(.3,.59,.11), l = e.alphaFilter || 0, c = !1;
- if (e.minHeight > e.maxHeight) {
- c = !0;
- var u = e.maxHeight;
- e.maxHeight = e.minHeight,
- e.minHeight = u
- }
- for (t = 0; t <= e.subdivisions; t++)
- for (i = 0; i <= e.subdivisions; i++) {
- var h = new x(i * e.width / e.subdivisions - e.width / 2,0,(e.subdivisions - t) * e.height / e.subdivisions - e.height / 2)
- , d = 4 * (((h.x + e.width / 2) / e.width * (e.bufferWidth - 1) | 0) + ((1 - (h.z + e.height / 2) / e.height) * (e.bufferHeight - 1) | 0) * e.bufferWidth)
- , p = e.buffer[d] / 255
- , f = e.buffer[d + 1] / 255
- , _ = e.buffer[d + 2] / 255
- , g = e.buffer[d + 3] / 255;
- c && (p = 1 - p,
- f = 1 - f,
- _ = 1 - _);
- var v = p * s.r + f * s.g + _ * s.b;
- h.y = g >= l ? e.minHeight + (e.maxHeight - e.minHeight) * v : e.minHeight - m,
- r.push(h.x, h.y, h.z),
- o.push(0, 0, 0),
- a.push(i / e.subdivisions, 1 - t / e.subdivisions)
- }
- for (t = 0; t < e.subdivisions; t++)
- for (i = 0; i < e.subdivisions; i++) {
- var y = i + 1 + (t + 1) * (e.subdivisions + 1)
- , b = i + 1 + t * (e.subdivisions + 1)
- , T = i + t * (e.subdivisions + 1)
- , E = i + (t + 1) * (e.subdivisions + 1)
- , S = r[3 * y + 1] >= e.minHeight
- , A = r[3 * b + 1] >= e.minHeight
- , R = r[3 * T + 1] >= e.minHeight;
- S && A && R && (n.push(y),
- n.push(b),
- n.push(T)),
- r[3 * E + 1] >= e.minHeight && S && R && (n.push(E),
- n.push(y),
- n.push(T))
- }
- $n.ComputeNormals(r, n, o);
- var C = new $n;
- return C.indices = n,
- C.positions = r,
- C.normals = o,
- C.uvs = a,
- C
- }
- function il(e, t, i) {
- void 0 === t && (t = {});
- var n = new Js(e,i);
- return n._setReady(!1),
- n._subdivisionsX = t.subdivisionsX || t.subdivisions || 1,
- n._subdivisionsY = t.subdivisionsY || t.subdivisions || 1,
- n._width = t.width || 1,
- n._height = t.height || 1,
- n._maxX = n._width / 2,
- n._maxZ = n._height / 2,
- n._minX = -n._maxX,
- n._minZ = -n._maxZ,
- $s(t).applyToMesh(n, t.updatable),
- n._setReady(!0),
- n
- }
- function nl(e, t, i) {
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return el(t).applyToMesh(n, t.updatable),
- n
- }
- function rl(e, t, i, n) {
- void 0 === i && (i = {}),
- void 0 === n && (n = null);
- var r = i.width || 10
- , o = i.height || 10
- , a = i.subdivisions || 1
- , s = i.minHeight || 0
- , l = i.maxHeight || 1
- , c = i.colorFilter || new D(.3,.59,.11)
- , u = i.alphaFilter || 0
- , h = i.updatable
- , d = i.onReady;
- n = n || E.LastCreatedScene;
- var p = new Js(e,n);
- return p._subdivisionsX = a,
- p._subdivisionsY = a,
- p._width = r,
- p._height = o,
- p._maxX = p._width / 2,
- p._maxZ = p._height / 2,
- p._minX = -p._maxX,
- p._minZ = -p._maxZ,
- p._setReady(!1),
- gi.LoadImage(t, (function(e) {
- var t = e.width
- , i = e.height;
- if (!n.isDisposed) {
- var f = null == n ? void 0 : n.getEngine().resizeImageBitmap(e, t, i);
- tl({
- width: r,
- height: o,
- subdivisions: a,
- minHeight: s,
- maxHeight: l,
- colorFilter: c,
- buffer: f,
- bufferWidth: t,
- bufferHeight: i,
- alphaFilter: u
- }).applyToMesh(p, h),
- d && d(p),
- p._setReady(!0)
- }
- }
- ), (function() {}
- ), n.offlineProvider),
- p
- }
- var ol = {
- CreateGround: il,
- CreateGroundFromHeightMap: rl,
- CreateTiledGround: nl
- };
- $n.CreateGround = $s,
- $n.CreateTiledGround = el,
- $n.CreateGroundFromHeightMap = tl,
- Vr.CreateGround = function(e, t, i, n, r, o) {
- return il(e, {
- width: t,
- height: i,
- subdivisions: n,
- updatable: o
- }, r)
- }
- ,
- Vr.CreateTiledGround = function(e, t, i, n, r, o, a, s, l) {
- return nl(e, {
- xmin: t,
- zmin: i,
- xmax: n,
- zmax: r,
- subdivisions: o,
- precision: a,
- updatable: l
- }, s)
- }
- ,
- Vr.CreateGroundFromHeightMap = function(e, t, i, n, r, o, a, s, l, c, u) {
- return rl(e, t, {
- width: i,
- height: n,
- subdivisions: r,
- minHeight: o,
- maxHeight: a,
- updatable: l,
- onReady: c,
- alphaFilter: u
- }, s)
- }
- ;
- var al, sl = function() {
- function e(t, i) {
- if (void 0 === i && (i = null),
- this.scene = t,
- 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 = e._IdCounter++,
- i)
- this._gazeTracker = i.clone("gazeTracker");
- else {
- this._gazeTracker = qs("gazeTracker", {
- diameter: .0035,
- thickness: .0025,
- tessellation: 20,
- updatable: !1
- }, t),
- this._gazeTracker.bakeCurrentTransformIntoVertices(),
- this._gazeTracker.isPickable = !1,
- this._gazeTracker.isVisible = !1;
- var n = new Os("targetMat",t);
- n.specularColor = D.Black(),
- n.emissiveColor = new D(.7,.7,.7),
- n.backFaceCulling = !1,
- this._gazeTracker.material = n
- }
- }
- return e.prototype._getForwardRay = function(e) {
- return new _o(x.Zero(),new x(0,0,e))
- }
- ,
- e.prototype._selectionPointerDown = function() {
- this._pointerDownOnMeshAsked = !0,
- this._currentHit && this.scene.simulatePointerDown(this._currentHit, {
- pointerId: this._id
- })
- }
- ,
- e.prototype._selectionPointerUp = function() {
- this._currentHit && this.scene.simulatePointerUp(this._currentHit, {
- pointerId: this._id
- }),
- this._pointerDownOnMeshAsked = !1
- }
- ,
- e.prototype._activatePointer = function() {
- this._activePointer = !0
- }
- ,
- e.prototype._deactivatePointer = function() {
- this._activePointer = !1
- }
- ,
- e.prototype._updatePointerDistance = function(e) {
- void 0 === e && (e = 100)
- }
- ,
- e.prototype.dispose = function() {
- this._interactionsEnabled = !1,
- this._teleportationEnabled = !1,
- this._gazeTracker && this._gazeTracker.dispose()
- }
- ,
- e._IdCounter = 0,
- e
- }(), ll = function(e) {
- function t(t, i, n) {
- var r = e.call(this, i, n) || this;
- r.webVRController = t,
- r._laserPointer = Ys("laserPointer", {
- updatable: !1,
- height: 1,
- diameterTop: .004,
- diameterBottom: 2e-4,
- tessellation: 20,
- subdivisions: 1
- }, i);
- var o = new Os("laserPointerMat",i);
- if (o.emissiveColor = new D(.7,.7,.7),
- o.alpha = .6,
- r._laserPointer.material = o,
- r._laserPointer.rotation.x = Math.PI / 2,
- r._laserPointer.position.z = -.5,
- r._laserPointer.isVisible = !1,
- r._laserPointer.isPickable = !1,
- !t.mesh) {
- var a = new Vr("preloadControllerMesh",i)
- , s = new Vr(Ra.POINTING_POSE,i);
- s.rotation.x = -.7,
- a.addChild(s),
- t.attachToMesh(a)
- }
- return r._setLaserPointerParent(t.mesh),
- r._meshAttachedObserver = t._meshAttachedObservable.add((function(e) {
- r._setLaserPointerParent(e)
- }
- )),
- r
- }
- return U(t, e),
- t.prototype._getForwardRay = function(e) {
- return this.webVRController.getForwardRay(e)
- }
- ,
- t.prototype._activatePointer = function() {
- e.prototype._activatePointer.call(this),
- this._laserPointer.isVisible = !0
- }
- ,
- t.prototype._deactivatePointer = function() {
- e.prototype._deactivatePointer.call(this),
- this._laserPointer.isVisible = !1
- }
- ,
- t.prototype._setLaserPointerColor = function(e) {
- this._laserPointer.material.emissiveColor = e
- }
- ,
- t.prototype._setLaserPointerLightingDisabled = function(e) {
- this._laserPointer.material.disableLighting = e
- }
- ,
- t.prototype._setLaserPointerParent = function(e) {
- var t = function(e) {
- e.isPickable = !1,
- e.getChildMeshes().forEach((function(e) {
- t(e)
- }
- ))
- };
- t(e);
- var i = e.getChildren(void 0, !1)
- , n = e;
- this.webVRController._pointingPoseNode = null;
- for (var r = 0; r < i.length; r++)
- if (i[r].name && i[r].name.indexOf(Ra.POINTING_POSE) >= 0) {
- n = i[r],
- this.webVRController._pointingPoseNode = n;
- break
- }
- this._laserPointer.parent = n
- }
- ,
- t.prototype._updatePointerDistance = function(e) {
- void 0 === e && (e = 100),
- this._laserPointer.scaling.y = e,
- this._laserPointer.position.z = -e / 2
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._laserPointer.dispose(),
- this._meshAttachedObserver && this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)
- }
- ,
- t
- }(sl), cl = function(e) {
- function t(t, i) {
- var n = e.call(this, i) || this;
- return n._getCamera = t,
- n
- }
- return U(t, e),
- t.prototype._getForwardRay = function(e) {
- var t = this._getCamera();
- return t ? t.getForwardRay(e) : new _o(x.Zero(),x.Forward())
- }
- ,
- t
- }(sl), ul = function() {}, hl = function() {
- function e(t, i) {
- void 0 === i && (i = {});
- var n = this;
- if (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 h,
- this.onAfterEnteringVRObservable = new h,
- this.onExitingVRObservable = new h,
- this.onControllerMeshLoadedObservable = new h,
- this._useCustomVRButton = !1,
- this._teleportationRequested = !1,
- this._teleportActive = !1,
- this._floorMeshesCollection = [],
- this._teleportationMode = e.TELEPORTATIONMODE_CONSTANTTIME,
- this._teleportationTime = 122,
- this._teleportationSpeed = 20,
- this._rotationAllowed = !0,
- this._teleportBackwardsVector = new x(0,-1,-1),
- this._isDefaultTeleportationTarget = !0,
- this._teleportationFillColor = "#444444",
- this._teleportationBorderColor = "#FFFFFF",
- this._rotationAngle = 0,
- this._haloCenter = new x(0,0,0),
- this._padSensibilityUp = .65,
- this._padSensibilityDown = .35,
- this._leftController = null,
- this._rightController = null,
- this._gazeColor = new D(.7,.7,.7),
- this._laserColor = new D(.7,.7,.7),
- this._pickedLaserColor = new D(.2,.2,1),
- this._pickedGazeColor = new D(0,0,1),
- this.onNewMeshSelected = new h,
- this.onMeshSelectedWithController = new h,
- this.onNewMeshPicked = new h,
- this.onBeforeCameraTeleport = new h,
- this.onAfterCameraTeleport = new h,
- this.onSelectedMeshUnselected = new h,
- 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() {
- n._moveButtonToBottomRight(),
- n._fullscreenVRpresenting && n._webVRready && n.exitVR()
- }
- ,
- this._onFullscreenChange = function() {
- var e = document;
- void 0 !== e.fullscreen ? n._fullscreenVRpresenting = document.fullscreen : void 0 !== e.mozFullScreen ? n._fullscreenVRpresenting = e.mozFullScreen : void 0 !== e.webkitIsFullScreen ? n._fullscreenVRpresenting = e.webkitIsFullScreen : void 0 !== e.msIsFullScreen ? n._fullscreenVRpresenting = e.msIsFullScreen : void 0 !== document.msFullscreenElement && (n._fullscreenVRpresenting = document.msFullscreenElement),
- !n._fullscreenVRpresenting && n._inputElement && (n.exitVR(),
- !n._useCustomVRButton && n._btnVR && (n._btnVR.style.top = n._inputElement.offsetTop + n._inputElement.offsetHeight - 70 + "px",
- n._btnVR.style.left = n._inputElement.offsetLeft + n._inputElement.offsetWidth - 100 + "px",
- n._updateButtonVisibility()))
- }
- ,
- this._cachedAngularSensibility = {
- angularSensibilityX: null,
- angularSensibilityY: null,
- angularSensibility: null
- },
- this._beforeRender = function() {
- n._leftController && n._leftController._activePointer && n._castRayAndSelectObject(n._leftController),
- n._rightController && n._rightController._activePointer && n._castRayAndSelectObject(n._rightController),
- n._noControllerIsActive && (n._scene.getEngine().isPointerLock || n.enableGazeEvenWhenNoPointerLock) ? n._castRayAndSelectObject(n._cameraGazer) : n._cameraGazer._gazeTracker.isVisible = !1
- }
- ,
- this._onNewGamepadConnected = function(e) {
- if (e.type !== zo.POSE_ENABLED)
- e.leftStick && e.onleftstickchanged((function(e) {
- n._teleportationInitialized && n.teleportationEnabled && (!n._leftController && !n._rightController || n._leftController && !n._leftController._activePointer && n._rightController && !n._rightController._activePointer) && (n._checkTeleportWithRay(e, n._cameraGazer),
- n._checkTeleportBackwards(e, n._cameraGazer))
- }
- )),
- e.rightStick && e.onrightstickchanged((function(e) {
- n._teleportationInitialized && n._checkRotate(e, n._cameraGazer)
- }
- )),
- e.type === zo.XBOX && (e.onbuttondown((function(e) {
- n._interactionsEnabled && e === Sa.A && n._cameraGazer._selectionPointerDown()
- }
- )),
- e.onbuttonup((function(e) {
- n._interactionsEnabled && e === Sa.A && n._cameraGazer._selectionPointerUp()
- }
- )));
- else {
- var t = e
- , i = new ll(t,n._scene,n._cameraGazer._gazeTracker);
- "right" === t.hand || n._leftController && n._leftController.webVRController != t ? n._rightController = i : n._leftController = i,
- n._tryEnableInteractionOnController(i)
- }
- }
- ,
- this._tryEnableInteractionOnController = function(e) {
- n._interactionsRequested && !e._interactionsEnabled && n._enableInteractionOnController(e),
- n._teleportationRequested && !e._teleportationEnabled && n._enableTeleportationOnController(e)
- }
- ,
- this._onNewGamepadDisconnected = function(e) {
- e instanceof _s && ("left" === e.hand && null != n._leftController && (n._leftController.dispose(),
- n._leftController = null),
- "right" === e.hand && null != n._rightController && (n._rightController.dispose(),
- n._rightController = null))
- }
- ,
- this._workingVector = x.Zero(),
- this._workingQuaternion = C.Identity(),
- this._workingMatrix = P.Identity(),
- K.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),
- this._scene = t,
- this._inputElement = t.getEngine().getInputElement(),
- "getVRDisplays"in navigator || void 0 !== i.useXR || (i.useXR = !0),
- void 0 === i.createFallbackVRDeviceOrientationFreeCamera && (i.createFallbackVRDeviceOrientationFreeCamera = !0),
- void 0 === i.createDeviceOrientationCamera && (i.createDeviceOrientationCamera = !0),
- void 0 === i.laserToggle && (i.laserToggle = !0),
- void 0 === i.defaultHeight && (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 x(0,this._defaultHeight,0),
- i.createDeviceOrientationCamera || !this._scene.activeCamera) {
- if (this._deviceOrientationCamera = new ma("deviceOrientationVRHelper",this._position.clone(),t),
- this._scene.activeCamera && (this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ,
- this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ,
- this._scene.activeCamera instanceof da && this._scene.activeCamera.rotation)) {
- var r = this._scene.activeCamera;
- r.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(C.RotationYawPitchRoll(r.rotation.y, r.rotation.x, r.rotation.z)),
- this._deviceOrientationCamera.rotation = r.rotation.clone()
- }
- this._scene.activeCamera = this._deviceOrientationCamera,
- this._inputElement && this._scene.activeCamera.attachControl()
- } else
- this._existingCamera = this._scene.activeCamera;
- this.webVROptions.useXR && navigator.xr ? Xs.IsSessionSupportedAsync("immersive-vr").then((function(e) {
- e ? (K.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),
- t.createDefaultXRExperienceAsync({
- floorMeshes: i.floorMeshes || []
- }).then((function(e) {
- n.xr = e,
- n.xrTestDone = !0,
- n._cameraGazer = new cl((function() {
- return n.xr.baseExperience.camera
- }
- ),t),
- n.xr.baseExperience.onStateChangedObservable.add((function(e) {
- switch (e) {
- case Ns.ENTERING_XR:
- n.onEnteringVRObservable.notifyObservers(n),
- n._interactionsEnabled || n.xr.pointerSelection.detach(),
- n.xr.pointerSelection.displayLaserPointer = n._displayLaserPointer;
- break;
- case Ns.EXITING_XR:
- n.onExitingVRObservable.notifyObservers(n),
- n._scene.getEngine().resize();
- break;
- case Ns.IN_XR:
- n._hasEnteredVR = !0;
- break;
- case Ns.NOT_IN_XR:
- n._hasEnteredVR = !1
- }
- }
- ))
- }
- ))) : n._completeVRInit(t, i)
- }
- )) : this._completeVRInit(t, i)
- }
- return Object.defineProperty(e.prototype, "onEnteringVR", {
- get: function() {
- return this.onEnteringVRObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onExitingVR", {
- get: function() {
- return this.onExitingVRObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onControllerMeshLoaded", {
- get: function() {
- return this.onControllerMeshLoadedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.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(e.prototype, "leftControllerGazeTrackerMesh", {
- get: function() {
- return this._leftController ? this._leftController._gazeTracker : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightControllerGazeTrackerMesh", {
- get: function() {
- return this._rightController ? this._rightController._gazeTracker : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.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(e.prototype, "deviceOrientationCamera", {
- get: function() {
- return this._deviceOrientationCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentVRCamera", {
- get: function() {
- return this._webVRready ? this._webVRCamera : this._scene.activeCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "webVRCamera", {
- get: function() {
- return this._webVRCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vrDeviceOrientationCamera", {
- get: function() {
- return this._vrDeviceOrientationCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vrButton", {
- get: function() {
- return this._btnVR
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_teleportationRequestInitiated", {
- get: function() {
- return this._cameraGazer._teleportationRequestInitiated || null !== this._leftController && this._leftController._teleportationRequestInitiated || null !== this._rightController && this._rightController._teleportationRequestInitiated
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._completeVRInit = function(e, t) {
- var i = this;
- if (this.xrTestDone = !0,
- t.createFallbackVRDeviceOrientationFreeCamera && (t.useMultiview && (t.vrDeviceOrientationCameraMetrics || (t.vrDeviceOrientationCameraMetrics = ts.GetDefault()),
- t.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0),
- this._vrDeviceOrientationCamera = new us("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),
- this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
- this._webVRCamera = new fs("WebVRHelper",this._position,this._scene,t),
- this._webVRCamera.useStandingMatrix(),
- this._cameraGazer = new cl((function() {
- return i.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 n = ".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(" + (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") + "); 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) }";
- n += ".babylonVRicon.vrdisplaypresenting { display: none; }";
- var r = document.createElement("style");
- r.appendChild(document.createTextNode(n)),
- document.getElementsByTagName("head")[0].appendChild(r),
- this._moveButtonToBottomRight()
- }
- this._btnVR && this._btnVR.addEventListener("click", (function() {
- i.isInVRMode ? i._scene.getEngine().disableVR() : i.enterVR()
- }
- ));
- var o = this._scene.getEngine().getHostWindow();
- o && (o.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,
- t.createFallbackVRDeviceOrientationFreeCamera ? this._displayVRButton() : this._scene.getEngine().onVRDisplayChangedObservable.add((function(e) {
- e.vrDisplay && i._displayVRButton()
- }
- )),
- this._onKeyDown = function(e) {
- 27 === e.keyCode && i.isInVRMode && i.exitVR()
- }
- ,
- document.addEventListener("keydown", this._onKeyDown),
- this._scene.onPrePointerObservable.add((function() {
- i._hasEnteredVR && i.exitVROnDoubleTap && (i.exitVR(),
- i._fullscreenVRpresenting && i._scene.getEngine().exitFullscreen())
- }
- ), Xi.POINTERDOUBLETAP, !1),
- this._onVRDisplayChangedBind = function(e) {
- return i._onVRDisplayChanged(e)
- }
- ,
- this._onVrDisplayPresentChangeBind = function() {
- return i._onVrDisplayPresentChange()
- }
- ,
- this._onVRRequestPresentStart = function() {
- i._webVRrequesting = !0,
- i._updateButtonVisibility()
- }
- ,
- this._onVRRequestPresentComplete = function() {
- i._webVRrequesting = !1,
- i._updateButtonVisibility()
- }
- ,
- e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChangedBind),
- e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),
- e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),
- o.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChangeBind),
- e.onDisposeObservable.add((function() {
- i.dispose()
- }
- )),
- this._webVRCamera.onControllerMeshLoadedObservable.add((function(e) {
- return i._onDefaultMeshLoaded(e)
- }
- )),
- this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),
- this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),
- this._updateButtonVisibility(),
- this._circleEase = new In,
- this._circleEase.setEasingMode(Mn.EASINGMODE_EASEINOUT),
- this._teleportationEasing = this._circleEase,
- e.onPointerObservable.add((function(t) {
- i._interactionsEnabled && e.activeCamera === i.vrDeviceOrientationCamera && "mouse" === t.event.pointerType && (t.type === Xi.POINTERDOWN ? i._cameraGazer._selectionPointerDown() : t.type === Xi.POINTERUP && i._cameraGazer._selectionPointerUp())
- }
- )),
- this.webVROptions.floorMeshes && this.enableTeleportation({
- floorMeshes: this.webVROptions.floorMeshes
- }))
- }
- ,
- e.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 (e) {
- K.Warn("Error in your custom logic onControllerMeshLoaded: " + e)
- }
- }
- ,
- Object.defineProperty(e.prototype, "isInVRMode", {
- get: function() {
- return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === Ns.IN_XR || this._webVRpresenting || this._fullscreenVRpresenting
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._onVrDisplayPresentChange = function() {
- var e = this._scene.getEngine().getVRDevice();
- if (e) {
- var t = this._webVRpresenting;
- this._webVRpresenting = e.isPresenting,
- t && !this._webVRpresenting && this.exitVR()
- } else
- K.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");
- this._updateButtonVisibility()
- }
- ,
- e.prototype._onVRDisplayChanged = function(e) {
- this._webVRsupported = e.vrSupported,
- this._webVRready = !!e.vrDisplay,
- this._webVRpresenting = e.vrDisplay && e.vrDisplay.isPresenting,
- this._updateButtonVisibility()
- }
- ,
- e.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"
- }
- }
- ,
- e.prototype._displayVRButton = function() {
- this._useCustomVRButton || this._btnVRDisplayed || !this._btnVR || (document.body.appendChild(this._btnVR),
- this._btnVRDisplayed = !0)
- }
- ,
- e.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")))
- }
- ,
- e.prototype.enterVR = function() {
- var e = this;
- if (this.xr)
- this.xr.baseExperience.enterXRAsync("immersive-vr", "local-floor", this.xr.renderTarget);
- else {
- if (this.onEnteringVRObservable)
- try {
- this.onEnteringVRObservable.notifyObservers(this)
- } catch (e) {
- K.Warn("Error in your custom logic onEnteringVR: " + e)
- }
- if (this._scene.activeCamera) {
- if (this._position = this._scene.activeCamera.position.clone(),
- this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.rotation = C.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),
- this.vrDeviceOrientationCamera.angularSensibility = 2e3),
- this.webVRCamera) {
- var t = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y
- , i = C.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y - t
- , n = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
- this.webVRCamera.rotationQuaternion = C.FromEulerAngles(0, n + i, 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(t) {
- e.onAfterEnteringVRObservable.notifyObservers({
- success: t
- })
- }
- )),
- 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(e) {
- e && e._activatePointer()
- }
- )),
- this._hasEnteredVR = !0)
- }
- }
- ,
- e.prototype.exitVR = function() {
- if (this.xr)
- this.xr.baseExperience.exitXRAsync();
- else if (this._hasEnteredVR) {
- if (this.onExitingVRObservable)
- try {
- this.onExitingVRObservable.notifyObservers(this)
- } catch (e) {
- K.Warn("Error in your custom logic onExitingVR: " + e)
- }
- 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(e) {
- e && e._deactivatePointer()
- }
- )),
- this._hasEnteredVR = !1;
- var e = this._scene.getEngine();
- e._onVrDisplayPresentChange && e._onVrDisplayPresentChange()
- }
- }
- ,
- Object.defineProperty(e.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
- }),
- e.prototype.enableInteractions = function() {
- var e = this;
- if (!this._interactionsEnabled) {
- if (this._interactionsRequested = !0,
- this.xr)
- return void (this.xr.baseExperience.state === Ns.IN_XR && this.xr.pointerSelection.attach());
- this._leftController && this._enableInteractionOnController(this._leftController),
- this._rightController && this._enableInteractionOnController(this._rightController),
- this.raySelectionPredicate = function(t) {
- return t.isVisible && (t.isPickable || t.name === e._floorMeshName)
- }
- ,
- this.meshSelectionPredicate = function() {
- return !0
- }
- ,
- this._raySelectionPredicate = function(t) {
- return !!(e._isTeleportationFloor(t) || -1 === t.name.indexOf("gazeTracker") && -1 === t.name.indexOf("teleportationTarget") && -1 === t.name.indexOf("torusTeleportation")) && e.raySelectionPredicate(t)
- }
- ,
- this._interactionsEnabled = !0
- }
- }
- ,
- Object.defineProperty(e.prototype, "_noControllerIsActive", {
- get: function() {
- return !(this._leftController && this._leftController._activePointer || this._rightController && this._rightController._activePointer)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._isTeleportationFloor = function(e) {
- for (var t = 0; t < this._floorMeshesCollection.length; t++)
- if (this._floorMeshesCollection[t].id === e.id)
- return !0;
- return !(!this._floorMeshName || e.name !== this._floorMeshName)
- }
- ,
- e.prototype.addFloorMesh = function(e) {
- this._floorMeshesCollection && (this._floorMeshesCollection.indexOf(e) > -1 || this._floorMeshesCollection.push(e))
- }
- ,
- e.prototype.removeFloorMesh = function(e) {
- if (this._floorMeshesCollection) {
- var t = this._floorMeshesCollection.indexOf(e);
- -1 !== t && this._floorMeshesCollection.splice(t, 1)
- }
- }
- ,
- e.prototype.enableTeleportation = function(e) {
- var t = this;
- if (void 0 === e && (e = {}),
- !this._teleportationInitialized) {
- if (this._teleportationRequested = !0,
- this.enableInteractions(),
- this.webVROptions.useXR && (e.floorMeshes || e.floorMeshName)) {
- var i = e.floorMeshes || [];
- if (!i.length) {
- var n = this._scene.getMeshByName(e.floorMeshName);
- n && i.push(n)
- }
- if (this.xr)
- return i.forEach((function(e) {
- t.xr.teleportation.addFloorMesh(e)
- }
- )),
- void (this.xr.teleportation.attached || this.xr.teleportation.attach());
- if (!this.xrTestDone) {
- var r = function() {
- t.xrTestDone && (t._scene.unregisterBeforeRender(r),
- t.xr ? t.xr.teleportation.attached || t.xr.teleportation.attach() : t.enableTeleportation(e))
- };
- return void this._scene.registerBeforeRender(r)
- }
- }
- 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),
- void 0 !== e.easingFunction && (this._teleportationEasing = e.easingFunction),
- null != this._leftController && this._enableTeleportationOnController(this._leftController),
- null != this._rightController && this._enableTeleportationOnController(this._rightController);
- var o = new Ri;
- o.vignetteColor = new N(0,0,0,0),
- o.vignetteEnabled = !0,
- this._postProcessMove = new Fs("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,o),
- this._webVRCamera.detachPostProcess(this._postProcessMove),
- this._teleportationInitialized = !0,
- this._isDefaultTeleportationTarget && (this._createTeleportationCircles(),
- this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))
- }
- }
- ,
- e.prototype._enableInteractionOnController = function(e) {
- var t = this;
- e.webVRController.mesh && (e._interactionsEnabled = !0,
- this.isInVRMode && this._displayLaserPointer && e._activatePointer(),
- this.webVROptions.laserToggle && e.webVRController.onMainButtonStateChangedObservable.add((function(i) {
- t._displayLaserPointer && 1 === i.value && (e._activePointer ? e._deactivatePointer() : e._activatePointer(),
- t.displayGaze && (e._gazeTracker.isVisible = e._activePointer))
- }
- )),
- e.webVRController.onTriggerStateChangedObservable.add((function(i) {
- var n = e;
- t._noControllerIsActive && (n = t._cameraGazer),
- n._pointerDownOnMeshAsked ? i.value < t._padSensibilityDown && n._selectionPointerUp() : i.value > t._padSensibilityUp && n._selectionPointerDown()
- }
- )))
- }
- ,
- e.prototype._checkTeleportWithRay = function(e, t) {
- this._teleportationRequestInitiated && !t._teleportationRequestInitiated || (t._teleportationRequestInitiated ? Math.sqrt(e.y * e.y + e.x * e.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter),
- t._teleportationRequestInitiated = !1) : e.y < -this._padSensibilityUp && t._dpadPressed && (t._activatePointer(),
- t._teleportationRequestInitiated = !0))
- }
- ,
- e.prototype._checkRotate = function(e, t) {
- t._teleportationRequestInitiated || (t._rotationLeftAsked ? e.x > -this._padSensibilityDown && (t._rotationLeftAsked = !1) : e.x < -this._padSensibilityUp && t._dpadPressed && (t._rotationLeftAsked = !0,
- this._rotationAllowed && this._rotateCamera(!1)),
- t._rotationRightAsked ? e.x < this._padSensibilityDown && (t._rotationRightAsked = !1) : e.x > this._padSensibilityUp && t._dpadPressed && (t._rotationRightAsked = !0,
- this._rotationAllowed && this._rotateCamera(!0)))
- }
- ,
- e.prototype._checkTeleportBackwards = function(e, t) {
- if (!t._teleportationRequestInitiated)
- if (e.y > this._padSensibilityUp && t._dpadPressed) {
- if (!t._teleportationBackRequestInitiated) {
- if (!this.currentVRCamera)
- return;
- var i = C.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix())
- , n = this.currentVRCamera.position;
- this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (i = this.currentVRCamera.deviceRotationQuaternion,
- n = this.currentVRCamera.devicePosition),
- i.toEulerAnglesToRef(this._workingVector),
- this._workingVector.z = 0,
- this._workingVector.x = 0,
- C.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion),
- this._workingQuaternion.toRotationMatrix(this._workingMatrix),
- x.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
- var r = new _o(n,this._workingVector)
- , o = this._scene.pickWithRay(r, this._raySelectionPredicate);
- o && o.pickedPoint && o.pickedMesh && this._isTeleportationFloor(o.pickedMesh) && o.distance < 5 && this.teleportCamera(o.pickedPoint),
- t._teleportationBackRequestInitiated = !0
- }
- } else
- t._teleportationBackRequestInitiated = !1
- }
- ,
- e.prototype._enableTeleportationOnController = function(e) {
- var t = this;
- e.webVRController.mesh && (e._interactionsEnabled || this._enableInteractionOnController(e),
- e._interactionsEnabled = !0,
- e._teleportationEnabled = !0,
- e.webVRController.controllerType === ba.VIVE && (e._dpadPressed = !1,
- e.webVRController.onPadStateChangedObservable.add((function(t) {
- e._dpadPressed = t.pressed,
- e._dpadPressed || (e._rotationLeftAsked = !1,
- e._rotationRightAsked = !1,
- e._teleportationBackRequestInitiated = !1)
- }
- ))),
- e.webVRController.onPadValuesChangedObservable.add((function(i) {
- t.teleportationEnabled && (t._checkTeleportBackwards(i, e),
- t._checkTeleportWithRay(i, e)),
- t._checkRotate(i, e)
- }
- )))
- }
- ,
- e.prototype._createTeleportationCircles = function() {
- this._teleportationTarget = il("teleportationTarget", {
- width: 2,
- height: 2,
- subdivisions: 2
- }, this._scene),
- this._teleportationTarget.isPickable = !1;
- var e = new Ds("DynamicTexture",512,this._scene,!0);
- e.hasAlpha = !0;
- var t = e.getContext();
- t.beginPath(),
- t.arc(256, 256, 200, 0, 2 * Math.PI, !1),
- t.fillStyle = this._teleportationFillColor,
- t.fill(),
- t.lineWidth = 10,
- t.strokeStyle = this._teleportationBorderColor,
- t.stroke(),
- t.closePath(),
- e.update();
- var i = new Os("TextPlaneMaterial",this._scene);
- i.diffuseTexture = e,
- this._teleportationTarget.material = i;
- var n = qs("torusTeleportation", {
- diameter: .75,
- thickness: .1,
- tessellation: 25,
- updatable: !1
- }, this._scene);
- n.isPickable = !1,
- n.parent = this._teleportationTarget;
- var r = new Qe("animationInnerCircle","position.y",30,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CYCLE)
- , o = [];
- o.push({
- frame: 0,
- value: 0
- }),
- o.push({
- frame: 30,
- value: .4
- }),
- o.push({
- frame: 60,
- value: 0
- }),
- r.setKeys(o);
- var a = new kn;
- a.setEasingMode(Mn.EASINGMODE_EASEINOUT),
- r.setEasingFunction(a),
- n.animations = [],
- n.animations.push(r),
- this._scene.beginAnimation(n, 0, 60, !0),
- this._hideTeleportationTarget()
- }
- ,
- e.prototype._displayTeleportationTarget = function() {
- this._teleportActive = !0,
- this._teleportationInitialized && (this._teleportationTarget.isVisible = !0,
- this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !0))
- }
- ,
- e.prototype._hideTeleportationTarget = function() {
- this._teleportActive = !1,
- this._teleportationInitialized && (this._teleportationTarget.isVisible = !1,
- this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !1))
- }
- ,
- e.prototype._rotateCamera = function(e) {
- var t = this;
- if (this.currentVRCamera instanceof pa) {
- e ? this._rotationAngle++ : this._rotationAngle--,
- this.currentVRCamera.animations = [];
- var i = C.FromRotationMatrix(P.RotationY(Math.PI / 4 * this._rotationAngle))
- , n = new Qe("animationRotation","rotationQuaternion",90,Qe.ANIMATIONTYPE_QUATERNION,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , r = [];
- r.push({
- frame: 0,
- value: this.currentVRCamera.rotationQuaternion
- }),
- r.push({
- frame: 6,
- value: i
- }),
- n.setKeys(r),
- n.setEasingFunction(this._circleEase),
- this.currentVRCamera.animations.push(n),
- this._postProcessMove.animations = [];
- var o = new Qe("animationPP","vignetteWeight",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , a = [];
- a.push({
- frame: 0,
- value: 0
- }),
- a.push({
- frame: 3,
- value: 4
- }),
- a.push({
- frame: 6,
- value: 0
- }),
- o.setKeys(a),
- o.setEasingFunction(this._circleEase),
- this._postProcessMove.animations.push(o);
- var s = new Qe("animationPP2","vignetteStretch",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , l = [];
- l.push({
- frame: 0,
- value: 0
- }),
- l.push({
- frame: 3,
- value: 10
- }),
- l.push({
- frame: 6,
- value: 0
- }),
- s.setKeys(l),
- s.setEasingFunction(this._circleEase),
- this._postProcessMove.animations.push(s),
- 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() {
- t._webVRCamera.detachPostProcess(t._postProcessMove)
- }
- )),
- this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1)
- }
- }
- ,
- e.prototype._moveTeleportationSelectorTo = function(e, t, i) {
- if (e.pickedPoint) {
- t._teleportationRequestInitiated && (this._displayTeleportationTarget(),
- this._haloCenter.copyFrom(e.pickedPoint),
- this._teleportationTarget.position.copyFrom(e.pickedPoint));
- var n = this._convertNormalToDirectionOfRay(e.getNormal(!0, !1), i);
- if (n) {
- var r = x.Cross(vn.Y, n)
- , o = x.Cross(n, r);
- x.RotationFromAxisToRef(o, n, r, this._teleportationTarget.rotation)
- }
- this._teleportationTarget.position.y += .1
- }
- }
- ,
- e.prototype.teleportCamera = function(t) {
- var i = this;
- if (this.currentVRCamera instanceof pa) {
- var n, r;
- if (this.webVRCamera.leftCamera ? (this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),
- this._workingVector.subtractInPlace(this.webVRCamera.position),
- t.subtractToRef(this._workingVector, this._workingVector)) : this._workingVector.copyFrom(t),
- this.isInVRMode ? this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor : this._workingVector.y += this._defaultHeight,
- this.onBeforeCameraTeleport.notifyObservers(this._workingVector),
- this._teleportationMode == e.TELEPORTATIONMODE_CONSTANTSPEED) {
- r = 90;
- var o = x.Distance(this.currentVRCamera.position, this._workingVector);
- n = this._teleportationSpeed / o
- } else
- r = Math.round(90 * this._teleportationTime / 1e3),
- n = 1;
- this.currentVRCamera.animations = [];
- var a = new Qe("animationCameraTeleportation","position",90,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , s = [{
- frame: 0,
- value: this.currentVRCamera.position
- }, {
- frame: r,
- value: this._workingVector
- }];
- a.setKeys(s),
- a.setEasingFunction(this._teleportationEasing),
- this.currentVRCamera.animations.push(a),
- this._postProcessMove.animations = [];
- var l = Math.round(r / 2)
- , c = new Qe("animationPP","vignetteWeight",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , u = [];
- u.push({
- frame: 0,
- value: 0
- }),
- u.push({
- frame: l,
- value: 8
- }),
- u.push({
- frame: r,
- value: 0
- }),
- c.setKeys(u),
- this._postProcessMove.animations.push(c);
- var h = new Qe("animationPP2","vignetteStretch",90,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , d = [];
- d.push({
- frame: 0,
- value: 0
- }),
- d.push({
- frame: l,
- value: 10
- }),
- d.push({
- frame: r,
- value: 0
- }),
- h.setKeys(d),
- this._postProcessMove.animations.push(h),
- this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
- this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
- this._webVRCamera.attachPostProcess(this._postProcessMove),
- this._scene.beginAnimation(this._postProcessMove, 0, r, !1, n, (function() {
- i._webVRCamera.detachPostProcess(i._postProcessMove)
- }
- )),
- this._scene.beginAnimation(this.currentVRCamera, 0, r, !1, n, (function() {
- i.onAfterCameraTeleport.notifyObservers(i._workingVector)
- }
- )),
- this._hideTeleportationTarget()
- }
- }
- ,
- e.prototype._convertNormalToDirectionOfRay = function(e, t) {
- return e && Math.acos(x.Dot(e, t.direction)) < Math.PI / 2 && e.scaleInPlace(-1),
- e
- }
- ,
- e.prototype._castRayAndSelectObject = function(e) {
- if (this.currentVRCamera instanceof pa) {
- var t = e._getForwardRay(this._rayLength)
- , i = this._scene.pickWithRay(t, this._raySelectionPredicate);
- if (i && this._scene.simulatePointerMove(i, {
- pointerId: e._id
- }),
- e._currentHit = i,
- i && i.pickedPoint) {
- if (this._displayGaze) {
- var n = 1;
- e._gazeTracker.isVisible = !0,
- e._isActionableMesh && (n = 3),
- this.updateGazeTrackerScale && (e._gazeTracker.scaling.x = i.distance * n,
- e._gazeTracker.scaling.y = i.distance * n,
- e._gazeTracker.scaling.z = i.distance * n);
- var r = this._convertNormalToDirectionOfRay(i.getNormal(), t)
- , o = .002;
- if (r) {
- var a = x.Cross(vn.Y, r)
- , s = x.Cross(r, a);
- x.RotationFromAxisToRef(s, r, a, e._gazeTracker.rotation)
- }
- e._gazeTracker.position.copyFrom(i.pickedPoint),
- e._gazeTracker.position.x < 0 ? e._gazeTracker.position.x += o : e._gazeTracker.position.x -= o,
- e._gazeTracker.position.y < 0 ? e._gazeTracker.position.y += o : e._gazeTracker.position.y -= o,
- e._gazeTracker.position.z < 0 ? e._gazeTracker.position.z += o : e._gazeTracker.position.z -= o
- }
- e._updatePointerDistance(i.distance)
- } else
- e._updatePointerDistance(),
- e._gazeTracker.isVisible = !1;
- if (i && i.pickedMesh) {
- if (this._teleportationInitialized && this._isTeleportationFloor(i.pickedMesh) && i.pickedPoint)
- return e._currentMeshSelected && !this._isTeleportationFloor(e._currentMeshSelected) && this._notifySelectedMeshUnselected(e._currentMeshSelected),
- e._currentMeshSelected = null,
- void (e._teleportationRequestInitiated && this._moveTeleportationSelectorTo(i, e, t));
- if (i.pickedMesh !== e._currentMeshSelected)
- if (this.meshSelectionPredicate(i.pickedMesh)) {
- this.onNewMeshPicked.notifyObservers(i),
- e._currentMeshSelected = i.pickedMesh,
- i.pickedMesh.isPickable && i.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(i.pickedMesh);
- var l = e;
- l.webVRController && this.onMeshSelectedWithController.notifyObservers({
- mesh: i.pickedMesh,
- controller: l.webVRController
- })
- } catch (e) {
- K.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: " + e)
- }
- } 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)
- }
- }
- ,
- e.prototype._notifySelectedMeshUnselected = function(e) {
- e && this.onSelectedMeshUnselected.notifyObservers(e)
- }
- ,
- e.prototype.setLaserColor = function(e, t) {
- void 0 === t && (t = this._pickedLaserColor),
- this._laserColor = e,
- this._pickedLaserColor = t
- }
- ,
- e.prototype.setLaserLightingState = function(e) {
- void 0 === e && (e = !0),
- this._leftController && this._leftController._setLaserPointerLightingDisabled(!e),
- this._rightController && this._rightController._setLaserPointerLightingDisabled(!e)
- }
- ,
- e.prototype.setGazeColor = function(e, t) {
- void 0 === t && (t = this._pickedGazeColor),
- this._gazeColor = e,
- this._pickedGazeColor = t
- }
- ,
- e.prototype.changeLaserColor = function(e) {
- this.updateControllerLaserColor && (this._leftController && this._leftController._setLaserPointerColor(e),
- this._rightController && this._rightController._setLaserPointerColor(e))
- }
- ,
- e.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))
- }
- ,
- e.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._onVrDisplayPresentChangeBind),
- 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._onVRDisplayChangedBind),
- this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),
- this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),
- this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),
- this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),
- this._scene.unregisterBeforeRender(this._beforeRender)
- }
- ,
- e.prototype.getClassName = function() {
- return "VRExperienceHelper"
- }
- ,
- e.TELEPORTATIONMODE_CONSTANTTIME = 0,
- e.TELEPORTATIONMODE_CONSTANTSPEED = 1,
- e
- }(), dl = (al = {
- root: 0,
- found: !1
- },
- function(e, t, i, n) {
- al.root = 0,
- al.found = !1;
- var r = t * t - 4 * e * i;
- if (r < 0)
- return al;
- var o = Math.sqrt(r)
- , a = (-t - o) / (2 * e)
- , s = (-t + o) / (2 * e);
- if (a > s) {
- var l = s;
- s = a,
- a = l
- }
- return a > 0 && a < n ? (al.root = a,
- al.found = !0,
- al) : s > 0 && s < n ? (al.root = s,
- al.found = !0,
- al) : al
- }
- ), pl = function() {
- function e() {
- this._collisionPoint = x.Zero(),
- this._planeIntersectionPoint = x.Zero(),
- this._tempVector = x.Zero(),
- this._tempVector2 = x.Zero(),
- this._tempVector3 = x.Zero(),
- this._tempVector4 = x.Zero(),
- this._edge = x.Zero(),
- this._baseToVertex = x.Zero(),
- this._destinationPoint = x.Zero(),
- this._slidePlaneNormal = x.Zero(),
- this._displacementVector = x.Zero(),
- this._radius = x.One(),
- this._retry = 0,
- this._basePointWorld = x.Zero(),
- this._velocityWorld = x.Zero(),
- this._normalizedVelocity = x.Zero(),
- this._collisionMask = -1
- }
- return Object.defineProperty(e.prototype, "collisionMask", {
- get: function() {
- return this._collisionMask
- },
- set: function(e) {
- this._collisionMask = isNaN(e) ? -1 : e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "slidePlaneNormal", {
- get: function() {
- return this._slidePlaneNormal
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._initialize = function(e, t, i) {
- this._velocity = t,
- this._velocitySquaredLength = this._velocity.lengthSquared();
- var n = Math.sqrt(this._velocitySquaredLength);
- 0 === n || 1 === n ? this._normalizedVelocity.copyFromFloats(t._x, t._y, t._z) : t.scaleToRef(1 / n, this._normalizedVelocity),
- this._basePoint = e,
- e.multiplyToRef(this._radius, this._basePointWorld),
- t.multiplyToRef(this._radius, this._velocityWorld),
- this._velocityWorldLength = this._velocityWorld.length(),
- this._epsilon = i,
- this.collisionFound = !1
- }
- ,
- e.prototype._checkPointInTriangle = function(e, t, i, n, r) {
- t.subtractToRef(e, this._tempVector),
- i.subtractToRef(e, this._tempVector2),
- x.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
- var o = x.Dot(this._tempVector4, r);
- return !(o < 0) && (n.subtractToRef(e, this._tempVector3),
- x.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4),
- !((o = x.Dot(this._tempVector4, r)) < 0) && (x.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4),
- (o = x.Dot(this._tempVector4, r)) >= 0))
- }
- ,
- e.prototype._canDoCollision = function(e, t, i, n) {
- var r = x.Distance(this._basePointWorld, e)
- , o = Math.max(this._radius.x, this._radius.y, this._radius.z);
- return !(r > this._velocityWorldLength + o + t || !function(e, t, i, n) {
- return !(e.x > i.x + n || i.x - n > t.x || e.y > i.y + n || i.y - n > t.y || e.z > i.z + n || i.z - n > t.z)
- }(i, n, this._basePointWorld, this._velocityWorldLength + o))
- }
- ,
- e.prototype._testTriangle = function(e, t, i, n, r, o, a) {
- var s, l = !1;
- t || (t = []),
- t[e] || (t[e] = new hn(0,0,0,0),
- t[e].copyFromPoints(i, n, r));
- var c = t[e];
- if (o || c.isFrontFacingTo(this._normalizedVelocity, 0)) {
- var u = c.signedDistanceTo(this._basePoint)
- , h = x.Dot(c.normal, this._velocity);
- if (0 == h) {
- if (Math.abs(u) >= 1)
- return;
- l = !0,
- s = 0
- } else {
- var d = (1 - u) / h;
- if ((s = (-1 - u) / h) > d) {
- var p = d;
- d = s,
- s = p
- }
- if (s > 1 || d < 0)
- return;
- s < 0 && (s = 0),
- s > 1 && (s = 1)
- }
- this._collisionPoint.copyFromFloats(0, 0, 0);
- var f = !1
- , _ = 1;
- if (l || (this._basePoint.subtractToRef(c.normal, this._planeIntersectionPoint),
- this._velocity.scaleToRef(s, this._tempVector),
- this._planeIntersectionPoint.addInPlace(this._tempVector),
- this._checkPointInTriangle(this._planeIntersectionPoint, i, n, r, c.normal) && (f = !0,
- _ = s,
- this._collisionPoint.copyFrom(this._planeIntersectionPoint))),
- !f) {
- var m = this._velocitySquaredLength;
- this._basePoint.subtractToRef(i, this._tempVector);
- var g = 2 * x.Dot(this._velocity, this._tempVector)
- , v = this._tempVector.lengthSquared() - 1
- , y = dl(m, g, v, _);
- y.found && (_ = y.root,
- f = !0,
- this._collisionPoint.copyFrom(i)),
- this._basePoint.subtractToRef(n, this._tempVector),
- g = 2 * x.Dot(this._velocity, this._tempVector),
- v = this._tempVector.lengthSquared() - 1,
- (y = dl(m, g, v, _)).found && (_ = y.root,
- f = !0,
- this._collisionPoint.copyFrom(n)),
- this._basePoint.subtractToRef(r, this._tempVector),
- g = 2 * x.Dot(this._velocity, this._tempVector),
- v = this._tempVector.lengthSquared() - 1,
- (y = dl(m, g, v, _)).found && (_ = y.root,
- f = !0,
- this._collisionPoint.copyFrom(r)),
- n.subtractToRef(i, this._edge),
- i.subtractToRef(this._basePoint, this._baseToVertex);
- var b, T = this._edge.lengthSquared(), E = x.Dot(this._edge, this._velocity), S = x.Dot(this._edge, this._baseToVertex);
- m = T * -this._velocitySquaredLength + E * E,
- g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
- v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
- (y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
- f = !0,
- this._edge.scaleInPlace(b),
- i.addToRef(this._edge, this._collisionPoint)),
- r.subtractToRef(n, this._edge),
- n.subtractToRef(this._basePoint, this._baseToVertex),
- T = this._edge.lengthSquared(),
- E = x.Dot(this._edge, this._velocity),
- S = x.Dot(this._edge, this._baseToVertex),
- m = T * -this._velocitySquaredLength + E * E,
- g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
- v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
- (y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
- f = !0,
- this._edge.scaleInPlace(b),
- n.addToRef(this._edge, this._collisionPoint)),
- i.subtractToRef(r, this._edge),
- r.subtractToRef(this._basePoint, this._baseToVertex),
- T = this._edge.lengthSquared(),
- E = x.Dot(this._edge, this._velocity),
- S = x.Dot(this._edge, this._baseToVertex),
- m = T * -this._velocitySquaredLength + E * E,
- g = 2 * (T * x.Dot(this._velocity, this._baseToVertex) - E * S),
- v = T * (1 - this._baseToVertex.lengthSquared()) + S * S,
- (y = dl(m, g, v, _)).found && (b = (E * y.root - S) / T) >= 0 && b <= 1 && (_ = y.root,
- f = !0,
- this._edge.scaleInPlace(b),
- r.addToRef(this._edge, this._collisionPoint))
- }
- if (f) {
- var A = _ * _ * this._velocitySquaredLength;
- (!this.collisionFound || A < this._nearestDistanceSquared) && (a.collisionResponse && (this.intersectionPoint ? this.intersectionPoint.copyFrom(this._collisionPoint) : this.intersectionPoint = this._collisionPoint.clone(),
- this._nearestDistanceSquared = A,
- this._nearestDistance = Math.sqrt(A),
- this.collisionFound = !0),
- this.collidedMesh = a)
- }
- }
- }
- ,
- e.prototype._collide = function(e, t, i, n, r, o, a, s, l, c) {
- if (void 0 === c && (c = !1),
- c)
- if (i && 0 !== i.length)
- for (p = n; p < r - 2; p += 1) {
- var u = i[p]
- , h = i[p + 1]
- , d = i[p + 2];
- 4294967295 !== d ? (f = t[u],
- _ = t[h],
- m = t[d],
- f && _ && m && ((l ? 1 : 0) ^ p % 2 ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, _, f, m, a, s))) : p += 2
- }
- else
- for (var p = 0; p < t.length - 2; p += 1) {
- var f = t[p]
- , _ = t[p + 1]
- , m = t[p + 2];
- f && _ && m && ((l ? 1 : 0) ^ p % 2 ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, _, f, m, a, s))
- }
- else if (i && 0 !== i.length)
- for (p = n; p < r; p += 3)
- f = t[i[p] - o],
- _ = t[i[p + 1] - o],
- m = t[i[p + 2] - o],
- l ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, m, _, f, a, s);
- else
- for (p = 0; p < t.length; p += 3) {
- f = t[p],
- _ = t[p + 1],
- m = t[p + 2];
- l ? this._testTriangle(p, e, f, _, m, a, s) : this._testTriangle(p, e, m, _, f, a, s)
- }
- }
- ,
- e.prototype._getResponse = function(e, t) {
- e.addToRef(t, this._destinationPoint),
- t.scaleInPlace(this._nearestDistance / t.length()),
- this._basePoint.addToRef(t, e),
- e.subtractToRef(this.intersectionPoint, this._slidePlaneNormal),
- this._slidePlaneNormal.normalize(),
- this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector),
- e.addInPlace(this._displacementVector),
- this.intersectionPoint.addInPlace(this._displacementVector),
- this._slidePlaneNormal.scaleInPlace(hn.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint)),
- this._destinationPoint.subtractInPlace(this._slidePlaneNormal),
- this._destinationPoint.subtractToRef(this.intersectionPoint, t)
- }
- ,
- e
- }(), fl = function() {
- function e() {
- this._scaledPosition = x.Zero(),
- this._scaledVelocity = x.Zero(),
- this._finalPosition = x.Zero()
- }
- return e.prototype.getNewPosition = function(e, t, i, n, r, o, a) {
- e.divideToRef(i._radius, this._scaledPosition),
- t.divideToRef(i._radius, this._scaledVelocity),
- i.collidedMesh = null,
- i._retry = 0,
- i._initialVelocity = this._scaledVelocity,
- i._initialPosition = this._scaledPosition,
- this._collideWithWorld(this._scaledPosition, this._scaledVelocity, i, n, this._finalPosition, r),
- this._finalPosition.multiplyInPlace(i._radius),
- o(a, this._finalPosition, i.collidedMesh)
- }
- ,
- e.prototype.createCollider = function() {
- return new pl
- }
- ,
- e.prototype.init = function(e) {
- this._scene = e
- }
- ,
- e.prototype._collideWithWorld = function(e, t, i, n, r, o) {
- void 0 === o && (o = null);
- var a = 10 * vr.CollisionsEpsilon;
- if (i._retry >= n)
- r.copyFrom(e);
- else {
- var s = o ? o.collisionMask : i.collisionMask;
- i._initialize(e, t, a);
- for (var l = o && o.surroundingMeshes || this._scene.meshes, c = 0; c < l.length; c++) {
- var u = l[c];
- u.isEnabled() && u.checkCollisions && u.subMeshes && u !== o && 0 != (s & u.collisionGroup) && u._checkCollision(i)
- }
- i.collisionFound ? (0 === t.x && 0 === t.y && 0 === t.z || i._getResponse(e, t),
- t.length() <= a ? r.copyFrom(e) : (i._retry++,
- this._collideWithWorld(e, t, i, n, r, o))) : e.addToRef(t, r)
- }
- }
- ,
- e
- }();
- mn.CollisionCoordinatorFactory = function() {
- return new fl
- }
- ;
- var _l, ml = function() {
- function e(t, i, n, r) {
- void 0 === r && (r = "");
- var o, a, s, l = this;
- this.name = null,
- this.defines = "",
- this.onCompiled = null,
- this.onError = null,
- this.uniqueId = 0,
- this.onCompileObservable = new h,
- this.onErrorObservable = new h,
- this.onBindObservable = new h,
- this._wasPreviouslyReady = !1,
- this._isReady = !1,
- this._compilationError = "",
- this._key = "",
- this._computeSourceCodeOverride = "",
- this._pipelineContext = null,
- this._computeSourceCode = "",
- this._rawComputeSourceCode = "",
- this._shaderLanguage = st.WGSL,
- this.name = t,
- this._key = r,
- this._engine = n,
- this.uniqueId = e._UniqueIdSeed++,
- this.defines = null !== (o = i.defines) && void 0 !== o ? o : "",
- this.onError = i.onError,
- this.onCompiled = i.onCompiled,
- this._entryPoint = null !== (a = i.entryPoint) && void 0 !== a ? a : "main",
- this._shaderStore = Pt.GetShadersStore(this._shaderLanguage),
- this._shaderRepository = Pt.GetShadersRepository(this._shaderLanguage),
- this._includeShaderStore = Pt.GetIncludesShadersStore(this._shaderLanguage);
- var c = nt() ? this._engine.getHostDocument() : null;
- t.computeSource ? s = "source:" + t.computeSource : t.computeElement ? (s = c ? c.getElementById(t.computeElement) : null) || (s = t.computeElement) : s = t.compute || t;
- var u = {
- defines: this.defines.split("\n"),
- indexParameters: void 0,
- isFragment: !1,
- shouldUseHighPrecisionShader: !1,
- processor: null,
- supportsUniformBuffers: this._engine.supportsUniformBuffers,
- shadersRepository: this._shaderRepository,
- includesShadersStore: this._includeShaderStore,
- version: (100 * this._engine.version).toString(),
- platformName: this._engine.shaderPlatformName,
- processingContext: null,
- isNDCHalfZRange: this._engine.isNDCHalfZRange,
- useReverseDepthBuffer: this._engine.useReverseDepthBuffer
- };
- this._loadShader(s, "Compute", "", (function(e) {
- Ct.Initialize(u),
- Ct.PreProcess(e, u, (function(n) {
- l._rawComputeSourceCode = e,
- i.processFinalCode && (n = i.processFinalCode(n));
- var r = Ct.Finalize(n, "", u);
- l._useFinalCode(r.vertexCode, t)
- }
- ), l._engine)
- }
- ))
- }
- return e.prototype._useFinalCode = function(e, t) {
- if (t) {
- var i = t.computeElement || t.compute || t.spectorName || t;
- this._computeSourceCode = "//#define SHADER_NAME compute:" + i + "\n" + e
- } else
- this._computeSourceCode = e;
- this._prepareEffect()
- }
- ,
- Object.defineProperty(e.prototype, "key", {
- get: function() {
- return this._key
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function() {
- try {
- return this._isReadyInternal()
- } catch (e) {
- return !1
- }
- }
- ,
- e.prototype._isReadyInternal = function() {
- return !!this._isReady || !!this._pipelineContext && this._pipelineContext.isReady
- }
- ,
- e.prototype.getEngine = function() {
- return this._engine
- }
- ,
- e.prototype.getPipelineContext = function() {
- return this._pipelineContext
- }
- ,
- e.prototype.getCompilationError = function() {
- return this._compilationError
- }
- ,
- e.prototype.executeWhenCompiled = function(e) {
- var t = this;
- this.isReady() ? e(this) : (this.onCompileObservable.add((function(t) {
- e(t)
- }
- )),
- this._pipelineContext && !this._pipelineContext.isAsync || setTimeout((function() {
- t._checkIsReady(null)
- }
- ), 16))
- }
- ,
- e.prototype._checkIsReady = function(e) {
- var t = this;
- try {
- if (this._isReadyInternal())
- return
- } catch (t) {
- return void this._processCompilationErrors(t, e)
- }
- setTimeout((function() {
- t._checkIsReady(e)
- }
- ), 16)
- }
- ,
- e.prototype._loadShader = function(e, t, i, n) {
- var r;
- "undefined" != typeof HTMLElement && e instanceof HTMLElement ? n(at(e)) : "source:" !== e.substr(0, 7) ? "base64:" !== e.substr(0, 7) ? this._shaderStore[e + t + "Shader"] ? n(this._shaderStore[e + t + "Shader"]) : i && this._shaderStore[e + i + "Shader"] ? n(this._shaderStore[e + i + "Shader"]) : (r = "." === e[0] || "/" === e[0] || e.indexOf("http") > -1 ? e : this._shaderRepository + e,
- this._engine._loadFile(r + "." + t.toLowerCase() + ".fx", n)) : n(window.atob(e.substr(7))) : n(e.substr(7))
- }
- ,
- Object.defineProperty(e.prototype, "computeSourceCode", {
- get: function() {
- var e, t;
- return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : null !== (t = null === (e = this._pipelineContext) || void 0 === e ? void 0 : e._getComputeShaderCode()) && void 0 !== t ? t : this._computeSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rawComputeSourceCode", {
- get: function() {
- return this._rawComputeSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._prepareEffect = function() {
- var e = this
- , t = this.defines
- , i = this._pipelineContext;
- this._isReady = !1;
- try {
- var n = this._engine;
- this._pipelineContext = n.createComputePipelineContext(),
- this._pipelineContext._name = this._key,
- n._prepareComputePipelineContext(this._pipelineContext, this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode, this._rawComputeSourceCode, this._computeSourceCodeOverride ? null : t, this._entryPoint),
- n._executeWhenComputeStateIsCompiled(this._pipelineContext, (function() {
- e._compilationError = "",
- e._isReady = !0,
- e.onCompiled && e.onCompiled(e),
- e.onCompileObservable.notifyObservers(e),
- e.onCompileObservable.clear(),
- i && e.getEngine()._deleteComputePipelineContext(i)
- }
- )),
- this._pipelineContext.isAsync && this._checkIsReady(i)
- } catch (e) {
- this._processCompilationErrors(e, i)
- }
- }
- ,
- e.prototype._getShaderCodeAndErrorLine = function(e, t) {
- var i = null;
- if (t && e) {
- var n = t.match(/COMPUTE SHADER ERROR: 0:(\d+?):/);
- if (n && 2 === n.length) {
- var r = parseInt(n[1])
- , o = e.split("\n", -1);
- o.length >= r && (i = "Offending line [".concat(r, "] in compute code: ").concat(o[r - 1]))
- }
- }
- return [e, i]
- }
- ,
- e.prototype._processCompilationErrors = function(t, i) {
- var n, r;
- if (void 0 === i && (i = null),
- this._compilationError = t.message,
- K.Error("Unable to compile compute effect:"),
- K.Error("Defines:\r\n" + this.defines),
- e.LogShaderCodeOnCompilationError) {
- var o = null
- , a = null;
- (null === (r = this._pipelineContext) || void 0 === r ? void 0 : r._getComputeShaderCode()) && (a = (n = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError))[0],
- o = n[1],
- a && (K.Error("Compute code:"),
- K.Error(a))),
- o && K.Error(o)
- }
- K.Error("Error: " + this._compilationError),
- i && (this._pipelineContext = i,
- this._isReady = !0,
- this.onError && this.onError(this, this._compilationError),
- this.onErrorObservable.notifyObservers(this))
- }
- ,
- e.prototype.dispose = function() {
- this._pipelineContext && this._pipelineContext.dispose(),
- this._engine._releaseComputeEffect(this)
- }
- ,
- e.RegisterShader = function(e, t) {
- Pt.GetShadersStore(st.WGSL)["".concat(e, "ComputeShader")] = t
- }
- ,
- e._UniqueIdSeed = 0,
- e.LogShaderCodeOnCompilationError = !0,
- e
- }();
- !function(e) {
- e[e.Texture = 0] = "Texture",
- e[e.StorageTexture = 1] = "StorageTexture",
- e[e.UniformBuffer = 2] = "UniformBuffer",
- e[e.StorageBuffer = 3] = "StorageBuffer",
- e[e.TextureWithoutSampler = 4] = "TextureWithoutSampler",
- e[e.Sampler = 5] = "Sampler"
- }(_l || (_l = {})),
- Ht.prototype.createComputeEffect = function(e, t) {
- throw new Error("createComputeEffect: This engine does not support compute shaders!")
- }
- ,
- Ht.prototype.createComputePipelineContext = function() {
- throw new Error("createComputePipelineContext: This engine does not support compute shaders!")
- }
- ,
- Ht.prototype.createComputeContext = function() {}
- ,
- Ht.prototype.computeDispatch = function(e, t, i, n, r, o, a) {
- throw new Error("computeDispatch: This engine does not support compute shaders!")
- }
- ,
- Ht.prototype.areAllComputeEffectsReady = function() {
- return !0
- }
- ,
- Ht.prototype.releaseComputeEffects = function() {}
- ,
- Ht.prototype._prepareComputePipelineContext = function(e, t, i, n, r) {}
- ,
- Ht.prototype._rebuildComputeEffects = function() {}
- ,
- Ht.prototype._executeWhenComputeStateIsCompiled = function(e, t) {
- t()
- }
- ,
- Ht.prototype._releaseComputeEffect = function(e) {}
- ,
- Ht.prototype._deleteComputePipelineContext = function(e) {}
- ;
- var gl = function() {
- function e(e, t, i, n) {
- void 0 === n && (n = {}),
- this._bindings = {},
- this._samplers = {},
- this._contextIsDirty = !1,
- this.onCompiled = null,
- this.onError = null,
- this.name = e,
- this._engine = t,
- this.uniqueId = pn.UniqueId,
- this._engine.getCaps().supportComputeShaders ? n.bindingsMapping ? (this._context = t.createComputeContext(),
- this._shaderPath = i,
- this._options = V({
- bindingsMapping: {},
- defines: []
- }, n)) : K.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!") : K.Error("This engine does not support compute shaders!")
- }
- return Object.defineProperty(e.prototype, "options", {
- get: function() {
- return this._options
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shaderPath", {
- get: function() {
- return this._shaderPath
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ComputeShader"
- }
- ,
- e.prototype.setTexture = function(e, t, i) {
- void 0 === i && (i = !0);
- var n = this._bindings[e];
- this._bindings[e] = {
- type: i ? _l.Texture : _l.TextureWithoutSampler,
- object: t,
- indexInGroupEntries: null == n ? void 0 : n.indexInGroupEntries
- },
- this._contextIsDirty || (this._contextIsDirty = !n || n.object !== t || n.type !== this._bindings[e].type)
- }
- ,
- e.prototype.setStorageTexture = function(e, t) {
- var i = this._bindings[e];
- this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t),
- this._bindings[e] = {
- type: _l.StorageTexture,
- object: t,
- indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
- }
- }
- ,
- e.prototype.setUniformBuffer = function(e, t) {
- var i = this._bindings[e];
- this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t),
- this._bindings[e] = {
- type: _l.UniformBuffer,
- object: t,
- indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
- }
- }
- ,
- e.prototype.setStorageBuffer = function(e, t) {
- var i = this._bindings[e];
- this._contextIsDirty || (this._contextIsDirty = !i || i.object !== t),
- this._bindings[e] = {
- type: _l.StorageBuffer,
- object: t,
- indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
- }
- }
- ,
- e.prototype.setTextureSampler = function(e, t) {
- var i = this._bindings[e];
- this._contextIsDirty || (this._contextIsDirty = !i || !t.compareSampler(i.object)),
- this._bindings[e] = {
- type: _l.Sampler,
- object: t,
- indexInGroupEntries: null == i ? void 0 : i.indexInGroupEntries
- }
- }
- ,
- e.prototype.isReady = function() {
- var e = this._effect;
- for (var t in this._bindings) {
- var i = this._bindings[t]
- , n = i.type
- , r = i.object;
- switch (n) {
- case _l.Texture:
- case _l.TextureWithoutSampler:
- case _l.StorageTexture:
- if (!r.isReady())
- return !1
- }
- }
- var o = []
- , a = this._shaderPath;
- if (this._options.defines)
- for (var s = 0; s < this._options.defines.length; s++)
- o.push(this._options.defines[s]);
- var l = o.join("\n");
- return this._cachedDefines !== l && (this._cachedDefines = l,
- e = this._engine.createComputeEffect(a, {
- defines: l,
- entryPoint: this._options.entryPoint,
- onCompiled: this.onCompiled,
- onError: this.onError
- }),
- this._effect = e),
- !!e.isReady()
- }
- ,
- e.prototype.dispatch = function(e, t, i) {
- var n;
- if (!this.isReady())
- return !1;
- for (var r in this._bindings) {
- var o = this._bindings[r];
- if (!this._options.bindingsMapping[r])
- throw new Error("ComputeShader ('" + this.name + "'): No binding mapping has been provided for the property '" + r + "'");
- if (o.type === _l.Texture) {
- var a = this._samplers[r]
- , s = o.object;
- a && s._texture && a.compareSampler(s._texture) || (this._samplers[r] = (new Nt).setParameters(s.wrapU, s.wrapV, s.wrapR, s.anisotropicFilteringLevel, s._texture.samplingMode, null === (n = s._texture) || void 0 === n ? void 0 : n._comparisonFunction),
- this._contextIsDirty = !0)
- }
- }
- return this._contextIsDirty && (this._contextIsDirty = !1,
- this._context.clear()),
- this._engine.computeDispatch(this._effect, this._context, this._bindings, e, t, i, this._options.bindingsMapping),
- !0
- }
- ,
- e.prototype.dispatchWhenReady = function(e, t, i, n) {
- var r = this;
- return void 0 === n && (n = 10),
- new Promise((function(o) {
- var a = function() {
- r.dispatch(e, t, i) ? o() : setTimeout(a, n)
- };
- a()
- }
- ))
- }
- ,
- e.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- for (var t in e.options = this._options,
- e.shaderPath = this._shaderPath,
- e.bindings = {},
- e.textures = {},
- this._bindings) {
- var i = this._bindings[t]
- , n = i.object;
- switch (i.type) {
- case _l.Texture:
- case _l.TextureWithoutSampler:
- case _l.StorageTexture:
- var r = n.serialize();
- r && (e.textures[t] = r,
- e.bindings[t] = {
- type: i.type
- });
- case _l.UniformBuffer:
- }
- }
- return e
- }
- ,
- e.Parse = function(t, i, n) {
- var r = Ge.Parse((function() {
- return new e(t.name,i.getEngine(),t.shaderPath,t.options)
- }
- ), t, i, n);
- for (var o in t.textures) {
- var a = t.bindings[o]
- , s = io.Parse(t.textures[o], i, n);
- a.type === _l.Texture ? r.setTexture(o, s) : a.type === _l.TextureWithoutSampler ? r.setTexture(o, s, !1) : r.setStorageTexture(o, s)
- }
- return r
- }
- ,
- k([Ce()], e.prototype, "name", void 0),
- e
- }();
- y("BABYLON.ComputeShader", gl);
- var vl = function() {
- function e(e, t, i, n, r, o) {
- this.entries = new Array,
- this._boundingVectors = new Array,
- this._capacity = i,
- this._depth = n,
- this._maxDepth = r,
- this._creationFunc = o,
- this._minPoint = e,
- this._maxPoint = t,
- this._boundingVectors.push(e.clone()),
- this._boundingVectors.push(t.clone()),
- this._boundingVectors.push(e.clone()),
- this._boundingVectors[2].x = t.x,
- this._boundingVectors.push(e.clone()),
- this._boundingVectors[3].y = t.y,
- this._boundingVectors.push(e.clone()),
- this._boundingVectors[4].z = t.z,
- this._boundingVectors.push(t.clone()),
- this._boundingVectors[5].z = e.z,
- this._boundingVectors.push(t.clone()),
- this._boundingVectors[6].x = e.x,
- this._boundingVectors.push(t.clone()),
- this._boundingVectors[7].y = e.y
- }
- return Object.defineProperty(e.prototype, "capacity", {
- get: function() {
- return this._capacity
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "minPoint", {
- get: function() {
- return this._minPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "maxPoint", {
- get: function() {
- return this._maxPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addEntry = function(e) {
- if (this.blocks)
- for (var t = 0; t < this.blocks.length; t++)
- this.blocks[t].addEntry(e);
- else
- this._creationFunc(e, this),
- this.entries.length > this.capacity && this._depth < this._maxDepth && this.createInnerBlocks()
- }
- ,
- e.prototype.removeEntry = function(e) {
- if (this.blocks)
- for (var t = 0; t < this.blocks.length; t++)
- this.blocks[t].removeEntry(e);
- else {
- var i = this.entries.indexOf(e);
- i > -1 && this.entries.splice(i, 1)
- }
- }
- ,
- e.prototype.addEntries = function(e) {
- for (var t = 0; t < e.length; t++) {
- var i = e[t];
- this.addEntry(i)
- }
- }
- ,
- e.prototype.select = function(e, t, i) {
- if (tr.IsInFrustum(this._boundingVectors, e)) {
- if (this.blocks) {
- for (var n = 0; n < this.blocks.length; n++)
- this.blocks[n].select(e, t, i);
- return
- }
- i ? t.concat(this.entries) : t.concatWithNoDuplicate(this.entries)
- }
- }
- ,
- e.prototype.intersects = function(e, t, i, n) {
- if (tr.IntersectsSphere(this._minPoint, this._maxPoint, e, t)) {
- if (this.blocks) {
- for (var r = 0; r < this.blocks.length; r++)
- this.blocks[r].intersects(e, t, i, n);
- return
- }
- n ? i.concat(this.entries) : i.concatWithNoDuplicate(this.entries)
- }
- }
- ,
- e.prototype.intersectsRay = function(e, t) {
- if (e.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
- if (this.blocks) {
- for (var i = 0; i < this.blocks.length; i++)
- this.blocks[i].intersectsRay(e, t);
- return
- }
- t.concatWithNoDuplicate(this.entries)
- }
- }
- ,
- e.prototype.createInnerBlocks = function() {
- e._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc)
- }
- ,
- e._CreateBlocks = function(t, i, n, r, o, a, s, l) {
- s.blocks = new Array;
- for (var c = new x((i.x - t.x) / 2,(i.y - t.y) / 2,(i.z - t.z) / 2), u = 0; u < 2; u++)
- for (var h = 0; h < 2; h++)
- for (var d = 0; d < 2; d++) {
- var p = new e(t.add(c.multiplyByFloats(u, h, d)),t.add(c.multiplyByFloats(u + 1, h + 1, d + 1)),r,o + 1,a,l);
- p.addEntries(n),
- s.blocks.push(p)
- }
- }
- ,
- e
- }()
- , yl = function() {
- function e(e, t, i) {
- void 0 === i && (i = 2),
- this.maxDepth = i,
- this.dynamicContent = new Array,
- this._maxBlockCapacity = t || 64,
- this._selectionContent = new Ti(1024),
- this._creationFunc = e
- }
- return e.prototype.update = function(e, t, i) {
- vl._CreateBlocks(e, t, i, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc)
- }
- ,
- e.prototype.addMesh = function(e) {
- for (var t = 0; t < this.blocks.length; t++)
- this.blocks[t].addEntry(e)
- }
- ,
- e.prototype.removeMesh = function(e) {
- for (var t = 0; t < this.blocks.length; t++)
- this.blocks[t].removeEntry(e)
- }
- ,
- e.prototype.select = function(e, t) {
- this._selectionContent.reset();
- for (var i = 0; i < this.blocks.length; i++)
- this.blocks[i].select(e, this._selectionContent, t);
- return t ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent),
- this._selectionContent
- }
- ,
- e.prototype.intersects = function(e, t, i) {
- this._selectionContent.reset();
- for (var n = 0; n < this.blocks.length; n++)
- this.blocks[n].intersects(e, t, this._selectionContent, i);
- return i ? this._selectionContent.concat(this.dynamicContent) : this._selectionContent.concatWithNoDuplicate(this.dynamicContent),
- this._selectionContent
- }
- ,
- e.prototype.intersectsRay = function(e) {
- this._selectionContent.reset();
- for (var t = 0; t < this.blocks.length; t++)
- this.blocks[t].intersectsRay(e, this._selectionContent);
- return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),
- this._selectionContent
- }
- ,
- e.CreationFuncForMeshes = function(e, t) {
- var i = e.getBoundingInfo();
- !e.isBlocked && i.boundingBox.intersectsMinMax(t.minPoint, t.maxPoint) && t.entries.push(e)
- }
- ,
- e.CreationFuncForSubMeshes = function(e, t) {
- e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint, t.maxPoint) && t.entries.push(e)
- }
- ,
- e
- }();
- mn.prototype.createOrUpdateSelectionOctree = function(e, t) {
- void 0 === e && (e = 64),
- void 0 === t && (t = 2);
- var i = this._getComponent(Wi.NAME_OCTREE);
- i || (i = new Tl(this),
- this._addComponent(i)),
- this._selectionOctree || (this._selectionOctree = new yl(yl.CreationFuncForMeshes,e,t));
- var n = this.getWorldExtends();
- return this._selectionOctree.update(n.min, n.max, this.meshes),
- this._selectionOctree
- }
- ,
- Object.defineProperty(mn.prototype, "selectionOctree", {
- get: function() {
- return this._selectionOctree
- },
- enumerable: !0,
- configurable: !0
- }),
- Sr.prototype.createOrUpdateSubmeshesOctree = function(e, t) {
- void 0 === e && (e = 64),
- void 0 === t && (t = 2);
- var i = this.getScene()
- , n = i._getComponent(Wi.NAME_OCTREE);
- n || (n = new Tl(i),
- i._addComponent(n)),
- this._submeshesOctree || (this._submeshesOctree = new yl(yl.CreationFuncForSubMeshes,e,t)),
- this.computeWorldMatrix(!0);
- var r = this.getBoundingInfo().boundingBox;
- return this._submeshesOctree.update(r.minimumWorld, r.maximumWorld, this.subMeshes),
- this._submeshesOctree
- }
- ;
- var bl, Tl = function() {
- function e(e) {
- this.name = Wi.NAME_OCTREE,
- this.checksIsEnabled = !0,
- this._tempRay = new _o(x.Zero(),new x(1,1,1)),
- (e = e || E.LastCreatedScene) && (this.scene = e,
- this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this),
- this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this),
- this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this),
- this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this))
- }
- return e.prototype.register = function() {
- var e = this;
- this.scene.onMeshRemovedObservable.add((function(t) {
- var i = e.scene.selectionOctree;
- if (null != i) {
- var n = i.dynamicContent.indexOf(t);
- -1 !== n && i.dynamicContent.splice(n, 1)
- }
- }
- )),
- this.scene.onMeshImportedObservable.add((function(t) {
- var i = e.scene.selectionOctree;
- null != i && i.addMesh(t)
- }
- ))
- }
- ,
- e.prototype.getActiveMeshCandidates = function() {
- return this.scene._selectionOctree ? this.scene._selectionOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultMeshCandidates()
- }
- ,
- e.prototype.getActiveSubMeshCandidates = function(e) {
- return e._submeshesOctree && e.useOctreeForRenderingSelection ? e._submeshesOctree.select(this.scene.frustumPlanes) : this.scene._getDefaultSubMeshCandidates(e)
- }
- ,
- e.prototype.getIntersectingSubMeshCandidates = function(e, t) {
- return e._submeshesOctree && e.useOctreeForPicking ? (_o.TransformToRef(t, e.getWorldMatrix(), this._tempRay),
- e._submeshesOctree.intersectsRay(this._tempRay)) : this.scene._getDefaultSubMeshCandidates(e)
- }
- ,
- e.prototype.getCollidingSubMeshCandidates = function(e, t) {
- if (e._submeshesOctree && e.useOctreeForCollisions) {
- var i = t._velocityWorldLength + Math.max(t._radius.x, t._radius.y, t._radius.z);
- return e._submeshesOctree.intersects(t._basePointWorld, i)
- }
- return this.scene._getDefaultSubMeshCandidates(e)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {}
- ,
- e
- }(), El = function() {
- function e(e, t) {
- void 0 === t && (t = !0);
- var i = this;
- 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 h,
- this.utilityLayerScene = new mn(e.getEngine(),{
- virtual: !0
- }),
- this.utilityLayerScene.useRightHandedSystem = e.useRightHandedSystem,
- this.utilityLayerScene._allowPostProcessClearColor = !1,
- this.utilityLayerScene.postProcessesEnabled = !1,
- this.utilityLayerScene.detachControl(),
- t && (this._originalPointerObserver = e.onPrePointerObservable.add((function(t) {
- if (i.utilityLayerScene.activeCamera && i.pickingEnabled && (i.processAllEvents || t.type === Xi.POINTERMOVE || t.type === Xi.POINTERUP || t.type === Xi.POINTERDOWN || t.type === Xi.POINTERDOUBLETAP)) {
- i.utilityLayerScene.pointerX = e.pointerX,
- i.utilityLayerScene.pointerY = e.pointerY;
- var n = t.event;
- if (e.isPointerCaptured(n.pointerId))
- i._pointerCaptures[n.pointerId] = !1;
- else {
- var r = function(n) {
- var r = null;
- if (t.nearInteractionPickingInfo)
- r = t.nearInteractionPickingInfo.pickedMesh.getScene() == n ? t.nearInteractionPickingInfo : new Ui;
- else {
- var o = null;
- i._renderCamera && (o = n._activeCamera,
- n._activeCamera = i._renderCamera,
- t.ray = null),
- r = t.ray ? n.pickWithRay(t.ray) : n.pick(e.pointerX, e.pointerY),
- o && (n._activeCamera = o)
- }
- return r
- }
- , o = r(i.utilityLayerScene);
- if (!t.ray && o && (t.ray = o.ray),
- i.utilityLayerScene.onPrePointerObservable.notifyObservers(t),
- i.onlyCheckPointerDownEvents && t.type != Xi.POINTERDOWN)
- return t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(t.type,t.event,o), t.type),
- void (t.type === Xi.POINTERUP && i._pointerCaptures[n.pointerId] && (i._pointerCaptures[n.pointerId] = !1));
- if (i.utilityLayerScene.autoClearDepthAndStencil || i.pickUtilitySceneFirst)
- o && o.hit && (t.skipOnPointerObservable || i.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(t.type,t.event,o), t.type),
- t.skipOnPointerObservable = !0);
- else {
- var a = r(e)
- , s = t.event;
- a && o && (0 === o.distance && a.pickedMesh ? i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(a.pickedMesh) ? (i._notifyObservers(t, a, s),
- t.skipOnPointerObservable = !0) : t.type === Xi.POINTERDOWN ? i._pointerCaptures[s.pointerId] = !0 : t.type !== Xi.POINTERMOVE && t.type !== Xi.POINTERUP || (i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId),
- delete i._lastPointerEvents[s.pointerId]),
- i._notifyObservers(t, a, s)) : !i._pointerCaptures[s.pointerId] && (o.distance < a.distance || 0 === a.distance) ? (i._notifyObservers(t, o, s),
- t.skipOnPointerObservable || (t.skipOnPointerObservable = o.distance > 0)) : !i._pointerCaptures[s.pointerId] && o.distance > a.distance && (i.mainSceneTrackerPredicate && i.mainSceneTrackerPredicate(a.pickedMesh) ? (i._notifyObservers(t, a, s),
- t.skipOnPointerObservable = !0) : t.type !== Xi.POINTERMOVE && t.type !== Xi.POINTERUP || (i._lastPointerEvents[s.pointerId] && (i.onPointerOutObservable.notifyObservers(s.pointerId),
- delete i._lastPointerEvents[s.pointerId]),
- i._notifyObservers(t, o, s))),
- t.type === Xi.POINTERUP && i._pointerCaptures[s.pointerId] && (i._pointerCaptures[s.pointerId] = !1))
- }
- }
- }
- }
- )),
- this._originalPointerObserver && e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),
- this.utilityLayerScene.autoClear = !1,
- this._afterRenderObserver = this.originalScene.onAfterCameraRenderObservable.add((function(e) {
- i.shouldRender && e == i.getRenderCamera() && (e.outputRenderTarget && e.isRigCamera && i.originalScene.getEngine().clear(null, !1, !0, !1),
- i.render())
- }
- )),
- this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add((function() {
- i.dispose()
- }
- )),
- this._updateCamera()
- }
- return e.prototype.getRenderCamera = function(e) {
- if (this._renderCamera)
- return this._renderCamera;
- var t;
- return t = this.originalScene.activeCameras && this.originalScene.activeCameras.length > 1 ? this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1] : this.originalScene.activeCamera,
- e && t && t.isRigCamera ? t.rigParent : t
- }
- ,
- e.prototype.setRenderCamera = function(e) {
- this._renderCamera = e
- }
- ,
- e.prototype._getSharedGizmoLight = function() {
- return this._sharedGizmoLight || (this._sharedGizmoLight = new ds("shared gizmo light",new x(0,1,0),this.utilityLayerScene),
- this._sharedGizmoLight.intensity = 2,
- this._sharedGizmoLight.groundColor = D.Gray()),
- this._sharedGizmoLight
- }
- ,
- Object.defineProperty(e, "DefaultUtilityLayer", {
- get: function() {
- return null == e._DefaultUtilityLayer ? e._CreateDefaultUtilityLayerFromScene(E.LastCreatedScene) : e._DefaultUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- e._CreateDefaultUtilityLayerFromScene = function(t) {
- return e._DefaultUtilityLayer = new e(t),
- e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function() {
- e._DefaultUtilityLayer = null
- }
- )),
- e._DefaultUtilityLayer
- }
- ,
- Object.defineProperty(e, "DefaultKeepDepthUtilityLayer", {
- get: function() {
- return null == e._DefaultKeepDepthUtilityLayer && (e._DefaultKeepDepthUtilityLayer = new e(E.LastCreatedScene),
- e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
- e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function() {
- e._DefaultKeepDepthUtilityLayer = null
- }
- ))),
- e._DefaultKeepDepthUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._notifyObservers = function(e, t, i) {
- e.skipOnPointerObservable || (this.utilityLayerScene.onPointerObservable.notifyObservers(new Ki(e.type,e.event,t), e.type),
- this._lastPointerEvents[i.pointerId] = !0)
- }
- ,
- e.prototype.render = function() {
- if (this._updateCamera(),
- this.utilityLayerScene.activeCamera) {
- var e = this.utilityLayerScene.activeCamera.getScene()
- , t = this.utilityLayerScene.activeCamera;
- t._scene = this.utilityLayerScene,
- t.leftCamera && (t.leftCamera._scene = this.utilityLayerScene),
- t.rightCamera && (t.rightCamera._scene = this.utilityLayerScene),
- this.utilityLayerScene.render(!1),
- t._scene = e,
- t.leftCamera && (t.leftCamera._scene = e),
- t.rightCamera && (t.rightCamera._scene = e)
- }
- }
- ,
- e.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()
- }
- ,
- e.prototype._updateCamera = function() {
- this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera(),
- this.utilityLayerScene.activeCamera = this.getRenderCamera()
- }
- ,
- e._DefaultUtilityLayer = null,
- e._DefaultKeepDepthUtilityLayer = null,
- e
- }(), Sl = function() {
- function e(e) {
- void 0 === e && (e = El.DefaultUtilityLayer);
- var t = this;
- 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 C(0,0,0,1),
- this._tempVector = new x,
- this._tempVector2 = new x,
- this._tempMatrix1 = new P,
- this._tempMatrix2 = new P,
- this._rightHandtoLeftHandMatrix = P.RotationY(Math.PI),
- this._rootMesh = new Vr("gizmoRootNode",e.utilityLayerScene),
- this._rootMesh.rotationQuaternion = C.Identity(),
- this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function() {
- t._update()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(e) {
- this._scaleRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isHovered", {
- get: function() {
- return this._isHovered
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.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
- }),
- e.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(e) {
- e.dispose()
- }
- )),
- e.parent = this._rootMesh,
- this._customMeshSet = !0
- }
- ,
- Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this._updateGizmoRotationToMatchAttachedMesh
- },
- set: function(e) {
- this._updateGizmoRotationToMatchAttachedMesh = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachedNodeChanged = function(e) {}
- ,
- Object.defineProperty(e.prototype, "customRotationQuaternion", {
- get: function() {
- return this._customRotationQuaternion
- },
- set: function(e) {
- this._customRotationQuaternion = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._update = function() {
- if (this.attachedNode) {
- var e = this.attachedNode;
- if (this.attachedMesh && (e = this.attachedMesh || this.attachedNode),
- this.updateGizmoPositionToMatchAttachedMesh) {
- var t = e.getWorldMatrix().getRow(3)
- , i = t ? t.toVector3() : new x(0,0,0);
- this._rootMesh.position.copyFrom(i)
- }
- 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 n = this.gizmoLayer.utilityLayerScene.activeCamera
- , r = n.globalPosition;
- n.devicePosition && (r = n.devicePosition),
- this._rootMesh.position.subtractToRef(r, this._tempVector);
- var o = this._tempVector.length() * this.scaleRatio;
- this._rootMesh.scaling.set(o, o, o),
- e._getWorldMatrixDeterminant() < 0 && (this._rootMesh.scaling.y *= -1)
- } else
- this._rootMesh.scaling.setAll(this.scaleRatio)
- }
- }
- ,
- e.prototype._handlePivot = function() {
- var e = this._attachedNode;
- e.isUsingPivotMatrix && e.isUsingPivotMatrix() && e.position && e.getWorldMatrix().setTranslation(e.position)
- }
- ,
- e.prototype._matrixChanged = function() {
- if (this._attachedNode)
- if (this._attachedNode._isCamera) {
- var e = this._attachedNode
- , t = void 0
- , i = void 0;
- if (e.parent) {
- var n = this._tempMatrix2;
- e.parent._worldMatrix.invertToRef(n),
- this._attachedNode._worldMatrix.multiplyToRef(n, this._tempMatrix1),
- t = this._tempMatrix1
- } else
- t = this._attachedNode._worldMatrix;
- if (e.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(t, this._tempMatrix2),
- i = this._tempMatrix2) : i = t,
- i.decompose(this._tempVector2, this._tempQuaternion, this._tempVector),
- "FreeCamera" === this._attachedNode.getClassName() || "FlyCamera" === this._attachedNode.getClassName() || "ArcFollowCamera" === this._attachedNode.getClassName() || "TargetCamera" === this._attachedNode.getClassName() || "TouchCamera" === this._attachedNode.getClassName() || "UniversalCamera" === this._attachedNode.getClassName()) {
- var r = this._attachedNode;
- r.rotation = this._tempQuaternion.toEulerAngles(),
- r.rotationQuaternion && (r.rotationQuaternion.copyFrom(this._tempQuaternion),
- r.rotationQuaternion.normalize())
- }
- e.position.copyFrom(this._tempVector)
- } else if (this._attachedNode._isMesh || "AbstractMesh" === this._attachedNode.getClassName() || "TransformNode" === this._attachedNode.getClassName() || "InstancedMesh" === this._attachedNode.getClassName()) {
- var o = this._attachedNode;
- if (o.parent) {
- n = this._tempMatrix1;
- var a = this._tempMatrix2;
- o.parent.getWorldMatrix().invertToRef(n),
- this._attachedNode.getWorldMatrix().multiplyToRef(n, a),
- a.decompose(o.scaling, this._tempQuaternion, o.position)
- } else
- this._attachedNode._worldMatrix.decompose(o.scaling, this._tempQuaternion, o.position);
- o.billboardMode || (o.rotationQuaternion ? (o.rotationQuaternion.copyFrom(this._tempQuaternion),
- o.rotationQuaternion.normalize()) : o.rotation = this._tempQuaternion.toEulerAngles())
- } else if ("Bone" === this._attachedNode.getClassName()) {
- var s = this._attachedNode
- , l = s.getParent();
- if (l) {
- var c = this._tempMatrix1
- , u = this._tempMatrix2;
- l.getWorldMatrix().invertToRef(c),
- s.getWorldMatrix().multiplyToRef(c, u),
- s.getLocalMatrix().copyFrom(u)
- } else
- s.getLocalMatrix().copyFrom(s.getWorldMatrix());
- s.markAsDirty()
- } else {
- var h = this._attachedNode;
- if (h.getTypeID) {
- var d = h.getTypeID();
- if (d === Cr.LIGHTTYPEID_DIRECTIONALLIGHT || d === Cr.LIGHTTYPEID_SPOTLIGHT || d === Cr.LIGHTTYPEID_POINTLIGHT) {
- var p = h.parent;
- if (p) {
- c = this._tempMatrix1;
- var f = this._tempMatrix2;
- p.getWorldMatrix().invertToRef(c),
- h.getWorldMatrix().multiplyToRef(c, f),
- f.decompose(void 0, this._tempQuaternion, this._tempVector)
- } else
- this._attachedNode._worldMatrix.decompose(void 0, this._tempQuaternion, this._tempVector);
- h.position = new x(this._tempVector.x,this._tempVector.y,this._tempVector.z),
- x.Backward(!1).rotateByQuaternionToRef(this._tempQuaternion, this._tempVector),
- h.direction = new x(this._tempVector.x,this._tempVector.y,this._tempVector.z)
- }
- }
- }
- }
- ,
- e.prototype._setGizmoMeshMaterial = function(e, t) {
- e && e.forEach((function(e) {
- e.material = t,
- e.color && (e.color = t.diffuseColor)
- }
- ))
- }
- ,
- e.GizmoAxisPointerObserver = function(e, t) {
- var i = !1
- , n = e.utilityLayerScene.onPointerObservable.add((function(e) {
- var n, r;
- if (e.pickInfo) {
- if (e.type === Xi.POINTERMOVE) {
- if (i)
- return;
- t.forEach((function(t) {
- var i, n;
- if (t.colliderMeshes && t.gizmoMeshes) {
- var r = -1 != (null === (i = t.colliderMeshes) || void 0 === i ? void 0 : i.indexOf(null === (n = null == e ? void 0 : e.pickInfo) || void 0 === n ? void 0 : n.pickedMesh))
- , o = t.dragBehavior.enabled ? r || t.active ? t.hoverMaterial : t.material : t.disableMaterial;
- t.gizmoMeshes.forEach((function(e) {
- e.material = o,
- e.color && (e.color = o.diffuseColor)
- }
- ))
- }
- }
- ))
- }
- e.type === Xi.POINTERDOWN && t.has(null === (n = e.pickInfo.pickedMesh) || void 0 === n ? void 0 : n.parent) && (i = !0,
- t.get(null === (r = e.pickInfo.pickedMesh) || void 0 === r ? void 0 : r.parent).active = !0,
- t.forEach((function(t) {
- var i, n, r = (-1 != (null === (i = t.colliderMeshes) || void 0 === i ? void 0 : i.indexOf(null === (n = null == e ? void 0 : e.pickInfo) || void 0 === n ? void 0 : n.pickedMesh)) || t.active) && t.dragBehavior.enabled ? t.hoverMaterial : t.disableMaterial;
- t.gizmoMeshes.forEach((function(e) {
- e.material = r,
- e.color && (e.color = r.diffuseColor)
- }
- ))
- }
- ))),
- e.type === Xi.POINTERUP && t.forEach((function(e) {
- e.active = !1,
- i = !1,
- e.gizmoMeshes.forEach((function(t) {
- t.material = e.dragBehavior.enabled ? e.material : e.disableMaterial,
- t.color && (t.color = e.material.diffuseColor)
- }
- ))
- }
- ))
- }
- }
- ));
- return n
- }
- ,
- e.prototype.dispose = function() {
- this._rootMesh.dispose(),
- this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)
- }
- ,
- e
- }(), Al = function(e) {
- function t(i, n, r, o, a) {
- void 0 === n && (n = D.Gray()),
- void 0 === r && (r = El.DefaultUtilityLayer),
- void 0 === o && (o = null),
- void 0 === a && (a = 1);
- var s, l = this;
- (l = e.call(this, r) || this)._pointerObserver = null,
- l.snapDistance = 0,
- l.onSnapObservable = new h,
- l._isEnabled = !0,
- l._parent = null,
- l._dragging = !1,
- l._parent = o,
- l._coloredMaterial = new Os("",r.utilityLayerScene),
- l._coloredMaterial.diffuseColor = n,
- l._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
- l._hoverMaterial = new Os("",r.utilityLayerScene),
- l._hoverMaterial.diffuseColor = D.Yellow(),
- l._disableMaterial = new Os("",r.utilityLayerScene),
- l._disableMaterial.diffuseColor = D.Gray(),
- l._disableMaterial.alpha = .4;
- var c = t._CreateArrow(r.utilityLayerScene, l._coloredMaterial, a)
- , u = t._CreateArrow(r.utilityLayerScene, l._coloredMaterial, a + 4, !0);
- l._gizmoMesh = new Vr("",r.utilityLayerScene),
- l._gizmoMesh.addChild(c),
- l._gizmoMesh.addChild(u),
- l._gizmoMesh.lookAt(l._rootMesh.position.add(i)),
- l._gizmoMesh.scaling.scaleInPlace(1 / 3),
- l._gizmoMesh.parent = l._rootMesh;
- var d = 0
- , p = new x
- , f = new x
- , _ = {
- snapDistance: 0
- };
- l.dragBehavior = new Ao({
- dragAxis: i
- }),
- l.dragBehavior.moveAttached = !1,
- l._rootMesh.addBehavior(l.dragBehavior),
- l.dragBehavior.onDragObservable.add((function(e) {
- if (l.attachedNode) {
- l._handlePivot();
- var t = !1;
- if (0 == l.snapDistance)
- l.attachedNode.getWorldMatrix().getTranslationToRef(f),
- f.addInPlace(e.delta),
- l.dragBehavior.validateDrag(f) && (l.attachedNode.position && l.attachedNode.position.addInPlaceFromFloats(e.delta.x, e.delta.y, e.delta.z),
- l.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x, e.delta.y, e.delta.z),
- l.attachedNode.updateCache(),
- t = !0);
- else if (d += e.dragDistance,
- Math.abs(d) > l.snapDistance) {
- var i = Math.floor(Math.abs(d) / l.snapDistance);
- d %= l.snapDistance,
- e.delta.normalizeToRef(p),
- p.scaleInPlace(l.snapDistance * i),
- l.attachedNode.getWorldMatrix().getTranslationToRef(f),
- f.addInPlace(p),
- l.dragBehavior.validateDrag(f) && (l.attachedNode.getWorldMatrix().addTranslationFromFloats(p.x, p.y, p.z),
- l.attachedNode.updateCache(),
- _.snapDistance = l.snapDistance * i,
- l.onSnapObservable.notifyObservers(_),
- t = !0)
- }
- t && l._matrixChanged()
- }
- }
- )),
- l.dragBehavior.onDragStartObservable.add((function() {
- l._dragging = !0
- }
- )),
- l.dragBehavior.onDragEndObservable.add((function() {
- l._dragging = !1
- }
- ));
- var m = r._getSharedGizmoLight();
- m.includedOnlyMeshes = m.includedOnlyMeshes.concat(l._rootMesh.getChildMeshes(!1));
- var g = {
- gizmoMeshes: c.getChildMeshes(),
- colliderMeshes: u.getChildMeshes(),
- material: l._coloredMaterial,
- hoverMaterial: l._hoverMaterial,
- disableMaterial: l._disableMaterial,
- active: !1,
- dragBehavior: l.dragBehavior
- };
- return null === (s = l._parent) || void 0 === s || s.addToAxisCache(u, g),
- l._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
- var t;
- if (!l._customMeshSet && (l._isHovered = !(-1 == g.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)),
- !l._parent)) {
- var i = l.dragBehavior.enabled ? l._isHovered || l._dragging ? l._hoverMaterial : l._coloredMaterial : l._disableMaterial;
- l._setGizmoMeshMaterial(g.gizmoMeshes, i)
- }
- }
- )),
- l.dragBehavior.onEnabledObservable.add((function(e) {
- l._setGizmoMeshMaterial(g.gizmoMeshes, e ? g.material : g.disableMaterial)
- }
- )),
- l
- }
- return U(t, e),
- t._CreateArrow = function(e, t, i, n) {
- void 0 === i && (i = 1),
- void 0 === n && (n = !1);
- var r = new yr("arrow",e)
- , o = Ys("cylinder", {
- diameterTop: 0,
- height: .075,
- diameterBottom: .0375 * (1 + (i - 1) / 4),
- tessellation: 96
- }, e)
- , a = Ys("cylinder", {
- diameterTop: .005 * i,
- height: .275,
- diameterBottom: .005 * i,
- tessellation: 96
- }, e);
- return o.parent = r,
- o.material = t,
- o.rotation.x = Math.PI / 2,
- o.position.z += .3,
- a.parent = r,
- a.material = t,
- a.position.z += .1375,
- a.rotation.x = Math.PI / 2,
- n && (a.visibility = 0,
- o.visibility = 0),
- r
- }
- ,
- t._CreateArrowInstance = function(e, t) {
- for (var i = new yr("arrow",e), n = 0, r = t.getChildMeshes(); n < r.length; n++) {
- var o = r[n];
- o.createInstance(o.name).parent = i
- }
- return i
- }
- ,
- t.prototype._attachedNodeChanged = function(e) {
- this.dragBehavior && (this.dragBehavior.enabled = !!e)
- }
- ,
- Object.defineProperty(t.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled = e,
- e ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
- this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
- this.attachedNode = null)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.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(e) {
- e && e.dispose()
- }
- )),
- e.prototype.dispose.call(this)
- }
- ,
- t
- }(Sl), xl = function() {
- function e(t, i, n, r, o, a, s) {
- if (void 0 === i && (i = 1),
- void 0 === n && (n = 2),
- void 0 === s && (s = 1),
- this._scaleLinesFactor = 4,
- this._instanced = !1,
- this.scene = null,
- this.scaleLines = 1,
- t = t || E.LastCreatedScene) {
- if (this.scaleLines = i,
- !r) {
- var l = new Os("",t);
- l.disableLighting = !0,
- l.emissiveColor = D.Red().scale(.5),
- r = Al._CreateArrow(t, l, s)
- }
- if (!o) {
- var c = new Os("",t);
- c.disableLighting = !0,
- c.emissiveColor = D.Green().scale(.5),
- o = Al._CreateArrow(t, c, s)
- }
- if (!a) {
- var u = new Os("",t);
- u.disableLighting = !0,
- u.emissiveColor = D.Blue().scale(.5),
- a = Al._CreateArrow(t, u, s)
- }
- this._xAxis = r,
- this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
- this._yAxis = o,
- this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
- this._zAxis = a,
- this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
- null != n && (e._SetRenderingGroupId(this._xAxis, n),
- e._SetRenderingGroupId(this._yAxis, n),
- e._SetRenderingGroupId(this._zAxis, n)),
- this.scene = t,
- this.update(new x, x.Right(), x.Up(), x.Forward())
- }
- }
- return Object.defineProperty(e.prototype, "xAxis", {
- get: function() {
- return this._xAxis
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "yAxis", {
- get: function() {
- return this._yAxis
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zAxis", {
- get: function() {
- return this._zAxis
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function(e, t, i, n) {
- this._xAxis.position.copyFrom(e),
- this._xAxis.setDirection(t),
- this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
- this._yAxis.position.copyFrom(e),
- this._yAxis.setDirection(i),
- this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor),
- this._zAxis.position.copyFrom(e),
- this._zAxis.setDirection(n),
- this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor)
- }
- ,
- e.prototype.createInstance = function() {
- var t = Al._CreateArrowInstance(this.scene, this._xAxis)
- , i = Al._CreateArrowInstance(this.scene, this._yAxis)
- , n = Al._CreateArrowInstance(this.scene, this._zAxis)
- , r = new e(this.scene,this.scaleLines,null,t,i,n);
- return r._instanced = !0,
- r
- }
- ,
- e.prototype.dispose = function() {
- this._xAxis && this._xAxis.dispose(!1, !this._instanced),
- this._yAxis && this._yAxis.dispose(!1, !this._instanced),
- this._zAxis && this._zAxis.dispose(!1, !this._instanced),
- this.scene = null
- }
- ,
- e._SetRenderingGroupId = function(e, t) {
- e.getChildMeshes().forEach((function(e) {
- e.renderingGroupId = t
- }
- ))
- }
- ,
- e
- }(), Rl = function(e) {
- function t(t, i, n, r) {
- void 0 === r && (r = 1);
- var o = e.call(this, t, r) || this;
- return o.pos = x.Zero(),
- o.xaxis = x.Zero(),
- o.yaxis = x.Zero(),
- o.zaxis = x.Zero(),
- o.mesh = n,
- o.bone = i,
- o
- }
- return U(t, e),
- t.prototype.update = function() {
- if (this.mesh && this.bone) {
- var t = this.bone;
- t._markAsDirtyAndCompose(),
- t.getAbsolutePositionToRef(this.mesh, this.pos),
- t.getDirectionToRef(vn.X, this.mesh, this.xaxis),
- t.getDirectionToRef(vn.Y, this.mesh, this.yaxis),
- t.getDirectionToRef(vn.Z, this.mesh, this.zaxis),
- e.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis)
- }
- }
- ,
- t.prototype.dispose = function() {
- this.mesh && (this.mesh = null,
- this.bone = null,
- e.prototype.dispose.call(this))
- }
- ,
- t
- }(xl);
- Object.defineProperty(mn.prototype, "debugLayer", {
- get: function() {
- return this._debugLayer || (this._debugLayer = new Cl(this)),
- this._debugLayer
- },
- enumerable: !0,
- configurable: !0
- }),
- function(e) {
- e[e.Properties = 0] = "Properties",
- e[e.Debug = 1] = "Debug",
- e[e.Statistics = 2] = "Statistics",
- e[e.Tools = 3] = "Tools",
- e[e.Settings = 4] = "Settings"
- }(bl || (bl = {}));
- var Cl = function() {
- function e(e) {
- var t = this;
- this.BJSINSPECTOR = this._getGlobalInspector(),
- this._scene = e || E.LastCreatedScene,
- this._scene && this._scene.onDisposeObservable.add((function() {
- t._scene._debugLayer && t._scene._debugLayer.hide()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "onPropertyChangedObservable", {
- get: function() {
- return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector ? this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable : (this._onPropertyChangedObservable || (this._onPropertyChangedObservable = new h),
- this._onPropertyChangedObservable)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createInspector = function(e) {
- if (!this.isVisible()) {
- if (this._onPropertyChangedObservable) {
- for (var t = 0, i = this._onPropertyChangedObservable.observers; t < i.length; t++) {
- var n = i[t];
- this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(n)
- }
- this._onPropertyChangedObservable.clear(),
- this._onPropertyChangedObservable = void 0
- }
- var r = V({
- overlay: !1,
- showExplorer: !0,
- showInspector: !0,
- embedMode: !1,
- handleResize: !0,
- enablePopup: !0
- }, e);
- this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector(),
- this.BJSINSPECTOR.Inspector.Show(this._scene, r)
- }
- }
- ,
- e.prototype.select = function(e, t) {
- this.BJSINSPECTOR && (t && ("[object String]" == Object.prototype.toString.call(t) ? this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(t) : this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(t)),
- this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(e))
- }
- ,
- e.prototype._getGlobalInspector = function() {
- return "undefined" != typeof INSPECTOR ? INSPECTOR : "undefined" != typeof BABYLON && void 0 !== BABYLON.Inspector ? BABYLON : void 0
- }
- ,
- e.prototype.isVisible = function() {
- return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible
- }
- ,
- e.prototype.hide = function() {
- this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.Hide()
- }
- ,
- e.prototype.setAsActiveScene = function() {
- this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector._SetNewScene(this._scene)
- }
- ,
- e.prototype.show = function(t) {
- var i = this;
- return new Promise((function(n) {
- if (void 0 === i.BJSINSPECTOR) {
- var r = t && t.inspectorURL ? t.inspectorURL : e.InspectorURL;
- gi.LoadScript(r, (function() {
- i._createInspector(t),
- n(i)
- }
- ))
- } else
- i._createInspector(t),
- n(i)
- }
- ))
- }
- ,
- e.InspectorURL = "https://unpkg.com/babylonjs-inspector@".concat(vr.Version, "/babylon.inspector.bundle.js"),
- e
- }();
- function Pl(e) {
- var t, 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], n = [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], r = [], o = e.width || e.size || 1, a = e.height || e.size || 1, s = e.depth || e.size || 1, l = e.wrap || !1, c = void 0 === e.topBaseAt ? 1 : e.topBaseAt, u = void 0 === e.bottomBaseAt ? 0 : e.bottomBaseAt, h = [2, 0, 3, 1][c = (c + 4) % 4], d = [2, 0, 1, 3][u = (u + 4) % 4], p = [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 (l) {
- 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],
- p = [-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 f = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]], _ = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]], m = [17, 18, 19, 16], g = [22, 23, 20, 21]; h > 0; )
- f.unshift(f.pop()),
- m.unshift(m.pop()),
- h--;
- for (; d > 0; )
- _.unshift(_.pop()),
- g.unshift(g.pop()),
- d--;
- f = f.flat(),
- _ = _.flat(),
- p = p.concat(f).concat(_),
- i.push(m[0], m[2], m[3], m[0], m[1], m[2]),
- i.push(g[0], g[2], g[3], g[0], g[1], g[2])
- }
- var v = [o / 2, a / 2, s / 2];
- t = p.reduce((function(e, t, i) {
- return e.concat(t * v[i % 3])
- }
- ), []);
- for (var y = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, b = e.faceUV || new Array(6), T = e.faceColors, E = [], S = 0; S < 6; S++)
- void 0 === b[S] && (b[S] = new R(0,0,1,1)),
- T && void 0 === T[S] && (T[S] = new N(1,1,1,1));
- for (var A = 0; A < 6; A++)
- if (r.push(b[A].z, pr.UseOpenGLOrientationForUV ? 1 - b[A].w : b[A].w),
- r.push(b[A].x, pr.UseOpenGLOrientationForUV ? 1 - b[A].w : b[A].w),
- r.push(b[A].x, pr.UseOpenGLOrientationForUV ? 1 - b[A].y : b[A].y),
- r.push(b[A].z, pr.UseOpenGLOrientationForUV ? 1 - b[A].y : b[A].y),
- T)
- for (var x = 0; x < 4; x++)
- E.push(T[A].r, T[A].g, T[A].b, T[A].a);
- $n._ComputeSides(y, t, i, n, r, e.frontUVs, e.backUVs);
- var C = new $n;
- if (C.indices = i,
- C.positions = t,
- C.normals = n,
- C.uvs = r,
- T) {
- var P = y === $n.DOUBLESIDE ? E.concat(E) : E;
- C.colors = P
- }
- return C
- }
- function Ml(e, t, i) {
- void 0 === t && (t = {}),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- Pl(t).applyToMesh(n, t.updatable),
- n
- }
- var Il = {
- CreateBox: Ml
- };
- function Ol(e) {
- for (var t = e.segments || 32, i = e.diameterX || e.diameter || 1, n = e.diameterY || e.diameter || 1, r = e.diameterZ || e.diameter || 1, o = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1, a = e.slice && e.slice <= 0 ? 1 : e.slice || 1, s = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, l = !!e.dedupTopBottomIndices, c = new x(i / 2,n / 2,r / 2), u = 2 + t, h = 2 * u, d = [], p = [], f = [], _ = [], m = 0; m <= u; m++) {
- for (var g = m / u, v = g * Math.PI * a, y = 0; y <= h; y++) {
- var b = y / h
- , T = b * Math.PI * 2 * o
- , E = P.RotationZ(-v)
- , S = P.RotationY(T)
- , A = x.TransformCoordinates(x.Up(), E)
- , R = x.TransformCoordinates(A, S)
- , C = R.multiply(c)
- , M = R.divide(c).normalize();
- p.push(C.x, C.y, C.z),
- f.push(M.x, M.y, M.z),
- _.push(b, pr.UseOpenGLOrientationForUV ? 1 - g : g)
- }
- if (m > 0)
- for (var I = p.length / 3, O = I - 2 * (h + 1); O + h + 2 < I; O++)
- l ? (m > 1 && (d.push(O),
- d.push(O + 1),
- d.push(O + h + 1)),
- (m < u || a < 1) && (d.push(O + h + 1),
- d.push(O + 1),
- d.push(O + h + 2))) : (d.push(O),
- d.push(O + 1),
- d.push(O + h + 1),
- d.push(O + h + 1),
- d.push(O + 1),
- d.push(O + h + 2))
- }
- $n._ComputeSides(s, p, d, f, _, e.frontUVs, e.backUVs);
- var D = new $n;
- return D.indices = d,
- D.positions = p,
- D.normals = f,
- D.uvs = _,
- D
- }
- function Dl(e, t, i) {
- void 0 === t && (t = {}),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- Ol(t).applyToMesh(n, t.updatable),
- n
- }
- $n.CreateBox = Pl,
- Vr.CreateBox = function(e, t, i, n, r) {
- return void 0 === i && (i = null),
- Ml(e, {
- size: t,
- sideOrientation: r,
- updatable: n
- }, i)
- }
- ;
- var Nl = {
- CreateSphere: Dl
- };
- $n.CreateSphere = Ol,
- Vr.CreateSphere = function(e, t, i, n, r, o) {
- return Dl(e, {
- segments: t,
- diameterX: i,
- diameterY: i,
- diameterZ: i,
- sideOrientation: o,
- updatable: r
- }, n)
- }
- ;
- var Ll = function() {
- function e(e, t) {
- this.type = e,
- this.jointData = t,
- t.nativeParams = t.nativeParams || {}
- }
- return Object.defineProperty(e.prototype, "physicsJoint", {
- get: function() {
- return this._physicsJoint
- },
- set: function(e) {
- this._physicsJoint,
- this._physicsJoint = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "physicsPlugin", {
- set: function(e) {
- this._physicsPlugin = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.executeNativeFunction = function(e) {
- e(this._physicsPlugin.world, this._physicsJoint)
- }
- ,
- e.DistanceJoint = 0,
- e.HingeJoint = 1,
- e.BallAndSocketJoint = 2,
- e.WheelJoint = 3,
- e.SliderJoint = 4,
- e.PrismaticJoint = 5,
- e.UniversalJoint = 6,
- e.Hinge2Joint = e.WheelJoint,
- e.PointToPointJoint = 8,
- e.SpringJoint = 9,
- e.LockJoint = 10,
- e
- }()
- , Fl = function(e) {
- function t(t) {
- return e.call(this, Ll.DistanceJoint, t) || this
- }
- return U(t, e),
- t.prototype.updateDistance = function(e, t) {
- this._physicsPlugin.updateDistanceJoint(this, e, t)
- }
- ,
- t
- }(Ll)
- , wl = function(e) {
- function t(t, i) {
- return e.call(this, t, i) || this
- }
- return U(t, e),
- t.prototype.setMotor = function(e, t) {
- this._physicsPlugin.setMotor(this, e || 0, t)
- }
- ,
- t.prototype.setLimit = function(e, t) {
- this._physicsPlugin.setLimit(this, e, t)
- }
- ,
- t
- }(Ll)
- , Bl = function(e) {
- function t(t) {
- return e.call(this, Ll.HingeJoint, t) || this
- }
- return U(t, e),
- t.prototype.setMotor = function(e, t) {
- this._physicsPlugin.setMotor(this, e || 0, t)
- }
- ,
- t.prototype.setLimit = function(e, t) {
- this._physicsPlugin.setLimit(this, e, t)
- }
- ,
- t
- }(wl)
- , Ul = function(e) {
- function t(t) {
- return e.call(this, Ll.Hinge2Joint, t) || this
- }
- return U(t, e),
- t.prototype.setMotor = function(e, t, i) {
- void 0 === i && (i = 0),
- this._physicsPlugin.setMotor(this, e || 0, t, i)
- }
- ,
- t.prototype.setLimit = function(e, t, i) {
- void 0 === i && (i = 0),
- this._physicsPlugin.setLimit(this, e, t, i)
- }
- ,
- t
- }(wl);
- Vr._PhysicsImpostorParser = function(e, t, i) {
- return new Vl(t,i.physicsImpostor,{
- mass: i.physicsMass,
- friction: i.physicsFriction,
- restitution: i.physicsRestitution
- },e)
- }
- ;
- var Vl = function() {
- function e(e, t, i, n) {
- void 0 === i && (i = {
- mass: 0
- });
- var r = this;
- this.object = e,
- this.type = t,
- this._options = i,
- this._scene = n,
- this._pluginData = {},
- this._bodyUpdateRequired = !1,
- this._onBeforePhysicsStepCallbacks = new Array,
- this._onAfterPhysicsStepCallbacks = new Array,
- this._onPhysicsCollideCallbacks = [],
- this._deltaPosition = x.Zero(),
- this._isDisposed = !1,
- this.soft = !1,
- this.segments = 0,
- this._tmpQuat = new C,
- this._tmpQuat2 = new C,
- this.beforeStep = function() {
- r._physicsEngine && (r.object.translate(r._deltaPosition, -1),
- r._deltaRotationConjugated && r.object.rotationQuaternion && r.object.rotationQuaternion.multiplyToRef(r._deltaRotationConjugated, r.object.rotationQuaternion),
- r.object.computeWorldMatrix(!1),
- r.object.parent && r.object.rotationQuaternion ? (r.getParentsRotation(),
- r._tmpQuat.multiplyToRef(r.object.rotationQuaternion, r._tmpQuat)) : r._tmpQuat.copyFrom(r.object.rotationQuaternion || new C),
- r._options.disableBidirectionalTransformation || r.object.rotationQuaternion && r._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(r, r.object.getAbsolutePosition(), r._tmpQuat),
- r._onBeforePhysicsStepCallbacks.forEach((function(e) {
- e(r)
- }
- )))
- }
- ,
- this.afterStep = function() {
- r._physicsEngine && (r._onAfterPhysicsStepCallbacks.forEach((function(e) {
- e(r)
- }
- )),
- r._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(r),
- r.object.parent && r.object.rotationQuaternion && (r.getParentsRotation(),
- r._tmpQuat.conjugateInPlace(),
- r._tmpQuat.multiplyToRef(r.object.rotationQuaternion, r.object.rotationQuaternion)),
- r.object.setAbsolutePosition(r.object.position),
- r._deltaRotation && r.object.rotationQuaternion && r.object.rotationQuaternion.multiplyToRef(r._deltaRotation, r.object.rotationQuaternion),
- r.object.translate(r._deltaPosition, 1))
- }
- ,
- this.onCollideEvent = null,
- this.onCollide = function(e) {
- if ((r._onPhysicsCollideCallbacks.length || r.onCollideEvent) && r._physicsEngine) {
- var t = r._physicsEngine.getImpostorWithPhysicsBody(e.body);
- t && (r.onCollideEvent && r.onCollideEvent(r, t),
- r._onPhysicsCollideCallbacks.filter((function(e) {
- return -1 !== e.otherImpostors.indexOf(t)
- }
- )).forEach((function(i) {
- i.callback(r, t, e.point)
- }
- )))
- }
- }
- ,
- this.object ? (this.object.parent && 0 !== i.mass && K.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 = C.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z) : this.object.rotationQuaternion = new C),
- this._options.mass = void 0 === i.mass ? 0 : i.mass,
- this._options.friction = void 0 === i.friction ? .2 : i.friction,
- this._options.restitution = void 0 === i.restitution ? .2 : i.restitution,
- this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1,
- this._options.pressure = void 0 === i.pressure ? 200 : i.pressure,
- this._options.stiffness = void 0 === i.stiffness ? 1 : i.stiffness,
- this._options.velocityIterations = void 0 === i.velocityIterations ? 20 : i.velocityIterations,
- this._options.positionIterations = void 0 === i.positionIterations ? 20 : i.positionIterations,
- this._options.fixedPoints = void 0 === i.fixedPoints ? 0 : i.fixedPoints,
- this._options.margin = void 0 === i.margin ? 0 : i.margin,
- this._options.damping = void 0 === i.damping ? 0 : i.damping,
- this._options.path = void 0 === i.path ? null : i.path,
- this._options.shape = void 0 === i.shape ? null : i.shape),
- this._joints = [],
- !this.object.parent || this._options.ignoreParent ? this._init() : this.object.parent.physicsImpostor && K.Warn("You must affect impostors to children before affecting impostor to parent.")) : K.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))) : K.Error("No object was provided. A physics object is obligatory")
- }
- return Object.defineProperty(e.prototype, "isDisposed", {
- get: function() {
- return this._isDisposed
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.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(e.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(e.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 t = this._physicsEngine.getPhysicsPlugin();
- t.setBodyPressure && t.setBodyPressure(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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 t = this._physicsEngine.getPhysicsPlugin();
- t.setBodyStiffness && t.setBodyStiffness(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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 t = this._physicsEngine.getPhysicsPlugin();
- t.setBodyVelocityIterations && t.setBodyVelocityIterations(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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 t = this._physicsEngine.getPhysicsPlugin();
- t.setBodyPositionIterations && t.setBodyPositionIterations(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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))
- }
- ,
- e.prototype._getPhysicsParent = function() {
- return this.object.parent instanceof Sr ? this.object.parent.physicsImpostor : null
- }
- ,
- e.prototype.isBodyInitRequired = function() {
- return this._bodyUpdateRequired || !this._physicsBody && !this._parent
- }
- ,
- e.prototype.setScalingUpdated = function() {
- this.forceUpdate()
- }
- ,
- e.prototype.forceUpdate = function() {
- this._init(),
- this.parent && !this._options.ignoreParent && this.parent.forceUpdate()
- }
- ,
- Object.defineProperty(e.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(e.prototype, "parent", {
- get: function() {
- return !this._options.ignoreParent && this._parent ? this._parent : null
- },
- set: function(e) {
- this._parent = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.resetUpdateFlags = function() {
- this._bodyUpdateRequired = !1
- }
- ,
- e.prototype.getObjectExtendSize = function() {
- if (this.object.getBoundingInfo) {
- var t = this.object.rotationQuaternion
- , i = this.object.scaling.clone();
- this.object.rotationQuaternion = e.IDENTITY_QUATERNION;
- var n = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
- n && n.decompose(i, void 0, void 0);
- var r = this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);
- return r.x = Math.abs(r.x),
- r.y = Math.abs(r.y),
- r.z = Math.abs(r.z),
- this.object.rotationQuaternion = t,
- this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0),
- r
- }
- return e.DEFAULT_OBJECT_SIZE
- }
- ,
- e.prototype.getObjectCenter = function() {
- return this.object.getBoundingInfo ? this.object.getBoundingInfo().boundingBox.centerWorld : this.object.position
- }
- ,
- e.prototype.getParam = function(e) {
- return this._options[e]
- }
- ,
- e.prototype.setParam = function(e, t) {
- this._options[e] = t,
- this._bodyUpdateRequired = !0
- }
- ,
- e.prototype.setMass = function(e) {
- this.getParam("mass") !== e && this.setParam("mass", e),
- this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyMass(this, e)
- }
- ,
- e.prototype.getLinearVelocity = function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : x.Zero()
- }
- ,
- e.prototype.setLinearVelocity = function(e) {
- this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, e)
- }
- ,
- e.prototype.getAngularVelocity = function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : x.Zero()
- }
- ,
- e.prototype.setAngularVelocity = function(e) {
- this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, e)
- }
- ,
- e.prototype.executeNativeFunction = function(e) {
- this._physicsEngine && e(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody)
- }
- ,
- e.prototype.registerBeforePhysicsStep = function(e) {
- this._onBeforePhysicsStepCallbacks.push(e)
- }
- ,
- e.prototype.unregisterBeforePhysicsStep = function(e) {
- var t = this._onBeforePhysicsStepCallbacks.indexOf(e);
- t > -1 ? this._onBeforePhysicsStepCallbacks.splice(t, 1) : K.Warn("Function to remove was not found")
- }
- ,
- e.prototype.registerAfterPhysicsStep = function(e) {
- this._onAfterPhysicsStepCallbacks.push(e)
- }
- ,
- e.prototype.unregisterAfterPhysicsStep = function(e) {
- var t = this._onAfterPhysicsStepCallbacks.indexOf(e);
- t > -1 ? this._onAfterPhysicsStepCallbacks.splice(t, 1) : K.Warn("Function to remove was not found")
- }
- ,
- e.prototype.registerOnPhysicsCollide = function(e, t) {
- var i = e instanceof Array ? e : [e];
- this._onPhysicsCollideCallbacks.push({
- callback: t,
- otherImpostors: i
- })
- }
- ,
- e.prototype.unregisterOnPhysicsCollide = function(e, t) {
- var i = e instanceof Array ? e : [e]
- , n = -1;
- this._onPhysicsCollideCallbacks.some((function(e, r) {
- if (e.callback === t && e.otherImpostors.length === i.length) {
- var o = e.otherImpostors.every((function(e) {
- return i.indexOf(e) > -1
- }
- ));
- return o && (n = r),
- o
- }
- return !1
- }
- )) ? this._onPhysicsCollideCallbacks.splice(n, 1) : K.Warn("Function to remove was not found")
- }
- ,
- e.prototype.getParentsRotation = function() {
- var e = this.object.parent;
- for (this._tmpQuat.copyFromFloats(0, 0, 0, 1); e; )
- e.rotationQuaternion ? this._tmpQuat2.copyFrom(e.rotationQuaternion) : C.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
- }
- ,
- e.prototype.applyForce = function(e, t) {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyForce(this, e, t),
- this
- }
- ,
- e.prototype.applyImpulse = function(e, t) {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyImpulse(this, e, t),
- this
- }
- ,
- e.prototype.createJoint = function(e, t, i) {
- var n = new Ll(t,i);
- return this.addJoint(e, n),
- this
- }
- ,
- e.prototype.addJoint = function(e, t) {
- return this._joints.push({
- otherImpostor: e,
- joint: t
- }),
- this._physicsEngine && this._physicsEngine.addJoint(this, e, t),
- this
- }
- ,
- e.prototype.addAnchor = function(e, t, i, n, r) {
- if (!this._physicsEngine)
- return this;
- var o = this._physicsEngine.getPhysicsPlugin();
- return o.appendAnchor ? (this._physicsEngine && o.appendAnchor(this, e, t, i, n, r),
- this) : this
- }
- ,
- e.prototype.addHook = function(e, t, i, n) {
- if (!this._physicsEngine)
- return this;
- var r = this._physicsEngine.getPhysicsPlugin();
- return r.appendAnchor ? (this._physicsEngine && r.appendHook(this, e, t, i, n),
- this) : this
- }
- ,
- e.prototype.sleep = function() {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().sleepBody(this),
- this
- }
- ,
- e.prototype.wakeUp = function() {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),
- this
- }
- ,
- e.prototype.clone = function(t) {
- return t ? new e(t,this.type,this._options,this._scene) : null
- }
- ,
- e.prototype.dispose = function() {
- var e = this;
- this._physicsEngine && (this._joints.forEach((function(t) {
- e._physicsEngine && e._physicsEngine.removeJoint(e, t.otherImpostor, t.joint)
- }
- )),
- this._physicsEngine.removeImpostor(this),
- this.parent && this.parent.forceUpdate(),
- this._isDisposed = !0)
- }
- ,
- e.prototype.setDeltaPosition = function(e) {
- this._deltaPosition.copyFrom(e)
- }
- ,
- e.prototype.setDeltaRotation = function(e) {
- this._deltaRotation || (this._deltaRotation = new C),
- this._deltaRotation.copyFrom(e),
- this._deltaRotationConjugated = this._deltaRotation.conjugate()
- }
- ,
- e.prototype.getBoxSizeToRef = function(e) {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, e),
- this
- }
- ,
- e.prototype.getRadius = function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0
- }
- ,
- e.prototype.syncBoneWithImpostor = function(t, i, n, r, o) {
- var a = e._TmpVecs[0]
- , s = this.object;
- if (s.rotationQuaternion)
- if (o) {
- var l = e._TmpQuat;
- s.rotationQuaternion.multiplyToRef(o, l),
- t.setRotationQuaternion(l, Ji.WORLD, i)
- } else
- t.setRotationQuaternion(s.rotationQuaternion, Ji.WORLD, i);
- a.x = 0,
- a.y = 0,
- a.z = 0,
- n && (a.x = n.x,
- a.y = n.y,
- a.z = n.z,
- t.getDirectionToRef(a, i, a),
- null == r && (r = n.length()),
- a.x *= r,
- a.y *= r,
- a.z *= r),
- t.getParent() ? (a.addInPlace(s.getAbsolutePosition()),
- t.setAbsolutePosition(a, i)) : (i.setAbsolutePosition(s.getAbsolutePosition()),
- i.position.x -= a.x,
- i.position.y -= a.y,
- i.position.z -= a.z)
- }
- ,
- e.prototype.syncImpostorWithBone = function(t, i, n, r, o, a) {
- var s = this.object;
- if (s.rotationQuaternion)
- if (o) {
- var l = e._TmpQuat;
- t.getRotationQuaternionToRef(Ji.WORLD, i, l),
- l.multiplyToRef(o, s.rotationQuaternion)
- } else
- t.getRotationQuaternionToRef(Ji.WORLD, i, s.rotationQuaternion);
- var c = e._TmpVecs[0]
- , u = e._TmpVecs[1];
- a || ((a = e._TmpVecs[2]).x = 0,
- a.y = 1,
- a.z = 0),
- t.getDirectionToRef(a, i, u),
- t.getAbsolutePositionToRef(i, c),
- null == r && n && (r = n.length()),
- null != r && (c.x += u.x * r,
- c.y += u.y * r,
- c.z += u.z * r),
- s.setAbsolutePosition(c)
- }
- ,
- e.DEFAULT_OBJECT_SIZE = new x(1,1,1),
- e.IDENTITY_QUATERNION = C.Identity(),
- e._TmpVecs = g.BuildArray(3, x.Zero),
- e._TmpQuat = C.Identity(),
- e.NoImpostor = 0,
- e.SphereImpostor = 1,
- e.BoxImpostor = 2,
- e.PlaneImpostor = 3,
- e.MeshImpostor = 4,
- e.CapsuleImpostor = 6,
- e.CylinderImpostor = 7,
- e.ParticleImpostor = 8,
- e.HeightmapImpostor = 9,
- e.ConvexHullImpostor = 10,
- e.CustomImpostor = 100,
- e.RopeImpostor = 101,
- e.ClothImpostor = 102,
- e.SoftbodyImpostor = 103,
- e
- }();
- function kl(e) {
- void 0 === e && (e = {
- subdivisions: 2,
- tessellation: 16,
- height: 1,
- radius: .25,
- capSubdivisions: 6
- });
- var t, i, n = Math.max(e.subdivisions ? e.subdivisions : 2, 1), r = Math.max(e.tessellation ? e.tessellation : 16, 3), o = Math.max(e.height ? e.height : 1, 0), a = Math.max(e.radius ? e.radius : .25, 0), s = Math.max(e.capSubdivisions ? e.capSubdivisions : 6, 1), l = r, c = n, u = Math.max(e.radiusTop ? e.radiusTop : a, 0), h = Math.max(e.radiusBottom ? e.radiusBottom : a, 0), d = o - (u + h), p = 2 * Math.PI, f = Math.max(e.topCapSubdivisions ? e.topCapSubdivisions : s, 1), _ = Math.max(e.bottomCapSubdivisions ? e.bottomCapSubdivisions : s, 1), m = Math.acos((h - u) / o), g = [], v = [], y = [], b = [], T = 0, E = [], S = .5 * d, R = .5 * Math.PI, C = x.Zero(), M = x.Zero(), I = Math.cos(m), O = Math.sin(m), D = new A(u * O,S + u * I).subtract(new A(h * O,h * I - S)).length(), N = u * m + D + h * (R - m), L = 0;
- for (i = 0; i <= f; i++) {
- var F = []
- , w = R - m * (i / f);
- L += u * m / f;
- var B = Math.cos(w)
- , U = Math.sin(w)
- , V = B * u;
- for (t = 0; t <= l; t++) {
- var k = (X = t / l) * p + 0
- , G = Math.sin(k)
- , z = Math.cos(k);
- M.x = V * G,
- M.y = S + U * u,
- M.z = V * z,
- v.push(M.x, M.y, M.z),
- C.set(B * G, U, B * z),
- y.push(C.x, C.y, C.z),
- b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
- F.push(T),
- T++
- }
- E.push(F)
- }
- var W = o - u - h + I * u - I * h
- , H = O * (h - u) / W;
- for (i = 1; i <= c; i++) {
- for (F = [],
- L += D / c,
- V = O * (i * (h - u) / c + u),
- t = 0; t <= l; t++)
- k = (X = t / l) * p + 0,
- G = Math.sin(k),
- z = Math.cos(k),
- M.x = V * G,
- M.y = S + I * u - i * W / c,
- M.z = V * z,
- v.push(M.x, M.y, M.z),
- C.set(G, H, z).normalize(),
- y.push(C.x, C.y, C.z),
- b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
- F.push(T),
- T++;
- E.push(F)
- }
- for (i = 1; i <= _; i++) {
- for (F = [],
- w = R - m - (Math.PI - m) * (i / _),
- L += h * m / _,
- B = Math.cos(w),
- U = Math.sin(w),
- V = B * h,
- t = 0; t <= l; t++) {
- var X;
- k = (X = t / l) * p + 0,
- G = Math.sin(k),
- z = Math.cos(k),
- M.x = V * G,
- M.y = U * h - S,
- M.z = V * z,
- v.push(M.x, M.y, M.z),
- C.set(B * G, U, B * z),
- y.push(C.x, C.y, C.z),
- b.push(X, pr.UseOpenGLOrientationForUV ? L / N : 1 - L / N),
- F.push(T),
- T++
- }
- E.push(F)
- }
- for (t = 0; t < l; t++)
- for (i = 0; i < f + c + _; i++) {
- var j = E[i][t]
- , Y = E[i + 1][t]
- , K = E[i + 1][t + 1]
- , Q = E[i][t + 1];
- g.push(j),
- g.push(Y),
- g.push(Q),
- g.push(Y),
- g.push(K),
- g.push(Q)
- }
- if (g = g.reverse(),
- e.orientation && !e.orientation.equals(x.Up())) {
- var q = new P;
- e.orientation.clone().scale(.5 * Math.PI).cross(x.Up()).toQuaternion().toRotationMatrix(q);
- for (var Z = x.Zero(), J = 0; J < v.length; J += 3)
- Z.set(v[J], v[J + 1], v[J + 2]),
- x.TransformCoordinatesToRef(Z.clone(), q, Z),
- v[J] = Z.x,
- v[J + 1] = Z.y,
- v[J + 2] = Z.z
- }
- var $ = new $n;
- return $.positions = v,
- $.normals = y,
- $.uvs = b,
- $.indices = g,
- $
- }
- function Gl(e, t, i) {
- void 0 === t && (t = {
- orientation: x.Up(),
- subdivisions: 2,
- tessellation: 16,
- height: 1,
- radius: .25,
- capSubdivisions: 6,
- updatable: !1
- }),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return kl(t).applyToMesh(n, t.updatable),
- n
- }
- var zl = {
- CreateCapsule: Gl
- };
- Vr.CreateCapsule = function(e, t, i) {
- return Gl(e, t, i)
- }
- ,
- $n.CreateCapsule = kl;
- var Wl = function() {
- function e(e) {
- if (this._impostors = [],
- this._meshes = [],
- this._numMeshes = 0,
- this._debugMeshMeshes = new Array,
- this._scene = e || E.LastCreatedScene,
- this._scene) {
- var t = this._scene.getPhysicsEngine();
- t && (this._physicsEnginePlugin = t.getPhysicsPlugin()),
- this._utilityLayer = new El(this._scene,!1),
- this._utilityLayer.pickUtilitySceneFirst = !1,
- this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0
- }
- }
- return e.prototype._updateDebugMeshes = function() {
- for (var e = this._physicsEnginePlugin, t = 0; t < this._numMeshes; t++) {
- var i = this._impostors[t];
- if (i)
- if (i.isDisposed)
- this.hideImpostor(this._impostors[t--]);
- else {
- if (i.type === Vl.MeshImpostor)
- continue;
- var n = this._meshes[t];
- n && e && e.syncMeshWithImpostor(n, i)
- }
- }
- }
- ,
- e.prototype.showImpostor = function(e, t) {
- if (!this._scene)
- return null;
- for (var i = 0; i < this._numMeshes; i++)
- if (this._impostors[i] == e)
- return null;
- var n = this._getDebugMesh(e, t);
- return n && (this._impostors[this._numMeshes] = e,
- this._meshes[this._numMeshes] = n,
- 0 === this._numMeshes && (this._renderFunction = this._updateDebugMeshes.bind(this),
- this._scene.registerBeforeRender(this._renderFunction)),
- this._numMeshes++),
- n
- }
- ,
- e.prototype.hideImpostor = function(e) {
- if (e && this._scene && this._utilityLayer) {
- for (var t = !1, i = this._utilityLayer.utilityLayerScene, n = 0; n < this._numMeshes; n++)
- if (this._impostors[n] == e) {
- var r = this._meshes[n];
- if (!r)
- continue;
- i.removeMesh(r),
- r.dispose();
- var o = this._debugMeshMeshes.indexOf(r);
- o > -1 && this._debugMeshMeshes.splice(o, 1),
- this._numMeshes--,
- this._numMeshes > 0 ? (this._meshes[n] = this._meshes[this._numMeshes],
- this._impostors[n] = this._impostors[this._numMeshes],
- this._meshes[this._numMeshes] = null,
- this._impostors[this._numMeshes] = null) : (this._meshes[0] = null,
- this._impostors[0] = null),
- t = !0;
- break
- }
- t && 0 === this._numMeshes && this._scene.unregisterBeforeRender(this._renderFunction)
- }
- }
- ,
- e.prototype._getDebugMaterial = function(e) {
- return this._debugMaterial || (this._debugMaterial = new Os("",e),
- this._debugMaterial.wireframe = !0,
- this._debugMaterial.emissiveColor = D.White(),
- this._debugMaterial.disableLighting = !0),
- this._debugMaterial
- }
- ,
- e.prototype._getDebugBoxMesh = function(e) {
- return this._debugBoxMesh || (this._debugBoxMesh = Ml("physicsBodyBoxViewMesh", {
- size: 1
- }, e),
- this._debugBoxMesh.rotationQuaternion = C.Identity(),
- this._debugBoxMesh.material = this._getDebugMaterial(e),
- this._debugBoxMesh.setEnabled(!1)),
- this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")
- }
- ,
- e.prototype._getDebugSphereMesh = function(e) {
- return this._debugSphereMesh || (this._debugSphereMesh = Dl("physicsBodySphereViewMesh", {
- diameter: 1
- }, e),
- this._debugSphereMesh.rotationQuaternion = C.Identity(),
- this._debugSphereMesh.material = this._getDebugMaterial(e),
- this._debugSphereMesh.setEnabled(!1)),
- this._debugSphereMesh.createInstance("physicsBodySphereViewInstance")
- }
- ,
- e.prototype._getDebugCapsuleMesh = function(e) {
- return this._debugCapsuleMesh || (this._debugCapsuleMesh = Gl("physicsBodyCapsuleViewMesh", {
- height: 1
- }, e),
- this._debugCapsuleMesh.rotationQuaternion = C.Identity(),
- this._debugCapsuleMesh.material = this._getDebugMaterial(e),
- this._debugCapsuleMesh.setEnabled(!1)),
- this._debugCapsuleMesh.createInstance("physicsBodyCapsuleViewInstance")
- }
- ,
- e.prototype._getDebugCylinderMesh = function(e) {
- return this._debugCylinderMesh || (this._debugCylinderMesh = Ys("physicsBodyCylinderViewMesh", {
- diameterTop: 1,
- diameterBottom: 1,
- height: 1
- }, e),
- this._debugCylinderMesh.rotationQuaternion = C.Identity(),
- this._debugCylinderMesh.material = this._getDebugMaterial(e),
- this._debugCylinderMesh.setEnabled(!1)),
- this._debugCylinderMesh.createInstance("physicsBodyCylinderViewInstance")
- }
- ,
- e.prototype._getDebugMeshMesh = function(e, t) {
- var i = new Vr(e.name,t,null,e);
- return i.setParent(e),
- i.position = x.Zero(),
- i.material = this._getDebugMaterial(t),
- this._debugMeshMeshes.push(i),
- i
- }
- ,
- e.prototype._getDebugMesh = function(e, t) {
- var i = this;
- if (!this._utilityLayer)
- return null;
- if (t && t.parent && t.parent.physicsImpostor)
- return null;
- var n = null
- , r = this._utilityLayer.utilityLayerScene;
- switch (e.type) {
- case Vl.BoxImpostor:
- n = this._getDebugBoxMesh(r),
- e.getBoxSizeToRef(n.scaling);
- break;
- case Vl.SphereImpostor:
- n = this._getDebugSphereMesh(r);
- var o = e.getRadius();
- n.scaling.x = 2 * o,
- n.scaling.y = 2 * o,
- n.scaling.z = 2 * o;
- break;
- case Vl.CapsuleImpostor:
- n = this._getDebugCapsuleMesh(r);
- var a = e.object.getBoundingInfo();
- n.scaling.x = 2 * (a.boundingBox.maximum.x - a.boundingBox.minimum.x) * e.object.scaling.x,
- n.scaling.y = (a.boundingBox.maximum.y - a.boundingBox.minimum.y) * e.object.scaling.y,
- n.scaling.z = 2 * (a.boundingBox.maximum.z - a.boundingBox.minimum.z) * e.object.scaling.z;
- break;
- case Vl.MeshImpostor:
- t && (n = this._getDebugMeshMesh(t, r));
- break;
- case Vl.NoImpostor:
- t && t.getChildMeshes().filter((function(e) {
- return e.physicsImpostor ? 1 : 0
- }
- )).forEach((function(e) {
- if (e.physicsImpostor && "Mesh" === e.getClassName()) {
- var t = e.getBoundingInfo()
- , o = t.boundingBox.minimum
- , a = t.boundingBox.maximum;
- switch (e.physicsImpostor.type) {
- case Vl.BoxImpostor:
- (n = i._getDebugBoxMesh(r)).position.copyFrom(o),
- n.position.addInPlace(a),
- n.position.scaleInPlace(.5);
- break;
- case Vl.SphereImpostor:
- n = i._getDebugSphereMesh(r);
- break;
- case Vl.CylinderImpostor:
- n = i._getDebugCylinderMesh(r);
- break;
- default:
- n = null
- }
- n && (n.scaling.x = a.x - o.x,
- n.scaling.y = a.y - o.y,
- n.scaling.z = a.z - o.z,
- n.parent = e)
- }
- }
- )),
- n = null;
- break;
- case Vl.CylinderImpostor:
- n = this._getDebugCylinderMesh(r),
- a = e.object.getBoundingInfo(),
- n.scaling.x = (a.boundingBox.maximum.x - a.boundingBox.minimum.x) * e.object.scaling.x,
- n.scaling.y = (a.boundingBox.maximum.y - a.boundingBox.minimum.y) * e.object.scaling.y,
- n.scaling.z = (a.boundingBox.maximum.z - a.boundingBox.minimum.z) * e.object.scaling.z
- }
- return n
- }
- ,
- e.prototype.dispose = function() {
- for (var e = this._numMeshes, t = 0; t < e; t++)
- this.hideImpostor(this._impostors[0]);
- this._debugBoxMesh && this._debugBoxMesh.dispose(),
- this._debugSphereMesh && this._debugSphereMesh.dispose(),
- this._debugCylinderMesh && this._debugCylinderMesh.dispose(),
- this._debugMaterial && this._debugMaterial.dispose(),
- this._impostors.length = 0,
- this._scene = null,
- this._physicsEnginePlugin = null,
- this._utilityLayer && (this._utilityLayer.dispose(),
- this._utilityLayer = null)
- }
- ,
- e
- }();
- Vr._instancedMeshFactory = function(e, t) {
- var i = new Hl(e,t);
- if (t.instancedBuffers)
- for (var n in i.instancedBuffers = {},
- t.instancedBuffers)
- i.instancedBuffers[n] = t.instancedBuffers[n];
- return i
- }
- ;
- var Hl = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i.getScene()) || this;
- n._indexInSourceMeshInstanceArray = -1,
- n._distanceToCamera = 0,
- i.addInstance(n),
- n._sourceMesh = i,
- n._unIndexed = i._unIndexed,
- n.position.copyFrom(i.position),
- n.rotation.copyFrom(i.rotation),
- n.scaling.copyFrom(i.scaling),
- i.rotationQuaternion && (n.rotationQuaternion = i.rotationQuaternion.clone()),
- n.animations = gi.Slice(i.animations);
- for (var r = 0, o = i.getAnimationRanges(); r < o.length; r++) {
- var a = o[r];
- null != a && n.createAnimationRange(a.name, a.from, a.to)
- }
- return n.infiniteDistance = i.infiniteDistance,
- n.setPivotMatrix(i.getPivotMatrix()),
- n.refreshBoundingInfo(!0, !0),
- n._syncSubMeshes(),
- n
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "InstancedMesh"
- }
- ,
- Object.defineProperty(t.prototype, "lightSources", {
- get: function() {
- return this._sourceMesh._lightSources
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._resyncLightSources = function() {}
- ,
- t.prototype._resyncLightSource = function() {}
- ,
- t.prototype._removeLightSource = function() {}
- ,
- Object.defineProperty(t.prototype, "receiveShadows", {
- get: function() {
- return this._sourceMesh.receiveShadows
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "material", {
- get: function() {
- return this._sourceMesh.material
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "visibility", {
- get: function() {
- return this._sourceMesh.visibility
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "skeleton", {
- get: function() {
- return this._sourceMesh.skeleton
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "renderingGroupId", {
- get: function() {
- return this._sourceMesh.renderingGroupId
- },
- set: function(e) {
- this._sourceMesh && e !== this._sourceMesh.renderingGroupId && K.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getTotalVertices = function() {
- return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0
- }
- ,
- t.prototype.getTotalIndices = function() {
- return this._sourceMesh.getTotalIndices()
- }
- ,
- Object.defineProperty(t.prototype, "sourceMesh", {
- get: function() {
- return this._sourceMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.createInstance = function(e) {
- return this._sourceMesh.createInstance(e)
- }
- ,
- t.prototype.isReady = function(e) {
- return void 0 === e && (e = !1),
- this._sourceMesh.isReady(e, !0)
- }
- ,
- t.prototype.getVerticesData = function(e, t) {
- return this._sourceMesh.getVerticesData(e, t)
- }
- ,
- t.prototype.setVerticesData = function(e, t, i, n) {
- return this.sourceMesh && this.sourceMesh.setVerticesData(e, t, i, n),
- this.sourceMesh
- }
- ,
- t.prototype.updateVerticesData = function(e, t, i, n) {
- return this.sourceMesh && this.sourceMesh.updateVerticesData(e, t, i, n),
- this.sourceMesh
- }
- ,
- t.prototype.setIndices = function(e, t) {
- return void 0 === t && (t = null),
- this.sourceMesh && this.sourceMesh.setIndices(e, t),
- this.sourceMesh
- }
- ,
- t.prototype.isVerticesDataPresent = function(e) {
- return this._sourceMesh.isVerticesDataPresent(e)
- }
- ,
- t.prototype.getIndices = function() {
- return this._sourceMesh.getIndices()
- }
- ,
- Object.defineProperty(t.prototype, "_positions", {
- get: function() {
- return this._sourceMesh._positions
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.refreshBoundingInfo = function(e, t) {
- if (void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- this.hasBoundingInfo && this.getBoundingInfo().isLocked)
- return this;
- var i = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
- return this._refreshBoundingInfo(this._sourceMesh._getPositionData(e, t), i),
- this
- }
- ,
- t.prototype._preActivate = function() {
- return this._currentLOD && this._currentLOD._preActivate(),
- this
- }
- ,
- t.prototype._activate = function(e, t) {
- if (this._sourceMesh.subMeshes || K.Warn("Instances should only be created for meshes with geometry."),
- this._currentLOD) {
- if (this._currentLOD._getWorldMatrixDeterminant() >= 0 != this._getWorldMatrixDeterminant() >= 0)
- return this._internalAbstractMeshDataInfo._actAsRegularMesh = !0,
- !0;
- if (this._internalAbstractMeshDataInfo._actAsRegularMesh = !1,
- this._currentLOD._registerInstanceForRenderId(this, e),
- t) {
- 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
- }
- ,
- t.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)
- }
- ,
- t.prototype.getWorldMatrix = function() {
- if (this._currentLOD && this._currentLOD.billboardMode !== yr.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
- this._billboardWorldMatrix || (this._billboardWorldMatrix = new P);
- var t = this._currentLOD._masterMesh;
- return this._currentLOD._masterMesh = this,
- I.Vector3[7].copyFrom(this._currentLOD.position),
- this._currentLOD.position.set(0, 0, 0),
- this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),
- this._currentLOD.position.copyFrom(I.Vector3[7]),
- this._currentLOD._masterMesh = t,
- this._billboardWorldMatrix
- }
- return e.prototype.getWorldMatrix.call(this)
- }
- ,
- Object.defineProperty(t.prototype, "isAnInstance", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getLOD = function(e) {
- if (!e)
- return this;
- var t = this.sourceMesh.getLODLevels();
- if (t && 0 !== t.length) {
- var i = this.getBoundingInfo();
- this._currentLOD = this.sourceMesh.getLOD(e, i.boundingSphere)
- } else
- this._currentLOD = this.sourceMesh;
- return this._currentLOD
- }
- ,
- t.prototype._preActivateForIntermediateRendering = function(e) {
- return this.sourceMesh._preActivateForIntermediateRendering(e)
- }
- ,
- t.prototype._syncSubMeshes = function() {
- if (this.releaseSubMeshes(),
- this._sourceMesh.subMeshes)
- for (var e = 0; e < this._sourceMesh.subMeshes.length; e++)
- this._sourceMesh.subMeshes[e].clone(this, this._sourceMesh);
- return this
- }
- ,
- t.prototype._generatePointsArray = function() {
- return this._sourceMesh._generatePointsArray()
- }
- ,
- t.prototype._updateBoundingInfo = function() {
- return this.hasBoundingInfo ? this.getBoundingInfo().update(this.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, this.worldMatrixFromCache),
- this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),
- this
- }
- ,
- t.prototype.clone = function(e, t, i) {
- void 0 === t && (t = null);
- var n = this._sourceMesh.createInstance(e);
- if (fe.DeepCopy(this, n, ["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(),
- t && (n.parent = t),
- !i)
- for (var r = 0; r < this.getScene().meshes.length; r++) {
- var o = this.getScene().meshes[r];
- o.parent === this && o.clone(o.name, n)
- }
- return n.computeWorldMatrix(!0),
- this.onClonedObservable.notifyObservers(n),
- n
- }
- ,
- t.prototype.dispose = function(t, i) {
- void 0 === i && (i = !1),
- this._sourceMesh.removeInstance(this),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t
- }(Sr);
- Vr.prototype.edgesShareWithInstances = !1,
- Vr.prototype.registerInstancedBuffer = function(e, t) {
- var i, n;
- if (null === (n = null === (i = this._userInstancedBuffersStorage) || void 0 === i ? void 0 : i.vertexBuffers[e]) || void 0 === n || n.dispose(),
- !this.instancedBuffers) {
- this.instancedBuffers = {};
- for (var r = 0, o = this.instances; r < o.length; r++)
- o[r].instancedBuffers = {};
- this._userInstancedBuffersStorage = {
- data: {},
- vertexBuffers: {},
- strides: {},
- sizes: {},
- vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
- }
- }
- this.instancedBuffers[e] = null,
- this._userInstancedBuffersStorage.strides[e] = t,
- this._userInstancedBuffersStorage.sizes[e] = 32 * t,
- this._userInstancedBuffersStorage.data[e] = new Float32Array(this._userInstancedBuffersStorage.sizes[e]),
- this._userInstancedBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),this._userInstancedBuffersStorage.data[e],e,!0,!1,t,!0);
- for (var a = 0, s = this.instances; a < s.length; a++)
- s[a].instancedBuffers[e] = null;
- this._invalidateInstanceVertexArrayObject()
- }
- ,
- Vr.prototype._processInstancedBuffers = function(e, t) {
- var i = e.length;
- for (var n in this.instancedBuffers) {
- for (var r = this._userInstancedBuffersStorage.sizes[n], o = this._userInstancedBuffersStorage.strides[n], a = (i + 1) * o; r < a; )
- r *= 2;
- this._userInstancedBuffersStorage.data[n].length != r && (this._userInstancedBuffersStorage.data[n] = new Float32Array(r),
- this._userInstancedBuffersStorage.sizes[n] = r,
- this._userInstancedBuffersStorage.vertexBuffers[n] && (this._userInstancedBuffersStorage.vertexBuffers[n].dispose(),
- this._userInstancedBuffersStorage.vertexBuffers[n] = null));
- var s = this._userInstancedBuffersStorage.data[n]
- , l = 0;
- t && ((u = this.instancedBuffers[n]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
- l += o);
- for (var c = 0; c < i; c++) {
- var u;
- (u = e[c].instancedBuffers[n]).toArray ? u.toArray(s, l) : u.copyToArray ? u.copyToArray(s, l) : s[l] = u,
- l += o
- }
- this._userInstancedBuffersStorage.vertexBuffers[n] ? this._userInstancedBuffersStorage.vertexBuffers[n].updateDirectly(s, 0) : (this._userInstancedBuffersStorage.vertexBuffers[n] = new Bi(this.getEngine(),this._userInstancedBuffersStorage.data[n],n,!0,!1,o,!0),
- this._invalidateInstanceVertexArrayObject())
- }
- }
- ,
- Vr.prototype._invalidateInstanceVertexArrayObject = function() {
- if (this._userInstancedBuffersStorage && void 0 !== this._userInstancedBuffersStorage.vertexArrayObjects) {
- for (var e in this._userInstancedBuffersStorage.vertexArrayObjects)
- this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[e]);
- this._userInstancedBuffersStorage.vertexArrayObjects = {}
- }
- }
- ,
- Vr.prototype._disposeInstanceSpecificData = function() {
- for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(),
- this._instanceDataStorage.instancesBuffer = null); this.instances.length; )
- this.instances[0].dispose();
- for (var e in this.instancedBuffers)
- this._userInstancedBuffersStorage.vertexBuffers[e] && this._userInstancedBuffersStorage.vertexBuffers[e].dispose();
- this._invalidateInstanceVertexArrayObject(),
- this.instancedBuffers = {}
- }
- ;
- var Xl = {
- effect: null,
- subMesh: null
- }
- , jl = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = {}),
- void 0 === o && (o = !0);
- var a = e.call(this, t, i, o) || this;
- return a._textures = {},
- a._textureArrays = {},
- a._externalTextures = {},
- a._floats = {},
- a._ints = {},
- a._floatsArrays = {},
- a._colors3 = {},
- a._colors3Arrays = {},
- a._colors4 = {},
- a._colors4Arrays = {},
- a._vectors2 = {},
- a._vectors3 = {},
- a._vectors4 = {},
- a._matrices = {},
- a._matrixArrays = {},
- a._matrices3x3 = {},
- a._matrices2x2 = {},
- a._vectors2Arrays = {},
- a._vectors3Arrays = {},
- a._vectors4Arrays = {},
- a._uniformBuffers = {},
- a._textureSamplers = {},
- a._storageBuffers = {},
- a._cachedWorldViewMatrix = new P,
- a._cachedWorldViewProjectionMatrix = new P,
- a._multiview = !1,
- a._shaderPath = n,
- a._options = V({
- needAlphaBlending: !1,
- needAlphaTesting: !1,
- attributes: ["position", "normal", "uv"],
- uniforms: ["worldViewProjection"],
- uniformBuffers: [],
- samplers: [],
- externalTextures: [],
- samplerObjects: [],
- storageBuffers: [],
- defines: [],
- useClipPlane: !1
- }, r),
- a
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "shaderPath", {
- get: function() {
- return this._shaderPath
- },
- set: function(e) {
- this._shaderPath = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "options", {
- get: function() {
- return this._options
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "ShaderMaterial"
- }
- ,
- t.prototype.needAlphaBlending = function() {
- return this.alpha < 1 || this._options.needAlphaBlending
- }
- ,
- t.prototype.needAlphaTesting = function() {
- return this._options.needAlphaTesting
- }
- ,
- t.prototype._checkUniform = function(e) {
- -1 === this._options.uniforms.indexOf(e) && this._options.uniforms.push(e)
- }
- ,
- t.prototype.setTexture = function(e, t) {
- return -1 === this._options.samplers.indexOf(e) && this._options.samplers.push(e),
- this._textures[e] = t,
- this
- }
- ,
- t.prototype.setTextureArray = function(e, t) {
- return -1 === this._options.samplers.indexOf(e) && this._options.samplers.push(e),
- this._checkUniform(e),
- this._textureArrays[e] = t,
- this
- }
- ,
- t.prototype.setExternalTexture = function(e, t) {
- return -1 === this._options.externalTextures.indexOf(e) && this._options.externalTextures.push(e),
- this._externalTextures[e] = t,
- this
- }
- ,
- t.prototype.setFloat = function(e, t) {
- return this._checkUniform(e),
- this._floats[e] = t,
- this
- }
- ,
- t.prototype.setInt = function(e, t) {
- return this._checkUniform(e),
- this._ints[e] = t,
- this
- }
- ,
- t.prototype.setFloats = function(e, t) {
- return this._checkUniform(e),
- this._floatsArrays[e] = t,
- this
- }
- ,
- t.prototype.setColor3 = function(e, t) {
- return this._checkUniform(e),
- this._colors3[e] = t,
- this
- }
- ,
- t.prototype.setColor3Array = function(e, t) {
- return this._checkUniform(e),
- this._colors3Arrays[e] = t.reduce((function(e, t) {
- return t.toArray(e, e.length),
- e
- }
- ), []),
- this
- }
- ,
- t.prototype.setColor4 = function(e, t) {
- return this._checkUniform(e),
- this._colors4[e] = t,
- this
- }
- ,
- t.prototype.setColor4Array = function(e, t) {
- return this._checkUniform(e),
- this._colors4Arrays[e] = t.reduce((function(e, t) {
- return t.toArray(e, e.length),
- e
- }
- ), []),
- this
- }
- ,
- t.prototype.setVector2 = function(e, t) {
- return this._checkUniform(e),
- this._vectors2[e] = t,
- this
- }
- ,
- t.prototype.setVector3 = function(e, t) {
- return this._checkUniform(e),
- this._vectors3[e] = t,
- this
- }
- ,
- t.prototype.setVector4 = function(e, t) {
- return this._checkUniform(e),
- this._vectors4[e] = t,
- this
- }
- ,
- t.prototype.setMatrix = function(e, t) {
- return this._checkUniform(e),
- this._matrices[e] = t,
- this
- }
- ,
- t.prototype.setMatrices = function(e, t) {
- this._checkUniform(e);
- for (var i = new Float32Array(16 * t.length), n = 0; n < t.length; n++)
- t[n].copyToArray(i, 16 * n);
- return this._matrixArrays[e] = i,
- this
- }
- ,
- t.prototype.setMatrix3x3 = function(e, t) {
- return this._checkUniform(e),
- this._matrices3x3[e] = t,
- this
- }
- ,
- t.prototype.setMatrix2x2 = function(e, t) {
- return this._checkUniform(e),
- this._matrices2x2[e] = t,
- this
- }
- ,
- t.prototype.setArray2 = function(e, t) {
- return this._checkUniform(e),
- this._vectors2Arrays[e] = t,
- this
- }
- ,
- t.prototype.setArray3 = function(e, t) {
- return this._checkUniform(e),
- this._vectors3Arrays[e] = t,
- this
- }
- ,
- t.prototype.setArray4 = function(e, t) {
- return this._checkUniform(e),
- this._vectors4Arrays[e] = t,
- this
- }
- ,
- t.prototype.setUniformBuffer = function(e, t) {
- return -1 === this._options.uniformBuffers.indexOf(e) && this._options.uniformBuffers.push(e),
- this._uniformBuffers[e] = t,
- this
- }
- ,
- t.prototype.setTextureSampler = function(e, t) {
- return -1 === this._options.samplerObjects.indexOf(e) && this._options.samplerObjects.push(e),
- this._textureSamplers[e] = t,
- this
- }
- ,
- t.prototype.setStorageBuffer = function(e, t) {
- return -1 === this._options.storageBuffers.indexOf(e) && this._options.storageBuffers.push(e),
- this._storageBuffers[e] = t,
- this
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- return this.isReady(e, i, t)
- }
- ,
- t.prototype.isReady = function(e, t, i) {
- var n, r, o, a, s = i && this._storeEffectOnSubMeshes;
- if (this.isFrozen)
- if (s) {
- if (i.effect && i.effect._wasPreviouslyReady)
- return !0
- } else {
- var l = this._drawWrapper.effect;
- if (l && l._wasPreviouslyReady && this._effectUsesInstances === t)
- return !0
- }
- var c = this.getScene()
- , u = c.getEngine()
- , h = []
- , d = []
- , p = new ys
- , f = this._shaderPath
- , _ = this._options.uniforms
- , m = this._options.uniformBuffers
- , g = this._options.samplers;
- u.getCaps().multiview && c.activeCamera && c.activeCamera.outputRenderTarget && c.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0,
- h.push("#define MULTIVIEW"),
- -1 !== this._options.uniforms.indexOf("viewProjection") && -1 === this._options.uniforms.indexOf("viewProjectionR") && this._options.uniforms.push("viewProjectionR"));
- for (var v = 0; v < this._options.defines.length; v++) {
- var y = 0 === this._options.defines[v].indexOf("#define") ? this._options.defines[v] : "#define ".concat(this._options.defines[v]);
- h.push(y)
- }
- for (v = 0; v < this._options.attributes.length; v++)
- d.push(this._options.attributes[v]);
- if (e && e.isVerticesDataPresent(Bi.ColorKind) && (d.push(Bi.ColorKind),
- h.push("#define VERTEXCOLOR")),
- t && (h.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(d),
- (null == e ? void 0 : e.hasThinInstances) && (h.push("#define THIN_INSTANCES"),
- e && e.isVerticesDataPresent(Bi.ColorInstanceKind) && (d.push(Bi.ColorInstanceKind),
- h.push("#define INSTANCESCOLOR")))),
- e && e.useBones && e.computeBonesUsingShaders && e.skeleton) {
- d.push(Bi.MatricesIndicesKind),
- d.push(Bi.MatricesWeightsKind),
- e.numBoneInfluencers > 4 && (d.push(Bi.MatricesIndicesExtraKind),
- d.push(Bi.MatricesWeightsExtraKind));
- var b = e.skeleton;
- h.push("#define NUM_BONE_INFLUENCERS " + e.numBoneInfluencers),
- p.addCPUSkinningFallback(0, e),
- b.isUsingTextureForMatrices ? (h.push("#define BONETEXTURE"),
- -1 === this._options.uniforms.indexOf("boneTextureWidth") && this._options.uniforms.push("boneTextureWidth"),
- -1 === this._options.samplers.indexOf("boneSampler") && this._options.samplers.push("boneSampler")) : (h.push("#define BonesPerMesh " + (b.bones.length + 1)),
- -1 === this._options.uniforms.indexOf("mBones") && this._options.uniforms.push("mBones"))
- } else
- h.push("#define NUM_BONE_INFLUENCERS 0");
- var T = 0
- , E = e ? e.morphTargetManager : null;
- if (E) {
- var S = E.supportsUVs && -1 !== h.indexOf("#define UV1")
- , A = E.supportsTangents && -1 !== h.indexOf("#define TANGENT")
- , x = E.supportsNormals && -1 !== h.indexOf("#define NORMAL");
- for (T = E.numInfluencers,
- S && h.push("#define MORPHTARGETS_UV"),
- A && h.push("#define MORPHTARGETS_TANGENT"),
- x && h.push("#define MORPHTARGETS_NORMAL"),
- T > 0 && h.push("#define MORPHTARGETS"),
- E.isUsingTextureForTargets && (h.push("#define MORPHTARGETS_TEXTURE"),
- -1 === this._options.uniforms.indexOf("morphTargetTextureIndices") && this._options.uniforms.push("morphTargetTextureIndices"),
- -1 === this._options.samplers.indexOf("morphTargets") && this._options.samplers.push("morphTargets")),
- h.push("#define NUM_MORPH_INFLUENCERS " + T),
- v = 0; v < T; v++)
- d.push(Bi.PositionKind + v),
- x && d.push(Bi.NormalKind + v),
- A && d.push(Bi.TangentKind + v),
- S && d.push(Bi.UVKind + "_" + v);
- T > 0 && ((_ = _.slice()).push("morphTargetInfluences"),
- _.push("morphTargetTextureInfo"),
- _.push("morphTargetTextureIndices"))
- } else
- h.push("#define NUM_MORPH_INFLUENCERS 0");
- if (e) {
- var R = e.bakedVertexAnimationManager;
- R && R.isEnabled && (h.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),
- -1 === this._options.uniforms.indexOf("bakedVertexAnimationSettings") && this._options.uniforms.push("bakedVertexAnimationSettings"),
- -1 === this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted") && this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),
- -1 === this._options.uniforms.indexOf("bakedVertexAnimationTime") && this._options.uniforms.push("bakedVertexAnimationTime"),
- -1 === this._options.samplers.indexOf("bakedVertexAnimationTexture") && this._options.samplers.push("bakedVertexAnimationTexture")),
- Mr.PrepareAttributesForBakedVertexAnimation(d, e, h)
- }
- for (var C in this._textures)
- if (!this._textures[C].isReady())
- return !1;
- e && this._shouldTurnAlphaTestOn(e) && h.push("#define ALPHATEST"),
- (null === this._options.useClipPlane && c.clipPlane || this._options.useClipPlane) && (h.push("#define CLIPPLANE"),
- -1 === _.indexOf("vClipPlane") && _.push("vClipPlane")),
- (null === this._options.useClipPlane && c.clipPlane2 || this._options.useClipPlane) && (h.push("#define CLIPPLANE2"),
- -1 === _.indexOf("vClipPlane2") && _.push("vClipPlane2")),
- (null === this._options.useClipPlane && c.clipPlane3 || this._options.useClipPlane) && (h.push("#define CLIPPLANE3"),
- -1 === _.indexOf("vClipPlane3") && _.push("vClipPlane3")),
- (null === this._options.useClipPlane && c.clipPlane4 || this._options.useClipPlane) && (h.push("#define CLIPPLANE4"),
- -1 === _.indexOf("vClipPlane4") && _.push("vClipPlane4")),
- (null === this._options.useClipPlane && c.clipPlane5 || this._options.useClipPlane) && (h.push("#define CLIPPLANE5"),
- -1 === _.indexOf("vClipPlane5") && _.push("vClipPlane5")),
- (null === this._options.useClipPlane && c.clipPlane6 || this._options.useClipPlane) && (h.push("#define CLIPPLANE6"),
- -1 === _.indexOf("vClipPlane6") && _.push("vClipPlane6")),
- this.customShaderNameResolve && (_ = _.slice(),
- m = m.slice(),
- g = g.slice(),
- f = this.customShaderNameResolve(f, _, m, g, h, d));
- var P = s ? i._getDrawWrapper() : this._drawWrapper
- , M = null !== (n = null == P ? void 0 : P.effect) && void 0 !== n ? n : null
- , I = null !== (r = null == P ? void 0 : P.defines) && void 0 !== r ? r : null
- , O = h.join("\n")
- , D = M;
- return I !== O && (D = u.createEffect(f, {
- attributes: d,
- uniformsNames: _,
- uniformBuffersNames: m,
- samplers: g,
- defines: O,
- fallbacks: p,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousMorphTargets: T
- },
- shaderLanguage: this._options.shaderLanguage
- }, u),
- s ? i.setEffect(D, O, this._materialContext) : P && P.setEffect(D, O),
- this._onEffectCreatedObservable && (Xl.effect = D,
- Xl.subMesh = null !== (o = null != i ? i : null == e ? void 0 : e.subMeshes[0]) && void 0 !== o ? o : null,
- this._onEffectCreatedObservable.notifyObservers(Xl))),
- this._effectUsesInstances = !!t,
- null !== (a = !(null == D ? void 0 : D.isReady())) && void 0 !== a && !a && (M !== D && c.resetCachedMaterial(),
- D._wasPreviouslyReady = !0,
- !0)
- }
- ,
- t.prototype.bindOnlyWorldMatrix = function(e, t) {
- var i = this.getScene()
- , n = null != t ? t : this.getEffect();
- n && (-1 !== this._options.uniforms.indexOf("world") && n.setMatrix("world", e),
- -1 !== this._options.uniforms.indexOf("worldView") && (e.multiplyToRef(i.getViewMatrix(), this._cachedWorldViewMatrix),
- n.setMatrix("worldView", this._cachedWorldViewMatrix)),
- -1 !== this._options.uniforms.indexOf("worldViewProjection") && (e.multiplyToRef(i.getTransformMatrix(), this._cachedWorldViewProjectionMatrix),
- n.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)))
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i) {
- var n;
- this.bind(e, t, null === (n = i._drawWrapperOverride) || void 0 === n ? void 0 : n.effect, i)
- }
- ,
- t.prototype.bind = function(e, t, i, n) {
- var r, o = n && this._storeEffectOnSubMeshes, a = null != i ? i : o ? n.effect : this.getEffect();
- if (a) {
- this._activeEffect = a,
- this.bindOnlyWorldMatrix(e, i);
- var s = this._options.uniformBuffers
- , l = !1;
- if (a && s && s.length > 0 && this.getScene().getEngine().supportsUniformBuffers)
- for (var c = 0; c < s.length; ++c)
- switch (s[c]) {
- case "Mesh":
- t && (t.getMeshUniformBuffer().bindToEffect(a, "Mesh"),
- t.transferToEffect(e));
- break;
- case "Scene":
- Mr.BindSceneUniformBuffer(a, this.getScene().getSceneUniformBuffer()),
- this.getScene().finalizeSceneUbo(),
- l = !0
- }
- var u = t && o ? this._mustRebind(this.getScene(), a, t.visibility) : this.getScene().getCachedMaterial() !== this;
- if (a && u) {
- var h;
- for (h in l || -1 === this._options.uniforms.indexOf("view") || a.setMatrix("view", this.getScene().getViewMatrix()),
- l || -1 === this._options.uniforms.indexOf("projection") || a.setMatrix("projection", this.getScene().getProjectionMatrix()),
- l || -1 === this._options.uniforms.indexOf("viewProjection") || (a.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
- this._multiview && a.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)),
- this.getScene().activeCamera && -1 !== this._options.uniforms.indexOf("cameraPosition") && a.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition),
- Mr.BindBonesParameters(t, a),
- Mr.BindClipPlane(a, this.getScene()),
- this._textures)
- a.setTexture(h, this._textures[h]);
- for (h in this._textureArrays)
- a.setTextureArray(h, this._textureArrays[h]);
- for (h in this._externalTextures)
- a.setExternalTexture(h, this._externalTextures[h]);
- for (h in this._ints)
- a.setInt(h, this._ints[h]);
- for (h in this._floats)
- a.setFloat(h, this._floats[h]);
- for (h in this._floatsArrays)
- a.setArray(h, this._floatsArrays[h]);
- for (h in this._colors3)
- a.setColor3(h, this._colors3[h]);
- for (h in this._colors3Arrays)
- a.setArray3(h, this._colors3Arrays[h]);
- for (h in this._colors4) {
- var d = this._colors4[h];
- a.setFloat4(h, d.r, d.g, d.b, d.a)
- }
- for (h in this._colors4Arrays)
- a.setArray4(h, this._colors4Arrays[h]);
- for (h in this._vectors2)
- a.setVector2(h, this._vectors2[h]);
- for (h in this._vectors3)
- a.setVector3(h, this._vectors3[h]);
- for (h in this._vectors4)
- a.setVector4(h, this._vectors4[h]);
- for (h in this._matrices)
- a.setMatrix(h, this._matrices[h]);
- for (h in this._matrixArrays)
- a.setMatrices(h, this._matrixArrays[h]);
- for (h in this._matrices3x3)
- a.setMatrix3x3(h, this._matrices3x3[h]);
- for (h in this._matrices2x2)
- a.setMatrix2x2(h, this._matrices2x2[h]);
- for (h in this._vectors2Arrays)
- a.setArray2(h, this._vectors2Arrays[h]);
- for (h in this._vectors3Arrays)
- a.setArray3(h, this._vectors3Arrays[h]);
- for (h in this._vectors4Arrays)
- a.setArray4(h, this._vectors4Arrays[h]);
- for (h in this._uniformBuffers) {
- var p = this._uniformBuffers[h].getBuffer();
- p && a.bindUniformBuffer(p, h)
- }
- for (h in this._textureSamplers)
- a.setTextureSampler(h, this._textureSamplers[h]);
- for (h in this._storageBuffers)
- a.setStorageBuffer(h, this._storageBuffers[h])
- }
- if (a && t && (u || !this.isFrozen)) {
- var f = t.morphTargetManager;
- f && f.numInfluencers > 0 && Mr.BindMorphTargetParameters(t, a);
- var _ = t.bakedVertexAnimationManager;
- _ && _.isEnabled && (null === (r = t.bakedVertexAnimationManager) || void 0 === r || r.bind(a, this._effectUsesInstances))
- }
- this._afterBind(t, a)
- }
- }
- ,
- t.prototype.getActiveTextures = function() {
- var t = e.prototype.getActiveTextures.call(this);
- for (var i in this._textures)
- t.push(this._textures[i]);
- for (var n in this._textureArrays)
- for (var r = this._textureArrays[n], o = 0; o < r.length; o++)
- t.push(r[o]);
- return t
- }
- ,
- t.prototype.hasTexture = function(t) {
- if (e.prototype.hasTexture.call(this, t))
- return !0;
- for (var i in this._textures)
- if (this._textures[i] === t)
- return !0;
- for (var n in this._textureArrays)
- for (var r = this._textureArrays[n], o = 0; o < r.length; o++)
- if (r[o] === t)
- return !0;
- return !1
- }
- ,
- t.prototype.clone = function(e) {
- var i = this
- , n = Ge.Clone((function() {
- return new t(e,i.getScene(),i._shaderPath,i._options,i._storeEffectOnSubMeshes)
- }
- ), this);
- for (var r in n.name = e,
- n.id = e,
- "object" == typeof n._shaderPath && (n._shaderPath = V({}, n._shaderPath)),
- this._options = V({}, this._options),
- Object.keys(this._options).forEach((function(e) {
- var t = i._options[e];
- Array.isArray(t) && (i._options[e] = t.slice(0))
- }
- )),
- this.stencil.copyTo(n.stencil),
- this._textures)
- n.setTexture(r, this._textures[r]);
- for (var r in this._textureArrays)
- n.setTextureArray(r, this._textureArrays[r]);
- for (var r in this._externalTextures)
- n.setExternalTexture(r, this._externalTextures[r]);
- for (var r in this._ints)
- n.setInt(r, this._ints[r]);
- for (var r in this._floats)
- n.setFloat(r, this._floats[r]);
- for (var r in this._floatsArrays)
- n.setFloats(r, this._floatsArrays[r]);
- for (var r in this._colors3)
- n.setColor3(r, this._colors3[r]);
- for (var r in this._colors3Arrays)
- n._colors3Arrays[r] = this._colors3Arrays[r];
- for (var r in this._colors4)
- n.setColor4(r, this._colors4[r]);
- for (var r in this._colors4Arrays)
- n._colors4Arrays[r] = this._colors4Arrays[r];
- for (var r in this._vectors2)
- n.setVector2(r, this._vectors2[r]);
- for (var r in this._vectors3)
- n.setVector3(r, this._vectors3[r]);
- for (var r in this._vectors4)
- n.setVector4(r, this._vectors4[r]);
- for (var r in this._matrices)
- n.setMatrix(r, this._matrices[r]);
- for (var r in this._matrixArrays)
- n._matrixArrays[r] = this._matrixArrays[r].slice();
- for (var r in this._matrices3x3)
- n.setMatrix3x3(r, this._matrices3x3[r]);
- for (var r in this._matrices2x2)
- n.setMatrix2x2(r, this._matrices2x2[r]);
- for (var r in this._vectors2Arrays)
- n.setArray2(r, this._vectors2Arrays[r]);
- for (var r in this._vectors3Arrays)
- n.setArray3(r, this._vectors3Arrays[r]);
- for (var r in this._vectors4Arrays)
- n.setArray4(r, this._vectors4Arrays[r]);
- for (var r in this._uniformBuffers)
- n.setUniformBuffer(r, this._uniformBuffers[r]);
- for (var r in this._textureSamplers)
- n.setTextureSampler(r, this._textureSamplers[r]);
- for (var r in this._storageBuffers)
- n.setStorageBuffer(r, this._storageBuffers[r]);
- return n
- }
- ,
- t.prototype.dispose = function(t, i, n) {
- if (i) {
- var r;
- for (r in this._textures)
- this._textures[r].dispose();
- for (r in this._textureArrays)
- for (var o = this._textureArrays[r], a = 0; a < o.length; a++)
- o[a].dispose()
- }
- this._textures = {},
- e.prototype.dispose.call(this, t, i, n)
- }
- ,
- t.prototype.serialize = function() {
- var e, t = Ge.Serialize(this);
- for (e in t.customType = "BABYLON.ShaderMaterial",
- t.options = this._options,
- t.shaderPath = this._shaderPath,
- t.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes,
- t.stencil = this.stencil.serialize(),
- t.textures = {},
- this._textures)
- t.textures[e] = this._textures[e].serialize();
- for (e in t.textureArrays = {},
- this._textureArrays) {
- t.textureArrays[e] = [];
- for (var i = this._textureArrays[e], n = 0; n < i.length; n++)
- t.textureArrays[e].push(i[n].serialize())
- }
- for (e in t.ints = {},
- this._ints)
- t.ints[e] = this._ints[e];
- for (e in t.floats = {},
- this._floats)
- t.floats[e] = this._floats[e];
- for (e in t.FloatArrays = {},
- this._floatsArrays)
- t.FloatArrays[e] = this._floatsArrays[e];
- for (e in t.colors3 = {},
- this._colors3)
- t.colors3[e] = this._colors3[e].asArray();
- for (e in t.colors3Arrays = {},
- this._colors3Arrays)
- t.colors3Arrays[e] = this._colors3Arrays[e];
- for (e in t.colors4 = {},
- this._colors4)
- t.colors4[e] = this._colors4[e].asArray();
- for (e in t.colors4Arrays = {},
- this._colors4Arrays)
- t.colors4Arrays[e] = this._colors4Arrays[e];
- for (e in t.vectors2 = {},
- this._vectors2)
- t.vectors2[e] = this._vectors2[e].asArray();
- for (e in t.vectors3 = {},
- this._vectors3)
- t.vectors3[e] = this._vectors3[e].asArray();
- for (e in t.vectors4 = {},
- this._vectors4)
- t.vectors4[e] = this._vectors4[e].asArray();
- for (e in t.matrices = {},
- this._matrices)
- t.matrices[e] = this._matrices[e].asArray();
- for (e in t.matrixArray = {},
- this._matrixArrays)
- t.matrixArray[e] = this._matrixArrays[e];
- for (e in t.matrices3x3 = {},
- this._matrices3x3)
- t.matrices3x3[e] = this._matrices3x3[e];
- for (e in t.matrices2x2 = {},
- this._matrices2x2)
- t.matrices2x2[e] = this._matrices2x2[e];
- for (e in t.vectors2Arrays = {},
- this._vectors2Arrays)
- t.vectors2Arrays[e] = this._vectors2Arrays[e];
- for (e in t.vectors3Arrays = {},
- this._vectors3Arrays)
- t.vectors3Arrays[e] = this._vectors3Arrays[e];
- for (e in t.vectors4Arrays = {},
- this._vectors4Arrays)
- t.vectors4Arrays[e] = this._vectors4Arrays[e];
- return t
- }
- ,
- t.Parse = function(e, i, n) {
- var r, o = Ge.Parse((function() {
- return new t(e.name,i,e.shaderPath,e.options,e.storeEffectOnSubMeshes)
- }
- ), e, i, n);
- for (r in e.stencil && o.stencil.parse(e.stencil, i, n),
- e.textures)
- o.setTexture(r, io.Parse(e.textures[r], i, n));
- for (r in e.textureArrays) {
- for (var a = e.textureArrays[r], s = new Array, l = 0; l < a.length; l++)
- s.push(io.Parse(a[l], i, n));
- o.setTextureArray(r, s)
- }
- for (r in e.ints)
- o.setInt(r, e.ints[r]);
- for (r in e.floats)
- o.setFloat(r, e.floats[r]);
- for (r in e.floatsArrays)
- o.setFloats(r, e.floatsArrays[r]);
- for (r in e.colors3)
- o.setColor3(r, D.FromArray(e.colors3[r]));
- for (r in e.colors3Arrays) {
- var c = e.colors3Arrays[r].reduce((function(e, t, i) {
- return i % 3 == 0 ? e.push([t]) : e[e.length - 1].push(t),
- e
- }
- ), []).map((function(e) {
- return D.FromArray(e)
- }
- ));
- o.setColor3Array(r, c)
- }
- for (r in e.colors4)
- o.setColor4(r, N.FromArray(e.colors4[r]));
- for (r in e.colors4Arrays)
- c = e.colors4Arrays[r].reduce((function(e, t, i) {
- return i % 4 == 0 ? e.push([t]) : e[e.length - 1].push(t),
- e
- }
- ), []).map((function(e) {
- return N.FromArray(e)
- }
- )),
- o.setColor4Array(r, c);
- for (r in e.vectors2)
- o.setVector2(r, A.FromArray(e.vectors2[r]));
- for (r in e.vectors3)
- o.setVector3(r, x.FromArray(e.vectors3[r]));
- for (r in e.vectors4)
- o.setVector4(r, R.FromArray(e.vectors4[r]));
- for (r in e.matrices)
- o.setMatrix(r, P.FromArray(e.matrices[r]));
- for (r in e.matrixArray)
- o._matrixArrays[r] = new Float32Array(e.matrixArray[r]);
- for (r in e.matrices3x3)
- o.setMatrix3x3(r, e.matrices3x3[r]);
- for (r in e.matrices2x2)
- o.setMatrix2x2(r, e.matrices2x2[r]);
- for (r in e.vectors2Arrays)
- o.setArray2(r, e.vectors2Arrays[r]);
- for (r in e.vectors3Arrays)
- o.setArray3(r, e.vectors3Arrays[r]);
- for (r in e.vectors4Arrays)
- o.setArray4(r, e.vectors4Arrays[r]);
- return o
- }
- ,
- t.ParseFromFileAsync = function(e, t, i, n) {
- var r = this;
- return void 0 === n && (n = ""),
- new Promise((function(o, a) {
- var s = new Ye;
- s.addEventListener("readystatechange", (function() {
- if (4 == s.readyState)
- if (200 == s.status) {
- var t = JSON.parse(s.responseText)
- , l = r.Parse(t, i || E.LastCreatedScene, n);
- e && (l.name = e),
- o(l)
- } else
- a("Unable to load the ShaderMaterial")
- }
- )),
- s.open("GET", t),
- s.send()
- }
- ))
- }
- ,
- t.CreateFromSnippetAsync = function(e, t, i) {
- var n = this;
- return void 0 === i && (i = ""),
- new Promise((function(r, o) {
- var a = new Ye;
- a.addEventListener("readystatechange", (function() {
- if (4 == a.readyState)
- if (200 == a.status) {
- var s = JSON.parse(JSON.parse(a.responseText).jsonPayload)
- , l = JSON.parse(s.shaderMaterial)
- , c = n.Parse(l, t || E.LastCreatedScene, i);
- c.snippetId = e,
- r(c)
- } else
- o("Unable to load the snippet " + e)
- }
- )),
- a.open("GET", n.SnippetUrl + "/" + e.replace(/#/g, "/")),
- a.send()
- }
- ))
- }
- ,
- t.SnippetUrl = "https://snippet.babylonjs.com",
- t
- }(gs);
- y("BABYLON.ShaderMaterial", jl);
- Pt.ShadersStore.colorPixelShader = "#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.colorVertexShader = "attribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}",
- Vr._LinesMeshParser = function(e, t) {
- return Yl.Parse(e, t)
- }
- ;
- var Yl = function(e) {
- function t(t, i, n, r, o, a, s, l) {
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- void 0 === r && (r = null);
- var c = e.call(this, t, i, n, r, o) || this;
- c.useVertexColor = a,
- c.useVertexAlpha = s,
- c.color = new D(1,1,1),
- c.alpha = 1,
- r && (c.color = r.color.clone(),
- c.alpha = r.alpha,
- c.useVertexColor = r.useVertexColor,
- c.useVertexAlpha = r.useVertexAlpha),
- c.intersectionThreshold = .1;
- var u = {
- attributes: [Bi.PositionKind],
- uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
- needAlphaBlending: !0,
- defines: [],
- useClipPlane: null
- };
- return !1 === s && (u.needAlphaBlending = !1),
- a ? (u.defines.push("#define VERTEXCOLOR"),
- u.attributes.push(Bi.ColorKind)) : (u.uniforms.push("color"),
- c._color4 = new N),
- c.material = l || new jl("colorShader",c.getScene(),"color",u,!1),
- c
- }
- return U(t, e),
- t.prototype._isShaderMaterial = function(e) {
- return "ShaderMaterial" === e.getClassName()
- }
- ,
- t.prototype.isReady = function() {
- return !!this._lineMaterial.isReady(this, !!this._userInstancedBuffersStorage) && e.prototype.isReady.call(this)
- }
- ,
- t.prototype.getClassName = function() {
- return "LinesMesh"
- }
- ,
- Object.defineProperty(t.prototype, "material", {
- get: function() {
- return this._lineMaterial
- },
- set: function(e) {
- this._lineMaterial = e,
- this._lineMaterial.fillMode = Or.LineListDrawMode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "checkCollisions", {
- get: function() {
- return !1
- },
- set: function(e) {},
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._bind = function() {
- if (!this._geometry)
- return this;
- var e = this._lineMaterial.getEffect()
- , t = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
- if (this._userInstancedBuffersStorage ? this._geometry._bind(e, t, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(e, t),
- !this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
- var i = this.color
- , n = i.r
- , r = i.g
- , o = i.b;
- this._color4.set(n, r, o, this.alpha),
- this._lineMaterial.setColor4("color", this._color4)
- }
- return this
- }
- ,
- t.prototype._draw = function(e, t, i) {
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
- return this;
- var n = this.getScene().getEngine();
- return this._unIndexed ? n.drawArraysType(Or.LineListDrawMode, e.verticesStart, e.verticesCount, i) : n.drawElementsType(Or.LineListDrawMode, e.indexStart, e.indexCount, i),
- this
- }
- ,
- t.prototype.dispose = function(t) {
- this._lineMaterial.dispose(!1, !1, !0),
- e.prototype.dispose.call(this, t)
- }
- ,
- t.prototype.clone = function(e, i, n) {
- return void 0 === i && (i = null),
- new t(e,this.getScene(),i,this,n)
- }
- ,
- t.prototype.createInstance = function(e) {
- var t = new Kl(e,this);
- if (this.instancedBuffers)
- for (var i in t.instancedBuffers = {},
- this.instancedBuffers)
- t.instancedBuffers[i] = this.instancedBuffers[i];
- return t
- }
- ,
- t.prototype.serialize = function(t) {
- e.prototype.serialize.call(this, t),
- t.color = this.color.asArray(),
- t.alpha = this.alpha
- }
- ,
- t.Parse = function(e, i) {
- var n = new t(e.name,i);
- return n.color = D.FromArray(e.color),
- n.alpha = e.alpha,
- n
- }
- ,
- t
- }(Vr)
- , Kl = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n.intersectionThreshold = i.intersectionThreshold,
- n
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "InstancedLinesMesh"
- }
- ,
- t
- }(Hl);
- function Ql(e) {
- for (var t = [], i = [], n = e.lines, r = e.colors, o = [], a = 0, s = 0; s < n.length; s++)
- for (var l = n[s], c = 0; c < l.length; c++) {
- if (i.push(l[c].x, l[c].y, l[c].z),
- r) {
- var u = r[s];
- o.push(u[c].r, u[c].g, u[c].b, u[c].a)
- }
- c > 0 && (t.push(a - 1),
- t.push(a)),
- a++
- }
- var h = new $n;
- return h.indices = t,
- h.positions = i,
- r && (h.colors = o),
- h
- }
- function ql(e) {
- var t, i, n = e.dashSize || 3, r = e.gapSize || 1, o = e.dashNb || 200, a = e.points, s = new Array, l = new Array, c = x.Zero(), u = 0, h = 0, d = 0, p = 0, f = 0;
- for (f = 0; f < a.length - 1; f++)
- a[f + 1].subtractToRef(a[f], c),
- u += c.length();
- for (i = n * (t = u / o) / (n + r),
- f = 0; f < a.length - 1; f++) {
- a[f + 1].subtractToRef(a[f], c),
- h = Math.floor(c.length() / t),
- c.normalize();
- for (var _ = 0; _ < h; _++)
- d = t * _,
- s.push(a[f].x + d * c.x, a[f].y + d * c.y, a[f].z + d * c.z),
- s.push(a[f].x + (d + i) * c.x, a[f].y + (d + i) * c.y, a[f].z + (d + i) * c.z),
- l.push(p, p + 1),
- p += 2
- }
- var m = new $n;
- return m.positions = s,
- m.indices = l,
- m
- }
- function Zl(e, t, i) {
- var n = t.instance
- , r = t.lines
- , o = t.colors;
- if (n) {
- var a = n.getVerticesData(Bi.PositionKind)
- , s = void 0
- , l = void 0;
- o && (s = n.getVerticesData(Bi.ColorKind));
- for (var c = 0, u = 0, h = 0; h < r.length; h++)
- for (var d = r[h], p = 0; p < d.length; p++)
- a[c] = d[p].x,
- a[c + 1] = d[p].y,
- a[c + 2] = d[p].z,
- o && s && (l = o[h],
- s[u] = l[p].r,
- s[u + 1] = l[p].g,
- s[u + 2] = l[p].b,
- s[u + 3] = l[p].a,
- u += 4),
- c += 3;
- return n.updateVerticesData(Bi.PositionKind, a, !1, !1),
- o && s && n.updateVerticesData(Bi.ColorKind, s, !1, !1),
- n
- }
- var f = new Yl(e,i,null,void 0,void 0,!!o,t.useVertexAlpha,t.material);
- return Ql(t).applyToMesh(f, t.updatable),
- f
- }
- function Jl(e, t, i) {
- void 0 === i && (i = null);
- var n = t.colors ? [t.colors] : null;
- return Zl(e, {
- lines: [t.points],
- updatable: t.updatable,
- instance: t.instance,
- colors: n,
- useVertexAlpha: t.useVertexAlpha,
- material: t.material
- }, i)
- }
- function $l(e, t, i) {
- void 0 === i && (i = null);
- var n = t.points
- , r = t.instance
- , o = t.gapSize || 1
- , a = t.dashSize || 3;
- if (r)
- return r.updateMeshPositions((function(e) {
- var t, i, o = x.Zero(), a = e.length / 6, s = 0, l = 0, c = 0, u = 0, h = 0, d = 0;
- for (h = 0; h < n.length - 1; h++)
- n[h + 1].subtractToRef(n[h], o),
- s += o.length();
- t = s / a;
- var p = r._creationDataStorage.dashSize;
- for (i = p * t / (p + r._creationDataStorage.gapSize),
- h = 0; h < n.length - 1; h++)
- for (n[h + 1].subtractToRef(n[h], o),
- l = Math.floor(o.length() / t),
- o.normalize(),
- d = 0; d < l && u < e.length; )
- c = t * d,
- e[u] = n[h].x + c * o.x,
- e[u + 1] = n[h].y + c * o.y,
- e[u + 2] = n[h].z + c * o.z,
- e[u + 3] = n[h].x + (c + i) * o.x,
- e[u + 4] = n[h].y + (c + i) * o.y,
- e[u + 5] = n[h].z + (c + i) * o.z,
- u += 6,
- d++;
- for (; u < e.length; )
- e[u] = n[h].x,
- e[u + 1] = n[h].y,
- e[u + 2] = n[h].z,
- u += 3
- }
- ), !1),
- r;
- var s = new Yl(e,i,null,void 0,void 0,void 0,t.useVertexAlpha,t.material);
- return ql(t).applyToMesh(s, t.updatable),
- s._creationDataStorage = new Lr,
- s._creationDataStorage.dashSize = a,
- s._creationDataStorage.gapSize = o,
- s
- }
- var ec = {
- CreateDashedLines: $l,
- CreateLineSystem: Zl,
- CreateLines: Jl
- };
- $n.CreateLineSystem = Ql,
- $n.CreateDashedLines = ql,
- Vr.CreateLines = function(e, t, i, n, r) {
- return void 0 === i && (i = null),
- void 0 === n && (n = !1),
- void 0 === r && (r = null),
- Jl(e, {
- points: t,
- updatable: n,
- instance: r
- }, i)
- }
- ,
- Vr.CreateDashedLines = function(e, t, i, n, r, o, a, s) {
- return void 0 === o && (o = null),
- $l(e, {
- points: t,
- dashSize: i,
- gapSize: n,
- dashNb: r,
- updatable: a,
- instance: s
- }, o)
- }
- ;
- var tc = function() {
- function e(e) {
- this.ray = e
- }
- return e.CreateAndShow = function(t, i, n) {
- var r = new e(t);
- return r.show(i, n),
- r
- }
- ,
- e.prototype.show = function(e, t) {
- if (!this._renderFunction && this.ray) {
- var i = this.ray;
- this._renderFunction = this._render.bind(this),
- this._scene = e,
- this._renderPoints = [i.origin, i.origin.add(i.direction.scale(i.length))],
- this._renderLine = Jl("ray", {
- points: this._renderPoints,
- updatable: !0
- }, e),
- this._renderLine.isPickable = !1,
- this._renderFunction && this._scene.registerBeforeRender(this._renderFunction)
- }
- t && this._renderLine && this._renderLine.color.copyFrom(t)
- }
- ,
- e.prototype.hide = function() {
- this._renderFunction && this._scene && (this._scene.unregisterBeforeRender(this._renderFunction),
- this._scene = null,
- this._renderFunction = null,
- this._renderLine && (this._renderLine.dispose(),
- this._renderLine = null),
- this._renderPoints = [])
- }
- ,
- e.prototype._render = function() {
- var e, t = this.ray;
- if (t) {
- var i = this._renderPoints[1]
- , n = Math.min(t.length, 1e6);
- i.copyFrom(t.direction),
- i.scaleInPlace(n),
- i.addInPlace(t.origin),
- this._renderPoints[0].copyFrom(t.origin),
- Jl("ray", {
- points: this._renderPoints,
- updatable: !0,
- instance: this._renderLine
- }, this._scene),
- null === (e = this._renderLine) || void 0 === e || e.refreshBoundingInfo()
- }
- }
- ,
- e.prototype.attachToMesh = function(e, t, i, n) {
- var r = this;
- this._attachedToMesh = e;
- var o = this.ray;
- o && (o.direction || (o.direction = x.Zero()),
- o.origin || (o.origin = x.Zero()),
- n && (o.length = n),
- i || (i = x.Zero()),
- t || (t = new x(0,0,-1)),
- this._scene || (this._scene = e.getScene()),
- this._meshSpaceDirection ? (this._meshSpaceDirection.copyFrom(t),
- this._meshSpaceOrigin.copyFrom(i)) : (this._meshSpaceDirection = t.clone(),
- this._meshSpaceOrigin = i.clone()),
- this._onAfterRenderObserver || (this._onAfterRenderObserver = this._scene.onBeforeRenderObservable.add((function() {
- return r._updateToMesh()
- }
- )),
- this._onAfterStepObserver = this._scene.onAfterStepObservable.add((function() {
- return r._updateToMesh()
- }
- ))),
- this._attachedToMesh.computeWorldMatrix(!0),
- this._updateToMesh())
- }
- ,
- e.prototype.detachFromMesh = function() {
- this._attachedToMesh && this._scene && (this._onAfterRenderObserver && (this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver),
- this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)),
- this._attachedToMesh = null,
- this._onAfterRenderObserver = null,
- this._onAfterStepObserver = null,
- this._scene = null)
- }
- ,
- e.prototype._updateToMesh = function() {
- var e = this.ray;
- this._attachedToMesh && e && (this._attachedToMesh.isDisposed() ? this.detachFromMesh() : (this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, e.direction),
- x.TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), e.origin)))
- }
- ,
- e.prototype.dispose = function() {
- this.hide(),
- this.detachFromMesh(),
- this.ray = null
- }
- ,
- e
- }();
- function ic(e) {
- var t = e.pathArray
- , i = e.closeArray || !1
- , n = e.closePath || !1
- , r = e.invertUV || !1
- , o = Math.floor(t[0].length / 2)
- , a = e.offset || o;
- a = a > o ? o : Math.floor(a);
- var s, l, c, u, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = e.uvs, p = e.colors, f = [], _ = [], m = [], g = [], v = [], y = [], b = [], T = [], E = [], S = [];
- if (t.length < 2) {
- var A = []
- , x = [];
- for (c = 0; c < t[0].length - a; c++)
- A.push(t[0][c]),
- x.push(t[0][c + a]);
- t = [A, x]
- }
- var R, C, P, M, I, O = 0, D = n ? 1 : 0;
- for (s = t[0].length,
- l = 0; l < t.length; l++) {
- for (b[l] = 0,
- v[l] = [0],
- s = s < (C = (R = t[l]).length) ? s : C,
- u = 0; u < C; )
- f.push(R[u].x, R[u].y, R[u].z),
- u > 0 && (P = R[u].subtract(R[u - 1]).length() + b[l],
- v[l].push(P),
- b[l] = P),
- u++;
- n && (u--,
- f.push(R[0].x, R[0].y, R[0].z),
- P = R[u].subtract(R[0]).length() + b[l],
- v[l].push(P),
- b[l] = P),
- E[l] = C + D,
- S[l] = O,
- O += C + D
- }
- var N, L, F = null, w = null;
- for (c = 0; c < s + D; c++) {
- for (T[c] = 0,
- y[c] = [0],
- l = 0; l < t.length - 1; l++)
- M = t[l],
- I = t[l + 1],
- c === s ? (F = M[0],
- w = I[0]) : (F = M[c],
- w = I[c]),
- P = w.subtract(F).length() + T[c],
- y[c].push(P),
- T[c] = P;
- i && w && F && (M = t[l],
- I = t[0],
- c === s && (w = I[0]),
- P = w.subtract(F).length() + T[c],
- T[c] = P)
- }
- if (d)
- for (l = 0; l < d.length; l++)
- g.push(d[l].x, pr.UseOpenGLOrientationForUV ? 1 - d[l].y : d[l].y);
- else
- for (l = 0; l < t.length; l++)
- for (c = 0; c < s + D; c++)
- N = 0 != b[l] ? v[l][c] / b[l] : 0,
- L = 0 != T[c] ? y[c][l] / T[c] : 0,
- r ? g.push(L, N) : g.push(N, pr.UseOpenGLOrientationForUV ? 1 - L : L);
- for (var B = 0, U = E[l = 0] - 1, V = E[l + 1] - 1, k = U < V ? U : V, G = S[1] - S[0], z = i ? E.length : E.length - 1; B <= k && l < z; )
- _.push(B, B + G, B + 1),
- _.push(B + G + 1, B + 1, B + G),
- (B += 1) === k && (++l == E.length - 1 ? (G = S[0] - S[l],
- U = E[l] - 1,
- V = E[0] - 1) : (G = S[l + 1] - S[l],
- U = E[l] - 1,
- V = E[l + 1] - 1),
- B = S[l],
- k = U < V ? U + B : V + B);
- if ($n.ComputeNormals(f, _, m),
- n) {
- var W = 0
- , H = 0;
- for (l = 0; l < t.length; l++)
- W = 3 * S[l],
- H = l + 1 < t.length ? 3 * (S[l + 1] - 1) : m.length - 3,
- m[W] = .5 * (m[W] + m[H]),
- m[W + 1] = .5 * (m[W + 1] + m[H + 1]),
- m[W + 2] = .5 * (m[W + 2] + m[H + 2]),
- m[H] = m[W],
- m[H + 1] = m[W + 1],
- m[H + 2] = m[W + 2]
- }
- $n._ComputeSides(h, f, _, m, g, e.frontUVs, e.backUVs);
- var X = null;
- if (p) {
- X = new Float32Array(4 * p.length);
- for (var j = 0; j < p.length; j++)
- X[4 * j] = p[j].r,
- X[4 * j + 1] = p[j].g,
- X[4 * j + 2] = p[j].b,
- X[4 * j + 3] = p[j].a
- }
- var Y = new $n
- , K = new Float32Array(f)
- , Q = new Float32Array(m)
- , q = new Float32Array(g);
- return Y.indices = _,
- Y.positions = K,
- Y.normals = Q,
- Y.uvs = q,
- X && Y.set(X, Bi.ColorKind),
- n && (Y._idx = S),
- Y
- }
- function nc(e, t, i) {
- void 0 === i && (i = null);
- var n = t.pathArray
- , r = t.closeArray
- , o = t.closePath
- , a = Vr._GetDefaultSideOrientation(t.sideOrientation)
- , s = t.instance
- , l = t.updatable;
- if (s) {
- var c = I.Vector3[0].setAll(Number.MAX_VALUE)
- , u = I.Vector3[1].setAll(-Number.MAX_VALUE)
- , h = s.getVerticesData(Bi.PositionKind);
- if (function(e) {
- for (var t = n[0].length, i = s, r = 0, o = i._originalBuilderSideOrientation === Vr.DOUBLESIDE ? 2 : 1, a = 1; a <= o; ++a)
- for (var l = 0; l < n.length; ++l) {
- var h = n[l]
- , d = h.length;
- t = t < d ? t : d;
- for (var p = 0; p < t; ++p) {
- var f = h[p];
- e[r] = f.x,
- e[r + 1] = f.y,
- e[r + 2] = f.z,
- c.minimizeInPlaceFromFloats(f.x, f.y, f.z),
- u.maximizeInPlaceFromFloats(f.x, f.y, f.z),
- r += 3
- }
- i._creationDataStorage && i._creationDataStorage.closePath && (f = h[0],
- e[r] = f.x,
- e[r + 1] = f.y,
- e[r + 2] = f.z,
- r += 3)
- }
- }(h),
- s.hasBoundingInfo ? s.getBoundingInfo().reConstruct(c, u, s._worldMatrix) : s.buildBoundingInfo(c, u, s._worldMatrix),
- s.updateVerticesData(Bi.PositionKind, h, !1, !1),
- t.colors) {
- for (var d = s.getVerticesData(Bi.ColorKind), p = 0, f = 0; p < t.colors.length; p++,
- f += 4) {
- var _ = t.colors[p];
- d[f] = _.r,
- d[f + 1] = _.g,
- d[f + 2] = _.b,
- d[f + 3] = _.a
- }
- s.updateVerticesData(Bi.ColorKind, d, !1, !1)
- }
- if (t.uvs) {
- for (var m = s.getVerticesData(Bi.UVKind), g = 0; g < t.uvs.length; g++)
- m[2 * g] = t.uvs[g].x,
- m[2 * g + 1] = pr.UseOpenGLOrientationForUV ? 1 - t.uvs[g].y : t.uvs[g].y;
- s.updateVerticesData(Bi.UVKind, m, !1, !1)
- }
- if (!s.areNormalsFrozen || s.isFacetDataEnabled) {
- var v = s.getIndices()
- , y = s.getVerticesData(Bi.NormalKind)
- , b = s.isFacetDataEnabled ? s.getFacetDataParameters() : null;
- if ($n.ComputeNormals(h, v, y, b),
- s._creationDataStorage && s._creationDataStorage.closePath)
- for (var T = 0, E = 0, S = 0; S < n.length; S++)
- T = 3 * s._creationDataStorage.idx[S],
- E = S + 1 < n.length ? 3 * (s._creationDataStorage.idx[S + 1] - 1) : y.length - 3,
- y[T] = .5 * (y[T] + y[E]),
- y[T + 1] = .5 * (y[T + 1] + y[E + 1]),
- y[T + 2] = .5 * (y[T + 2] + y[E + 2]),
- y[E] = y[T],
- y[E + 1] = y[T + 1],
- y[E + 2] = y[T + 2];
- s.areNormalsFrozen || s.updateVerticesData(Bi.NormalKind, y, !1, !1)
- }
- return s
- }
- var A = new Vr(e,i);
- A._originalBuilderSideOrientation = a,
- A._creationDataStorage = new Lr;
- var x = ic(t);
- return o && (A._creationDataStorage.idx = x._idx),
- A._creationDataStorage.closePath = o,
- A._creationDataStorage.closeArray = r,
- x.applyToMesh(A, l),
- A
- }
- var rc = {
- CreateRibbon: nc
- };
- function oc(e, t, i) {
- void 0 === i && (i = null);
- var n = t.path
- , r = t.shape
- , o = t.scale || 1
- , a = t.rotation || 0
- , s = 0 === t.cap ? 0 : t.cap || Vr.NO_CAP
- , l = t.updatable
- , c = Vr._GetDefaultSideOrientation(t.sideOrientation)
- , u = t.instance || null
- , h = t.invertUV || !1
- , d = t.closeShape || !1;
- return sc(e, r, n, o, a, null, null, t.closePath || !1, d, s, !1, i, !!l, c, u, h, t.frontUVs || null, t.backUVs || null)
- }
- function ac(e, t, i) {
- void 0 === i && (i = null);
- var n = t.path;
- return sc(e, t.shape, n, null, null, t.scaleFunction || function() {
- return 1
- }
- , t.rotationFunction || function() {
- return 0
- }
- , t.closePath || t.ribbonCloseArray || !1, t.closeShape || t.ribbonClosePath || !1, 0 === t.cap ? 0 : t.cap || Vr.NO_CAP, !0, i, !!t.updatable, Vr._GetDefaultSideOrientation(t.sideOrientation), t.instance || null, t.invertUV || !1, t.frontUVs || null, t.backUVs || null)
- }
- function sc(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g) {
- var v, y, b = function(e, t, i, n, r, o, a, s, l, c) {
- for (var u = i.getTangents(), h = i.getNormals(), d = i.getBinormals(), p = i.getDistances(), f = 0, _ = c && s ? s : function() {
- return null !== o ? o : 0
- }
- , m = c && a ? a : function() {
- return null !== r ? r : 1
- }
- , g = l === Vr.NO_CAP || l === Vr.CAP_END ? 0 : 2, v = I.Matrix[0], y = 0; y < t.length; y++) {
- for (var b = new Array, T = _(y, p[y]), E = m(y, p[y]), S = 0; S < e.length; S++) {
- P.RotationAxisToRef(u[y], f, v);
- var A = u[y].scale(e[S].z).add(h[y].scale(e[S].x)).add(d[y].scale(e[S].y))
- , R = b[S] ? b[S] : x.Zero();
- x.TransformCoordinatesToRef(A, v, R),
- R.scaleInPlace(E).addInPlace(t[y]),
- b[S] = R
- }
- n[g] = b,
- f += T,
- g++
- }
- var C = function(e) {
- var t, i = Array(), n = x.Zero();
- for (t = 0; t < e.length; t++)
- n.addInPlace(e[t]);
- for (n.scaleInPlace(1 / e.length),
- t = 0; t < e.length; t++)
- i.push(n);
- return i
- };
- switch (l) {
- case Vr.NO_CAP:
- break;
- case Vr.CAP_START:
- n[0] = C(n[2]),
- n[1] = n[2];
- break;
- case Vr.CAP_END:
- n[g] = n[g - 1],
- n[g + 1] = C(n[g - 1]);
- break;
- case Vr.CAP_ALL:
- n[0] = C(n[2]),
- n[1] = n[2],
- n[g] = n[g - 1],
- n[g + 1] = C(n[g - 1])
- }
- return n
- };
- if (f) {
- var T = f._creationDataStorage;
- return v = T.path3D.update(i),
- nc("", {
- pathArray: y = b(t, i, T.path3D, T.pathArray, n, r, o, a, T.cap, u),
- closeArray: !1,
- closePath: !1,
- offset: 0,
- updatable: !1,
- sideOrientation: 0,
- instance: f
- }, h || void 0)
- }
- c = c < 0 || c > 3 ? 0 : c;
- var E = nc(e, {
- pathArray: y = b(t, i, v = new Cn(i), new Array, n, r, o, a, c, u),
- closeArray: s,
- closePath: l,
- updatable: d,
- sideOrientation: p,
- invertUV: _,
- frontUVs: m || void 0,
- backUVs: g || void 0
- }, h);
- return E._creationDataStorage.pathArray = y,
- E._creationDataStorage.path3D = v,
- E._creationDataStorage.cap = c,
- E
- }
- $n.CreateRibbon = ic,
- Vr.CreateRibbon = function(e, t, i, n, r, o, a, s, l) {
- return void 0 === i && (i = !1),
- void 0 === a && (a = !1),
- nc(e, {
- pathArray: t,
- closeArray: i,
- closePath: n,
- offset: r,
- updatable: a,
- sideOrientation: s,
- instance: l
- }, o)
- }
- ;
- var lc = {
- ExtrudeShape: oc,
- ExtrudeShapeCustom: ac
- };
- Vr.ExtrudeShape = function(e, t, i, n, r, o, a, s, l, c) {
- return void 0 === a && (a = null),
- oc(e, {
- shape: t,
- path: i,
- scale: n,
- rotation: r,
- cap: 0 === o ? 0 : o || Vr.NO_CAP,
- sideOrientation: l,
- instance: c,
- updatable: s
- }, a)
- }
- ,
- Vr.ExtrudeShapeCustom = function(e, t, i, n, r, o, a, s, l, c, u, h) {
- return ac(e, {
- shape: t,
- path: i,
- scaleFunction: n,
- rotationFunction: r,
- ribbonCloseArray: o,
- ribbonClosePath: a,
- cap: 0 === s ? 0 : s || Vr.NO_CAP,
- sideOrientation: u,
- instance: h,
- updatable: c
- }, l)
- }
- ;
- var cc = function() {
- function e(t, i, n, r, o, a) {
- var s, l, c, u, h, d, p, f, _, m, g, v, y, b;
- void 0 === r && (r = !0),
- void 0 === o && (o = 3),
- void 0 === a && (a = {}),
- this.skeleton = t,
- this.mesh = i,
- this.autoUpdateBonesMatrices = r,
- this.renderingGroupId = o,
- this.options = a,
- this.color = D.White(),
- this._debugLines = new Array,
- this._localAxes = null,
- this._isEnabled = !0,
- this._obs = null,
- this._scene = n,
- this._ready = !1,
- a.pauseAnimations = null === (s = a.pauseAnimations) || void 0 === s || s,
- a.returnToRest = null !== (l = a.returnToRest) && void 0 !== l && l,
- a.displayMode = null !== (c = a.displayMode) && void 0 !== c ? c : e.DISPLAY_LINES,
- a.displayOptions = null !== (u = a.displayOptions) && void 0 !== u ? u : {},
- a.displayOptions.midStep = null !== (h = a.displayOptions.midStep) && void 0 !== h ? h : .235,
- a.displayOptions.midStepFactor = null !== (d = a.displayOptions.midStepFactor) && void 0 !== d ? d : .155,
- a.displayOptions.sphereBaseSize = null !== (p = a.displayOptions.sphereBaseSize) && void 0 !== p ? p : .15,
- a.displayOptions.sphereScaleUnit = null !== (f = a.displayOptions.sphereScaleUnit) && void 0 !== f ? f : 2,
- a.displayOptions.sphereFactor = null !== (_ = a.displayOptions.sphereFactor) && void 0 !== _ ? _ : .865,
- a.displayOptions.spurFollowsChild = null !== (m = a.displayOptions.spurFollowsChild) && void 0 !== m && m,
- a.displayOptions.showLocalAxes = null !== (g = a.displayOptions.showLocalAxes) && void 0 !== g && g,
- a.displayOptions.localAxesSize = null !== (v = a.displayOptions.localAxesSize) && void 0 !== v ? v : .075,
- a.computeBonesUsingShaders = null === (y = a.computeBonesUsingShaders) || void 0 === y || y,
- a.useAllBones = null === (b = a.useAllBones) || void 0 === b || b;
- var T = i.getVerticesData(Bi.MatricesIndicesKind)
- , E = i.getVerticesData(Bi.MatricesWeightsKind);
- if (this._boneIndices = new Set,
- !a.useAllBones && T && E)
- for (var S = 0; S < T.length; ++S) {
- var A = T[S];
- 0 !== E[S] && this._boneIndices.add(A)
- }
- this._utilityLayer = new El(this._scene,!1),
- this._utilityLayer.pickUtilitySceneFirst = !1,
- this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = !0;
- var x = this.options.displayMode || 0;
- x > e.DISPLAY_SPHERE_AND_SPURS && (x = e.DISPLAY_LINES),
- this.displayMode = x,
- this.update(),
- this._bindObs()
- }
- return e.CreateBoneWeightShader = function(e, t) {
- var i, n, r, o, a, s, l = e.skeleton, c = null !== (i = e.colorBase) && void 0 !== i ? i : D.Black(), u = null !== (n = e.colorZero) && void 0 !== n ? n : D.Blue(), h = null !== (r = e.colorQuarter) && void 0 !== r ? r : D.Green(), d = null !== (o = e.colorHalf) && void 0 !== o ? o : D.Yellow(), p = null !== (a = e.colorFull) && void 0 !== a ? a : D.Red(), f = null !== (s = e.targetBoneIndex) && void 0 !== s ? s : 0;
- Mt.ShadersStore["boneWeights:" + l.name + "VertexShader"] = "precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n\n #include<bonesDeclaration>\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include<bakedVertexAnimationDeclaration>\n\n #include<instancesDeclaration>\n\n varying vec3 vColor;\n\n uniform vec3 colorBase;\n uniform vec3 colorZero;\n uniform vec3 colorQuarter;\n uniform vec3 colorHalf;\n uniform vec3 colorFull;\n\n uniform float targetBoneIndex;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include<instancesVertex>\n #include<bonesVertex>\n #include<bakedVertexAnimation>\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n vec3 color = colorBase;\n float totalWeight = 0.;\n if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){\n totalWeight += matricesWeights[0];\n }\n if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){\n totalWeight += matricesWeights[1];\n }\n if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){\n totalWeight += matricesWeights[2];\n }\n if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){\n totalWeight += matricesWeights[3];\n }\n\n color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));\n color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));\n color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));\n color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));\n vColor = color;\n\n gl_Position = projection * view * worldPos;\n }",
- Mt.ShadersStore["boneWeights:" + l.name + "FragmentShader"] = "\n precision highp float;\n varying vec3 vPosition;\n\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4(vColor, 1.0);\n gl_FragColor = color;\n }\n ";
- var _ = new jl("boneWeight:" + l.name,t,{
- vertex: "boneWeights:" + l.name,
- fragment: "boneWeights:" + l.name
- },{
- attributes: ["position", "normal", "matricesIndices", "matricesWeights"],
- uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorBase", "colorZero", "colorQuarter", "colorHalf", "colorFull", "targetBoneIndex"]
- });
- return _.setColor3("colorBase", c),
- _.setColor3("colorZero", u),
- _.setColor3("colorQuarter", h),
- _.setColor3("colorHalf", d),
- _.setColor3("colorFull", p),
- _.setFloat("targetBoneIndex", f),
- _.getClassName = function() {
- return "BoneWeightShader"
- }
- ,
- _.transparencyMode = Or.MATERIAL_OPAQUE,
- _
- }
- ,
- e.CreateSkeletonMapShader = function(t, i) {
- var n, r = t.skeleton, o = null !== (n = t.colorMap) && void 0 !== n ? n : [{
- color: new D(1,.38,.18),
- location: 0
- }, {
- color: new D(.59,.18,1),
- location: .2
- }, {
- color: new D(.59,1,.18),
- location: .4
- }, {
- color: new D(1,.87,.17),
- location: .6
- }, {
- color: new D(1,.17,.42),
- location: .8
- }, {
- color: new D(.17,.68,1),
- location: 1
- }], a = r.bones.length + 1, s = e._CreateBoneMapColorBuffer(a, o, i), l = new jl("boneWeights:" + r.name,i,{
- vertexSource: "precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n uniform float colorMap[" + 4 * r.bones.length + "];\n\n #include<bonesDeclaration>\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include<bakedVertexAnimationDeclaration>\n #include<instancesDeclaration>\n\n varying vec3 vColor;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include<instancesVertex>\n #include<bonesVertex>\n #include<bakedVertexAnimation>\n\n vec3 color = vec3(0.);\n bool first = true;\n\n for (int i = 0; i < 4; i++) {\n int boneIdx = int(matricesIndices[i]);\n float boneWgt = matricesWeights[i];\n\n vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);\n\n if (boneWgt > 0.) {\n if (first) {\n first = false;\n color = c;\n } else {\n color = mix(color, c, boneWgt);\n }\n }\n }\n\n vColor = color;\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n gl_Position = projection * view * worldPos;\n }",
- fragmentSource: "\n precision highp float;\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4( vColor, 1.0 );\n gl_FragColor = color;\n }\n "
- },{
- attributes: ["position", "normal", "matricesIndices", "matricesWeights"],
- uniforms: ["world", "worldView", "worldViewProjection", "view", "projection", "viewProjection", "colorMap"]
- });
- return l.setFloats("colorMap", s),
- l.getClassName = function() {
- return "SkeletonMapShader"
- }
- ,
- l.transparencyMode = Or.MATERIAL_OPAQUE,
- l
- }
- ,
- e._CreateBoneMapColorBuffer = function(e, t, i) {
- var n = new Ds("temp",{
- width: e,
- height: 1
- },i,!1)
- , r = n.getContext()
- , o = r.createLinearGradient(0, 0, e, 0);
- t.forEach((function(e) {
- o.addColorStop(e.location, e.color.toHexString())
- }
- )),
- r.fillStyle = o,
- r.fillRect(0, 0, e, 1),
- n.update();
- for (var a = [], s = r.getImageData(0, 0, e, 1).data, l = 0; l < s.length; l++)
- a.push(.00392156862745098 * s[l]);
- return n.dispose(),
- a
- }
- ,
- Object.defineProperty(e.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "utilityLayer", {
- get: function() {
- return this._utilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isReady", {
- get: function() {
- return this._ready
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ready", {
- set: function(e) {
- this._ready = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "debugMesh", {
- get: function() {
- return this._debugMesh
- },
- set: function(e) {
- this._debugMesh = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "displayMode", {
- get: function() {
- return this.options.displayMode || e.DISPLAY_LINES
- },
- set: function(t) {
- t > e.DISPLAY_SPHERE_AND_SPURS && (t = e.DISPLAY_LINES),
- this.options.displayMode = t
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._bindObs = function() {
- var t = this;
- this.displayMode === e.DISPLAY_LINES && (this._obs = this.scene.onBeforeRenderObservable.add((function() {
- t._displayLinesUpdate()
- }
- )))
- }
- ,
- e.prototype.update = function() {
- switch (this.displayMode) {
- case e.DISPLAY_LINES:
- this._displayLinesUpdate();
- break;
- case e.DISPLAY_SPHERES:
- this._buildSpheresAndSpurs(!0);
- break;
- case e.DISPLAY_SPHERE_AND_SPURS:
- this._buildSpheresAndSpurs(!1)
- }
- this._buildLocalAxes()
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this.isEnabled !== e && (this._isEnabled = e,
- this.debugMesh && this.debugMesh.setEnabled(e),
- e && !this._obs ? this._bindObs() : !e && this._obs && (this.scene.onBeforeRenderObservable.remove(this._obs),
- this._obs = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getBonePosition = function(e, t, i, n, r, o) {
- void 0 === n && (n = 0),
- void 0 === r && (r = 0),
- void 0 === o && (o = 0);
- var a = I.Matrix[0]
- , s = t.getParent();
- if (a.copyFrom(t.getLocalMatrix()),
- 0 !== n || 0 !== r || 0 !== o) {
- var l = I.Matrix[1];
- P.IdentityToRef(l),
- l.setTranslationFromFloats(n, r, o),
- l.multiplyToRef(a, a)
- }
- s && a.multiplyToRef(s.getAbsoluteTransform(), a),
- a.multiplyToRef(i, a),
- e.x = a.m[12],
- e.y = a.m[13],
- e.z = a.m[14]
- }
- ,
- e.prototype._getLinesForBonesWithLength = function(e, t) {
- for (var i = e.length, n = this.mesh.position, r = 0, o = 0; o < i; o++) {
- var a = e[o]
- , s = this._debugLines[r];
- -1 !== a._index && (this._boneIndices.has(a.getIndex()) || this.options.useAllBones) && (s || (s = [x.Zero(), x.Zero()],
- this._debugLines[r] = s),
- this._getBonePosition(s[0], a, t),
- this._getBonePosition(s[1], a, t, 0, a.length, 0),
- s[0].subtractInPlace(n),
- s[1].subtractInPlace(n),
- r++)
- }
- }
- ,
- e.prototype._getLinesForBonesNoLength = function(e) {
- for (var t = e.length, i = 0, n = this.mesh, r = n.position, o = t - 1; o >= 0; o--) {
- var a = e[o]
- , s = a.getParent();
- if (s && (this._boneIndices.has(a.getIndex()) || this.options.useAllBones)) {
- var l = this._debugLines[i];
- l || (l = [x.Zero(), x.Zero()],
- this._debugLines[i] = l),
- a.getAbsolutePositionToRef(n, l[0]),
- s.getAbsolutePositionToRef(n, l[1]),
- l[0].subtractInPlace(r),
- l[1].subtractInPlace(r),
- i++
- }
- }
- }
- ,
- e.prototype._revert = function(e) {
- this.options.pauseAnimations && (this.scene.animationsEnabled = e,
- this.utilityLayer.utilityLayerScene.animationsEnabled = e)
- }
- ,
- e.prototype._getAbsoluteBindPoseToRef = function(e, t) {
- null !== e && -1 !== e._index ? (this._getAbsoluteBindPoseToRef(e.getParent(), t),
- e.getBaseMatrix().multiplyToRef(t, t)) : t.copyFrom(P.Identity())
- }
- ,
- e.prototype._buildSpheresAndSpurs = function(e) {
- var t, i;
- void 0 === e && (e = !0),
- this._debugMesh && (this._debugMesh.dispose(),
- this._debugMesh = null,
- this.ready = !1),
- this._ready = !1;
- var n = null === (t = this.utilityLayer) || void 0 === t ? void 0 : t.utilityLayerScene
- , r = this.skeleton.bones
- , o = []
- , a = []
- , s = this.scene.animationsEnabled;
- try {
- this.options.pauseAnimations && (this.scene.animationsEnabled = !1,
- n.animationsEnabled = !1),
- this.options.returnToRest && this.skeleton.returnToRest(),
- this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms();
- for (var l = Number.NEGATIVE_INFINITY, c = this.options.displayOptions || {}, u = function(t) {
- var i = r[t];
- if (-1 === i._index || !h._boneIndices.has(i.getIndex()) && !h.options.useAllBones)
- return "continue";
- var s = new P;
- h._getAbsoluteBindPoseToRef(i, s);
- var u = new x;
- s.decompose(void 0, void 0, u),
- i.children.forEach((function(t) {
- var r = new P;
- t.getBaseMatrix().multiplyToRef(s, r);
- var o = new x;
- r.decompose(void 0, void 0, o);
- var h = x.Distance(u, o);
- if (h > l && (l = h),
- !e) {
- for (var d = o.clone().subtract(u.clone()), p = d.length(), f = d.normalize().scale(p), _ = c.midStep || .165, m = c.midStepFactor || .215, g = f.scale(_), v = ac("skeletonViewer", {
- shape: [new x(1,-1,0), new x(1,1,0), new x(-1,1,0), new x(-1,-1,0), new x(1,-1,0)],
- path: [x.Zero(), g, f],
- scaleFunction: function(e) {
- switch (e) {
- case 0:
- case 2:
- return 0;
- case 1:
- return p * m
- }
- return 0
- },
- sideOrientation: Vr.DEFAULTSIDE,
- updatable: !1
- }, n), y = v.getTotalVertices(), b = [], T = [], E = 0; E < y; E++)
- b.push(1, 0, 0, 0),
- c.spurFollowsChild && E > 9 ? T.push(t.getIndex(), 0, 0, 0) : T.push(i.getIndex(), 0, 0, 0);
- v.position = u.clone(),
- v.setVerticesData(Bi.MatricesWeightsKind, b, !1),
- v.setVerticesData(Bi.MatricesIndicesKind, T, !1),
- v.convertToFlatShadedMesh(),
- a.push(v)
- }
- }
- ));
- for (var d = Dl("skeletonViewer", {
- segments: 6,
- diameter: c.sphereBaseSize || .2,
- updatable: !0
- }, n), p = d.getTotalVertices(), f = [], _ = [], m = 0; m < p; m++)
- f.push(1, 0, 0, 0),
- _.push(i.getIndex(), 0, 0, 0);
- d.setVerticesData(Bi.MatricesWeightsKind, f, !1),
- d.setVerticesData(Bi.MatricesIndicesKind, _, !1),
- d.position = u.clone(),
- o.push([d, i])
- }, h = this, d = 0; d < r.length; d++)
- u(d);
- var p = c.sphereScaleUnit || 2
- , f = c.sphereFactor || .85
- , _ = [];
- for (d = 0; d < o.length; d++) {
- for (var m = o[d], g = m[0], v = m[1], y = 1 / (p / l), b = 0, T = v; T.getParent() && -1 !== T.getParent().getIndex(); )
- b++,
- T = T.getParent();
- g.scaling.scaleInPlace(y * Math.pow(f, b)),
- _.push(g)
- }
- this.debugMesh = Vr.MergeMeshes(_.concat(a), !0, !0),
- this.debugMesh && (this.debugMesh.renderingGroupId = this.renderingGroupId,
- this.debugMesh.skeleton = this.skeleton,
- this.debugMesh.parent = this.mesh,
- this.debugMesh.computeBonesUsingShaders = null === (i = this.options.computeBonesUsingShaders) || void 0 === i || i,
- this.debugMesh.alwaysSelectAsActiveMesh = !0),
- this.utilityLayer._getSharedGizmoLight().intensity = .7,
- this._revert(s),
- this.ready = !0
- } catch (e) {
- console.error(e),
- this._revert(s),
- this.dispose()
- }
- }
- ,
- e.prototype._buildLocalAxes = function() {
- var e;
- this._localAxes && this._localAxes.dispose(),
- this._localAxes = null;
- var t = this.options.displayOptions || {};
- if (t.showLocalAxes) {
- var i = this._utilityLayer.utilityLayerScene
- , n = t.localAxesSize || .075
- , r = []
- , o = []
- , a = new N(1,0,0,1)
- , s = new N(0,1,0,1)
- , l = new N(0,0,1,1)
- , c = []
- , u = [];
- for (var h in this.skeleton.bones) {
- var d = this.skeleton.bones[h];
- if (-1 !== d._index && (this._boneIndices.has(d.getIndex()) || this.options.useAllBones)) {
- var p = new P
- , f = new x;
- this._getAbsoluteBindPoseToRef(d, p),
- p.decompose(void 0, void 0, f);
- var _ = d.getBaseMatrix().getRotationMatrix()
- , m = x.TransformCoordinates(new x(0 + n,0,0), _)
- , g = x.TransformCoordinates(new x(0,0 + n,0), _)
- , v = x.TransformCoordinates(new x(0,0,0 + n), _)
- , y = [[f, f.add(m)], [f, f.add(g)], [f, f.add(v)]]
- , b = [[a, a], [s, s], [l, l]];
- r.push.apply(r, y),
- o.push.apply(o, b);
- for (var T = 0; T < 6; T++)
- c.push(1, 0, 0, 0),
- u.push(d.getIndex(), 0, 0, 0)
- }
- }
- this._localAxes = Zl("localAxes", {
- lines: r,
- colors: o,
- updatable: !0
- }, i),
- this._localAxes.setVerticesData(Bi.MatricesWeightsKind, c, !1),
- this._localAxes.setVerticesData(Bi.MatricesIndicesKind, u, !1),
- this._localAxes.skeleton = this.skeleton,
- this._localAxes.renderingGroupId = this.renderingGroupId,
- this._localAxes.parent = this.mesh,
- this._localAxes.computeBonesUsingShaders = null === (e = this.options.computeBonesUsingShaders) || void 0 === e || e
- }
- }
- ,
- e.prototype._displayLinesUpdate = function() {
- if (this._utilityLayer) {
- this.autoUpdateBonesMatrices && this.skeleton.computeAbsoluteTransforms(),
- void 0 === this.skeleton.bones[0].length ? this._getLinesForBonesNoLength(this.skeleton.bones) : this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
- var e = this._utilityLayer.utilityLayerScene;
- e && (this._debugMesh ? Zl("", {
- lines: this._debugLines,
- updatable: !0,
- instance: this._debugMesh
- }, e) : (this._debugMesh = Zl("", {
- lines: this._debugLines,
- updatable: !0,
- instance: null
- }, e),
- this._debugMesh.renderingGroupId = this.renderingGroupId),
- this._debugMesh.position.copyFrom(this.mesh.position),
- this._debugMesh.color = this.color)
- }
- }
- ,
- e.prototype.changeDisplayMode = function(e) {
- var t = !!this.isEnabled;
- this.displayMode !== e && (this.isEnabled = !1,
- this._debugMesh && (this._debugMesh.dispose(),
- this._debugMesh = null,
- this.ready = !1),
- this.displayMode = e,
- this.update(),
- this._bindObs(),
- this.isEnabled = t)
- }
- ,
- e.prototype.changeDisplayOptions = function(e, t) {
- var i = !!this.isEnabled;
- this.options.displayOptions[e] = t,
- this.isEnabled = !1,
- this._debugMesh && (this._debugMesh.dispose(),
- this._debugMesh = null,
- this.ready = !1),
- this.update(),
- this._bindObs(),
- this.isEnabled = i
- }
- ,
- e.prototype.dispose = function() {
- this.isEnabled = !1,
- this._debugMesh && (this._debugMesh.dispose(),
- this._debugMesh = null),
- this._utilityLayer && (this._utilityLayer.dispose(),
- this._utilityLayer = null),
- this.ready = !1
- }
- ,
- e.DISPLAY_LINES = 0,
- e.DISPLAY_SPHERES = 1,
- e.DISPLAY_SPHERE_AND_SPURS = 2,
- e
- }()
- , uc = function() {
- function e(e, t) {
- this._oldPosition = new x(Number.NaN,Number.NaN,Number.NaN),
- this._oldDirection = new x(Number.NaN,Number.NaN,Number.NaN),
- this._transparency = .3,
- this._showLines = !0,
- this._showPlanes = !0,
- this._scene = e.getScene(),
- this._light = e,
- this._camera = t,
- this._inverseViewMatrix = P.Identity(),
- this._lightHelperFrustumMeshes = [],
- this._createGeometry(),
- this.show(),
- this.update()
- }
- return Object.defineProperty(e.prototype, "transparency", {
- get: function() {
- return this._transparency
- },
- set: function(e) {
- this._transparency = e;
- for (var t = 6; t < 12; ++t)
- this._lightHelperFrustumMeshes[t].material.alpha = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "showLines", {
- get: function() {
- return this._showLines
- },
- set: function(e) {
- if (this._showLines !== e) {
- this._showLines = e;
- for (var t = 0; t < 6; ++t)
- this._lightHelperFrustumMeshes[t].setEnabled(e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "showPlanes", {
- get: function() {
- return this._showPlanes
- },
- set: function(e) {
- if (this._showPlanes !== e) {
- this._showPlanes = e;
- for (var t = 6; t < 12; ++t)
- this._lightHelperFrustumMeshes[t].setEnabled(e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.show = function() {
- var e = this;
- this._lightHelperFrustumMeshes.forEach((function(t, i) {
- t.setEnabled(i < 6 && e._showLines || i >= 6 && e._showPlanes)
- }
- )),
- this._oldPosition.set(Number.NaN, Number.NaN, Number.NaN),
- this._visible = !0
- }
- ,
- e.prototype.hide = function() {
- this._lightHelperFrustumMeshes.forEach((function(e) {
- e.setEnabled(!1)
- }
- )),
- this._visible = !1
- }
- ,
- e.prototype.update = function() {
- var e, t, i, n, r, o;
- if (this._visible && (!this._oldPosition.equals(this._light.position) || !this._oldDirection.equals(this._light.direction) || this._oldAutoCalc !== this._light.autoCalcShadowZBounds || this._oldMinZ !== this._light.shadowMinZ || this._oldMaxZ !== this._light.shadowMaxZ)) {
- this._oldPosition.copyFrom(this._light.position),
- this._oldDirection.copyFrom(this._light.direction),
- this._oldAutoCalc = this._light.autoCalcShadowZBounds,
- this._oldMinZ = this._light.shadowMinZ,
- this._oldMaxZ = this._light.shadowMaxZ,
- I.Vector3[0].set(this._light.orthoLeft, this._light.orthoBottom, void 0 !== this._light.shadowMinZ ? this._light.shadowMinZ : this._camera.minZ),
- I.Vector3[1].set(this._light.orthoRight, this._light.orthoTop, void 0 !== this._light.shadowMaxZ ? this._light.shadowMaxZ : this._camera.maxZ);
- var a = this._getInvertViewMatrix();
- I.Vector3[2].copyFromFloats(I.Vector3[1].x, I.Vector3[1].y, I.Vector3[0].z),
- I.Vector3[3].copyFromFloats(I.Vector3[1].x, I.Vector3[0].y, I.Vector3[0].z),
- I.Vector3[4].copyFromFloats(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[0].z),
- I.Vector3[5].copyFromFloats(I.Vector3[0].x, I.Vector3[1].y, I.Vector3[0].z),
- x.TransformCoordinatesToRef(I.Vector3[2], a, I.Vector3[2]),
- x.TransformCoordinatesToRef(I.Vector3[3], a, I.Vector3[3]),
- x.TransformCoordinatesToRef(I.Vector3[4], a, I.Vector3[4]),
- x.TransformCoordinatesToRef(I.Vector3[5], a, I.Vector3[5]),
- I.Vector3[6].copyFromFloats(I.Vector3[1].x, I.Vector3[1].y, I.Vector3[1].z),
- I.Vector3[7].copyFromFloats(I.Vector3[1].x, I.Vector3[0].y, I.Vector3[1].z),
- I.Vector3[8].copyFromFloats(I.Vector3[0].x, I.Vector3[0].y, I.Vector3[1].z),
- I.Vector3[9].copyFromFloats(I.Vector3[0].x, I.Vector3[1].y, I.Vector3[1].z),
- x.TransformCoordinatesToRef(I.Vector3[6], a, I.Vector3[6]),
- x.TransformCoordinatesToRef(I.Vector3[7], a, I.Vector3[7]),
- x.TransformCoordinatesToRef(I.Vector3[8], a, I.Vector3[8]),
- x.TransformCoordinatesToRef(I.Vector3[9], a, I.Vector3[9]),
- Jl("nearlines", {
- updatable: !0,
- points: this._nearLinesPoints,
- instance: this._lightHelperFrustumMeshes[0]
- }, this._scene),
- Jl("farlines", {
- updatable: !0,
- points: this._farLinesPoints,
- instance: this._lightHelperFrustumMeshes[1]
- }, this._scene),
- Jl("trlines", {
- updatable: !0,
- points: this._trLinesPoints,
- instance: this._lightHelperFrustumMeshes[2]
- }, this._scene),
- Jl("brlines", {
- updatable: !0,
- points: this._brLinesPoints,
- instance: this._lightHelperFrustumMeshes[3]
- }, this._scene),
- Jl("tllines", {
- updatable: !0,
- points: this._tlLinesPoints,
- instance: this._lightHelperFrustumMeshes[4]
- }, this._scene),
- Jl("bllines", {
- updatable: !0,
- points: this._blLinesPoints,
- instance: this._lightHelperFrustumMeshes[5]
- }, this._scene),
- I.Vector3[2].toArray(this._nearPlaneVertices, 0),
- I.Vector3[3].toArray(this._nearPlaneVertices, 3),
- I.Vector3[4].toArray(this._nearPlaneVertices, 6),
- I.Vector3[5].toArray(this._nearPlaneVertices, 9),
- null === (e = this._lightHelperFrustumMeshes[6].geometry) || void 0 === e || e.updateVerticesDataDirectly("position", this._nearPlaneVertices, 0),
- I.Vector3[6].toArray(this._farPlaneVertices, 0),
- I.Vector3[7].toArray(this._farPlaneVertices, 3),
- I.Vector3[8].toArray(this._farPlaneVertices, 6),
- I.Vector3[9].toArray(this._farPlaneVertices, 9),
- null === (t = this._lightHelperFrustumMeshes[7].geometry) || void 0 === t || t.updateVerticesDataDirectly("position", this._farPlaneVertices, 0),
- I.Vector3[2].toArray(this._rightPlaneVertices, 0),
- I.Vector3[6].toArray(this._rightPlaneVertices, 3),
- I.Vector3[7].toArray(this._rightPlaneVertices, 6),
- I.Vector3[3].toArray(this._rightPlaneVertices, 9),
- null === (i = this._lightHelperFrustumMeshes[8].geometry) || void 0 === i || i.updateVerticesDataDirectly("position", this._rightPlaneVertices, 0),
- I.Vector3[5].toArray(this._leftPlaneVertices, 0),
- I.Vector3[9].toArray(this._leftPlaneVertices, 3),
- I.Vector3[8].toArray(this._leftPlaneVertices, 6),
- I.Vector3[4].toArray(this._leftPlaneVertices, 9),
- null === (n = this._lightHelperFrustumMeshes[9].geometry) || void 0 === n || n.updateVerticesDataDirectly("position", this._leftPlaneVertices, 0),
- I.Vector3[2].toArray(this._topPlaneVertices, 0),
- I.Vector3[6].toArray(this._topPlaneVertices, 3),
- I.Vector3[9].toArray(this._topPlaneVertices, 6),
- I.Vector3[5].toArray(this._topPlaneVertices, 9),
- null === (r = this._lightHelperFrustumMeshes[10].geometry) || void 0 === r || r.updateVerticesDataDirectly("position", this._topPlaneVertices, 0),
- I.Vector3[3].toArray(this._bottomPlaneVertices, 0),
- I.Vector3[7].toArray(this._bottomPlaneVertices, 3),
- I.Vector3[8].toArray(this._bottomPlaneVertices, 6),
- I.Vector3[4].toArray(this._bottomPlaneVertices, 9),
- null === (o = this._lightHelperFrustumMeshes[11].geometry) || void 0 === o || o.updateVerticesDataDirectly("position", this._bottomPlaneVertices, 0)
- }
- }
- ,
- e.prototype.dispose = function() {
- this._lightHelperFrustumMeshes.forEach((function(e) {
- var t;
- null === (t = e.material) || void 0 === t || t.dispose(),
- e.dispose()
- }
- )),
- this._rootNode.dispose()
- }
- ,
- e.prototype._createGeometry = function() {
- var e = this;
- this._rootNode = new yr("directionalLightHelperRoot_" + this._light.name,this._scene),
- this._rootNode.parent = this._light.parent,
- this._nearLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly];
- var t = Jl("nearlines", {
- updatable: !0,
- points: this._nearLinesPoints
- }, this._scene);
- t.parent = this._rootNode,
- t.alwaysSelectAsActiveMesh = !0,
- this._farLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly, x.ZeroReadOnly];
- var i = Jl("farlines", {
- updatable: !0,
- points: this._farLinesPoints
- }, this._scene);
- i.parent = this._rootNode,
- i.alwaysSelectAsActiveMesh = !0,
- this._trLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
- var n = Jl("trlines", {
- updatable: !0,
- points: this._trLinesPoints
- }, this._scene);
- n.parent = this._rootNode,
- n.alwaysSelectAsActiveMesh = !0,
- this._brLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
- var r = Jl("brlines", {
- updatable: !0,
- points: this._brLinesPoints
- }, this._scene);
- r.parent = this._rootNode,
- r.alwaysSelectAsActiveMesh = !0,
- this._tlLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
- var o = Jl("tllines", {
- updatable: !0,
- points: this._tlLinesPoints
- }, this._scene);
- o.parent = this._rootNode,
- o.alwaysSelectAsActiveMesh = !0,
- this._blLinesPoints = [x.ZeroReadOnly, x.ZeroReadOnly];
- var a = Jl("bllines", {
- updatable: !0,
- points: this._blLinesPoints
- }, this._scene);
- a.parent = this._rootNode,
- a.alwaysSelectAsActiveMesh = !0,
- this._lightHelperFrustumMeshes.push(t, i, n, r, o, a);
- var s = function(t, i, n) {
- var r = new Vr(t + "plane",e._scene)
- , o = new Os(t + "PlaneMat",e._scene);
- r.material = o,
- r.parent = e._rootNode,
- r.alwaysSelectAsActiveMesh = !0,
- o.emissiveColor = i,
- o.alpha = e.transparency,
- o.backFaceCulling = !1,
- o.disableLighting = !0;
- var a = new $n;
- a.positions = n,
- a.indices = [0, 1, 2, 0, 2, 3],
- a.applyToMesh(r, !0),
- e._lightHelperFrustumMeshes.push(r)
- };
- this._nearPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- this._farPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- this._rightPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- this._leftPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- this._topPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- this._bottomPlaneVertices = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- s("near", new D(1,0,0), this._nearPlaneVertices),
- s("far", new D(.3,0,0), this._farPlaneVertices),
- s("right", new D(0,1,0), this._rightPlaneVertices),
- s("left", new D(0,.3,0), this._leftPlaneVertices),
- s("top", new D(0,0,1), this._topPlaneVertices),
- s("bottom", new D(0,0,.3), this._bottomPlaneVertices),
- this._nearLinesPoints[0] = I.Vector3[2],
- this._nearLinesPoints[1] = I.Vector3[3],
- this._nearLinesPoints[2] = I.Vector3[4],
- this._nearLinesPoints[3] = I.Vector3[5],
- this._nearLinesPoints[4] = I.Vector3[2],
- this._farLinesPoints[0] = I.Vector3[6],
- this._farLinesPoints[1] = I.Vector3[7],
- this._farLinesPoints[2] = I.Vector3[8],
- this._farLinesPoints[3] = I.Vector3[9],
- this._farLinesPoints[4] = I.Vector3[6],
- this._trLinesPoints[0] = I.Vector3[2],
- this._trLinesPoints[1] = I.Vector3[6],
- this._brLinesPoints[0] = I.Vector3[3],
- this._brLinesPoints[1] = I.Vector3[7],
- this._tlLinesPoints[0] = I.Vector3[4],
- this._tlLinesPoints[1] = I.Vector3[8],
- this._blLinesPoints[0] = I.Vector3[5],
- this._blLinesPoints[1] = I.Vector3[9]
- }
- ,
- e.prototype._getInvertViewMatrix = function() {
- return P.LookAtLHToRef(this._light.position, this._light.position.add(this._light.direction), x.UpReadOnly, this._inverseViewMatrix),
- this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),
- this._inverseViewMatrix
- }
- ,
- e
- }()
- , hc = function() {
- this.renderWidth = 512,
- this.renderHeight = 256,
- this.textureSize = 512,
- this.deterministicLockstep = !1,
- this.lockstepMaxSteps = 4
- }
- , dc = function(t) {
- function i(i) {
- void 0 === i && (i = new hc);
- var n = t.call(this, null) || this;
- vr.Instances.push(n),
- void 0 === i.deterministicLockstep && (i.deterministicLockstep = !1),
- void 0 === i.lockstepMaxSteps && (i.lockstepMaxSteps = 4),
- n._options = i,
- T.SetMatrixPrecision(!!i.useHighPrecisionMatrix),
- n._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,
- supportTransformFeedbacks: !1,
- textureMaxLevel: !1
- },
- n._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
- },
- K.Log("Babylon.js v".concat(vr.Version, " - Null engine"));
- var r = "undefined" != typeof self ? self : void 0 !== e.g ? e.g : window;
- return "undefined" == typeof URL && (r.URL = {
- createObjectURL: function() {},
- revokeObjectURL: function() {}
- }),
- "undefined" == typeof Blob && (r.Blob = function() {}
- ),
- n
- }
- return U(i, t),
- i.prototype.isDeterministicLockStep = function() {
- return this._options.deterministicLockstep
- }
- ,
- i.prototype.getLockstepMaxSteps = function() {
- return this._options.lockstepMaxSteps
- }
- ,
- i.prototype.getHardwareScalingLevel = function() {
- return 1
- }
- ,
- i.prototype.createVertexBuffer = function(e) {
- var t = new Bt;
- return t.references = 1,
- t
- }
- ,
- i.prototype.createIndexBuffer = function(e) {
- var t = new Bt;
- return t.references = 1,
- t
- }
- ,
- i.prototype.clear = function(e, t, i, n) {
- void 0 === n && (n = !1)
- }
- ,
- i.prototype.getRenderWidth = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._options.renderWidth
- }
- ,
- i.prototype.getRenderHeight = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._options.renderHeight
- }
- ,
- i.prototype.setViewport = function(e, t, i) {
- this._cachedViewport = e
- }
- ,
- i.prototype.createShaderProgram = function(e, t, i, n, r) {
- return {
- __SPECTOR_rebuildProgram: null
- }
- }
- ,
- i.prototype.getUniforms = function(e, t) {
- return []
- }
- ,
- i.prototype.getAttributes = function(e, t) {
- return []
- }
- ,
- i.prototype.bindSamplers = function(e) {
- this._currentEffect = null
- }
- ,
- i.prototype.enableEffect = function(e) {
- e = null !== e && Gt.IsWrapper(e) ? e.effect : e,
- this._currentEffect = e,
- e && (e.onBind && e.onBind(e),
- e._onBindObservable && e._onBindObservable.notifyObservers(e))
- }
- ,
- i.prototype.setState = function(e, t, i, n, r, o, a) {
- void 0 === t && (t = 0),
- void 0 === n && (n = !1),
- void 0 === a && (a = 0)
- }
- ,
- i.prototype.setIntArray = function(e, t) {
- return !0
- }
- ,
- i.prototype.setIntArray2 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setIntArray3 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setIntArray4 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloatArray = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloatArray2 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloatArray3 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloatArray4 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setArray = function(e, t) {
- return !0
- }
- ,
- i.prototype.setArray2 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setArray3 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setArray4 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setMatrices = function(e, t) {
- return !0
- }
- ,
- i.prototype.setMatrix3x3 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setMatrix2x2 = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloat = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloat2 = function(e, t, i) {
- return !0
- }
- ,
- i.prototype.setFloat3 = function(e, t, i, n) {
- return !0
- }
- ,
- i.prototype.setBool = function(e, t) {
- return !0
- }
- ,
- i.prototype.setFloat4 = function(e, t, i, n, r) {
- return !0
- }
- ,
- i.prototype.setAlphaMode = function(e, t) {
- void 0 === t && (t = !1),
- this._alphaMode !== e && (this.alphaState.alphaBlend = e !== a.ALPHA_DISABLE,
- t || this.setDepthWrite(e === a.ALPHA_DISABLE),
- this._alphaMode = e)
- }
- ,
- i.prototype.bindBuffers = function(e, t, i) {}
- ,
- i.prototype.wipeCaches = function(e) {
- this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
- this._currentEffect = null,
- e && (this._currentProgram = null,
- this._stencilStateComposer.reset(),
- this.depthCullingState.reset(),
- this.alphaState.reset()),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._cachedEffectForVertexBuffers = null)
- }
- ,
- i.prototype.draw = function(e, t, i, n) {}
- ,
- i.prototype.drawElementsType = function(e, t, i, n) {}
- ,
- i.prototype.drawArraysType = function(e, t, i, n) {}
- ,
- i.prototype._createTexture = function() {
- return {}
- }
- ,
- i.prototype._releaseTexture = function(e) {}
- ,
- i.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d) {
- void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = null);
- var p = new Lt(this,At.Url)
- , f = String(e);
- return p.url = f,
- p.generateMipMaps = !t,
- p.samplingMode = r,
- p.invertY = i,
- p.baseWidth = this._options.textureSize,
- p.baseHeight = this._options.textureSize,
- p.width = this._options.textureSize,
- p.height = this._options.textureSize,
- u && (p.format = u),
- p.isReady = !0,
- o && o(),
- this._internalTexturesCache.push(p),
- p
- }
- ,
- i.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
- var n = new Fa(e,t,i,this);
- return this._renderTargetWrapperCache.push(n),
- n
- }
- ,
- i.prototype.createRenderTargetTexture = function(e, t) {
- var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
- , n = {};
- void 0 !== t && "object" == typeof t ? (n.generateMipMaps = t.generateMipMaps,
- n.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
- n.generateStencilBuffer = n.generateDepthBuffer && t.generateStencilBuffer,
- n.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
- n.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode) : (n.generateMipMaps = t,
- n.generateDepthBuffer = !0,
- n.generateStencilBuffer = !1,
- n.type = a.TEXTURETYPE_UNSIGNED_INT,
- n.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE);
- var r = new Lt(this,At.RenderTarget)
- , o = e.width || e
- , s = e.height || e;
- return i._generateDepthBuffer = n.generateDepthBuffer,
- i._generateStencilBuffer = !!n.generateStencilBuffer,
- r.baseWidth = o,
- r.baseHeight = s,
- r.width = o,
- r.height = s,
- r.isReady = !0,
- r.samples = 1,
- r.generateMipMaps = !!n.generateMipMaps,
- r.samplingMode = n.samplingMode,
- r.type = n.type,
- this._internalTexturesCache.push(r),
- i
- }
- ,
- i.prototype.updateTextureSamplingMode = function(e, t) {
- t.samplingMode = e
- }
- ,
- i.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
- void 0 === l && (l = null),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = 0);
- var h = new Lt(this,At.Raw);
- return h.baseWidth = t,
- h.baseHeight = i,
- h.width = t,
- h.height = i,
- h.format = n,
- h.generateMipMaps = r,
- h.samplingMode = s,
- h.invertY = o,
- h._compression = l,
- h.type = c,
- this._doNotHandleContextLost || (h._bufferView = e),
- h
- }
- ,
- i.prototype.updateRawTexture = function(e, t, i, n, r, o) {
- void 0 === r && (r = null),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- e && (e._bufferView = t,
- e.format = i,
- e.invertY = n,
- e._compression = r,
- e.type = o)
- }
- ,
- i.prototype.bindFramebuffer = function(e, t, i, n, r) {
- this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
- this._currentRenderTarget = e,
- this._currentFramebuffer = null,
- this._cachedViewport && !r && this.setViewport(this._cachedViewport, i, n)
- }
- ,
- i.prototype.unBindFramebuffer = function(e, t, i) {
- void 0 === t && (t = !1),
- this._currentRenderTarget = null,
- i && i(),
- this._currentFramebuffer = null
- }
- ,
- i.prototype.createDynamicVertexBuffer = function(e) {
- var t = new Bt;
- return t.references = 1,
- t.capacity = 1,
- t
- }
- ,
- i.prototype.updateDynamicTexture = function(e, t, i, n, r) {
- void 0 === n && (n = !1)
- }
- ,
- i.prototype.areAllEffectsReady = function() {
- return !0
- }
- ,
- i.prototype.getError = function() {
- return 0
- }
- ,
- i.prototype._getUnpackAlignement = function() {
- return 1
- }
- ,
- i.prototype._unpackFlipY = function(e) {}
- ,
- i.prototype.updateDynamicIndexBuffer = function(e, t, i) {
- void 0 === i && (i = 0)
- }
- ,
- i.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {}
- ,
- i.prototype._bindTextureDirectly = function(e, t) {
- return this._boundTexturesCache[this._activeChannel] !== t && (this._boundTexturesCache[this._activeChannel] = t,
- !0)
- }
- ,
- i.prototype._bindTexture = function(e, t) {
- e < 0 || this._bindTextureDirectly(0, t)
- }
- ,
- i.prototype._deleteBuffer = function(e) {}
- ,
- i.prototype.releaseEffects = function() {}
- ,
- i.prototype.displayLoadingUI = function() {}
- ,
- i.prototype.hideLoadingUI = function() {}
- ,
- i.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
- void 0 === o && (o = 0),
- void 0 === a && (a = 0)
- }
- ,
- i.prototype._uploadDataToTextureDirectly = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0)
- }
- ,
- i.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0)
- }
- ,
- i.prototype._uploadImageToTexture = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0)
- }
- ,
- i
- }(vr);
- Ht.prototype._debugPushGroup = function(e, t) {}
- ,
- Ht.prototype._debugPopGroup = function(e) {}
- ,
- Ht.prototype._debugInsertMarker = function(e, t) {}
- ,
- Ht.prototype._debugFlushPendingCommands = function() {}
- ;
- var pc = function() {
- this._timeElapsedQueryEnded = !1
- }
- , fc = function() {
- this.occlusionInternalRetryCounter = 0,
- this.isOcclusionQueryInProgress = !1,
- this.isOccluded = !1,
- this.occlusionRetryCount = -1,
- this.occlusionType = Sr.OCCLUSION_TYPE_NONE,
- this.occlusionQueryAlgorithmType = Sr.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,
- this.forceRenderingWhenOccluded = !1
- };
- vr.prototype.createQuery = function() {
- return this._gl.createQuery()
- }
- ,
- vr.prototype.deleteQuery = function(e) {
- return this._gl.deleteQuery(e),
- this
- }
- ,
- vr.prototype.isQueryResultAvailable = function(e) {
- return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT_AVAILABLE)
- }
- ,
- vr.prototype.getQueryResult = function(e) {
- return this._gl.getQueryParameter(e, this._gl.QUERY_RESULT)
- }
- ,
- vr.prototype.beginOcclusionQuery = function(e, t) {
- var i = this._getGlAlgorithmType(e);
- return this._gl.beginQuery(i, t),
- !0
- }
- ,
- vr.prototype.endOcclusionQuery = function(e) {
- var t = this._getGlAlgorithmType(e);
- return this._gl.endQuery(t),
- this
- }
- ,
- vr.prototype._createTimeQuery = function() {
- var e = this.getCaps().timerQuery;
- return e.createQueryEXT ? e.createQueryEXT() : this.createQuery()
- }
- ,
- vr.prototype._deleteTimeQuery = function(e) {
- var t = this.getCaps().timerQuery;
- t.deleteQueryEXT ? t.deleteQueryEXT(e) : this.deleteQuery(e)
- }
- ,
- vr.prototype._getTimeQueryResult = function(e) {
- var t = this.getCaps().timerQuery;
- return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_EXT) : this.getQueryResult(e)
- }
- ,
- vr.prototype._getTimeQueryAvailability = function(e) {
- var t = this.getCaps().timerQuery;
- return t.getQueryObjectEXT ? t.getQueryObjectEXT(e, t.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(e)
- }
- ,
- vr.prototype.startTimeQuery = function() {
- var e = this.getCaps()
- , t = e.timerQuery;
- if (!t)
- return null;
- var i = new pc;
- if (this._gl.getParameter(t.GPU_DISJOINT_EXT),
- e.canUseTimestampForTimerQuery)
- i._startTimeQuery = this._createTimeQuery(),
- t.queryCounterEXT(i._startTimeQuery, t.TIMESTAMP_EXT);
- else {
- if (this._currentNonTimestampToken)
- return this._currentNonTimestampToken;
- i._timeElapsedQuery = this._createTimeQuery(),
- t.beginQueryEXT ? t.beginQueryEXT(t.TIME_ELAPSED_EXT, i._timeElapsedQuery) : this._gl.beginQuery(t.TIME_ELAPSED_EXT, i._timeElapsedQuery),
- this._currentNonTimestampToken = i
- }
- return i
- }
- ,
- vr.prototype.endTimeQuery = function(e) {
- var t = this.getCaps()
- , i = t.timerQuery;
- if (!i || !e)
- return -1;
- if (t.canUseTimestampForTimerQuery) {
- if (!e._startTimeQuery)
- return -1;
- e._endTimeQuery || (e._endTimeQuery = this._createTimeQuery(),
- i.queryCounterEXT(e._endTimeQuery, i.TIMESTAMP_EXT))
- } else if (!e._timeElapsedQueryEnded) {
- if (!e._timeElapsedQuery)
- return -1;
- i.endQueryEXT ? i.endQueryEXT(i.TIME_ELAPSED_EXT) : this._gl.endQuery(i.TIME_ELAPSED_EXT),
- e._timeElapsedQueryEnded = !0
- }
- var n = this._gl.getParameter(i.GPU_DISJOINT_EXT)
- , r = !1;
- if (e._endTimeQuery ? r = this._getTimeQueryAvailability(e._endTimeQuery) : e._timeElapsedQuery && (r = this._getTimeQueryAvailability(e._timeElapsedQuery)),
- r && !n) {
- var o = 0;
- if (t.canUseTimestampForTimerQuery) {
- if (!e._startTimeQuery || !e._endTimeQuery)
- return -1;
- var a = this._getTimeQueryResult(e._startTimeQuery);
- o = this._getTimeQueryResult(e._endTimeQuery) - a,
- this._deleteTimeQuery(e._startTimeQuery),
- this._deleteTimeQuery(e._endTimeQuery),
- e._startTimeQuery = null,
- e._endTimeQuery = null
- } else {
- if (!e._timeElapsedQuery)
- return -1;
- o = this._getTimeQueryResult(e._timeElapsedQuery),
- this._deleteTimeQuery(e._timeElapsedQuery),
- e._timeElapsedQuery = null,
- e._timeElapsedQueryEnded = !1,
- this._currentNonTimestampToken = null
- }
- return o
- }
- return -1
- }
- ,
- vr.prototype._captureGPUFrameTime = !1,
- vr.prototype._gpuFrameTime = new un,
- vr.prototype.getGPUFrameTimeCounter = function() {
- return this._gpuFrameTime
- }
- ,
- vr.prototype.captureGPUFrameTime = function(e) {
- var t = this;
- e !== this._captureGPUFrameTime && (this._captureGPUFrameTime = e,
- e ? (this._onBeginFrameObserver = this.onBeginFrameObservable.add((function() {
- t._gpuFrameTimeToken || (t._gpuFrameTimeToken = t.startTimeQuery())
- }
- )),
- this._onEndFrameObserver = this.onEndFrameObservable.add((function() {
- if (t._gpuFrameTimeToken) {
- var e = t.endTimeQuery(t._gpuFrameTimeToken);
- e > -1 && (t._gpuFrameTimeToken = null,
- t._gpuFrameTime.fetchNewFrame(),
- t._gpuFrameTime.addCount(e, !0))
- }
- }
- ))) : (this.onBeginFrameObservable.remove(this._onBeginFrameObserver),
- this._onBeginFrameObserver = null,
- this.onEndFrameObservable.remove(this._onEndFrameObserver),
- this._onEndFrameObserver = null))
- }
- ,
- vr.prototype._getGlAlgorithmType = function(e) {
- return e === Sr.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED
- }
- ,
- Object.defineProperty(Sr.prototype, "isOcclusionQueryInProgress", {
- get: function() {
- return this._occlusionDataStorage.isOcclusionQueryInProgress
- },
- set: function(e) {
- this._occlusionDataStorage.isOcclusionQueryInProgress = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(Sr.prototype, "_occlusionDataStorage", {
- get: function() {
- return this.__occlusionDataStorage || (this.__occlusionDataStorage = new fc),
- this.__occlusionDataStorage
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(Sr.prototype, "isOccluded", {
- get: function() {
- return this._occlusionDataStorage.isOccluded
- },
- set: function(e) {
- this._occlusionDataStorage.isOccluded = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(Sr.prototype, "occlusionQueryAlgorithmType", {
- get: function() {
- return this._occlusionDataStorage.occlusionQueryAlgorithmType
- },
- set: function(e) {
- this._occlusionDataStorage.occlusionQueryAlgorithmType = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(Sr.prototype, "occlusionType", {
- get: function() {
- return this._occlusionDataStorage.occlusionType
- },
- set: function(e) {
- this._occlusionDataStorage.occlusionType = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(Sr.prototype, "occlusionRetryCount", {
- get: function() {
- return this._occlusionDataStorage.occlusionRetryCount
- },
- set: function(e) {
- this._occlusionDataStorage.occlusionRetryCount = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(Sr.prototype, "forceRenderingWhenOccluded", {
- get: function() {
- return this._occlusionDataStorage.forceRenderingWhenOccluded
- },
- set: function(e) {
- this._occlusionDataStorage.forceRenderingWhenOccluded = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Sr.prototype._checkOcclusionQuery = function() {
- var e = this._occlusionDataStorage;
- if (e.occlusionType === Sr.OCCLUSION_TYPE_NONE)
- return e.isOccluded = !1,
- !1;
- var t = this.getEngine();
- if (!t.getCaps().supportOcclusionQuery)
- return e.isOccluded = !1,
- !1;
- if (!t.isQueryResultAvailable)
- return e.isOccluded = !1,
- !1;
- if (this.isOcclusionQueryInProgress && this._occlusionQuery)
- if (t.isQueryResultAvailable(this._occlusionQuery)) {
- var i = t.getQueryResult(this._occlusionQuery);
- e.isOcclusionQueryInProgress = !1,
- e.occlusionInternalRetryCounter = 0,
- e.isOccluded = !(i > 0)
- } else {
- if (e.occlusionInternalRetryCounter++,
- !(-1 !== e.occlusionRetryCount && e.occlusionInternalRetryCounter > e.occlusionRetryCount))
- return e.occlusionType !== Sr.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded;
- e.isOcclusionQueryInProgress = !1,
- e.occlusionInternalRetryCounter = 0,
- e.isOccluded = e.occlusionType !== Sr.OCCLUSION_TYPE_OPTIMISTIC && e.isOccluded
- }
- var n = this.getScene();
- if (n.getBoundingBoxRenderer) {
- var r = n.getBoundingBoxRenderer();
- null === this._occlusionQuery && (this._occlusionQuery = t.createQuery()),
- t.beginOcclusionQuery(e.occlusionQueryAlgorithmType, this._occlusionQuery) && (r.renderOcclusionBoundingBox(this),
- t.endOcclusionQuery(e.occlusionQueryAlgorithmType),
- this._occlusionDataStorage.isOcclusionQueryInProgress = !0)
- }
- return e.isOccluded
- }
- ;
- var _c = !0;
- vr.prototype.createTransformFeedback = function() {
- return this._gl.createTransformFeedback()
- }
- ,
- vr.prototype.deleteTransformFeedback = function(e) {
- this._gl.deleteTransformFeedback(e)
- }
- ,
- vr.prototype.bindTransformFeedback = function(e) {
- this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, e)
- }
- ,
- vr.prototype.beginTransformFeedback = function(e) {
- void 0 === e && (e = !0),
- this._gl.beginTransformFeedback(e ? this._gl.POINTS : this._gl.TRIANGLES)
- }
- ,
- vr.prototype.endTransformFeedback = function() {
- this._gl.endTransformFeedback()
- }
- ,
- vr.prototype.setTranformFeedbackVaryings = function(e, t) {
- this._gl.transformFeedbackVaryings(e, t, this._gl.INTERLEAVED_ATTRIBS)
- }
- ,
- vr.prototype.bindTransformFeedbackBuffer = function(e) {
- this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, e ? e.underlyingResource : null)
- }
- ,
- Ht.prototype.createExternalTexture = function(e) {
- return null
- }
- ,
- Ht.prototype.setExternalTexture = function(e, t) {
- throw new Error("setExternalTexture: This engine does not support external textures!")
- }
- ,
- Ht.prototype.updateVideoTexture = function(e, t, i) {
- if (e && !e._isDisabled) {
- var n = this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0);
- this._unpackFlipY(!i);
- try {
- if (void 0 === this._videoTextureSupported && (this._gl.getError(),
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, t),
- 0 !== this._gl.getError() ? 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, t);
- else {
- if (!e._workingCanvas) {
- e._workingCanvas = this.createCanvas(e.width, e.height);
- var r = e._workingCanvas.getContext("2d");
- if (!r)
- throw new Error("Unable to get 2d context");
- e._workingContext = r,
- e._workingCanvas.width = e.width,
- e._workingCanvas.height = e.height
- }
- e._workingContext.clearRect(0, 0, e.width, e.height),
- e._workingContext.drawImage(t, 0, 0, t.videoWidth, t.videoHeight, 0, 0, e.width, e.height),
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e._workingCanvas)
- }
- e.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- n || this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- e.isReady = !0
- } catch (t) {
- e._isDisabled = !0
- }
- }
- }
- ,
- Ht.prototype.restoreSingleAttachment = function() {
- var e = this._gl;
- this.bindAttachments([e.BACK])
- }
- ,
- Ht.prototype.restoreSingleAttachmentForRenderTarget = function() {
- var e = this._gl;
- this.bindAttachments([e.COLOR_ATTACHMENT0])
- }
- ,
- Ht.prototype.buildTextureLayout = function(e) {
- for (var t = this._gl, i = [], n = 0; n < e.length; n++)
- e[n] ? i.push(t["COLOR_ATTACHMENT" + n]) : i.push(t.NONE);
- return i
- }
- ,
- Ht.prototype.bindAttachments = function(e) {
- this._gl.drawBuffers(e)
- }
- ,
- Ht.prototype.unBindMultiColorAttachmentFramebuffer = function(e, t, i) {
- void 0 === t && (t = !1),
- this._currentRenderTarget = null;
- var n = this._gl
- , r = e._attachments
- , o = r.length;
- if (e._MSAAFramebuffer) {
- n.bindFramebuffer(n.READ_FRAMEBUFFER, e._MSAAFramebuffer),
- n.bindFramebuffer(n.DRAW_FRAMEBUFFER, e._framebuffer);
- for (var a = 0; a < o; a++) {
- for (var s = e.textures[a], l = 0; l < o; l++)
- r[l] = n.NONE;
- r[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"],
- n.readBuffer(r[a]),
- n.drawBuffers(r),
- n.blitFramebuffer(0, 0, s.width, s.height, 0, 0, s.width, s.height, n.COLOR_BUFFER_BIT, n.NEAREST)
- }
- for (a = 0; a < o; a++)
- r[a] = n[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"];
- n.drawBuffers(r)
- }
- for (a = 0; a < o; a++)
- !(s = e.textures[a]).generateMipMaps || t || s.isCube || (this._bindTextureDirectly(n.TEXTURE_2D, s, !0),
- n.generateMipmap(n.TEXTURE_2D),
- this._bindTextureDirectly(n.TEXTURE_2D, null));
- i && (e._MSAAFramebuffer && this._bindUnboundFramebuffer(e._framebuffer),
- i()),
- this._bindUnboundFramebuffer(null)
- }
- ,
- Ht.prototype.createMultipleRenderTarget = function(e, t, i) {
- void 0 === i && (i = !0);
- var n = !1
- , r = !0
- , o = !1
- , s = !1
- , l = a.TEXTUREFORMAT_DEPTH16
- , c = 1
- , u = a.TEXTURETYPE_UNSIGNED_INT
- , h = a.TEXTURE_TRILINEAR_SAMPLINGMODE
- , d = new Array
- , p = new Array
- , f = this._createHardwareRenderTargetWrapper(!0, !1, e);
- void 0 !== t && (n = void 0 !== t.generateMipMaps && t.generateMipMaps,
- r = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
- o = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer,
- s = void 0 !== t.generateDepthTexture && t.generateDepthTexture,
- c = t.textureCount || 1,
- t.types && (d = t.types),
- t.samplingModes && (p = t.samplingModes),
- this.webGLVersion > 1 && (t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24_STENCIL8 || t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24 || t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH32_FLOAT) && (l = t.depthTextureFormat));
- var _ = this._gl
- , m = _.createFramebuffer();
- this._bindUnboundFramebuffer(m);
- var g = e.width || e
- , v = e.height || e
- , y = []
- , b = []
- , T = this.webGLVersion > 1 && s && t.depthTextureFormat === a.TEXTUREFORMAT_DEPTH24_STENCIL8
- , E = this._setupFramebufferDepthAttachments(!T && o, !s && r, g, v);
- f._framebuffer = m,
- f._depthStencilBuffer = E,
- f._generateDepthBuffer = !s && r,
- f._generateStencilBuffer = !T && o,
- f._attachments = b;
- for (var S = 0; S < c; S++) {
- var A = p[S] || h
- , x = d[S] || u;
- (x !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (x !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (A = a.TEXTURE_NEAREST_SAMPLINGMODE);
- var R = this._getSamplingParameters(A, n);
- x !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (x = a.TEXTURETYPE_UNSIGNED_INT,
- K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
- var C = new Lt(this,At.MultiRenderTarget)
- , P = _[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + S : "COLOR_ATTACHMENT" + S + "_WEBGL"];
- y.push(C),
- b.push(P),
- _.activeTexture(_["TEXTURE" + S]),
- _.bindTexture(_.TEXTURE_2D, C._hardwareTexture.underlyingResource),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, R.mag),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, R.min),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE),
- _.texImage2D(_.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(x), g, v, 0, _.RGBA, this._getWebGLTextureType(x), null),
- _.framebufferTexture2D(_.DRAW_FRAMEBUFFER, P, _.TEXTURE_2D, C._hardwareTexture.underlyingResource, 0),
- n && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(_.TEXTURE_2D, null),
- C.baseWidth = g,
- C.baseHeight = v,
- C.width = g,
- C.height = v,
- C.isReady = !0,
- C.samples = 1,
- C.generateMipMaps = n,
- C.samplingMode = A,
- C.type = x,
- this._internalTexturesCache.push(C)
- }
- if (s && this._caps.depthTextureExtension) {
- var M = new Lt(this,At.Depth)
- , I = a.TEXTURETYPE_UNSIGNED_SHORT
- , O = _.DEPTH_COMPONENT16
- , D = _.DEPTH_COMPONENT
- , N = _.UNSIGNED_SHORT
- , L = _.DEPTH_ATTACHMENT;
- this.webGLVersion < 2 ? O = _.DEPTH_COMPONENT : l === a.TEXTUREFORMAT_DEPTH32_FLOAT ? (I = a.TEXTURETYPE_FLOAT,
- N = _.FLOAT,
- O = _.DEPTH_COMPONENT32F) : l === a.TEXTUREFORMAT_DEPTH24 ? (I = a.TEXTURETYPE_UNSIGNED_INT,
- N = _.UNSIGNED_INT,
- O = _.DEPTH_COMPONENT24,
- L = _.DEPTH_ATTACHMENT) : l === a.TEXTUREFORMAT_DEPTH24_STENCIL8 && (I = a.TEXTURETYPE_UNSIGNED_INT_24_8,
- N = _.UNSIGNED_INT_24_8,
- O = _.DEPTH24_STENCIL8,
- D = _.DEPTH_STENCIL,
- L = _.DEPTH_STENCIL_ATTACHMENT),
- _.activeTexture(_.TEXTURE0),
- _.bindTexture(_.TEXTURE_2D, M._hardwareTexture.underlyingResource),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, _.NEAREST),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, _.NEAREST),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE),
- _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE),
- _.texImage2D(_.TEXTURE_2D, 0, O, g, v, 0, D, N, null),
- _.framebufferTexture2D(_.FRAMEBUFFER, L, _.TEXTURE_2D, M._hardwareTexture.underlyingResource, 0),
- M.baseWidth = g,
- M.baseHeight = v,
- M.width = g,
- M.height = v,
- M.isReady = !0,
- M.samples = 1,
- M.generateMipMaps = n,
- M.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE,
- M.format = l,
- M.type = I,
- y.push(M),
- this._internalTexturesCache.push(M)
- }
- return f.setTextures(y),
- i && _.drawBuffers(b),
- this._bindUnboundFramebuffer(null),
- this.resetTextureCache(),
- f
- }
- ,
- Ht.prototype.updateMultipleRenderTargetTextureSampleCount = function(e, t, i) {
- if (void 0 === i && (i = !0),
- this.webGLVersion < 2 || !e || !e.texture)
- return 1;
- if (e.samples === t)
- return t;
- var n = e._attachments.length;
- if (0 === n)
- return 1;
- var r = this._gl;
- t = Math.min(t, this.getCaps().maxMSAASamples),
- e._depthStencilBuffer && (r.deleteRenderbuffer(e._depthStencilBuffer),
- e._depthStencilBuffer = null),
- e._MSAAFramebuffer && (r.deleteFramebuffer(e._MSAAFramebuffer),
- e._MSAAFramebuffer = null);
- for (var o = 0; o < n; o++)
- (null == (c = e.textures[o]._hardwareTexture) ? void 0 : c._MSAARenderBuffer) && (r.deleteRenderbuffer(c._MSAARenderBuffer),
- c._MSAARenderBuffer = null);
- if (t > 1 && r.renderbufferStorageMultisample) {
- var a = r.createFramebuffer();
- if (!a)
- throw new Error("Unable to create multi sampled framebuffer");
- e._MSAAFramebuffer = a,
- this._bindUnboundFramebuffer(a);
- var s = [];
- for (o = 0; o < n; o++) {
- var l = e.textures[o]
- , c = l._hardwareTexture
- , u = r[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + o : "COLOR_ATTACHMENT" + o + "_WEBGL"]
- , h = this._createRenderBuffer(l.width, l.height, t, -1, this._getRGBAMultiSampleBufferFormat(l.type), u);
- if (!h)
- throw new Error("Unable to create multi sampled framebuffer");
- c._MSAARenderBuffer = h,
- l.samples = t,
- s.push(u)
- }
- i && r.drawBuffers(s)
- } else
- this._bindUnboundFramebuffer(e._framebuffer);
- return e._depthStencilBuffer = this._setupFramebufferDepthAttachments(e._generateStencilBuffer, e._generateDepthBuffer, e.texture.width, e.texture.height, t),
- this._bindUnboundFramebuffer(null),
- t
- }
- ,
- Ht.prototype._createDepthStencilCubeTexture = function(e, t, i) {
- var n = new Lt(this,At.DepthStencil);
- if (n.isCube = !0,
- 1 === this.webGLVersion)
- return K.Error("Depth cube texture is not supported by WebGL 1."),
- n;
- var r = V({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1
- }, t)
- , o = this._gl;
- this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, n, !0),
- this._setupDepthStencilTexture(n, e, r.generateStencil, r.bilinearFiltering, r.comparisonFunction),
- i._depthStencilTexture = n,
- i._depthStencilTextureWithStencil = r.generateStencil;
- for (var a = 0; a < 6; a++)
- r.generateStencil ? o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH24_STENCIL8, e, e, 0, o.DEPTH_STENCIL, o.UNSIGNED_INT_24_8, null) : o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X + a, 0, o.DEPTH_COMPONENT24, e, e, 0, o.DEPTH_COMPONENT, o.UNSIGNED_INT, null);
- return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP, null),
- this._internalTexturesCache.push(n),
- n
- }
- ,
- Ht.prototype._partialLoadFile = function(e, t, i, n, r) {
- void 0 === r && (r = null),
- this._loadFile(e, (function(e) {
- i[t] = e,
- i._internalCount++,
- 6 === i._internalCount && n(i)
- }
- ), void 0, void 0, !0, (function(e, t) {
- r && e && r(e.status + " " + e.statusText, t)
- }
- ))
- }
- ,
- Ht.prototype._cascadeLoadFiles = function(e, t, i, n) {
- void 0 === n && (n = null);
- var r = [];
- r._internalCount = 0;
- for (var o = 0; o < 6; o++)
- this._partialLoadFile(i[o], o, r, t, n)
- }
- ,
- Ht.prototype._cascadeLoadImgs = function(e, t, i, n, r, o) {
- void 0 === r && (r = null);
- var a = [];
- a._internalCount = 0;
- for (var s = 0; s < 6; s++)
- this._partialLoadImg(n[s], s, a, e, t, i, r, o)
- }
- ,
- Ht.prototype._partialLoadImg = function(e, t, i, n, r, o, a, s) {
- void 0 === a && (a = null);
- var l = fi();
- $t(e, (function(e) {
- i[t] = e,
- i._internalCount++,
- n && n._removePendingData(l),
- 6 === i._internalCount && o && o(r, i)
- }
- ), (function(e, t) {
- n && n._removePendingData(l),
- a && a(e, t)
- }
- ), n ? n.offlineProvider : null, s),
- n && n._addPendingData(l)
- }
- ,
- Ht.prototype._setCubeMapTextureParams = function(e, t, i) {
- var n = this._gl;
- n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAG_FILTER, n.LINEAR),
- n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MIN_FILTER, t ? n.LINEAR_MIPMAP_LINEAR : n.LINEAR),
- n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE),
- n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE),
- e.samplingMode = t ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : a.TEXTURE_LINEAR_LINEAR,
- t && this.getCaps().textureMaxLevel && void 0 !== i && i > 0 && (n.texParameteri(n.TEXTURE_CUBE_MAP, n.TEXTURE_MAX_LEVEL, i),
- e._maxLodLevel = i),
- this._bindTextureDirectly(n.TEXTURE_CUBE_MAP, null)
- }
- ,
- Ht.prototype.createCubeTextureBase = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f) {
- var _ = this;
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = !1),
- void 0 === c && (c = 0),
- void 0 === u && (u = 0),
- void 0 === h && (h = null),
- void 0 === d && (d = null),
- void 0 === p && (p = null),
- void 0 === f && (f = !1);
- var m = h || new Lt(this,At.Cube);
- m.isCube = !0,
- m.url = e,
- m.generateMipMaps = !n,
- m._lodGenerationScale = c,
- m._lodGenerationOffset = u,
- m._useSRGBBuffer = !!f && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!n),
- this._doNotHandleContextLost || (m._extension = s,
- m._files = i);
- var g = e;
- this._transformTextureUrl && !h && (e = this._transformTextureUrl(e));
- for (var v = e.lastIndexOf("."), y = s || (v > -1 ? e.substring(v).toLowerCase() : ""), b = null, T = 0, E = Ht._TextureLoaders; T < E.length; T++) {
- var S = E[T];
- if (S.canLoad(y)) {
- b = S;
- break
- }
- }
- if (b) {
- var A = function(e) {
- d && d(m, e),
- b.loadCubeData(e, m, l, r, o)
- };
- i && 6 === i.length ? b.supportCascades ? this._cascadeLoadFiles(t, (function(e) {
- return A(e.map((function(e) {
- return new Uint8Array(e)
- }
- )))
- }
- ), i, o) : o ? o("Textures type does not support cascades.") : K.Warn("Texture loader does not support cascades.") : this._loadFile(e, (function(e) {
- return A(new Uint8Array(e))
- }
- ), void 0, void 0, !0, (function(h, v) {
- e === g ? o && h && o(h.status + " " + h.statusText, v) : (K.Warn("Failed to load ".concat(e, ", falling back to the ").concat(g)),
- _.createCubeTextureBase(g, t, i, !!n, r, o, a, s, l, c, u, m, d, p, f))
- }
- ))
- } else {
- if (!i)
- throw new Error("Cannot load cubemap because files were not defined");
- this._cascadeLoadImgs(t, m, (function(e, t) {
- p && p(e, t)
- }
- ), i, o)
- }
- return this._internalTexturesCache.push(m),
- m
- }
- ,
- Ht.prototype.createCubeTexture = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p) {
- var f = this;
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = !1),
- void 0 === c && (c = 0),
- void 0 === u && (u = 0),
- void 0 === h && (h = null),
- void 0 === p && (p = !1);
- var _ = this._gl;
- return this.createCubeTextureBase(e, t, i, !!n, r, o, a, s, l, c, u, h, (function(e) {
- return f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0)
- }
- ), (function(e, t) {
- var i = f.needPOTTextures ? Ht.GetExponentOfTwo(t[0].width, f._caps.maxCubemapTextureSize) : t[0].width
- , o = i
- , s = [_.TEXTURE_CUBE_MAP_POSITIVE_X, _.TEXTURE_CUBE_MAP_POSITIVE_Y, _.TEXTURE_CUBE_MAP_POSITIVE_Z, _.TEXTURE_CUBE_MAP_NEGATIVE_X, _.TEXTURE_CUBE_MAP_NEGATIVE_Y, _.TEXTURE_CUBE_MAP_NEGATIVE_Z];
- f._bindTextureDirectly(_.TEXTURE_CUBE_MAP, e, !0),
- f._unpackFlipY(!1);
- var l = a ? f._getInternalFormat(a, e._useSRGBBuffer) : e._useSRGBBuffer ? _.SRGB8_ALPHA8 : _.RGBA
- , c = a ? f._getInternalFormat(a) : _.RGBA;
- e._useSRGBBuffer && 1 === f.webGLVersion && (c = l);
- for (var u = 0; u < s.length; u++)
- if (t[u].width !== i || t[u].height !== o) {
- if (f._prepareWorkingCanvas(),
- !f._workingCanvas || !f._workingContext)
- return void K.Warn("Cannot create canvas to resize texture.");
- f._workingCanvas.width = i,
- f._workingCanvas.height = o,
- f._workingContext.drawImage(t[u], 0, 0, t[u].width, t[u].height, 0, 0, i, o),
- _.texImage2D(s[u], 0, l, c, _.UNSIGNED_BYTE, f._workingCanvas)
- } else
- _.texImage2D(s[u], 0, l, c, _.UNSIGNED_BYTE, t[u]);
- n || _.generateMipmap(_.TEXTURE_CUBE_MAP),
- f._setCubeMapTextureParams(e, !n),
- e.width = i,
- e.height = o,
- e.isReady = !0,
- a && (e.format = a),
- e.onLoadedObservable.notifyObservers(e),
- e.onLoadedObservable.clear(),
- r && r()
- }
- ), !!p)
- }
- ,
- Ht.prototype.setTextureSampler = function(e, t) {
- throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!")
- }
- ;
- var mc = function() {};
- function gc(e) {
- if (this._excludedCompressedTextures && this._excludedCompressedTextures.some((function(t) {
- var i = "\\b" + t + "\\b";
- return e && (e === t || e.match(new RegExp(i,"g")))
- }
- )))
- return e;
- var t = e.lastIndexOf(".")
- , i = e.lastIndexOf("?")
- , n = i > -1 ? e.substring(i, e.length) : "";
- return (t > -1 ? e.substring(0, t) : e) + this._textureFormatInUse + n
- }
- Object.defineProperty(vr.prototype, "inputElement", {
- get: function() {
- return this._inputElement
- },
- set: function(e) {
- var t;
- this._inputElement !== e && (this._inputElement = e,
- null === (t = this._onEngineViewChanged) || void 0 === t || t.call(this))
- }
- }),
- vr.prototype.getInputElement = function() {
- return this.inputElement || this.getRenderingCanvas()
- }
- ,
- vr.prototype.registerView = function(e, t, i) {
- var n = this;
- this.views || (this.views = []);
- for (var r = 0, o = this.views; r < o.length; r++) {
- var a = o[r];
- if (a.target === e)
- return a
- }
- var s = this.getRenderingCanvas();
- s && (e.width = s.width,
- e.height = s.height);
- var l = {
- target: e,
- camera: t,
- clearBeforeCopy: i,
- enabled: !0
- };
- return this.views.push(l),
- t && t.onDisposeObservable.add((function() {
- n.unRegisterView(e)
- }
- )),
- l
- }
- ,
- vr.prototype.unRegisterView = function(e) {
- if (!this.views)
- return this;
- for (var t = 0, i = this.views; t < i.length; t++) {
- var n = i[t];
- if (n.target === e) {
- var r = this.views.indexOf(n);
- -1 !== r && this.views.splice(r, 1);
- break
- }
- }
- return this
- }
- ,
- vr.prototype._renderViews = function() {
- if (!this.views)
- return !1;
- var e = this.getRenderingCanvas();
- if (!e)
- return !1;
- for (var t = 0, i = this.views; t < i.length; t++) {
- var n = i[t];
- if (n.enabled) {
- var r = n.target
- , o = r.getContext("2d");
- if (o) {
- var a = n.camera
- , s = null
- , l = null;
- if (a) {
- if ((l = a.getScene()).activeCameras && l.activeCameras.length)
- continue;
- this.activeView = n,
- s = l.activeCamera,
- l.activeCamera = a
- }
- if (n.customResize)
- n.customResize(r);
- else {
- var c = Math.floor(r.clientWidth / this._hardwareScalingLevel)
- , u = Math.floor(r.clientHeight / this._hardwareScalingLevel)
- , h = c !== r.width || e.width !== r.width || u !== r.height || e.height !== r.height;
- r.clientWidth && r.clientHeight && h && (r.width = c,
- r.height = u,
- this.setSize(c, u))
- }
- if (!e.width || !e.height)
- return !1;
- this._renderFrame(),
- this.flushFramebuffer(),
- n.clearBeforeCopy && o.clearRect(0, 0, e.width, e.height),
- o.drawImage(e, 0, 0),
- s && l && (l.activeCamera = s)
- }
- }
- }
- return this.activeView = null,
- !0
- }
- ,
- Ht.prototype.createStorageBuffer = function(e, t) {
- throw new Error("createStorageBuffer: Unsupported method in this engine!")
- }
- ,
- Ht.prototype.updateStorageBuffer = function(e, t, i, n) {}
- ,
- Ht.prototype.readFromStorageBuffer = function(e, t, i, n) {
- throw new Error("readFromStorageBuffer: Unsupported method in this engine!")
- }
- ,
- Ht.prototype.setStorageBuffer = function(e, t) {
- throw new Error("setStorageBuffer: Unsupported method in this engine!")
- }
- ,
- Object.defineProperty(vr.prototype, "texturesSupported", {
- get: function() {
- var e = new Array;
- return this._caps.astc && e.push("-astc.ktx"),
- this._caps.s3tc && e.push("-dxt.ktx"),
- this._caps.pvrtc && e.push("-pvrtc.ktx"),
- this._caps.etc2 && e.push("-etc2.ktx"),
- this._caps.etc1 && e.push("-etc1.ktx"),
- e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(vr.prototype, "textureFormatInUse", {
- get: function() {
- return this._textureFormatInUse || null
- },
- enumerable: !0,
- configurable: !0
- }),
- vr.prototype.setCompressedTextureExclusions = function(e) {
- this._excludedCompressedTextures = e
- }
- ,
- vr.prototype.setTextureFormatToUse = function(e) {
- for (var t = this.texturesSupported, i = 0, n = t.length; i < n; i++)
- for (var r = 0, o = e.length; r < o; r++)
- if (t[i] === e[r].toLowerCase())
- return this._transformTextureUrl = gc.bind(this),
- this._textureFormatInUse = t[i];
- return this._textureFormatInUse = "",
- this._transformTextureUrl = null,
- null
- }
- ;
- var vc, yc, bc = function() {
- function e() {
- var t = this
- , i = new ArrayBuffer(e.DEFAULT_BUFFER_SIZE);
- this._uint32s = new Uint32Array(i),
- this._int32s = new Int32Array(i),
- this._float32s = new Float32Array(i),
- this._length = e.DEFAULT_BUFFER_SIZE / 4,
- this._position = 0,
- this._nativeDataStream = new _native.NativeDataStream((function() {
- t._flush()
- }
- ))
- }
- return e.prototype.writeUint32 = function(e) {
- this._flushIfNecessary(1),
- this._uint32s[this._position++] = e
- }
- ,
- e.prototype.writeInt32 = function(e) {
- this._flushIfNecessary(1),
- this._int32s[this._position++] = e
- }
- ,
- e.prototype.writeFloat32 = function(e) {
- this._flushIfNecessary(1),
- this._float32s[this._position++] = e
- }
- ,
- e.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
- }
- ,
- e.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
- }
- ,
- e.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
- }
- ,
- e.prototype.writeNativeData = function(e) {
- this._flushIfNecessary(e.length),
- this._uint32s.set(e, this._position),
- this._position += e.length
- }
- ,
- e.prototype.writeBoolean = function(e) {
- this.writeUint32(e ? 1 : 0)
- }
- ,
- e.prototype._flushIfNecessary = function(e) {
- this._position + e > this._length && this._flush()
- }
- ,
- e.prototype._flush = function() {
- this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position),
- this._position = 0
- }
- ,
- e.DEFAULT_BUFFER_SIZE = 65536,
- e
- }(), Tc = function() {
- function e(e, t) {
- void 0 === e && (e = x.Zero()),
- void 0 === t && (t = x.Up()),
- this.position = e,
- this.normal = t
- }
- return e.prototype.clone = function() {
- return new e(this.position.clone(),this.normal.clone())
- }
- ,
- e
- }(), Ec = function() {
- function e(e, t, i) {
- void 0 === e && (e = x.Zero()),
- void 0 === t && (t = x.Up()),
- void 0 === i && (i = A.Zero()),
- this.position = e,
- this.normal = t,
- this.uv = i
- }
- return e.prototype.clone = function() {
- return new e(this.position.clone(),this.normal.clone(),this.uv.clone())
- }
- ,
- e
- }(), Sc = [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))], Ac = [function() {
- return 1
- }
- , function(e) {
- return e.y
- }
- , function(e) {
- return e.z
- }
- , function(e) {
- return e.x
- }
- , function(e) {
- return e.x * e.y
- }
- , function(e) {
- return e.y * e.z
- }
- , function(e) {
- return 3 * e.z * e.z - 1
- }
- , function(e) {
- return e.x * e.z
- }
- , function(e) {
- return e.x * e.x - e.y * e.y
- }
- ], xc = function(e, t) {
- return Sc[e] * Ac[e](t)
- }, Rc = [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], Cc = function() {
- function e() {
- this.preScaled = !1,
- this.l00 = x.Zero(),
- this.l1_1 = x.Zero(),
- this.l10 = x.Zero(),
- this.l11 = x.Zero(),
- this.l2_2 = x.Zero(),
- this.l2_1 = x.Zero(),
- this.l20 = x.Zero(),
- this.l21 = x.Zero(),
- this.l22 = x.Zero()
- }
- return e.prototype.addLight = function(e, t, i) {
- I.Vector3[0].set(t.r, t.g, t.b);
- var n = I.Vector3[0]
- , r = I.Vector3[1];
- n.scaleToRef(i, r),
- r.scaleToRef(xc(0, e), I.Vector3[2]),
- this.l00.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(1, e), I.Vector3[2]),
- this.l1_1.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(2, e), I.Vector3[2]),
- this.l10.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(3, e), I.Vector3[2]),
- this.l11.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(4, e), I.Vector3[2]),
- this.l2_2.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(5, e), I.Vector3[2]),
- this.l2_1.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(6, e), I.Vector3[2]),
- this.l20.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(7, e), I.Vector3[2]),
- this.l21.addInPlace(I.Vector3[2]),
- r.scaleToRef(xc(8, e), I.Vector3[2]),
- this.l22.addInPlace(I.Vector3[2])
- }
- ,
- e.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)
- }
- ,
- e.prototype.convertIncidentRadianceToIrradiance = function() {
- this.l00.scaleInPlace(Rc[0]),
- this.l1_1.scaleInPlace(Rc[1]),
- this.l10.scaleInPlace(Rc[2]),
- this.l11.scaleInPlace(Rc[3]),
- this.l2_2.scaleInPlace(Rc[4]),
- this.l2_1.scaleInPlace(Rc[5]),
- this.l20.scaleInPlace(Rc[6]),
- this.l21.scaleInPlace(Rc[7]),
- this.l22.scaleInPlace(Rc[8])
- }
- ,
- e.prototype.convertIrradianceToLambertianRadiance = function() {
- this.scaleInPlace(1 / Math.PI)
- }
- ,
- e.prototype.preScaleForRendering = function() {
- this.preScaled = !0,
- this.l00.scaleInPlace(Sc[0]),
- this.l1_1.scaleInPlace(Sc[1]),
- this.l10.scaleInPlace(Sc[2]),
- this.l11.scaleInPlace(Sc[3]),
- this.l2_2.scaleInPlace(Sc[4]),
- this.l2_1.scaleInPlace(Sc[5]),
- this.l20.scaleInPlace(Sc[6]),
- this.l21.scaleInPlace(Sc[7]),
- this.l22.scaleInPlace(Sc[8])
- }
- ,
- e.prototype.updateFromArray = function(e) {
- return x.FromArrayToRef(e[0], 0, this.l00),
- x.FromArrayToRef(e[1], 0, this.l1_1),
- x.FromArrayToRef(e[2], 0, this.l10),
- x.FromArrayToRef(e[3], 0, this.l11),
- x.FromArrayToRef(e[4], 0, this.l2_2),
- x.FromArrayToRef(e[5], 0, this.l2_1),
- x.FromArrayToRef(e[6], 0, this.l20),
- x.FromArrayToRef(e[7], 0, this.l21),
- x.FromArrayToRef(e[8], 0, this.l22),
- this
- }
- ,
- e.prototype.updateFromFloatsArray = function(e) {
- return x.FromFloatsToRef(e[0], e[1], e[2], this.l00),
- x.FromFloatsToRef(e[3], e[4], e[5], this.l1_1),
- x.FromFloatsToRef(e[6], e[7], e[8], this.l10),
- x.FromFloatsToRef(e[9], e[10], e[11], this.l11),
- x.FromFloatsToRef(e[12], e[13], e[14], this.l2_2),
- x.FromFloatsToRef(e[15], e[16], e[17], this.l2_1),
- x.FromFloatsToRef(e[18], e[19], e[20], this.l20),
- x.FromFloatsToRef(e[21], e[22], e[23], this.l21),
- x.FromFloatsToRef(e[24], e[25], e[26], this.l22),
- this
- }
- ,
- e.FromArray = function(t) {
- return (new e).updateFromArray(t)
- }
- ,
- e.FromPolynomial = function(t) {
- var i = new e;
- return i.l00 = t.xx.scale(.376127).add(t.yy.scale(.376127)).add(t.zz.scale(.376126)),
- i.l1_1 = t.y.scale(.977204),
- i.l10 = t.z.scale(.977204),
- i.l11 = t.x.scale(.977204),
- i.l2_2 = t.xy.scale(1.16538),
- i.l2_1 = t.yz.scale(1.16538),
- i.l20 = t.zz.scale(1.34567).subtract(t.xx.scale(.672834)).subtract(t.yy.scale(.672834)),
- i.l21 = t.zx.scale(1.16538),
- i.l22 = t.xx.scale(1.16538).subtract(t.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
- }
- ,
- e
- }(), Pc = function() {
- function e() {
- this.x = x.Zero(),
- this.y = x.Zero(),
- this.z = x.Zero(),
- this.xx = x.Zero(),
- this.yy = x.Zero(),
- this.zz = x.Zero(),
- this.xy = x.Zero(),
- this.yz = x.Zero(),
- this.zx = x.Zero()
- }
- return Object.defineProperty(e.prototype, "preScaledHarmonics", {
- get: function() {
- return this._harmonics || (this._harmonics = Cc.FromPolynomial(this)),
- this._harmonics.preScaled || this._harmonics.preScaleForRendering(),
- this._harmonics
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addAmbient = function(e) {
- I.Vector3[0].copyFromFloats(e.r, e.g, e.b);
- var t = I.Vector3[0];
- this.xx.addInPlace(t),
- this.yy.addInPlace(t),
- this.zz.addInPlace(t)
- }
- ,
- e.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)
- }
- ,
- e.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),
- I.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),
- I.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),
- this.xx.scaleInPlace(.886277).subtractInPlace(I.Vector3[0]).addInPlace(I.Vector3[1]),
- this.yy.copyFrom(e.l00),
- this.yy.scaleInPlace(.886277).subtractInPlace(I.Vector3[0]).subtractInPlace(I.Vector3[1]),
- this.zz.copyFrom(e.l00),
- I.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),
- this.zz.scaleInPlace(.886277).addInPlace(I.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
- }
- ,
- e.FromHarmonics = function(t) {
- return (new e).updateFromHarmonics(t)
- }
- ,
- e.FromArray = function(t) {
- var i = new e;
- return x.FromArrayToRef(t[0], 0, i.x),
- x.FromArrayToRef(t[1], 0, i.y),
- x.FromArrayToRef(t[2], 0, i.z),
- x.FromArrayToRef(t[3], 0, i.xx),
- x.FromArrayToRef(t[4], 0, i.yy),
- x.FromArrayToRef(t[5], 0, i.zz),
- x.FromArrayToRef(t[6], 0, i.yz),
- x.FromArrayToRef(t[7], 0, i.zx),
- x.FromArrayToRef(t[8], 0, i.xy),
- i
- }
- ,
- e
- }();
- function Mc(e, t, i, n) {
- void 0 === n && (n = !0);
- var r = e.getScene()
- , o = r.getEngine()
- , s = new ns("resized" + e.name,{
- width: t,
- height: i
- },r,!e.noMipmap,!0,e._texture.type,!1,e.samplingMode,!1);
- s.wrapU = e.wrapU,
- s.wrapV = e.wrapV,
- s.uOffset = e.uOffset,
- s.vOffset = e.vOffset,
- s.uScale = e.uScale,
- s.vScale = e.vScale,
- s.uAng = e.uAng,
- s.vAng = e.vAng,
- s.wAng = e.wAng,
- s.coordinatesIndex = e.coordinatesIndex,
- s.level = e.level,
- s.anisotropicFilteringLevel = e.anisotropicFilteringLevel,
- s._texture.isReady = !1,
- e.wrapU = io.CLAMP_ADDRESSMODE,
- e.wrapV = io.CLAMP_ADDRESSMODE;
- var l = new Ua("pass",1,null,n ? io.BILINEAR_SAMPLINGMODE : io.NEAREST_SAMPLINGMODE,o,!1,a.TEXTURETYPE_UNSIGNED_INT);
- return l.externalTextureSamplerBinding = !0,
- l.getEffect().executeWhenCompiled((function() {
- l.onApply = function(t) {
- t.setTexture("textureSampler", e)
- }
- ;
- var t = s.renderTarget;
- t && (r.postProcessManager.directRender([l], t),
- o.unBindFramebuffer(t),
- s.disposeFramebufferObjects(),
- l.dispose(),
- s.getInternalTexture().isReady = !0)
- }
- )),
- s
- }
- function Ic(e, t, i, n, r, o) {
- var s = t.getEngine();
- return t.isReady = !1,
- r = null != r ? r : t.samplingMode,
- n = null != n ? n : t.type,
- o = null != o ? o : t.format,
- -1 === n && (n = a.TEXTURETYPE_UNSIGNED_BYTE),
- new Promise((function(l) {
- var c = new Ba("postprocess",e,null,null,1,null,r,s,!1,void 0,n,void 0,null,!1,o);
- c.externalTextureSamplerBinding = !0;
- var u = s.createRenderTargetTexture({
- width: t.width,
- height: t.height
- }, {
- generateDepthBuffer: !1,
- generateMipMaps: !1,
- generateStencilBuffer: !1,
- samplingMode: r,
- type: n,
- format: o
- });
- c.getEffect().executeWhenCompiled((function() {
- c.onApply = function(e) {
- e._bindTexture("textureSampler", t),
- e.setFloat2("scale", 1, 1)
- }
- ,
- i.postProcessManager.directRender([c], u, !0),
- s.restoreDefaultFramebuffer(),
- s._releaseTexture(t),
- c && c.dispose(),
- u._swapAndDie(t),
- t.type = n,
- t.format = a.TEXTUREFORMAT_RGBA,
- t.isReady = !0,
- l(t)
- }
- ))
- }
- ))
- }
- function Oc(e) {
- vc || (vc = new Float32Array(1),
- yc = new Int32Array(vc.buffer)),
- vc[0] = e;
- var t = yc[0]
- , i = t >> 16 & 32768
- , n = t >> 12 & 2047
- , r = t >> 23 & 255;
- return r < 103 ? i : r > 142 ? (i |= 31744,
- i |= (255 == r ? 0 : 1) && 8388607 & t) : r < 113 ? i |= ((n |= 2048) >> 114 - r) + (n >> 113 - r & 1) : (i |= r - 112 << 10 | n >> 1,
- i += 1 & n)
- }
- function Dc(e) {
- var t = (32768 & e) >> 15
- , i = (31744 & e) >> 10
- , n = 1023 & e;
- return 0 === i ? (t ? -1 : 1) * Math.pow(2, -14) * (n / Math.pow(2, 10)) : 31 == i ? n ? NaN : 1 / 0 * (t ? -1 : 1) : (t ? -1 : 1) * Math.pow(2, i - 15) * (1 + n / Math.pow(2, 10))
- }
- Pt.ShadersStore.rgbdDecodePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";
- var Nc = {
- CreateResizedCopy: Mc,
- ApplyPostProcess: Ic,
- ToHalfFloat: Oc,
- FromHalfFloat: Dc
- }
- , Lc = function() {
- function e() {}
- return e.ExpandRGBDTexture = function(e) {
- var t = e._texture;
- if (t && e.isRGBD) {
- var i = t.getEngine()
- , n = i.getCaps()
- , r = t.isReady
- , o = !1;
- n.textureHalfFloatRender && n.textureHalfFloatLinearFiltering ? (o = !0,
- t.type = a.TEXTURETYPE_HALF_FLOAT) : n.textureFloatRender && n.textureFloatLinearFiltering && (o = !0,
- t.type = a.TEXTURETYPE_FLOAT),
- o && (t.isReady = !1,
- t._isRGBD = !1,
- t.invertY = !1);
- var s = function() {
- if (o) {
- var n = new Ba("rgbdDecode","rgbdDecode",null,null,1,null,a.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!1,void 0,t.type,void 0,null,!1);
- n.externalTextureSamplerBinding = !0;
- var r = i.createRenderTargetTexture(t.width, {
- generateDepthBuffer: !1,
- generateMipMaps: !1,
- generateStencilBuffer: !1,
- samplingMode: t.samplingMode,
- type: t.type,
- format: a.TEXTUREFORMAT_RGBA
- });
- n.getEffect().executeWhenCompiled((function() {
- n.onApply = function(e) {
- e._bindTexture("textureSampler", t),
- e.setFloat2("scale", 1, 1)
- }
- ,
- e.getScene().postProcessManager.directRender([n], r, !0),
- i.restoreDefaultFramebuffer(),
- i._releaseTexture(t),
- n && n.dispose(),
- r._swapAndDie(t),
- t.isReady = !0
- }
- ))
- }
- };
- r ? s() : e.onLoadObservable.addOnce(s)
- }
- }
- ,
- e.EncodeTextureToRGBD = function(e, t, i) {
- return void 0 === i && (i = a.TEXTURETYPE_UNSIGNED_BYTE),
- Ic("rgbdEncode", e, t, i, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTUREFORMAT_RGBA)
- }
- ,
- e
- }()
- , Fc = function(e, t, i, n) {
- this.name = e,
- this.worldAxisForNormal = t,
- this.worldAxisForFileX = i,
- this.worldAxisForFileY = n
- }
- , wc = function() {
- function e() {}
- return e.ConvertCubeMapTextureToSphericalPolynomial = function(e) {
- var t, i = this;
- if (!e.isCube)
- return null;
- null === (t = e.getScene()) || void 0 === t || t.getEngine().flushFramebuffer();
- var n, r, o = e.getSize().width, s = e.readPixels(0, void 0, void 0, !1), l = e.readPixels(1, void 0, void 0, !1);
- e.isRenderTarget ? (n = e.readPixels(3, void 0, void 0, !1),
- r = e.readPixels(2, void 0, void 0, !1)) : (n = e.readPixels(2, void 0, void 0, !1),
- r = e.readPixels(3, void 0, void 0, !1));
- var c = e.readPixels(4, void 0, void 0, !1)
- , u = e.readPixels(5, void 0, void 0, !1)
- , h = e.gammaSpace
- , d = a.TEXTUREFORMAT_RGBA
- , p = a.TEXTURETYPE_UNSIGNED_INT;
- return e.textureType != a.TEXTURETYPE_FLOAT && e.textureType != a.TEXTURETYPE_HALF_FLOAT || (p = a.TEXTURETYPE_FLOAT),
- new Promise((function(e) {
- Promise.all([l, s, n, r, c, u]).then((function(t) {
- var n = t[0]
- , r = t[1]
- , a = t[2]
- , s = t[3]
- , l = t[4]
- , c = t[5]
- , u = {
- size: o,
- right: r,
- left: n,
- up: a,
- down: s,
- front: l,
- back: c,
- format: d,
- type: p,
- gammaSpace: h
- };
- e(i.ConvertCubeMapToSphericalPolynomial(u))
- }
- ))
- }
- ))
- }
- ,
- e._AreaElement = function(e, t) {
- return Math.atan2(e * t, Math.sqrt(e * e + t * t + 1))
- }
- ,
- e.ConvertCubeMapToSphericalPolynomial = function(e) {
- for (var t = new Cc, i = 0, n = 2 / e.size, r = n, o = .5 * n, s = o - 1, l = 0; l < 6; l++)
- for (var c = this._FileFaces[l], u = e[c.name], h = s, p = e.format === a.TEXTUREFORMAT_RGBA ? 4 : 3, _ = 0; _ < e.size; _++) {
- for (var m = s, g = 0; g < e.size; g++) {
- var v = c.worldAxisForFileX.scale(m).add(c.worldAxisForFileY.scale(h)).add(c.worldAxisForNormal);
- v.normalize();
- var y = this._AreaElement(m - o, h - o) - this._AreaElement(m - o, h + o) - this._AreaElement(m + o, h - o) + this._AreaElement(m + o, h + o)
- , b = u[_ * e.size * p + g * p + 0]
- , T = u[_ * e.size * p + g * p + 1]
- , E = u[_ * e.size * p + g * p + 2];
- isNaN(b) && (b = 0),
- isNaN(T) && (T = 0),
- isNaN(E) && (E = 0),
- e.type === a.TEXTURETYPE_UNSIGNED_INT && (b /= 255,
- T /= 255,
- E /= 255),
- e.gammaSpace && (b = Math.pow(d.Clamp(b), f),
- T = Math.pow(d.Clamp(T), f),
- E = Math.pow(d.Clamp(E), f));
- var S = 4096;
- b = d.Clamp(b, 0, S),
- T = d.Clamp(T, 0, S),
- E = d.Clamp(E, 0, S);
- var A = new D(b,T,E);
- t.addLight(v, A, y),
- i += y,
- m += n
- }
- h += r
- }
- var x = 4 * Math.PI * 6 / 6 / i;
- return t.scaleInPlace(x),
- t.convertIncidentRadianceToIrradiance(),
- t.convertIrradianceToLambertianRadiance(),
- Pc.FromHarmonics(t)
- }
- ,
- e._FileFaces = [new Fc("right",new x(1,0,0),new x(0,0,-1),new x(0,-1,0)), new Fc("left",new x(-1,0,0),new x(0,0,1),new x(0,-1,0)), new Fc("up",new x(0,1,0),new x(1,0,0),new x(0,0,1)), new Fc("down",new x(0,-1,0),new x(1,0,0),new x(0,0,-1)), new Fc("front",new x(0,0,1),new x(1,0,0),new x(0,-1,0)), new Fc("back",new x(0,0,-1),new x(-1,0,0),new x(0,-1,0))],
- e
- }();
- Zr.prototype.forceSphericalPolynomialsRecompute = function() {
- this._texture && (this._texture._sphericalPolynomial = null,
- this._texture._sphericalPolynomialPromise = null,
- this._texture._sphericalPolynomialComputed = !1)
- }
- ,
- Object.defineProperty(Zr.prototype, "sphericalPolynomial", {
- get: function() {
- var e = 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 = wc.ConvertCubeMapTextureToSphericalPolynomial(this),
- null === this._texture._sphericalPolynomialPromise ? this._texture._sphericalPolynomialComputed = !0 : this._texture._sphericalPolynomialPromise.then((function(t) {
- e._texture._sphericalPolynomial = t,
- e._texture._sphericalPolynomialComputed = !0
- }
- ))),
- null
- }
- return null
- },
- set: function(e) {
- this._texture && (this._texture._sphericalPolynomial = e)
- },
- enumerable: !0,
- configurable: !0
- });
- Pt.ShadersStore.rgbdEncodePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
- var Bc = "image/png"
- , Uc = [134, 22, 135, 150, 246, 214, 150, 54];
- function Vc(e) {
- for (var t = new DataView(e.buffer,e.byteOffset,e.byteLength), i = 0, n = 0; n < Uc.length; n++)
- if (t.getUint8(i++) !== Uc[n])
- return K.Error("Not a babylon environment map"),
- null;
- for (var r = "", o = 0; o = t.getUint8(i++); )
- r += String.fromCharCode(o);
- var a = JSON.parse(r);
- return (a = kc(a)).specular && (a.specular.specularDataPosition = i,
- a.specular.lodGenerationScale = a.specular.lodGenerationScale || .8),
- a
- }
- function kc(e) {
- if (e.version > 2)
- throw new Error('Unsupported babylon environment map version "'.concat(e.version, '". Latest supported version is "').concat(2, '".'));
- return 2 === e.version ? e : e = V(V({}, e), {
- version: 2,
- imageType: Bc
- })
- }
- function Gc(e, t) {
- var i;
- return void 0 === t && (t = {}),
- G(this, void 0, void 0, (function() {
- var n, r, o, s, l, c, u, h, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D, N, L;
- return z(this, (function(F) {
- switch (F.label) {
- case 0:
- if (!(n = e.getInternalTexture()))
- return [2, Promise.reject("The cube texture is invalid.")];
- if (r = null !== (i = t.imageType) && void 0 !== i ? i : Bc,
- o = n.getEngine(),
- e.textureType !== a.TEXTURETYPE_HALF_FLOAT && e.textureType !== a.TEXTURETYPE_FLOAT && e.textureType !== a.TEXTURETYPE_UNSIGNED_BYTE && e.textureType !== a.TEXTURETYPE_UNSIGNED_INT && e.textureType !== a.TEXTURETYPE_UNSIGNED_INTEGER && -1 !== e.textureType)
- return [2, Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];
- if (s = a.TEXTURETYPE_FLOAT,
- !o.getCaps().textureFloatRender && (s = a.TEXTURETYPE_HALF_FLOAT,
- !o.getCaps().textureHalfFloatRender))
- return [2, Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];
- l = n.width,
- c = new mn(o),
- u = {},
- o.flushFramebuffer(),
- h = d.ILog2(n.width),
- D = 0,
- F.label = 1;
- case 1:
- if (!(D <= h))
- return [3, 9];
- p = Math.pow(2, h - D),
- N = 0,
- F.label = 2;
- case 2:
- return N < 6 ? [4, e.readPixels(N, D, void 0, !1)] : [3, 8];
- case 3:
- if ((f = F.sent()) && f.byteLength === f.length) {
- for (_ = new Float32Array(4 * f.byteLength),
- m = 0; m < f.byteLength; m++)
- _[m] = f[m] / 255,
- _[m] = Math.pow(_[m], 2.2);
- f = _
- }
- return g = o.createRawTexture(f, p, p, a.TEXTUREFORMAT_RGBA, !1, !0, a.TEXTURE_NEAREST_SAMPLINGMODE, null, s),
- [4, Lc.EncodeTextureToRGBD(g, c, s)];
- case 4:
- return F.sent(),
- [4, o._readTexturePixels(g, p, p)];
- case 5:
- return v = F.sent(),
- [4, gi.DumpDataAsync(p, p, v, r, void 0, !1, !0, t.imageQuality)];
- case 6:
- y = F.sent(),
- u[6 * D + N] = y,
- g.dispose(),
- F.label = 7;
- case 7:
- return N++,
- [3, 2];
- case 8:
- return D++,
- [3, 1];
- case 9:
- for (c.dispose(),
- b = {
- version: 2,
- width: l,
- imageType: r,
- irradiance: zc(e),
- specular: {
- mipmaps: [],
- lodGenerationScale: e.lodGenerationScale
- }
- },
- T = 0,
- D = 0; D <= h; D++)
- for (N = 0; N < 6; N++)
- E = u[6 * D + N].byteLength,
- b.specular.mipmaps.push({
- length: E,
- position: T
- }),
- T += E;
- for (S = JSON.stringify(b),
- A = new ArrayBuffer(S.length + 1),
- x = new Uint8Array(A),
- D = 0,
- R = S.length; D < R; D++)
- x[D] = S.charCodeAt(D);
- for (x[S.length] = 0,
- C = Uc.length + T + A.byteLength,
- P = new ArrayBuffer(C),
- M = new Uint8Array(P),
- I = new DataView(P),
- O = 0,
- D = 0; D < Uc.length; D++)
- I.setUint8(O++, Uc[D]);
- for (M.set(new Uint8Array(A), O),
- O += A.byteLength,
- D = 0; D <= h; D++)
- for (N = 0; N < 6; N++)
- L = u[6 * D + N],
- M.set(new Uint8Array(L), O),
- O += L.byteLength;
- return [2, P]
- }
- }
- ))
- }
- ))
- }
- function zc(e) {
- var t = e.sphericalPolynomial;
- return null == t ? null : {
- x: [t.x.x, t.x.y, t.x.z],
- y: [t.y.x, t.y.y, t.y.z],
- z: [t.z.x, t.z.y, t.z.z],
- xx: [t.xx.x, t.xx.y, t.xx.z],
- yy: [t.yy.x, t.yy.y, t.yy.z],
- zz: [t.zz.x, t.zz.y, t.zz.z],
- yz: [t.yz.x, t.yz.y, t.yz.z],
- zx: [t.zx.x, t.zx.y, t.zx.z],
- xy: [t.xy.x, t.xy.y, t.xy.z]
- }
- }
- function Wc(e, t) {
- var i = (t = kc(t)).specular
- , n = d.Log2(t.width);
- if (n = Math.round(n) + 1,
- i.mipmaps.length !== 6 * n)
- throw new Error('Unsupported specular mipmaps number "'.concat(i.mipmaps.length, '"'));
- for (var r = new Array(n), o = 0; o < n; o++) {
- r[o] = new Array(6);
- for (var a = 0; a < 6; a++) {
- var s = i.mipmaps[6 * o + a];
- r[o][a] = new Uint8Array(e.buffer,e.byteOffset + i.specularDataPosition + s.position,s.length)
- }
- }
- return r
- }
- function Hc(e, t, i) {
- var n = (i = kc(i)).specular;
- return n ? (e._lodGenerationScale = n.lodGenerationScale,
- jc(e, Wc(t, i), i.imageType)) : Promise.resolve()
- }
- function Xc(e, t, i, n, r, o, s, l, c, u, h) {
- return new Promise((function(d, p) {
- if (i) {
- var f = t.createTexture(null, !0, !0, null, a.TEXTURE_NEAREST_SAMPLINGMODE, null, (function(e) {
- p(e)
- }
- ), e);
- n.getEffect().executeWhenCompiled((function() {
- n.externalTextureSamplerBinding = !0,
- n.onApply = function(i) {
- i._bindTexture("textureSampler", f),
- i.setFloat2("scale", 1, t._features.needsInvertingBitmap && e instanceof ImageBitmap ? -1 : 1)
- }
- ,
- t.scenes.length && (t.scenes[0].postProcessManager.directRender([n], u, !0, o, s),
- t.restoreDefaultFramebuffer(),
- f.dispose(),
- URL.revokeObjectURL(r),
- d())
- }
- ))
- } else {
- if (t._uploadImageToTexture(h, e, o, s),
- l) {
- var _ = c[s];
- _ && t._uploadImageToTexture(_._texture, e, o, 0)
- }
- d()
- }
- }
- ))
- }
- function jc(e, t, i) {
- if (void 0 === i && (i = Bc),
- !gi.IsExponentOfTwo(e.width))
- throw new Error("Texture size must be a power of two");
- var n = d.ILog2(e.width) + 1
- , r = e.getEngine()
- , o = !1
- , s = !1
- , l = null
- , c = null
- , u = null
- , h = r.getCaps();
- if (e.format = a.TEXTUREFORMAT_RGBA,
- e.type = a.TEXTURETYPE_UNSIGNED_INT,
- e.generateMipMaps = !0,
- e._cachedAnisotropicFilteringLevel = null,
- r.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, e),
- h.textureLOD ? r._features.supportRenderAndCopyToLodForFloatTextures ? h.textureHalfFloatRender && h.textureHalfFloatLinearFiltering ? (o = !0,
- e.type = a.TEXTURETYPE_HALF_FLOAT) : h.textureFloatRender && h.textureFloatLinearFiltering && (o = !0,
- e.type = a.TEXTURETYPE_FLOAT) : o = !1 : (o = !1,
- s = !0,
- u = {}),
- o)
- l = new Ba("rgbdDecode","rgbdDecode",null,null,1,null,a.TEXTURE_TRILINEAR_SAMPLINGMODE,r,!1,void 0,e.type,void 0,null,!1),
- e._isRGBD = !1,
- e.invertY = !1,
- c = r.createRenderTargetCubeTexture(e.width, {
- generateDepthBuffer: !1,
- generateMipMaps: !0,
- generateStencilBuffer: !1,
- samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- type: e.type,
- format: a.TEXTUREFORMAT_RGBA
- });
- else if (e._isRGBD = !0,
- e.invertY = !0,
- s)
- for (var p = e._lodGenerationScale, f = e._lodGenerationOffset, _ = 0; _ < 3; _++) {
- var m = (n - 1) * p + f
- , g = f + (m - f) * (1 - _ / 2)
- , v = Math.round(Math.min(Math.max(g, 0), m))
- , y = new Lt(r,At.Temp);
- y.isCube = !0,
- y.invertY = !0,
- y.generateMipMaps = !1,
- r.updateTextureSamplingMode(a.TEXTURE_LINEAR_LINEAR, y);
- var b = new Zr(null);
- switch (b.isCube = !0,
- b._texture = y,
- u[v] = b,
- _) {
- case 0:
- e._lodTextureLow = b;
- break;
- case 1:
- e._lodTextureMid = b;
- break;
- case 2:
- e._lodTextureHigh = b
- }
- }
- var T = []
- , E = function(n) {
- for (var a = function(a) {
- var h = t[n][a]
- , d = new Blob([h],{
- type: i
- })
- , p = URL.createObjectURL(d)
- , f = void 0;
- if ("undefined" == typeof Image || r._features.forceBitmapOverHTMLImageElement)
- f = r.createImageBitmap(d, {
- premultiplyAlpha: "none"
- }).then((function(t) {
- return Xc(t, r, o, l, p, a, n, s, u, c, e)
- }
- ));
- else {
- var _ = new Image;
- _.src = p,
- f = new Promise((function(t, i) {
- _.onload = function() {
- Xc(_, r, o, l, p, a, n, s, u, c, e).then((function() {
- return t()
- }
- )).catch((function(e) {
- i(e)
- }
- ))
- }
- ,
- _.onerror = function(e) {
- i(e)
- }
- }
- ))
- }
- T.push(f)
- }, h = 0; h < 6; h++)
- a(h)
- };
- for (_ = 0; _ < t.length; _++)
- E(_);
- if (t.length < n) {
- var S = void 0
- , A = Math.pow(2, n - 1 - t.length)
- , x = A * A * 4;
- switch (e.type) {
- case a.TEXTURETYPE_UNSIGNED_INT:
- S = new Uint8Array(x);
- break;
- case a.TEXTURETYPE_HALF_FLOAT:
- S = new Uint16Array(x);
- break;
- case a.TEXTURETYPE_FLOAT:
- S = new Float32Array(x)
- }
- for (_ = t.length; _ < n; _++)
- for (var R = 0; R < 6; R++)
- r._uploadArrayBufferViewToTexture(e, S, R, _)
- }
- return Promise.all(T).then((function() {
- c && (r._releaseTexture(e),
- c._swapAndDie(e)),
- l && l.dispose(),
- s && (e._lodTextureHigh && e._lodTextureHigh._texture && (e._lodTextureHigh._texture.isReady = !0),
- e._lodTextureMid && e._lodTextureMid._texture && (e._lodTextureMid._texture.isReady = !0),
- e._lodTextureLow && e._lodTextureLow._texture && (e._lodTextureLow._texture.isReady = !0))
- }
- ))
- }
- function Yc(e, t) {
- var i = (t = kc(t)).irradiance;
- if (i) {
- var n = new Pc;
- x.FromArrayToRef(i.x, 0, n.x),
- x.FromArrayToRef(i.y, 0, n.y),
- x.FromArrayToRef(i.z, 0, n.z),
- x.FromArrayToRef(i.xx, 0, n.xx),
- x.FromArrayToRef(i.yy, 0, n.yy),
- x.FromArrayToRef(i.zz, 0, n.zz),
- x.FromArrayToRef(i.yz, 0, n.yz),
- x.FromArrayToRef(i.zx, 0, n.zx),
- x.FromArrayToRef(i.xy, 0, n.xy),
- e._sphericalPolynomial = n
- }
- }
- function Kc(e, t, i, n, r) {
- var o = jc(e.getEngine().createRawCubeTexture(null, e.width, e.format, e.type, e.generateMipMaps, e.invertY, e.samplingMode, e._compression), t).then((function() {
- return e
- }
- ));
- return e.onRebuildCallback = function(e) {
- return {
- proxy: o,
- isReady: !0,
- isAsync: !0
- }
- }
- ,
- e._source = At.CubeRawRGBD,
- e._bufferViewArrayArray = t,
- e._lodGenerationScale = n,
- e._lodGenerationOffset = r,
- e._sphericalPolynomial = i,
- jc(e, t).then((function() {
- return e.isReady = !0,
- e
- }
- ))
- }
- var Qc = {
- GetEnvInfo: Vc,
- CreateEnvTextureAsync: Gc,
- CreateImageDataArrayBufferViews: Wc,
- UploadEnvLevelsAsync: Hc,
- UploadLevelsAsync: jc,
- UploadEnvSpherical: Yc
- };
- function qc(e, t, i, n) {
- for (var r = n, o = 0, a = ""; r < i.length; ) {
- var s = i.charAt(r);
- if (a)
- s === a ? '"' === a || "'" === a ? "\\" !== i.charAt(r - 1) && (a = "") : a = "" : "*/" === a && "*" === s && r + 1 < i.length && ("/" === i.charAt(r + 1) && (a = ""),
- "" === a && r++);
- else
- switch (s) {
- case e:
- o++;
- break;
- case t:
- o--;
- break;
- case '"':
- case "'":
- case "`":
- a = s;
- break;
- case "/":
- if (r + 1 < i.length) {
- var l = i.charAt(r + 1);
- "/" === l ? a = "\n" : "*" === l && (a = "*/")
- }
- }
- if (r++,
- 0 === o)
- break
- }
- return 0 === o ? r - 1 : -1
- }
- function Zc(e, t) {
- for (; t < e.length; ) {
- var i = e[t];
- if (" " !== i && "\n" !== i && "\r" !== i && "\t" !== i && "\n" !== i && " " !== i)
- break;
- t++
- }
- return t
- }
- function Jc(e) {
- var t = e.charCodeAt(0);
- return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || 95 == t
- }
- function $c(e) {
- for (var t = 0, i = "", n = !1, r = []; t < e.length; ) {
- var o = e.charAt(t);
- if (i)
- o === i ? '"' === i || "'" === i ? ("\\" !== e.charAt(t - 1) && (i = ""),
- r.push(o)) : (i = "",
- n = !1) : "*/" === i && "*" === o && t + 1 < e.length ? ("/" === e.charAt(t + 1) && (i = ""),
- "" === i && (n = !1,
- t++)) : n || r.push(o);
- else {
- switch (o) {
- case '"':
- case "'":
- case "`":
- i = o;
- break;
- case "/":
- if (t + 1 < e.length) {
- var a = e.charAt(t + 1);
- "/" === a ? (i = "\n",
- n = !0) : "*" === a && (i = "*/",
- n = !0)
- }
- }
- n || r.push(o)
- }
- t++
- }
- return r.join("")
- }
- function eu(e, t, i) {
- for (; t >= 0 && e.charAt(t) !== i; )
- t--;
- return t
- }
- var tu, iu = function() {
- function e(e, t) {
- void 0 === t && (t = 20),
- this.debug = !1,
- this._sourceCode = e,
- this._numMaxIterations = t,
- this._functionDescr = [],
- this.inlineToken = "#define inline"
- }
- return Object.defineProperty(e.prototype, "code", {
- get: function() {
- return this._sourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.processCode = function() {
- this.debug && console.log("Start inlining process (code size=".concat(this._sourceCode.length, ")...")),
- this._collectFunctions(),
- this._processInlining(this._numMaxIterations),
- this.debug && console.log("End of inlining process.")
- }
- ,
- e.prototype._collectFunctions = function() {
- for (var t = 0; t < this._sourceCode.length; ) {
- var i = this._sourceCode.indexOf(this.inlineToken, t);
- if (i < 0)
- break;
- var n = this._sourceCode.indexOf("(", i + this.inlineToken.length);
- if (n < 0)
- this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=".concat(t)),
- t = i + this.inlineToken.length;
- else {
- var r = e._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i + this.inlineToken.length, n));
- if (r) {
- var o = [r[3], r[4]]
- , a = o[0]
- , s = o[1]
- , l = qc("(", ")", this._sourceCode, n);
- if (l < 0)
- this.debug && console.warn("Could not extract the parameters the function '".concat(s, "' (type=").concat(a, "). funcParamsStartIndex=").concat(n)),
- t = i + this.inlineToken.length;
- else {
- var c = this._sourceCode.substring(n + 1, l)
- , u = Zc(this._sourceCode, l + 1);
- if (u !== this._sourceCode.length) {
- var h = qc("{", "}", this._sourceCode, u);
- if (h < 0)
- this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcBodyStartIndex=").concat(u)),
- t = i + this.inlineToken.length;
- else {
- for (var d = this._sourceCode.substring(u, h + 1), p = $c(c).split(","), f = [], _ = 0; _ < p.length; ++_) {
- var m = p[_].trim()
- , g = m.lastIndexOf(" ");
- g >= 0 && f.push(m.substring(g + 1))
- }
- "void" !== a && f.push("return"),
- this._functionDescr.push({
- name: s,
- type: a,
- parameters: f,
- body: d,
- callIndex: 0
- }),
- t = h + 1;
- var v = i > 0 ? this._sourceCode.substring(0, i) : ""
- , y = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : "";
- this._sourceCode = v + y,
- t -= h + 1 - i
- }
- } else
- this.debug && console.warn("Could not extract the body of the function '".concat(s, "' (type=").concat(a, "). funcParamsEndIndex=").concat(l)),
- t = i + this.inlineToken.length
- }
- } else
- this.debug && console.warn("Could not extract the name/type of the function from: ".concat(this._sourceCode.substring(i + this.inlineToken.length, n))),
- t = i + this.inlineToken.length
- }
- }
- this.debug && console.log("Collect functions: ".concat(this._functionDescr.length, " functions found. functionDescr="), this._functionDescr)
- }
- ,
- e.prototype._processInlining = function(e) {
- for (void 0 === e && (e = 20); e-- >= 0 && this._replaceFunctionCallsByCode(); )
- ;
- return this.debug && console.log("numMaxIterations is ".concat(e, " after inlining process")),
- e >= 0
- }
- ,
- e.prototype._replaceFunctionCallsByCode = function() {
- for (var e = !1, t = 0, i = this._functionDescr; t < i.length; t++)
- for (var n = i[t], r = n.name, o = n.type, a = n.parameters, s = n.body, l = 0; l < this._sourceCode.length; ) {
- var c = this._sourceCode.indexOf(r, l);
- if (c < 0)
- break;
- if (0 === c || Jc(this._sourceCode.charAt(c - 1)))
- l = c + r.length;
- else {
- var u = Zc(this._sourceCode, c + r.length);
- if (u !== this._sourceCode.length && "(" === this._sourceCode.charAt(u)) {
- var h = qc("(", ")", this._sourceCode, u);
- if (h < 0)
- this.debug && console.warn("Could not extract the parameters of the function call. Function '".concat(r, "' (type=").concat(o, "). callParamsStartIndex=").concat(u)),
- l = c + r.length;
- else {
- var d = this._sourceCode.substring(u + 1, h)
- , p = function(e) {
- for (var t = [], i = 0, n = 0; i < e.length; ) {
- if ("(" === e.charAt(i)) {
- var r = qc("(", ")", e, i);
- if (r < 0)
- return null;
- i = r
- } else
- "," === e.charAt(i) && (t.push(e.substring(n, i)),
- n = i + 1);
- i++
- }
- return n < i && t.push(e.substring(n, i)),
- t
- }($c(d));
- if (null !== p) {
- for (var f = [], _ = 0; _ < p.length; ++_) {
- var m = p[_].trim();
- f.push(m)
- }
- var g = "void" !== o ? r + "_" + n.callIndex++ : null;
- if (g && f.push(g + " ="),
- f.length === a.length) {
- l = h + 1;
- var v = this._replaceNames(s, a, f)
- , y = c > 0 ? this._sourceCode.substring(0, c) : ""
- , b = h + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(h + 1) : "";
- if (g) {
- var T = eu(this._sourceCode, c - 1, "\n");
- y = this._sourceCode.substring(0, T + 1);
- var E = this._sourceCode.substring(T + 1, c);
- this._sourceCode = y + o + " " + g + ";\n" + v + "\n" + E + g + b,
- this.debug && console.log("Replace function call by code. Function '".concat(r, "' (type=").concat(o, "). injectDeclarationIndex=").concat(T, ", call parameters=").concat(f))
- } else
- this._sourceCode = y + v + b,
- l += v.length - (h + 1 - c),
- this.debug && console.log("Replace function call by code. Function '".concat(r, "' (type=").concat(o, "). functionCallIndex=").concat(c, ", call parameters=").concat(f));
- e = !0
- } else
- this.debug && console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '".concat(r, "' (type=").concat(o, "). function parameters=").concat(a, ", call parameters=").concat(f)),
- l = c + r.length
- } else
- this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '".concat(r, "' (type=").concat(o, "). callParamsStartIndex=").concat(u, ", callParams=") + d),
- l = c + r.length
- }
- } else
- l = c + r.length
- }
- }
- return e
- }
- ,
- e.prototype._replaceNames = function(e, t, i) {
- for (var n = function(n) {
- var r = new RegExp(t[n].replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),"g")
- , o = t[n].length
- , a = i[n];
- e = e.replace(r, (function(i) {
- for (var r = [], s = 1; s < arguments.length; s++)
- r[s - 1] = arguments[s];
- var l = r[0];
- return Jc(e.charAt(l - 1)) || Jc(e.charAt(l + o)) ? t[n] : a
- }
- ))
- }, r = 0; r < t.length; ++r)
- n(r);
- return e
- }
- ,
- e._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/,
- e
- }(), nu = new h;
- function ru() {
- return new Promise((function(e) {
- "undefined" == typeof _native ? nu.addOnce((function(t) {
- return e(t)
- }
- )) : e(_native)
- }
- ))
- }
- function ou(e, t) {
- return G(this, void 0, void 0, (function() {
- return z(this, (function(i) {
- switch (i.label) {
- case 0:
- return [4, ru()];
- case 1:
- return i.sent()[e] = t,
- [2]
- }
- }
- ))
- }
- ))
- }
- "undefined" == typeof self || Object.prototype.hasOwnProperty.call(self, "_native") || Object.defineProperty(self, "_native", {
- get: function() {
- return tu
- },
- set: function(e) {
- (tu = e) && nu.notifyObservers(tu)
- }
- });
- var au = function() {
- function e(e) {
- this.isAsync = !1,
- this.isReady = !1,
- this._valueCache = {},
- this.engine = e
- }
- return e.prototype._getVertexShaderCode = function() {
- return null
- }
- ,
- e.prototype._getFragmentShaderCode = function() {
- return null
- }
- ,
- e.prototype._handlesSpectorRebuildCallback = function(e) {
- throw new Error("Not implemented")
- }
- ,
- e.prototype._fillEffectInformation = function(e, t, i, n, r, o, a, s) {
- var l, c = this.engine;
- if (c.supportsUniformBuffers)
- for (var u in t)
- e.bindUniformBlock(u, t[u]);
- for (this.engine.getUniforms(this, i).forEach((function(e, t) {
- n[i[t]] = e
- }
- )),
- this._uniforms = n,
- l = 0; l < r.length; l++)
- null == e.getUniform(r[l]) && (r.splice(l, 1),
- l--);
- r.forEach((function(e, t) {
- o[e] = t
- }
- )),
- s.push.apply(s, c.getAttributes(this, a))
- }
- ,
- e.prototype.dispose = function() {
- this._uniforms = {}
- }
- ,
- e.prototype._cacheMatrix = function(e, t) {
- var i = this._valueCache[e]
- , n = t.updateFlag;
- return (void 0 === i || i !== n) && (this._valueCache[e] = n,
- !0)
- }
- ,
- e.prototype._cacheFloat2 = function(e, t, i) {
- var n = this._valueCache[e];
- if (!n)
- return n = [t, i],
- this._valueCache[e] = n,
- !0;
- var r = !1;
- return n[0] !== t && (n[0] = t,
- r = !0),
- n[1] !== i && (n[1] = i,
- r = !0),
- r
- }
- ,
- e.prototype._cacheFloat3 = function(e, t, i, n) {
- var r = this._valueCache[e];
- if (!r)
- return r = [t, i, n],
- this._valueCache[e] = r,
- !0;
- var o = !1;
- return r[0] !== t && (r[0] = t,
- o = !0),
- r[1] !== i && (r[1] = i,
- o = !0),
- r[2] !== n && (r[2] = n,
- o = !0),
- o
- }
- ,
- e.prototype._cacheFloat4 = function(e, t, i, n, r) {
- var o = this._valueCache[e];
- if (!o)
- return o = [t, i, n, r],
- this._valueCache[e] = o,
- !0;
- var a = !1;
- return o[0] !== t && (o[0] = t,
- a = !0),
- o[1] !== i && (o[1] = i,
- a = !0),
- o[2] !== n && (o[2] = n,
- a = !0),
- o[3] !== r && (o[3] = r,
- a = !0),
- a
- }
- ,
- e.prototype.setInt = function(e, t) {
- var i = this._valueCache[e];
- void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t) && (this._valueCache[e] = t)
- }
- ,
- e.prototype.setInt2 = function(e, t, i) {
- this._cacheFloat2(e, t, i) && (this.engine.setInt2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setInt3 = function(e, t, i, n) {
- this._cacheFloat3(e, t, i, n) && (this.engine.setInt3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setInt4 = function(e, t, i, n, r) {
- this._cacheFloat4(e, t, i, n, r) && (this.engine.setInt4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setIntArray = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray(this._uniforms[e], t)
- }
- ,
- e.prototype.setIntArray2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray2(this._uniforms[e], t)
- }
- ,
- e.prototype.setIntArray3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray3(this._uniforms[e], t)
- }
- ,
- e.prototype.setIntArray4 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setIntArray4(this._uniforms[e], t)
- }
- ,
- e.prototype.setFloatArray = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setFloatArray(this._uniforms[e], t)
- }
- ,
- e.prototype.setFloatArray2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setFloatArray2(this._uniforms[e], t)
- }
- ,
- e.prototype.setFloatArray3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setFloatArray3(this._uniforms[e], t)
- }
- ,
- e.prototype.setFloatArray4 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setFloatArray4(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray2(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray3(this._uniforms[e], t)
- }
- ,
- e.prototype.setArray4 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setArray4(this._uniforms[e], t)
- }
- ,
- e.prototype.setMatrices = function(e, t) {
- t && (this._valueCache[e] = null,
- this.engine.setMatrices(this._uniforms[e], t))
- }
- ,
- e.prototype.setMatrix = function(e, t) {
- this._cacheMatrix(e, t) && (this.engine.setMatrices(this._uniforms[e], t.toArray()) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setMatrix3x3 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setMatrix3x3(this._uniforms[e], t)
- }
- ,
- e.prototype.setMatrix2x2 = function(e, t) {
- this._valueCache[e] = null,
- this.engine.setMatrix2x2(this._uniforms[e], t)
- }
- ,
- e.prototype.setFloat = function(e, t) {
- var i = this._valueCache[e];
- void 0 !== i && i === t || this.engine.setFloat(this._uniforms[e], t) && (this._valueCache[e] = t)
- }
- ,
- e.prototype.setBool = function(e, t) {
- var i = this._valueCache[e];
- void 0 !== i && i === t || this.engine.setInt(this._uniforms[e], t ? 1 : 0) && (this._valueCache[e] = t ? 1 : 0)
- }
- ,
- e.prototype.setVector2 = function(e, t) {
- this._cacheFloat2(e, t.x, t.y) && (this.engine.setFloat2(this._uniforms[e], t.x, t.y) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setFloat2 = function(e, t, i) {
- this._cacheFloat2(e, t, i) && (this.engine.setFloat2(this._uniforms[e], t, i) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setVector3 = function(e, t) {
- this._cacheFloat3(e, t.x, t.y, t.z) && (this.engine.setFloat3(this._uniforms[e], t.x, t.y, t.z) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setFloat3 = function(e, t, i, n) {
- this._cacheFloat3(e, t, i, n) && (this.engine.setFloat3(this._uniforms[e], t, i, n) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setVector4 = function(e, t) {
- this._cacheFloat4(e, t.x, t.y, t.z, t.w) && (this.engine.setFloat4(this._uniforms[e], t.x, t.y, t.z, t.w) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setFloat4 = function(e, t, i, n, r) {
- this._cacheFloat4(e, t, i, n, r) && (this.engine.setFloat4(this._uniforms[e], t, i, n, r) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setColor3 = function(e, t) {
- this._cacheFloat3(e, t.r, t.g, t.b) && (this.engine.setFloat3(this._uniforms[e], t.r, t.g, t.b) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setColor4 = function(e, t, i) {
- this._cacheFloat4(e, t.r, t.g, t.b, i) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, i) || (this._valueCache[e] = null))
- }
- ,
- e.prototype.setDirectColor4 = function(e, t) {
- this._cacheFloat4(e, t.r, t.g, t.b, t.a) && (this.engine.setFloat4(this._uniforms[e], t.r, t.g, t.b, t.a) || (this._valueCache[e] = null))
- }
- ,
- e
- }()
- , su = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, i, n, r) || this;
- return o.__framebuffer = null,
- o.__framebufferDepthStencil = null,
- o._engine = r,
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "_framebuffer", {
- get: function() {
- return this.__framebuffer
- },
- set: function(e) {
- this.__framebuffer && this._engine._releaseFramebufferObjects(this.__framebuffer),
- this.__framebuffer = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_framebufferDepthStencil", {
- get: function() {
- return this.__framebufferDepthStencil
- },
- set: function(e) {
- this.__framebufferDepthStencil && this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil),
- this.__framebufferDepthStencil = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.dispose = function(t) {
- void 0 === t && (t = !1),
- this._framebuffer = null,
- this._framebufferDepthStencil = null,
- e.prototype.dispose.call(this, t)
- }
- ,
- t
- }(Fa)
- , lu = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t
- }(Bt)
- , cu = function() {
- function e(e) {
- this._engine = e,
- this._pending = new Array,
- this._isCommandBufferScopeActive = !1,
- this._commandStream = uu._createNativeDataStream(),
- this._engine.setCommandDataStream(this._commandStream)
- }
- return e.prototype.beginCommandScope = function() {
- if (this._isCommandBufferScopeActive)
- throw new Error("Command scope already active.");
- this._isCommandBufferScopeActive = !0
- }
- ,
- e.prototype.endCommandScope = function() {
- if (!this._isCommandBufferScopeActive)
- throw new Error("Command scope is not active.");
- this._isCommandBufferScopeActive = !1,
- this._submit()
- }
- ,
- e.prototype.startEncodingCommand = function(e) {
- this._commandStream.writeNativeData(e)
- }
- ,
- e.prototype.encodeCommandArgAsUInt32 = function(e) {
- this._commandStream.writeUint32(e)
- }
- ,
- e.prototype.encodeCommandArgAsUInt32s = function(e) {
- this._commandStream.writeUint32Array(e)
- }
- ,
- e.prototype.encodeCommandArgAsInt32 = function(e) {
- this._commandStream.writeInt32(e)
- }
- ,
- e.prototype.encodeCommandArgAsInt32s = function(e) {
- this._commandStream.writeInt32Array(e)
- }
- ,
- e.prototype.encodeCommandArgAsFloat32 = function(e) {
- this._commandStream.writeFloat32(e)
- }
- ,
- e.prototype.encodeCommandArgAsFloat32s = function(e) {
- this._commandStream.writeFloat32Array(e)
- }
- ,
- e.prototype.encodeCommandArgAsNativeData = function(e) {
- this._commandStream.writeNativeData(e),
- this._pending.push(e)
- }
- ,
- e.prototype.finishEncodingCommand = function() {
- this._isCommandBufferScopeActive || this._submit()
- }
- ,
- e.prototype._submit = function() {
- this._engine.submitCommands(),
- this._pending.length = 0
- }
- ,
- e
- }()
- , uu = function(e) {
- function t(i) {
- void 0 === i && (i = {});
- var n = e.call(this, null, !1, void 0, i.adaptToDeviceRatio) || this;
- if (n._engine = new _native.Engine,
- n._camera = _native.Camera ? new _native.Camera : null,
- n._commandBufferEncoder = new cu(n._engine),
- n._boundBuffersVertexArray = null,
- n._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL,
- n._stencilTest = !1,
- n._stencilMask = 255,
- n._stencilFunc = a.ALWAYS,
- n._stencilFuncRef = 0,
- n._stencilFuncMask = 255,
- n._stencilOpStencilFail = a.KEEP,
- n._stencilOpDepthFail = a.KEEP,
- n._stencilOpStencilDepthPass = a.REPLACE,
- n._zOffset = 0,
- n._zOffsetUnits = 0,
- n._depthWrite = !0,
- _native.Engine.PROTOCOL_VERSION !== t.PROTOCOL_VERSION)
- throw new Error("Protocol version mismatch: ".concat(_native.Engine.PROTOCOL_VERSION, " (Native) !== ").concat(t.PROTOCOL_VERSION, " (JS)"));
- n._webGLVersion = 2,
- n.disableUniformBuffers = !0,
- n._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,
- supportTransformFeedbacks: !1,
- textureMaxLevel: !1
- },
- n._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
- },
- gi.Log("Babylon Native (v" + vr.Version + ") launched"),
- gi.LoadScript = function(e, t, i, n) {
- gi.LoadFile(e, (function(e) {
- Function(e).apply(null),
- t && t()
- }
- ), void 0, void 0, !1, (function(e, t) {
- i && i("LoadScript Error", t)
- }
- ))
- }
- ,
- "undefined" == typeof URL && (window.URL = {
- createObjectURL: function() {},
- revokeObjectURL: function() {}
- }),
- "undefined" == typeof Blob && (window.Blob = function(e) {
- return e
- }
- );
- var r = window && window.devicePixelRatio || 1;
- n._hardwareScalingLevel = i.adaptToDeviceRatio ? r : 1,
- n.resize();
- var o = n.getDepthFunction();
- return o && n.setDepthFunction(o),
- n._shaderProcessor = new wt,
- n.onNewSceneAddedObservable.add((function(e) {
- var t = e.render;
- e.render = function() {
- for (var i = [], r = 0; r < arguments.length; r++)
- i[r] = arguments[r];
- n._commandBufferEncoder.beginCommandScope(),
- t.apply(e, i),
- n._commandBufferEncoder.endCommandScope()
- }
- }
- )),
- n
- }
- return U(t, e),
- t.prototype.getHardwareScalingLevel = function() {
- return this._engine.getHardwareScalingLevel()
- }
- ,
- t.prototype.setHardwareScalingLevel = function(e) {
- this._engine.setHardwareScalingLevel(e)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
- this._engine.dispose()
- }
- ,
- t._createNativeDataStream = function() {
- return new bc
- }
- ,
- t.prototype._queueNewFrame = function(e, t) {
- return t.requestAnimationFrame && t !== window ? t.requestAnimationFrame(e) : this._engine.requestAnimationFrame(e),
- 0
- }
- ,
- t.prototype._bindUnboundFramebuffer = function(e) {
- this._currentFramebuffer !== e && (this._currentFramebuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer),
- this._commandBufferEncoder.finishEncodingCommand()),
- e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.finishEncodingCommand()),
- this._currentFramebuffer = e)
- }
- ,
- t.prototype.getHostDocument = function() {
- return null
- }
- ,
- t.prototype.clear = function(e, t, i, n) {
- if (void 0 === n && (n = !1),
- this.useReverseDepthBuffer)
- throw new Error("reverse depth buffer is not currently implemented");
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(t && e ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.r : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.g : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.b : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(e ? e.a : 1),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(1),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(n ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(0),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.createIndexBuffer = function(e, t) {
- var i = this._normalizeIndexData(e)
- , n = new lu;
- return n.references = 1,
- n.is32Bits = 4 === i.BYTES_PER_ELEMENT,
- i.byteLength && (n.nativeIndexBuffer = this._engine.createIndexBuffer(i.buffer, i.byteOffset, i.byteLength, n.is32Bits, null != t && t)),
- n
- }
- ,
- t.prototype.createVertexBuffer = function(e, t) {
- var i = ArrayBuffer.isView(e) ? e : new Float32Array(e)
- , n = new lu;
- return n.references = 1,
- i.byteLength && (n.nativeVertexBuffer = this._engine.createVertexBuffer(i.buffer, i.byteOffset, i.byteLength, null != t && t)),
- n
- }
- ,
- t.prototype._recordVertexArrayObject = function(e, t, i, n) {
- i && this._engine.recordIndexBuffer(e, i.nativeIndexBuffer);
- for (var r = n.getAttributesNames(), o = 0; o < r.length; o++) {
- var a = n.getAttributeLocation(o);
- if (a >= 0) {
- var s = t[r[o]];
- if (s) {
- var l = s.getBuffer();
- l && this._engine.recordVertexBuffer(e, l.nativeVertexBuffer, a, s.byteOffset, s.byteStride, s.getSize(), this._getNativeAttribType(s.type), s.normalized, s.getInstanceDivisor())
- }
- }
- }
- }
- ,
- t.prototype.bindBuffers = function(e, t, i) {
- this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
- this._boundBuffersVertexArray = this._engine.createVertexArray(),
- this._recordVertexArrayObject(this._boundBuffersVertexArray, e, t, i),
- this.bindVertexArrayObject(this._boundBuffersVertexArray)
- }
- ,
- t.prototype.recordVertexArrayObject = function(e, t, i) {
- var n = this._engine.createVertexArray();
- return this._recordVertexArrayObject(n, e, t, i),
- n
- }
- ,
- t.prototype._deleteVertexArray = function(e) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.bindVertexArrayObject = function(e) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.releaseVertexArrayObject = function(e) {
- this._deleteVertexArray(e)
- }
- ,
- t.prototype.getAttributes = function(e, t) {
- var i = e;
- return this._engine.getAttributes(i.nativeProgram, t)
- }
- ,
- t.prototype.drawElementsType = function(e, t, i, n) {
- this._drawCalls.addCount(1, !1),
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.drawArraysType = function(e, t, i, n) {
- this._drawCalls.addCount(1, !1),
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.createPipelineContext = function() {
- return new au(this)
- }
- ,
- t.prototype.createMaterialContext = function() {}
- ,
- t.prototype.createDrawContext = function() {}
- ,
- t.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s, l) {
- e.nativeProgram = n ? this.createRawShaderProgram(e, t, i, void 0, l) : this.createShaderProgram(e, t, i, s, void 0, l)
- }
- ,
- t.prototype._isRenderingStateCompiled = function(e) {
- return !0
- }
- ,
- t.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
- t()
- }
- ,
- t.prototype.createRawShaderProgram = function(e, t, i, n, r) {
- throw void 0 === r && (r = null),
- new Error("Not Supported")
- }
- ,
- t.prototype.createShaderProgram = function(e, t, i, n, r, o) {
- void 0 === o && (o = null),
- this.onBeforeShaderCompilationObservable.notifyObservers(this);
- var a = new iu(t);
- a.processCode(),
- t = a.code;
- var s = new iu(i);
- s.processCode(),
- i = s.code,
- t = Ht._ConcatenateShader(t, n),
- i = Ht._ConcatenateShader(i, n);
- var l = this._engine.createProgram(t, i);
- return this.onAfterShaderCompilationObservable.notifyObservers(this),
- l
- }
- ,
- t.prototype.inlineShaderCode = function(e) {
- var t = new iu(e);
- return t.debug = !1,
- t.processCode(),
- t.code
- }
- ,
- t.prototype._setProgram = function(e) {
- this._currentProgram !== e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.finishEncodingCommand(),
- this._currentProgram = e)
- }
- ,
- t.prototype._deletePipelineContext = function(e) {
- var t = e;
- t && t.nativeProgram && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(t.nativeProgram),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- t.prototype.getUniforms = function(e, t) {
- var i = e;
- return this._engine.getUniforms(i.nativeProgram, t)
- }
- ,
- t.prototype.bindUniformBlock = function(e, t, i) {
- throw new Error("Not Implemented")
- }
- ,
- t.prototype.bindSamplers = function(e) {
- var t = e.getPipelineContext();
- this._setProgram(t.nativeProgram);
- for (var i = e.getSamplers(), n = 0; n < i.length; n++) {
- var r = e.getUniform(i[n]);
- r && (this._boundUniforms[n] = r)
- }
- this._currentEffect = null
- }
- ,
- t.prototype.setMatrix = function(e, t) {
- if (e) {
- var i = t.toArray();
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(i),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- }
- ,
- t.prototype.getRenderWidth = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._engine.getRenderWidth()
- }
- ,
- t.prototype.getRenderHeight = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._engine.getRenderHeight()
- }
- ,
- t.prototype.setViewport = function(e, t, i) {
- this._cachedViewport = e,
- this._engine.setViewPort(e.x, e.y, e.width, e.height)
- }
- ,
- t.prototype.setState = function(e, t, i, n, r, o, a) {
- var s, l;
- void 0 === t && (t = 0),
- void 0 === n && (n = !1),
- void 0 === a && (a = 0),
- this._zOffset = t,
- this._zOffsetUnits = a,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(a),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : r) || void 0 === l || l ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(n ? 1 : 0),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.getInputElementClientRect = function() {
- return {
- bottom: this.getRenderHeight(),
- height: this.getRenderHeight(),
- left: 0,
- right: this.getRenderWidth(),
- top: 0,
- width: this.getRenderWidth(),
- x: 0,
- y: 0,
- toJSON: function() {}
- }
- }
- ,
- t.prototype.setZOffset = function(e) {
- e !== this._zOffset && (this._zOffset = e,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- t.prototype.getZOffset = function() {
- return this._zOffset
- }
- ,
- t.prototype.setZOffsetUnits = function(e) {
- e !== this._zOffsetUnits && (this._zOffsetUnits = e,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -e : e),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- t.prototype.getZOffsetUnits = function() {
- return this._zOffsetUnits
- }
- ,
- t.prototype.setDepthBuffer = function(e) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(e ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.getDepthWrite = function() {
- return this._depthWrite
- }
- ,
- t.prototype.getDepthFunction = function() {
- switch (this._currentDepthTest) {
- case _native.Engine.DEPTH_TEST_NEVER:
- return a.NEVER;
- case _native.Engine.DEPTH_TEST_ALWAYS:
- return a.ALWAYS;
- case _native.Engine.DEPTH_TEST_GREATER:
- return a.GREATER;
- case _native.Engine.DEPTH_TEST_GEQUAL:
- return a.GEQUAL;
- case _native.Engine.DEPTH_TEST_NOTEQUAL:
- return a.NOTEQUAL;
- case _native.Engine.DEPTH_TEST_EQUAL:
- return a.EQUAL;
- case _native.Engine.DEPTH_TEST_LESS:
- return a.LESS;
- case _native.Engine.DEPTH_TEST_LEQUAL:
- return a.LEQUAL
- }
- return null
- }
- ,
- t.prototype.setDepthFunction = function(e) {
- var t = 0;
- switch (e) {
- case a.NEVER:
- t = _native.Engine.DEPTH_TEST_NEVER;
- break;
- case a.ALWAYS:
- t = _native.Engine.DEPTH_TEST_ALWAYS;
- break;
- case a.GREATER:
- t = _native.Engine.DEPTH_TEST_GREATER;
- break;
- case a.GEQUAL:
- t = _native.Engine.DEPTH_TEST_GEQUAL;
- break;
- case a.NOTEQUAL:
- t = _native.Engine.DEPTH_TEST_NOTEQUAL;
- break;
- case a.EQUAL:
- t = _native.Engine.DEPTH_TEST_EQUAL;
- break;
- case a.LESS:
- t = _native.Engine.DEPTH_TEST_LESS;
- break;
- case a.LEQUAL:
- t = _native.Engine.DEPTH_TEST_LEQUAL
- }
- this._currentDepthTest = t,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.setDepthWrite = function(e) {
- this._depthWrite = e,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.setColorWrite = function(e) {
- this._colorWrite = e,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(e)),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.getColorWrite = function() {
- return this._colorWrite
- }
- ,
- t.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)
- }
- ,
- t.prototype._setStencil = function(e, t, i, n, r, o) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(e),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(n),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(r),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype.setStencilBuffer = function(e) {
- this._stencilTest = e,
- e ? 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)
- }
- ,
- t.prototype.getStencilBuffer = function() {
- return this._stencilTest
- }
- ,
- t.prototype.getStencilOperationPass = function() {
- return this._stencilOpStencilDepthPass
- }
- ,
- t.prototype.setStencilOperationPass = function(e) {
- this._stencilOpStencilDepthPass = e,
- this.applyStencil()
- }
- ,
- t.prototype.setStencilMask = function(e) {
- this._stencilMask = e,
- this.applyStencil()
- }
- ,
- t.prototype.setStencilFunction = function(e) {
- this._stencilFunc = e,
- this.applyStencil()
- }
- ,
- t.prototype.setStencilFunctionReference = function(e) {
- this._stencilFuncRef = e,
- this.applyStencil()
- }
- ,
- t.prototype.setStencilFunctionMask = function(e) {
- this._stencilFuncMask = e
- }
- ,
- t.prototype.setStencilOperationFail = function(e) {
- this._stencilOpStencilFail = e,
- this.applyStencil()
- }
- ,
- t.prototype.setStencilOperationDepthFail = function(e) {
- this._stencilOpDepthFail = e,
- this.applyStencil()
- }
- ,
- t.prototype.getStencilMask = function() {
- return this._stencilMask
- }
- ,
- t.prototype.getStencilFunction = function() {
- return this._stencilFunc
- }
- ,
- t.prototype.getStencilFunctionReference = function() {
- return this._stencilFuncRef
- }
- ,
- t.prototype.getStencilFunctionMask = function() {
- return this._stencilFuncMask
- }
- ,
- t.prototype.getStencilOperationFail = function() {
- return this._stencilOpStencilFail
- }
- ,
- t.prototype.getStencilOperationDepthFail = function() {
- return this._stencilOpDepthFail
- }
- ,
- t.prototype.setAlphaConstants = function(e, t, i, n) {
- throw new Error("Setting alpha blend constant color not yet implemented.")
- }
- ,
- t.prototype.setAlphaMode = function(e, t) {
- if (void 0 === t && (t = !1),
- this._alphaMode !== e) {
- var i = this._getNativeAlphaMode(e);
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.finishEncodingCommand(),
- t || this.setDepthWrite(e === a.ALPHA_DISABLE),
- this._alphaMode = e
- }
- }
- ,
- t.prototype.getAlphaMode = function() {
- return this._alphaMode
- }
- ,
- t.prototype.setInt = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsInt32(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setIntArray = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setIntArray2 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setIntArray3 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setIntArray4 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloatArray = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloatArray2 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloatArray3 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloatArray4 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setArray = function(e, t) {
- return !!e && this.setFloatArray(e, new Float32Array(t))
- }
- ,
- t.prototype.setArray2 = function(e, t) {
- return !!e && this.setFloatArray2(e, new Float32Array(t))
- }
- ,
- t.prototype.setArray3 = function(e, t) {
- return !!e && this.setFloatArray3(e, new Float32Array(t))
- }
- ,
- t.prototype.setArray4 = function(e, t) {
- return !!e && this.setFloatArray4(e, new Float32Array(t))
- }
- ,
- t.prototype.setMatrices = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setMatrix3x3 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setMatrix2x2 = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloat = function(e, t) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloat2 = function(e, t, i) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloat3 = function(e, t, i, n) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(n),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setFloat4 = function(e, t, i, n, r) {
- return !!e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(t),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(n),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(r),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0)
- }
- ,
- t.prototype.setColor3 = function(e, t) {
- return !!e && (this.setFloat3(e, t.r, t.g, t.b),
- !0)
- }
- ,
- t.prototype.setColor4 = function(e, t, i) {
- return !!e && (this.setFloat4(e, t.r, t.g, t.b, i),
- !0)
- }
- ,
- t.prototype.wipeCaches = function(e) {
- this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
- this._currentEffect = null,
- e && (this._currentProgram = null,
- this._stencilStateComposer.reset(),
- this._depthCullingState.reset(),
- this._alphaState.reset()),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._cachedEffectForVertexBuffers = null)
- }
- ,
- t.prototype._createTexture = function() {
- return this._engine.createTexture()
- }
- ,
- t.prototype._deleteTexture = function(e) {
- e && this._engine.deleteTexture(e)
- }
- ,
- t.prototype.updateDynamicTexture = function(e, t, i, n, r) {
- if (void 0 === n && (n = !1),
- void 0 === n && (n = !1),
- e && e._hardwareTexture) {
- var o = t.getCanvasTexture()
- , a = e._hardwareTexture.underlyingResource;
- this._engine.copyTexture(a, o),
- e.isReady = !0
- }
- }
- ,
- t.prototype.createDynamicTexture = function(e, t, i, n) {
- return e = Math.max(e, 1),
- t = Math.max(t, 1),
- this.createRawTexture(new Uint8Array(e * t * 4), e, t, a.TEXTUREFORMAT_RGBA, !1, !1, n)
- }
- ,
- t.prototype.createVideoElement = function(e) {
- return this._camera ? this._camera.createVideo(e) : null
- }
- ,
- t.prototype.updateVideoTexture = function(e, t, i) {
- if (e && e._hardwareTexture && this._camera) {
- var n = e._hardwareTexture.underlyingResource;
- this._camera.updateVideoTexture(n, t, i)
- }
- }
- ,
- t.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c) {
- void 0 === l && (l = null),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
- var u = new Lt(this,At.Raw);
- if (u.format = n,
- u.generateMipMaps = r,
- u.samplingMode = s,
- u.invertY = o,
- u.baseWidth = t,
- u.baseHeight = i,
- u.width = u.baseWidth,
- u.height = u.baseHeight,
- u._compression = l,
- u.type = c,
- this.updateRawTexture(u, e, n, o, l, c),
- u._hardwareTexture) {
- var h = u._hardwareTexture.underlyingResource
- , d = this._getNativeSamplingMode(s);
- this._setTextureSampling(h, d)
- }
- return this._internalTexturesCache.push(u),
- u
- }
- ,
- t.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u) {
- void 0 === c && (c = null),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT);
- var h = new Lt(this,At.Raw2DArray);
- if (h.baseWidth = t,
- h.baseHeight = i,
- h.baseDepth = n,
- h.width = t,
- h.height = i,
- h.depth = n,
- h.format = r,
- h.type = u,
- h.generateMipMaps = o,
- h.samplingMode = l,
- h.is2DArray = !0,
- h._hardwareTexture) {
- var d = h._hardwareTexture.underlyingResource;
- this._engine.loadRawTexture2DArray(d, e, t, i, n, this._getNativeTextureFormat(r, u), o, s);
- var p = this._getNativeSamplingMode(l);
- this._setTextureSampling(d, p)
- }
- return h.isReady = !0,
- this._internalTexturesCache.push(h),
- h
- }
- ,
- t.prototype.updateRawTexture = function(e, t, i, n, r, o) {
- if (void 0 === r && (r = null),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- e) {
- if (t && e._hardwareTexture) {
- var s = e._hardwareTexture.underlyingResource;
- this._engine.loadRawTexture(s, t, e.width, e.height, this._getNativeTextureFormat(i, o), e.generateMipMaps, e.invertY)
- }
- e.isReady = !0
- }
- }
- ,
- t.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
- var m = this;
- void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = null),
- void 0 === _ && (_ = !1);
- var g = "data:" === (e = e || "").substr(0, 5)
- , v = g && -1 !== e.indexOf(";base64,")
- , y = c || new Lt(this,At.Url)
- , b = e;
- !this._transformTextureUrl || v || c || l || (e = this._transformTextureUrl(e));
- for (var T = e.lastIndexOf("."), S = h || (T > -1 ? e.substring(T).toLowerCase() : ""), A = null, x = 0, R = vr._TextureLoaders; x < R.length; x++) {
- var C = R[x];
- if (C.canLoad(S)) {
- A = C;
- break
- }
- }
- n && n._addPendingData(y),
- y.url = e,
- y.generateMipMaps = !t,
- y.samplingMode = r,
- y.invertY = i,
- y._useSRGBBuffer = this._getUseSRGBBuffer(_, t),
- this.doNotHandleContextLost || (y._buffer = l);
- var P = null;
- if (o && !c && (P = y.onLoadedObservable.add(o)),
- c || this._internalTexturesCache.push(y),
- A)
- throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
- var M = function(e) {
- if (y._hardwareTexture) {
- var o = y._hardwareTexture.underlyingResource;
- m._engine.loadTexture(o, e, !t, i, _, (function() {
- y.baseWidth = m._engine.getTextureWidth(o),
- y.baseHeight = m._engine.getTextureHeight(o),
- y.width = y.baseWidth,
- y.height = y.baseHeight,
- y.isReady = !0;
- var e = m._getNativeSamplingMode(r);
- m._setTextureSampling(o, e),
- n && n._removePendingData(y),
- y.onLoadedObservable.notifyObservers(y),
- y.onLoadedObservable.clear()
- }
- ), (function() {
- throw new Error("Could not load a native texture.")
- }
- ))
- } else
- n && n._removePendingData(y)
- };
- if (g && l)
- if (l instanceof ArrayBuffer)
- M(new Uint8Array(l));
- else if (ArrayBuffer.isView(l))
- M(l);
- else {
- if ("string" != typeof l)
- throw new Error("Unsupported buffer type");
- M(new Uint8Array(gi.DecodeBase64(l)))
- }
- else
- v ? M(new Uint8Array(gi.DecodeBase64(e))) : this._loadFile(e, (function(e) {
- return M(new Uint8Array(e))
- }
- ), void 0, void 0, !0, (function(i, a) {
- var c;
- c = "Unable to load " + (i && i.responseURL,
- a),
- n && n._removePendingData(y),
- e === b ? (P && y.onLoadedObservable.remove(P),
- E.UseFallbackTexture && m.createTexture(E.FallbackTexture, t, y.invertY, n, r, null, s, l, y),
- s && s((c || "Unknown error") + (E.UseFallbackTexture ? " - Fallback texture was used" : ""), void 0)) : (K.Warn("Failed to load ".concat(e, ", falling back to ").concat(b)),
- m.createTexture(b, t, y.invertY, n, r, o, s, l, y, u, h, d, p))
- }
- ));
- return y
- }
- ,
- t.prototype._createDepthStencilTexture = function(e, t, i) {
- var n = i
- , r = new Lt(this,At.DepthStencil)
- , o = e.width || e
- , a = e.height || e
- , s = this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource, o, a, _native.Engine.TEXTURE_FORMAT_RGBA8, !1, !0, !1);
- return n._framebufferDepthStencil = s,
- r
- }
- ,
- t.prototype._releaseFramebufferObjects = function(e) {
- e && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- t.prototype.createImageBitmapFromSource = function(e, t) {
- var i = this;
- return new Promise((function(t, n) {
- var r = i.createCanvasImage();
- r.onload = function() {
- var e = i._engine.createImageBitmap(r);
- e ? t(e) : n("Error loading image ".concat(r.src))
- }
- ,
- r.onerror = function() {
- n("Error loading image ".concat(r.src))
- }
- ,
- r.src = e
- }
- ))
- }
- ,
- t.prototype.createImageBitmap = function(e, t) {
- var i = this;
- return new Promise((function(t, n) {
- if (Array.isArray(e)) {
- var r = e;
- if (r.length) {
- var o = i._engine.createImageBitmap(r[0]);
- if (o)
- return void t(o)
- }
- }
- n("Unsupported data for createImageBitmap.")
- }
- ))
- }
- ,
- t.prototype.resizeImageBitmap = function(e, t, i) {
- return this._engine.resizeImageBitmap(e, t, i)
- }
- ,
- t.prototype.createCubeTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f) {
- var _ = this;
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === l && (l = null),
- void 0 === c && (c = !1),
- void 0 === u && (u = 0),
- void 0 === h && (h = 0),
- void 0 === d && (d = null),
- void 0 === f && (f = !1);
- var m = d || new Lt(this,At.Cube);
- m.isCube = !0,
- m.url = e,
- m.generateMipMaps = !n,
- m._lodGenerationScale = u,
- m._lodGenerationOffset = h,
- this._doNotHandleContextLost || (m._extension = l,
- m._files = i);
- var g = e.lastIndexOf(".");
- if (".env" === (l || (g > -1 ? e.substring(g).toLowerCase() : ""))) {
- if (i && 6 === i.length)
- throw new Error("Multi-file loading not allowed on env files.");
- this._loadFile(e, (function(e) {
- return function(e) {
- var t = Vc(e);
- m.width = t.width,
- m.height = t.width,
- Yc(m, t);
- var i = t.specular;
- if (!i)
- throw new Error("Nothing else parsed so far");
- m._lodGenerationScale = i.lodGenerationScale;
- var n = Wc(e, t);
- m.format = a.TEXTUREFORMAT_RGBA,
- m.type = a.TEXTURETYPE_UNSIGNED_INT,
- m.generateMipMaps = !0,
- m.getEngine().updateTextureSamplingMode(io.TRILINEAR_SAMPLINGMODE, m),
- m._isRGBD = !0,
- m.invertY = !0,
- _._engine.loadCubeTextureWithMips(m._hardwareTexture.underlyingResource, n, !1, f, (function() {
- m.isReady = !0,
- r && r()
- }
- ), (function() {
- throw new Error("Could not load a native cube texture.")
- }
- ))
- }(new Uint8Array(e))
- }
- ), void 0, void 0, !0, (function(e, t) {
- o && e && o(e.status + " " + e.statusText, t)
- }
- ))
- } else {
- if (!i || 6 !== i.length)
- throw new Error("Cannot load cubemap because 6 files were not defined");
- var v = [i[0], i[3], i[1], i[4], i[2], i[5]];
- Promise.all(v.map((function(e) {
- return gi.LoadFileAsync(e).then((function(e) {
- return new Uint8Array(e)
- }
- ))
- }
- ))).then((function(e) {
- return new Promise((function(t, i) {
- _._engine.loadCubeTexture(m._hardwareTexture.underlyingResource, e, !n, !0, f, t, i)
- }
- ))
- }
- )).then((function() {
- m.isReady = !0,
- r && r()
- }
- ), (function(e) {
- o && o("Failed to load cubemap: ".concat(e.message), e)
- }
- ))
- }
- return this._internalTexturesCache.push(m),
- m
- }
- ,
- t.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
- var n = new su(e,t,i,this);
- return this._renderTargetWrapperCache.push(n),
- n
- }
- ,
- t.prototype.createRenderTargetTexture = function(e, t) {
- var i = this._createHardwareRenderTargetWrapper(!1, !1, e)
- , n = {};
- void 0 !== t && "object" == typeof t ? (n.generateMipMaps = t.generateMipMaps,
- n.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
- n.generateStencilBuffer = n.generateDepthBuffer && t.generateStencilBuffer,
- n.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
- n.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
- n.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format) : (n.generateMipMaps = t,
- n.generateDepthBuffer = !0,
- n.generateStencilBuffer = !1,
- n.type = a.TEXTURETYPE_UNSIGNED_INT,
- n.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- n.format = a.TEXTUREFORMAT_RGBA),
- (n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (n.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (n.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE);
- var r = new Lt(this,At.RenderTarget)
- , o = e.width || e
- , s = e.height || e;
- n.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (n.type = a.TEXTURETYPE_UNSIGNED_INT,
- K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
- var l = this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource, o, s, this._getNativeTextureFormat(n.format, n.type), !!n.generateStencilBuffer, n.generateDepthBuffer, !!n.generateMipMaps);
- return i._framebuffer = l,
- i._generateDepthBuffer = n.generateDepthBuffer,
- i._generateStencilBuffer = !!n.generateStencilBuffer,
- r.baseWidth = o,
- r.baseHeight = s,
- r.width = o,
- r.height = s,
- r.isReady = !0,
- r.samples = 1,
- r.generateMipMaps = !!n.generateMipMaps,
- r.samplingMode = n.samplingMode,
- r.type = n.type,
- r.format = n.format,
- this._internalTexturesCache.push(r),
- i.setTextures(r),
- i
- }
- ,
- t.prototype.updateTextureSamplingMode = function(e, t) {
- if (t._hardwareTexture) {
- var i = this._getNativeSamplingMode(e);
- this._setTextureSampling(t._hardwareTexture.underlyingResource, i)
- }
- t.samplingMode = e
- }
- ,
- t.prototype.bindFramebuffer = function(e, t, i, n, r) {
- var o = e;
- if (t)
- throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
- if (i || n)
- throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
- o._framebufferDepthStencil ? this._bindUnboundFramebuffer(o._framebufferDepthStencil) : this._bindUnboundFramebuffer(o._framebuffer)
- }
- ,
- t.prototype.unBindFramebuffer = function(e, t, i) {
- void 0 === t && (t = !1),
- i && i(),
- this._bindUnboundFramebuffer(null)
- }
- ,
- t.prototype.createDynamicVertexBuffer = function(e) {
- return this.createVertexBuffer(e, !0)
- }
- ,
- t.prototype.updateDynamicIndexBuffer = function(e, t, i) {
- void 0 === i && (i = 0);
- var n = e
- , r = this._normalizeIndexData(t);
- n.is32Bits = 4 === r.BYTES_PER_ELEMENT,
- this._engine.updateDynamicIndexBuffer(n.nativeIndexBuffer, r.buffer, r.byteOffset, r.byteLength, i)
- }
- ,
- t.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
- var r = e
- , o = ArrayBuffer.isView(t) ? t : new Float32Array(t);
- this._engine.updateDynamicVertexBuffer(r.nativeVertexBuffer, o.buffer, o.byteOffset + (null != i ? i : 0), null != n ? n : o.byteLength)
- }
- ,
- t.prototype._setTexture = function(e, t, i, n) {
- void 0 === i && (i = !1),
- void 0 === n && (n = !1);
- var r, o = this._boundUniforms[e];
- if (!o)
- return !1;
- if (!t)
- return null != this._boundTexturesCache[e] && (this._activeChannel = e,
- this._setTextureCore(o, null)),
- !1;
- if (t.video)
- this._activeChannel = e,
- t.update();
- else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
- return t.delayLoad(),
- !1;
- return r = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture,
- this._activeChannel = e,
- !(!r || !r._hardwareTexture || (this._setTextureWrapMode(r._hardwareTexture.underlyingResource, this._getAddressMode(t.wrapU), this._getAddressMode(t.wrapV), this._getAddressMode(t.wrapR)),
- this._updateAnisotropicLevel(t),
- this._setTextureCore(o, r._hardwareTexture.underlyingResource),
- 0))
- }
- ,
- t.prototype._setTextureSampling = function(e, t) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype._setTextureWrapMode = function(e, t, i, n) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(t),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(n),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype._setTextureCore = function(e, t) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(t),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- t.prototype._updateAnisotropicLevel = function(e) {
- var t = e.getInternalTexture()
- , i = e.anisotropicFilteringLevel;
- t && t._hardwareTexture && t._cachedAnisotropicFilteringLevel !== i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(t._hardwareTexture.underlyingResource),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.finishEncodingCommand(),
- t._cachedAnisotropicFilteringLevel = i)
- }
- ,
- t.prototype._getAddressMode = function(e) {
- switch (e) {
- case a.TEXTURE_WRAP_ADDRESSMODE:
- return _native.Engine.ADDRESS_MODE_WRAP;
- case a.TEXTURE_CLAMP_ADDRESSMODE:
- return _native.Engine.ADDRESS_MODE_CLAMP;
- case a.TEXTURE_MIRROR_ADDRESSMODE:
- return _native.Engine.ADDRESS_MODE_MIRROR;
- default:
- throw new Error("Unexpected wrap mode: " + e + ".")
- }
- }
- ,
- t.prototype._bindTexture = function(e, t) {
- var i = this._boundUniforms[e];
- if (i && t && t._hardwareTexture) {
- var n = t._hardwareTexture.underlyingResource;
- this._setTextureCore(i, n)
- }
- }
- ,
- t.prototype._deleteBuffer = function(e) {
- e.nativeIndexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeIndexBuffer),
- this._commandBufferEncoder.finishEncodingCommand(),
- delete e.nativeIndexBuffer),
- e.nativeVertexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeVertexBuffer),
- this._commandBufferEncoder.finishEncodingCommand(),
- delete e.nativeVertexBuffer)
- }
- ,
- t.prototype.createCanvas = function(e, t) {
- if (!_native.Canvas)
- throw new Error("Native Canvas plugin not available.");
- var i = new _native.Canvas;
- return i.width = e,
- i.height = t,
- i
- }
- ,
- t.prototype.createCanvasImage = function() {
- if (!_native.Canvas)
- throw new Error("Native Canvas plugin not available.");
- return new _native.Image
- }
- ,
- t.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
- throw void 0 === o && (o = 0),
- void 0 === a && (a = 0),
- new Error("_uploadCompressedDataToTextureDirectly not implemented.")
- }
- ,
- t.prototype._uploadDataToTextureDirectly = function(e, t, i, n) {
- throw void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- new Error("_uploadDataToTextureDirectly not implemented.")
- }
- ,
- t.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
- throw void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- new Error("_uploadArrayBufferViewToTexture not implemented.")
- }
- ,
- t.prototype._uploadImageToTexture = function(e, t, i, n) {
- throw void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- new Error("_uploadArrayBufferViewToTexture not implemented.")
- }
- ,
- t.prototype._getNativeSamplingMode = function(e) {
- switch (e) {
- case a.TEXTURE_NEAREST_NEAREST:
- return _native.Engine.TEXTURE_NEAREST_NEAREST;
- case a.TEXTURE_LINEAR_LINEAR:
- return _native.Engine.TEXTURE_LINEAR_LINEAR;
- case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
- return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;
- case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
- return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;
- case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
- return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;
- case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
- return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;
- case a.TEXTURE_NEAREST_LINEAR:
- return _native.Engine.TEXTURE_NEAREST_LINEAR;
- case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
- return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;
- case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
- return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;
- case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
- return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
- case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
- return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
- case a.TEXTURE_LINEAR_NEAREST:
- return _native.Engine.TEXTURE_LINEAR_NEAREST;
- default:
- throw new Error("Unsupported sampling mode: ".concat(e, "."))
- }
- }
- ,
- t.prototype._getStencilFunc = function(e) {
- switch (e) {
- case a.LESS:
- return _native.Engine.STENCIL_TEST_LESS;
- case a.LEQUAL:
- return _native.Engine.STENCIL_TEST_LEQUAL;
- case a.EQUAL:
- return _native.Engine.STENCIL_TEST_EQUAL;
- case a.GEQUAL:
- return _native.Engine.STENCIL_TEST_GEQUAL;
- case a.GREATER:
- return _native.Engine.STENCIL_TEST_GREATER;
- case a.NOTEQUAL:
- return _native.Engine.STENCIL_TEST_NOTEQUAL;
- case a.NEVER:
- return _native.Engine.STENCIL_TEST_NEVER;
- case a.ALWAYS:
- return _native.Engine.STENCIL_TEST_ALWAYS;
- default:
- throw new Error("Unsupported stencil func mode: ".concat(e, "."))
- }
- }
- ,
- t.prototype._getStencilOpFail = function(e) {
- switch (e) {
- case a.KEEP:
- return _native.Engine.STENCIL_OP_FAIL_S_KEEP;
- case a.ZERO:
- return _native.Engine.STENCIL_OP_FAIL_S_ZERO;
- case a.REPLACE:
- return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;
- case a.INCR:
- return _native.Engine.STENCIL_OP_FAIL_S_INCR;
- case a.DECR:
- return _native.Engine.STENCIL_OP_FAIL_S_DECR;
- case a.INVERT:
- return _native.Engine.STENCIL_OP_FAIL_S_INVERT;
- case a.INCR_WRAP:
- return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;
- case a.DECR_WRAP:
- return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;
- default:
- throw new Error("Unsupported stencil OpFail mode: ".concat(e, "."))
- }
- }
- ,
- t.prototype._getStencilDepthFail = function(e) {
- switch (e) {
- case a.KEEP:
- return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;
- case a.ZERO:
- return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;
- case a.REPLACE:
- return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;
- case a.INCR:
- return _native.Engine.STENCIL_OP_FAIL_Z_INCR;
- case a.DECR:
- return _native.Engine.STENCIL_OP_FAIL_Z_DECR;
- case a.INVERT:
- return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;
- case a.INCR_WRAP:
- return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;
- case a.DECR_WRAP:
- return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;
- default:
- throw new Error("Unsupported stencil depthFail mode: ".concat(e, "."))
- }
- }
- ,
- t.prototype._getStencilDepthPass = function(e) {
- switch (e) {
- case a.KEEP:
- return _native.Engine.STENCIL_OP_PASS_Z_KEEP;
- case a.ZERO:
- return _native.Engine.STENCIL_OP_PASS_Z_ZERO;
- case a.REPLACE:
- return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;
- case a.INCR:
- return _native.Engine.STENCIL_OP_PASS_Z_INCR;
- case a.DECR:
- return _native.Engine.STENCIL_OP_PASS_Z_DECR;
- case a.INVERT:
- return _native.Engine.STENCIL_OP_PASS_Z_INVERT;
- case a.INCR_WRAP:
- return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;
- case a.DECR_WRAP:
- return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;
- default:
- throw new Error("Unsupported stencil opPass mode: ".concat(e, "."))
- }
- }
- ,
- t.prototype._getNativeTextureFormat = function(e, t) {
- if (e == a.TEXTUREFORMAT_RGB && t == a.TEXTURETYPE_UNSIGNED_INT)
- return _native.Engine.TEXTURE_FORMAT_RGB8;
- if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_UNSIGNED_INT)
- return _native.Engine.TEXTURE_FORMAT_RGBA8;
- if (e == a.TEXTUREFORMAT_RGBA && t == a.TEXTURETYPE_FLOAT)
- return _native.Engine.TEXTURE_FORMAT_RGBA32F;
- throw new ft("Unsupported texture format or type: format ".concat(e, ", type ").concat(t, "."),pt.UnsupportedTextureError)
- }
- ,
- t.prototype._getNativeAlphaMode = function(e) {
- switch (e) {
- case a.ALPHA_DISABLE:
- return _native.Engine.ALPHA_DISABLE;
- case a.ALPHA_ADD:
- return _native.Engine.ALPHA_ADD;
- case a.ALPHA_COMBINE:
- return _native.Engine.ALPHA_COMBINE;
- case a.ALPHA_SUBTRACT:
- return _native.Engine.ALPHA_SUBTRACT;
- case a.ALPHA_MULTIPLY:
- return _native.Engine.ALPHA_MULTIPLY;
- case a.ALPHA_MAXIMIZED:
- return _native.Engine.ALPHA_MAXIMIZED;
- case a.ALPHA_ONEONE:
- return _native.Engine.ALPHA_ONEONE;
- case a.ALPHA_PREMULTIPLIED:
- return _native.Engine.ALPHA_PREMULTIPLIED;
- case a.ALPHA_PREMULTIPLIED_PORTERDUFF:
- return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
- case a.ALPHA_INTERPOLATE:
- return _native.Engine.ALPHA_INTERPOLATE;
- case a.ALPHA_SCREENMODE:
- return _native.Engine.ALPHA_SCREENMODE;
- default:
- throw new Error("Unsupported alpha mode: ".concat(e, "."))
- }
- }
- ,
- t.prototype._getNativeAttribType = function(e) {
- switch (e) {
- case Bi.BYTE:
- return _native.Engine.ATTRIB_TYPE_INT8;
- case Bi.UNSIGNED_BYTE:
- return _native.Engine.ATTRIB_TYPE_UINT8;
- case Bi.SHORT:
- return _native.Engine.ATTRIB_TYPE_INT16;
- case Bi.UNSIGNED_SHORT:
- return _native.Engine.ATTRIB_TYPE_UINT16;
- case Bi.FLOAT:
- return _native.Engine.ATTRIB_TYPE_FLOAT;
- default:
- throw new Error("Unsupported attribute type: ".concat(e, "."))
- }
- }
- ,
- t.prototype.getFontOffset = function(e) {
- return {
- ascent: 0,
- height: 0,
- descent: 0
- }
- }
- ,
- t.PROTOCOL_VERSION = 5,
- t
- }(vr);
- uu._createNativeDataStream = function() {
- return _native.NativeDataStream.VALIDATION_ENABLED ? new Ku : new bc
- }
- ;
- var hu, du, pu, fu, _u, mu, gu, vu, yu, bu, Tu, Eu, Su, Au, xu, Ru, Cu, Pu, Mu, Iu, Ou, Du, Nu, Lu, Fu, wu, Bu, Uu, Vu, ku, Gu, zu, Wu, Hu, Xu, ju, Yu, Ku = function(e) {
- function t() {
- return e.call(this) || this
- }
- return U(t, e),
- t.prototype.writeUint32 = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32),
- e.prototype.writeUint32.call(this, t)
- }
- ,
- t.prototype.writeInt32 = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32),
- e.prototype.writeInt32.call(this, t)
- }
- ,
- t.prototype.writeFloat32 = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32),
- e.prototype.writeFloat32.call(this, t)
- }
- ,
- t.prototype.writeUint32Array = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32_ARRAY),
- e.prototype.writeUint32Array.call(this, t)
- }
- ,
- t.prototype.writeInt32Array = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32_ARRAY),
- e.prototype.writeInt32Array.call(this, t)
- }
- ,
- t.prototype.writeFloat32Array = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),
- e.prototype.writeFloat32Array.call(this, t)
- }
- ,
- t.prototype.writeNativeData = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_NATIVE_DATA),
- e.prototype.writeNativeData.call(this, t)
- }
- ,
- t.prototype.writeBoolean = function(t) {
- e.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_BOOLEAN),
- e.prototype.writeBoolean.call(this, t)
- }
- ,
- t
- }(bc);
- !function(e) {
- e.SRGB = "srgb"
- }(hu || (hu = {})),
- function(e) {
- e.LowPower = "low-power",
- e.HighPerformance = "high-performance"
- }(du || (du = {})),
- function(e) {
- e.DepthClipControl = "depth-clip-control",
- e.Depth24UnormStencil8 = "depth24unorm-stencil8",
- e.Depth32FloatStencil8 = "depth32float-stencil8",
- e.TextureCompressionBC = "texture-compression-bc",
- e.TextureCompressionETC2 = "texture-compression-etc2",
- e.TextureCompressionASTC = "texture-compression-astc",
- e.TimestampQuery = "timestamp-query",
- e.IndirectFirstInstance = "indirect-first-instance"
- }(pu || (pu = {})),
- function(e) {
- e[e.MapRead = 1] = "MapRead",
- e[e.MapWrite = 2] = "MapWrite",
- e[e.CopySrc = 4] = "CopySrc",
- e[e.CopyDst = 8] = "CopyDst",
- e[e.Index = 16] = "Index",
- e[e.Vertex = 32] = "Vertex",
- e[e.Uniform = 64] = "Uniform",
- e[e.Storage = 128] = "Storage",
- e[e.Indirect = 256] = "Indirect",
- e[e.QueryResolve = 512] = "QueryResolve"
- }(fu || (fu = {})),
- function(e) {
- e[e.Read = 1] = "Read",
- e[e.Write = 2] = "Write"
- }(_u || (_u = {})),
- function(e) {
- e.E1d = "1d",
- e.E2d = "2d",
- e.E3d = "3d"
- }(mu || (mu = {})),
- function(e) {
- e[e.CopySrc = 1] = "CopySrc",
- e[e.CopyDst = 2] = "CopyDst",
- e[e.TextureBinding = 4] = "TextureBinding",
- e[e.StorageBinding = 8] = "StorageBinding",
- e[e.RenderAttachment = 16] = "RenderAttachment"
- }(gu || (gu = {})),
- function(e) {
- e.E1d = "1d",
- e.E2d = "2d",
- e.E2dArray = "2d-array",
- e.Cube = "cube",
- e.CubeArray = "cube-array",
- e.E3d = "3d"
- }(vu || (vu = {})),
- function(e) {
- e.All = "all",
- e.StencilOnly = "stencil-only",
- e.DepthOnly = "depth-only"
- }(yu || (yu = {})),
- function(e) {
- e.R8Unorm = "r8unorm",
- e.R8Snorm = "r8snorm",
- e.R8Uint = "r8uint",
- e.R8Sint = "r8sint",
- e.R16Uint = "r16uint",
- e.R16Sint = "r16sint",
- e.R16Float = "r16float",
- e.RG8Unorm = "rg8unorm",
- e.RG8Snorm = "rg8snorm",
- e.RG8Uint = "rg8uint",
- e.RG8Sint = "rg8sint",
- e.R32Uint = "r32uint",
- e.R32Sint = "r32sint",
- e.R32Float = "r32float",
- e.RG16Uint = "rg16uint",
- e.RG16Sint = "rg16sint",
- e.RG16Float = "rg16float",
- e.RGBA8Unorm = "rgba8unorm",
- e.RGBA8UnormSRGB = "rgba8unorm-srgb",
- e.RGBA8Snorm = "rgba8snorm",
- e.RGBA8Uint = "rgba8uint",
- e.RGBA8Sint = "rgba8sint",
- e.BGRA8Unorm = "bgra8unorm",
- e.BGRA8UnormSRGB = "bgra8unorm-srgb",
- e.RGB9E5UFloat = "rgb9e5ufloat",
- e.RGB10A2Unorm = "rgb10a2unorm",
- e.RG11B10UFloat = "rg11b10ufloat",
- e.RG32Uint = "rg32uint",
- e.RG32Sint = "rg32sint",
- e.RG32Float = "rg32float",
- e.RGBA16Uint = "rgba16uint",
- e.RGBA16Sint = "rgba16sint",
- e.RGBA16Float = "rgba16float",
- e.RGBA32Uint = "rgba32uint",
- e.RGBA32Sint = "rgba32sint",
- e.RGBA32Float = "rgba32float",
- e.Stencil8 = "stencil8",
- e.Depth16Unorm = "depth16unorm",
- e.Depth24Plus = "depth24plus",
- e.Depth24PlusStencil8 = "depth24plus-stencil8",
- e.Depth32Float = "depth32float",
- e.BC1RGBAUnorm = "bc1-rgba-unorm",
- e.BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
- e.BC2RGBAUnorm = "bc2-rgba-unorm",
- e.BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
- e.BC3RGBAUnorm = "bc3-rgba-unorm",
- e.BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
- e.BC4RUnorm = "bc4-r-unorm",
- e.BC4RSnorm = "bc4-r-snorm",
- e.BC5RGUnorm = "bc5-rg-unorm",
- e.BC5RGSnorm = "bc5-rg-snorm",
- e.BC6HRGBUFloat = "bc6h-rgb-ufloat",
- e.BC6HRGBFloat = "bc6h-rgb-float",
- e.BC7RGBAUnorm = "bc7-rgba-unorm",
- e.BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
- e.ETC2RGB8Unorm = "etc2-rgb8unorm",
- e.ETC2RGB8UnormSRGB = "etc2-rgb8unorm-srgb",
- e.ETC2RGB8A1Unorm = "etc2-rgb8a1unorm",
- e.ETC2RGB8A1UnormSRGB = "etc2-rgb8a1unorm-srgb",
- e.ETC2RGBA8Unorm = "etc2-rgba8unorm",
- e.ETC2RGBA8UnormSRGB = "etc2-rgba8unorm-srgb",
- e.EACR11Unorm = "eac-r11unorm",
- e.EACR11Snorm = "eac-r11snorm",
- e.EACRG11Unorm = "eac-rg11unorm",
- e.EACRG11Snorm = "eac-rg11snorm",
- e.ASTC4x4Unorm = "astc-4x4-unorm",
- e.ASTC4x4UnormSRGB = "astc-4x4-unorm-srgb",
- e.ASTC5x4Unorm = "astc-5x4-unorm",
- e.ASTC5x4UnormSRGB = "astc-5x4-unorm-srgb",
- e.ASTC5x5Unorm = "astc-5x5-unorm",
- e.ASTC5x5UnormSRGB = "astc-5x5-unorm-srgb",
- e.ASTC6x5Unorm = "astc-6x5-unorm",
- e.ASTC6x5UnormSRGB = "astc-6x5-unorm-srgb",
- e.ASTC6x6Unorm = "astc-6x6-unorm",
- e.ASTC6x6UnormSRGB = "astc-6x6-unorm-srgb",
- e.ASTC8x5Unorm = "astc-8x5-unorm",
- e.ASTC8x5UnormSRGB = "astc-8x5-unorm-srgb",
- e.ASTC8x6Unorm = "astc-8x6-unorm",
- e.ASTC8x6UnormSRGB = "astc-8x6-unorm-srgb",
- e.ASTC8x8Unorm = "astc-8x8-unorm",
- e.ASTC8x8UnormSRGB = "astc-8x8-unorm-srgb",
- e.ASTC10x5Unorm = "astc-10x5-unorm",
- e.ASTC10x5UnormSRGB = "astc-10x5-unorm-srgb",
- e.ASTC10x6Unorm = "astc-10x6-unorm",
- e.ASTC10x6UnormSRGB = "astc-10x6-unorm-srgb",
- e.ASTC10x8Unorm = "astc-10x8-unorm",
- e.ASTC10x8UnormSRGB = "astc-10x8-unorm-srgb",
- e.ASTC10x10Unorm = "astc-10x10-unorm",
- e.ASTC10x10UnormSRGB = "astc-10x10-unorm-srgb",
- e.ASTC12x10Unorm = "astc-12x10-unorm",
- e.ASTC12x10UnormSRGB = "astc-12x10-unorm-srgb",
- e.ASTC12x12Unorm = "astc-12x12-unorm",
- e.ASTC12x12UnormSRGB = "astc-12x12-unorm-srgb",
- e.Depth24UnormStencil8 = "depth24unorm-stencil8",
- e.Depth32FloatStencil8 = "depth32float-stencil8"
- }(bu || (bu = {})),
- function(e) {
- e.ClampToEdge = "clamp-to-edge",
- e.Repeat = "repeat",
- e.MirrorRepeat = "mirror-repeat"
- }(Tu || (Tu = {})),
- function(e) {
- e.Nearest = "nearest",
- e.Linear = "linear"
- }(Eu || (Eu = {})),
- function(e) {
- e.Never = "never",
- e.Less = "less",
- e.Equal = "equal",
- e.LessEqual = "less-equal",
- e.Greater = "greater",
- e.NotEqual = "not-equal",
- e.GreaterEqual = "greater-equal",
- e.Always = "always"
- }(Su || (Su = {})),
- function(e) {
- e[e.Vertex = 1] = "Vertex",
- e[e.Fragment = 2] = "Fragment",
- e[e.Compute = 4] = "Compute"
- }(Au || (Au = {})),
- function(e) {
- e.Uniform = "uniform",
- e.Storage = "storage",
- e.ReadOnlyStorage = "read-only-storage"
- }(xu || (xu = {})),
- function(e) {
- e.Filtering = "filtering",
- e.NonFiltering = "non-filtering",
- e.Comparison = "comparison"
- }(Ru || (Ru = {})),
- function(e) {
- e.Float = "float",
- e.UnfilterableFloat = "unfilterable-float",
- e.Depth = "depth",
- e.Sint = "sint",
- e.Uint = "uint"
- }(Cu || (Cu = {})),
- function(e) {
- e.WriteOnly = "write-only"
- }(Pu || (Pu = {})),
- function(e) {
- e.Error = "error",
- e.Warning = "warning",
- e.Info = "info"
- }(Mu || (Mu = {})),
- function(e) {
- e.PointList = "point-list",
- e.LineList = "line-list",
- e.LineStrip = "line-strip",
- e.TriangleList = "triangle-list",
- e.TriangleStrip = "triangle-strip"
- }(Iu || (Iu = {})),
- function(e) {
- e.CCW = "ccw",
- e.CW = "cw"
- }(Ou || (Ou = {})),
- function(e) {
- e.None = "none",
- e.Front = "front",
- e.Back = "back"
- }(Du || (Du = {})),
- function(e) {
- e[e.Red = 1] = "Red",
- e[e.Green = 2] = "Green",
- e[e.Blue = 4] = "Blue",
- e[e.Alpha = 8] = "Alpha",
- e[e.All = 15] = "All"
- }(Nu || (Nu = {})),
- function(e) {
- e.Zero = "zero",
- e.One = "one",
- e.Src = "src",
- e.OneMinusSrc = "one-minus-src",
- e.SrcAlpha = "src-alpha",
- e.OneMinusSrcAlpha = "one-minus-src-alpha",
- e.Dst = "dst",
- e.OneMinusDst = "one-minus-dst",
- e.DstAlpha = "dst-alpha",
- e.OneMinusDstAlpha = "one-minus-dst-alpha",
- e.SrcAlphaSaturated = "src-alpha-saturated",
- e.Constant = "constant",
- e.OneMinusConstant = "one-minus-constant"
- }(Lu || (Lu = {})),
- function(e) {
- e.Add = "add",
- e.Subtract = "subtract",
- e.ReverseSubtract = "reverse-subtract",
- e.Min = "min",
- e.Max = "max"
- }(Fu || (Fu = {})),
- function(e) {
- e.Keep = "keep",
- e.Zero = "zero",
- e.Replace = "replace",
- e.Invert = "invert",
- e.IncrementClamp = "increment-clamp",
- e.DecrementClamp = "decrement-clamp",
- e.IncrementWrap = "increment-wrap",
- e.DecrementWrap = "decrement-wrap"
- }(wu || (wu = {})),
- function(e) {
- e.Uint16 = "uint16",
- e.Uint32 = "uint32"
- }(Bu || (Bu = {})),
- function(e) {
- e.Uint8x2 = "uint8x2",
- e.Uint8x4 = "uint8x4",
- e.Sint8x2 = "sint8x2",
- e.Sint8x4 = "sint8x4",
- e.Unorm8x2 = "unorm8x2",
- e.Unorm8x4 = "unorm8x4",
- e.Snorm8x2 = "snorm8x2",
- e.Snorm8x4 = "snorm8x4",
- e.Uint16x2 = "uint16x2",
- e.Uint16x4 = "uint16x4",
- e.Sint16x2 = "sint16x2",
- e.Sint16x4 = "sint16x4",
- e.Unorm16x2 = "unorm16x2",
- e.Unorm16x4 = "unorm16x4",
- e.Snorm16x2 = "snorm16x2",
- e.Snorm16x4 = "snorm16x4",
- e.Float16x2 = "float16x2",
- e.Float16x4 = "float16x4",
- e.Float32 = "float32",
- e.Float32x2 = "float32x2",
- e.Float32x3 = "float32x3",
- e.Float32x4 = "float32x4",
- e.Uint32 = "uint32",
- e.Uint32x2 = "uint32x2",
- e.Uint32x3 = "uint32x3",
- e.Uint32x4 = "uint32x4",
- e.Sint32 = "sint32",
- e.Sint32x2 = "sint32x2",
- e.Sint32x3 = "sint32x3",
- e.Sint32x4 = "sint32x4"
- }(Uu || (Uu = {})),
- function(e) {
- e.Vertex = "vertex",
- e.Instance = "instance"
- }(Vu || (Vu = {})),
- function(e) {
- e.Beginning = "beginning",
- e.End = "end"
- }(ku || (ku = {})),
- function(e) {
- e.Beginning = "beginning",
- e.End = "end"
- }(Gu || (Gu = {})),
- function(e) {
- e.Load = "load",
- e.Clear = "clear"
- }(zu || (zu = {})),
- function(e) {
- e.Store = "store",
- e.Discard = "discard"
- }(Wu || (Wu = {})),
- function(e) {
- e.Occlusion = "occlusion",
- e.Timestamp = "timestamp"
- }(Hu || (Hu = {})),
- function(e) {
- e.Opaque = "opaque",
- e.Premultiplied = "premultiplied"
- }(Xu || (Xu = {})),
- function(e) {
- e.Destroyed = "destroyed"
- }(ju || (ju = {})),
- function(e) {
- e.OutOfMemory = "out-of-memory",
- e.Validation = "validation"
- }(Yu || (Yu = {}));
- var Qu = function() {
- function e() {
- this.shaderLanguage = st.GLSL
- }
- return e.prototype._addUniformToLeftOverUBO = function(e, t, i) {
- var n, r;
- e = (n = this._getArraySize(e, t, i))[0],
- t = n[1],
- r = n[2];
- for (var o = 0; o < this._webgpuProcessingContext.leftOverUniforms.length; o++)
- if (this._webgpuProcessingContext.leftOverUniforms[o].name === e)
- return;
- this._webgpuProcessingContext.leftOverUniforms.push({
- name: e,
- type: t,
- length: r
- })
- }
- ,
- e.prototype._buildLeftOverUBO = function() {
- if (!this._webgpuProcessingContext.leftOverUniforms.length)
- return "";
- var t = e.LeftOvertUBOName
- , i = this._webgpuProcessingContext.availableBuffers[t];
- return i || (i = {
- binding: this._webgpuProcessingContext.getNextFreeUBOBinding()
- },
- this._webgpuProcessingContext.availableBuffers[t] = i,
- this._addBufferBindingDescription(t, i, xu.Uniform, !0),
- this._addBufferBindingDescription(t, i, xu.Uniform, !1)),
- this._generateLeftOverUBOCode(t, i)
- }
- ,
- e.prototype._collectBindingNames = function() {
- for (var e = 0; e < this._webgpuProcessingContext.bindGroupLayoutEntries.length; e++) {
- var t = this._webgpuProcessingContext.bindGroupLayoutEntries[e];
- if (void 0 !== t)
- for (var i = 0; i < t.length; i++) {
- var n = this._webgpuProcessingContext.bindGroupLayoutEntries[e][i]
- , r = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][n.binding].name
- , o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[e][n.binding].nameInArrayOfTexture;
- n && (n.texture || n.externalTexture || n.storageTexture ? this._webgpuProcessingContext.textureNames.push(o) : n.sampler ? this._webgpuProcessingContext.samplerNames.push(r) : n.buffer && this._webgpuProcessingContext.bufferNames.push(r))
- }
- else
- this._webgpuProcessingContext.bindGroupLayoutEntries[e] = []
- }
- }
- ,
- e.prototype._preCreateBindGroupEntries = function() {
- for (var e = this._webgpuProcessingContext.bindGroupEntries, t = 0; t < this._webgpuProcessingContext.bindGroupLayoutEntries.length; t++) {
- for (var i = this._webgpuProcessingContext.bindGroupLayoutEntries[t], n = [], r = 0; r < i.length; r++) {
- var o = this._webgpuProcessingContext.bindGroupLayoutEntries[t][r];
- o.sampler || o.texture || o.storageTexture || o.externalTexture ? n.push({
- binding: o.binding,
- resource: void 0
- }) : o.buffer && n.push({
- binding: o.binding,
- resource: {
- buffer: void 0,
- offset: 0,
- size: 0
- }
- })
- }
- e[t] = n
- }
- }
- ,
- e.prototype._addTextureBindingDescription = function(e, t, i, n, r, o) {
- var a = t.textures[i]
- , s = a.groupIndex
- , l = a.bindingIndex;
- if (this._webgpuProcessingContext.bindGroupLayoutEntries[s] || (this._webgpuProcessingContext.bindGroupLayoutEntries[s] = [],
- this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s] = []),
- !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l]) {
- var c;
- c = null === n ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
- binding: l,
- visibility: 0,
- externalTexture: {}
- }) : r ? this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
- binding: l,
- visibility: 0,
- storageTexture: {
- access: Pu.WriteOnly,
- format: r,
- viewDimension: n
- }
- }) : this._webgpuProcessingContext.bindGroupLayoutEntries[s].push({
- binding: l,
- visibility: 0,
- texture: {
- sampleType: t.sampleType,
- viewDimension: n,
- multisampled: !1
- }
- });
- var u = t.isTextureArray ? e + i : e;
- this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l] = {
- name: e,
- index: c - 1,
- nameInArrayOfTexture: u
- }
- }
- l = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[s][l].index,
- this._webgpuProcessingContext.bindGroupLayoutEntries[s][l].visibility |= o ? Au.Vertex : Au.Fragment
- }
- ,
- e.prototype._addSamplerBindingDescription = function(e, t, i) {
- var n = t.binding
- , r = n.groupIndex
- , o = n.bindingIndex;
- if (this._webgpuProcessingContext.bindGroupLayoutEntries[r] || (this._webgpuProcessingContext.bindGroupLayoutEntries[r] = [],
- this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r] = []),
- !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o]) {
- var a = this._webgpuProcessingContext.bindGroupLayoutEntries[r].push({
- binding: o,
- visibility: 0,
- sampler: {
- type: t.type
- }
- });
- this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o] = {
- name: e,
- index: a - 1
- }
- }
- o = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[r][o].index,
- this._webgpuProcessingContext.bindGroupLayoutEntries[r][o].visibility |= i ? Au.Vertex : Au.Fragment
- }
- ,
- e.prototype._addBufferBindingDescription = function(e, t, i, n) {
- var r = t.binding
- , o = r.groupIndex
- , a = r.bindingIndex;
- if (this._webgpuProcessingContext.bindGroupLayoutEntries[o] || (this._webgpuProcessingContext.bindGroupLayoutEntries[o] = [],
- this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o] = []),
- !this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a]) {
- var s = this._webgpuProcessingContext.bindGroupLayoutEntries[o].push({
- binding: a,
- visibility: 0,
- buffer: {
- type: i
- }
- });
- this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a] = {
- name: e,
- index: s - 1
- }
- }
- a = this._webgpuProcessingContext.bindGroupLayoutEntryInfo[o][a].index,
- this._webgpuProcessingContext.bindGroupLayoutEntries[o][a].visibility |= n ? Au.Vertex : Au.Fragment
- }
- ,
- e.prototype._injectStartingAndEndingCode = function(e, t, i, n) {
- if (i) {
- var r = e.indexOf(t);
- if (r >= 0) {
- for (; r++ < e.length && "{" != e.charAt(r); )
- ;
- if (r < e.length) {
- for (; r++ < e.length && "\n" != e.charAt(r); )
- ;
- if (r < e.length) {
- var o = e.substring(0, r + 1)
- , a = e.substring(r + 1);
- e = o + i + a
- }
- }
- }
- }
- if (n) {
- var s = e.lastIndexOf("}");
- e = e.substring(0, s),
- e += n + "\n}"
- }
- return e
- }
- ,
- e.AutoSamplerSuffix = "Sampler",
- e.LeftOvertUBOName = "LeftOver",
- e.InternalsUBOName = "Internals",
- e.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
- },
- e._SamplerFunctionByWebGLSamplerType = {
- sampler2D: "sampler2D",
- sampler2DArray: "sampler2DArray",
- sampler2DShadow: "sampler2DShadow",
- sampler2DArrayShadow: "sampler2DArrayShadow",
- samplerCube: "samplerCube",
- sampler3D: "sampler3D"
- },
- e._TextureTypeByWebGLSamplerType = {
- sampler2D: "texture2D",
- sampler2DArray: "texture2DArray",
- sampler2DShadow: "texture2D",
- sampler2DArrayShadow: "texture2DArray",
- samplerCube: "textureCube",
- samplerCubeArray: "textureCubeArray",
- sampler3D: "texture3D"
- },
- e._GpuTextureViewDimensionByWebGPUTextureType = {
- textureCube: vu.Cube,
- textureCubeArray: vu.CubeArray,
- texture2D: vu.E2d,
- texture2DArray: vu.E2dArray,
- texture3D: vu.E3d
- },
- e._SamplerTypeByWebGLSamplerType = {
- sampler2DShadow: "samplerShadow",
- sampler2DArrayShadow: "samplerShadow"
- },
- e._IsComparisonSamplerByWebGPUSamplerType = {
- samplerShadow: !0,
- samplerArrayShadow: !0,
- sampler: !1
- },
- e
- }()
- , qu = function() {
- function e(e, t) {
- this._name = "unnamed",
- this.shaderProcessingContext = e,
- this._leftOverUniformsByName = {},
- this.engine = t
- }
- return Object.defineProperty(e.prototype, "isAsync", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isReady", {
- get: function() {
- return !!this.stages
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._handlesSpectorRebuildCallback = function() {}
- ,
- e.prototype._fillEffectInformation = function(e, t, i, n, r, o, a, s) {
- var l = this.engine;
- e._fragmentSourceCode = "",
- e._vertexSourceCode = "";
- var c, u = this.shaderProcessingContext.availableTextures;
- for (c = 0; c < r.length; c++) {
- var h = r[c]
- , d = u[r[c]];
- null == d || null == d ? (r.splice(c, 1),
- c--) : o[h] = c
- }
- for (var p = 0, f = l.getAttributes(this, a); p < f.length; p++) {
- var _ = f[p];
- s.push(_)
- }
- this.buildUniformLayout();
- var m = []
- , g = [];
- for (c = 0; c < a.length; c++) {
- var v = s[c];
- v >= 0 && (m.push(a[c]),
- g.push(v))
- }
- this.shaderProcessingContext.attributeNamesFromEffect = m,
- this.shaderProcessingContext.attributeLocationsFromEffect = g
- }
- ,
- e.prototype.buildUniformLayout = function() {
- if (this.shaderProcessingContext.leftOverUniforms.length) {
- this.uniformBuffer = new Fi(this.engine,void 0,void 0,"leftOver-" + this._name);
- for (var e = 0, t = this.shaderProcessingContext.leftOverUniforms; e < t.length; e++) {
- var i = t[e]
- , n = i.type.replace(/^(.*?)(<.*>)?$/, "$1")
- , r = Qu.UniformSizes[n];
- this.uniformBuffer.addUniform(i.name, r, i.length),
- this._leftOverUniformsByName[i.name] = i.type
- }
- this.uniformBuffer.create()
- }
- }
- ,
- e.prototype.dispose = function() {
- this.uniformBuffer && this.uniformBuffer.dispose()
- }
- ,
- e.prototype.setInt = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt(e, t)
- }
- ,
- e.prototype.setInt2 = function(e, t, i) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt2(e, t, i)
- }
- ,
- e.prototype.setInt3 = function(e, t, i, n) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt3(e, t, i, n)
- }
- ,
- e.prototype.setInt4 = function(e, t, i, n, r) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateInt4(e, t, i, n, r)
- }
- ,
- e.prototype.setIntArray = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateIntArray(e, t)
- }
- ,
- e.prototype.setIntArray2 = function(e, t) {
- this.setIntArray(e, t)
- }
- ,
- e.prototype.setIntArray3 = function(e, t) {
- this.setIntArray(e, t)
- }
- ,
- e.prototype.setIntArray4 = function(e, t) {
- this.setIntArray(e, t)
- }
- ,
- e.prototype.setArray = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateArray(e, t)
- }
- ,
- e.prototype.setArray2 = function(e, t) {
- this.setArray(e, t)
- }
- ,
- e.prototype.setArray3 = function(e, t) {
- this.setArray(e, t)
- }
- ,
- e.prototype.setArray4 = function(e, t) {
- this.setArray(e, t)
- }
- ,
- e.prototype.setMatrices = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrices(e, t)
- }
- ,
- e.prototype.setMatrix = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrix(e, t)
- }
- ,
- e.prototype.setMatrix3x3 = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrix3x3(e, t)
- }
- ,
- e.prototype.setMatrix2x2 = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateMatrix2x2(e, t)
- }
- ,
- e.prototype.setFloat = function(e, t) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat(e, t)
- }
- ,
- e.prototype.setVector2 = function(e, t) {
- this.setFloat2(e, t.x, t.y)
- }
- ,
- e.prototype.setFloat2 = function(e, t, i) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat2(e, t, i)
- }
- ,
- e.prototype.setVector3 = function(e, t) {
- this.setFloat3(e, t.x, t.y, t.z)
- }
- ,
- e.prototype.setFloat3 = function(e, t, i, n) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat3(e, t, i, n)
- }
- ,
- e.prototype.setVector4 = function(e, t) {
- this.setFloat4(e, t.x, t.y, t.z, t.w)
- }
- ,
- e.prototype.setFloat4 = function(e, t, i, n, r) {
- this.uniformBuffer && this._leftOverUniformsByName[e] && this.uniformBuffer.updateFloat4(e, t, i, n, r)
- }
- ,
- e.prototype.setColor3 = function(e, t) {
- this.setFloat3(e, t.r, t.g, t.b)
- }
- ,
- e.prototype.setColor4 = function(e, t, i) {
- this.setFloat4(e, t.r, t.g, t.b, i)
- }
- ,
- e.prototype.setDirectColor4 = function(e, t) {
- this.setFloat4(e, t.r, t.g, t.b, t.a)
- }
- ,
- e.prototype._getVertexShaderCode = function() {
- var e;
- return null === (e = this.sources) || void 0 === e ? void 0 : e.vertex
- }
- ,
- e.prototype._getFragmentShaderCode = function() {
- var e;
- return null === (e = this.sources) || void 0 === e ? void 0 : e.fragment
- }
- ,
- e
- }()
- , Zu = {
- mat2: 2,
- mat3: 3,
- mat4: 4,
- mat2x2: 2,
- mat3x3: 3,
- mat4x4: 4
- }
- , Ju = function() {
- function e(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(e, "KnownUBOs", {
- get: function() {
- return e._SimplifiedKnownBindings ? e._SimplifiedKnownUBOs : e._KnownUBOs
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._findStartingGroupBinding = function() {
- var t = e.KnownUBOs
- , i = [];
- for (var n in t) {
- var r = t[n].binding;
- -1 !== r.groupIndex && (void 0 === i[r.groupIndex] ? i[r.groupIndex] = r.bindingIndex : i[r.groupIndex] = Math.max(i[r.groupIndex], r.bindingIndex))
- }
- this.freeGroupIndex = i.length - 1,
- 0 === this.freeGroupIndex ? (this.freeGroupIndex++,
- this.freeBindingIndex = 0) : this.freeBindingIndex = i[i.length - 1] + 1
- }
- ,
- e.prototype.getAttributeNextLocation = function(e, t) {
- var i;
- void 0 === t && (t = 0);
- var n = this._attributeNextLocation;
- return this._attributeNextLocation += (null !== (i = Zu[e]) && void 0 !== i ? i : 1) * (t || 1),
- n
- }
- ,
- e.prototype.getVaryingNextLocation = function(e, t) {
- var i;
- void 0 === t && (t = 0);
- var n = this._varyingNextLocation;
- return this._varyingNextLocation += (null !== (i = Zu[e]) && void 0 !== i ? i : 1) * (t || 1),
- n
- }
- ,
- e.prototype.getNextFreeUBOBinding = function() {
- return this._getNextFreeBinding(1)
- }
- ,
- e.prototype._getNextFreeBinding = function(e) {
- if (this.freeBindingIndex > 65536 - e && (this.freeGroupIndex++,
- this.freeBindingIndex = 0),
- 4 === this.freeGroupIndex)
- throw "Too many textures or UBOs have been declared and it is not supported in WebGPU.";
- var t = {
- groupIndex: this.freeGroupIndex,
- bindingIndex: this.freeBindingIndex
- };
- return this.freeBindingIndex += e,
- t
- }
- ,
- e._SimplifiedKnownBindings = !0,
- e._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
- }
- },
- Internals: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- }
- },
- e._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
- }
- },
- Internals: {
- binding: {
- groupIndex: 2,
- bindingIndex: 2
- }
- }
- },
- e
- }()
- , $u = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t._missingVaryings = [],
- t._textureArrayProcessing = [],
- t.shaderLanguage = st.GLSL,
- t
- }
- return U(t, e),
- t.prototype._getArraySize = function(e, t, i) {
- var n = 0
- , r = e.indexOf("[")
- , o = e.indexOf("]");
- if (r > 0 && o > 0) {
- var a = e.substring(r + 1, o);
- n = +a,
- isNaN(n) && (n = +i[a.trim()]),
- e = e.substr(0, r)
- }
- return [e, t, n]
- }
- ,
- t.prototype.initializeShaders = function(e) {
- this._webgpuProcessingContext = e,
- this._missingVaryings.length = 0,
- this._textureArrayProcessing.length = 0
- }
- ,
- t.prototype.preProcessShaderCode = function(e, t) {
- var i = "uniform ".concat(Qu.InternalsUBOName, " {\nfloat yFactor__;\nfloat textureOutputHeight__;\n};\n");
- return t ? i + "##INJECTCODE##\n" + e : i + e
- }
- ,
- t.prototype.varyingProcessor = function(e, t, i) {
- this._preProcessors = i;
- var n = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);
- if (null != n) {
- var r, o = n[1], a = n[2];
- t ? (r = this._webgpuProcessingContext.availableVaryings[a],
- this._missingVaryings[r] = "",
- void 0 === r && K.Warn('Invalid fragment shader: The varying named "'.concat(a, '" is not declared in the vertex shader! This declaration will be ignored.'))) : (r = this._webgpuProcessingContext.getVaryingNextLocation(o, this._getArraySize(a, o, i)[2]),
- this._webgpuProcessingContext.availableVaryings[a] = r,
- this._missingVaryings[r] = "layout(location = ".concat(r, ") in ").concat(o, " ").concat(a, ";")),
- e = e.replace(n[0], void 0 === r ? "" : "layout(location = ".concat(r, ") ").concat(t ? "in" : "out", " ").concat(o, " ").concat(a, ";"))
- }
- return e
- }
- ,
- t.prototype.attributeProcessor = function(e, t) {
- this._preProcessors = t;
- var i = /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm.exec(e);
- if (null != i) {
- var n = i[1]
- , r = i[2]
- , o = this._webgpuProcessingContext.getAttributeNextLocation(n, this._getArraySize(r, n, t)[2]);
- this._webgpuProcessingContext.availableAttributes[r] = o,
- this._webgpuProcessingContext.orderedAttributes[o] = r,
- e = e.replace(i[0], "layout(location = ".concat(o, ") in ").concat(n, " ").concat(r, ";"))
- }
- return e
- }
- ,
- t.prototype.uniformProcessor = function(e, t, i) {
- var n, r;
- this._preProcessors = i;
- var o = /\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);
- if (null != o) {
- var a = o[1]
- , s = o[2];
- if (0 === a.indexOf("sampler") || 1 === a.indexOf("sampler")) {
- var l = 0;
- s = (n = this._getArraySize(s, a, i))[0],
- a = n[1],
- l = n[2];
- var c = this._webgpuProcessingContext.availableTextures[s];
- if (!c) {
- c = {
- autoBindSampler: !0,
- isTextureArray: l > 0,
- isStorageTexture: !1,
- textures: [],
- sampleType: Cu.Float
- };
- for (var u = 0; u < (l || 1); ++u)
- c.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())
- }
- var h = null !== (r = Qu._SamplerTypeByWebGLSamplerType[a]) && void 0 !== r ? r : "sampler"
- , d = !!Qu._IsComparisonSamplerByWebGPUSamplerType[h]
- , p = d ? Ru.Comparison : Ru.Filtering
- , f = s + Qu.AutoSamplerSuffix
- , _ = this._webgpuProcessingContext.availableSamplers[f];
- _ || (_ = {
- binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),
- type: p
- });
- var m = "u" === a.charAt(0) ? "u" : "i" === a.charAt(0) ? "i" : "";
- m && (a = a.substr(1));
- var g = d ? Cu.Depth : "u" === m ? Cu.Uint : "i" === m ? Cu.Sint : Cu.Float;
- c.sampleType = g;
- var v = l > 0
- , y = _.binding.groupIndex
- , b = _.binding.bindingIndex
- , T = Qu._SamplerFunctionByWebGLSamplerType[a]
- , E = Qu._TextureTypeByWebGLSamplerType[a]
- , S = Qu._GpuTextureViewDimensionByWebGPUTextureType[E];
- if (v) {
- var A = [];
- for (A.push("layout(set = ".concat(y, ", binding = ").concat(b, ") uniform ").concat(m).concat(h, " ").concat(f, ";")),
- e = "\r\n",
- u = 0; u < l; ++u) {
- var x = c.textures[u].groupIndex
- , R = c.textures[u].bindingIndex;
- A.push("layout(set = ".concat(x, ", binding = ").concat(R, ") uniform ").concat(E, " ").concat(s, "Texture").concat(u, ";")),
- e += "".concat(u > 0 ? "\r\n" : "", "#define ").concat(s).concat(u, " ").concat(m).concat(T, "(").concat(s, "Texture").concat(u, ", ").concat(f, ")")
- }
- e = A.join("\r\n") + e,
- this._textureArrayProcessing.push(s)
- } else
- l = 1,
- e = "layout(set = ".concat(y, ", binding = ").concat(b, ") uniform ").concat(m).concat(h, " ").concat(f, ";\n layout(set = ").concat(c.textures[0].groupIndex, ", binding = ").concat(c.textures[0].bindingIndex, ") uniform ").concat(E, " ").concat(s, "Texture;\n #define ").concat(s, " ").concat(m).concat(T, "(").concat(s, "Texture, ").concat(f, ")");
- for (this._webgpuProcessingContext.availableTextures[s] = c,
- this._webgpuProcessingContext.availableSamplers[f] = _,
- this._addSamplerBindingDescription(f, _, !t),
- u = 0; u < l; ++u)
- this._addTextureBindingDescription(s, c, u, S, null, !t)
- } else
- this._addUniformToLeftOverUBO(s, a, i),
- e = ""
- }
- return e
- }
- ,
- t.prototype.uniformBufferProcessor = function(e, t) {
- var i = /uniform\s+(\w+)/gm.exec(e);
- if (null != i) {
- var n = i[1]
- , r = this._webgpuProcessingContext.availableBuffers[n];
- if (!r) {
- var o = Ju.KnownUBOs[n];
- r = {
- binding: o && -1 !== o.binding.groupIndex ? o.binding : this._webgpuProcessingContext.getNextFreeUBOBinding()
- },
- this._webgpuProcessingContext.availableBuffers[n] = r
- }
- this._addBufferBindingDescription(n, r, xu.Uniform, !t),
- e = e.replace("uniform", "layout(set = ".concat(r.binding.groupIndex, ", binding = ").concat(r.binding.bindingIndex, ") uniform"))
- }
- return e
- }
- ,
- t.prototype.postProcessor = function(e, t, i, n, r) {
- var o = -1 !== e.search(/#extension.+GL_EXT_draw_buffers.+require/);
- if (e = (e = e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g, "")).replace(/texture2D\s*\(/g, "texture("),
- i) {
- var a = e.indexOf("gl_FragCoord") >= 0
- , s = a ? "vec4 glFragCoord__;\n" : "";
- e = (e = (e = (e = (e = (e = (e = (e = (e = (e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod(")).replace(/textureCubeLodEXT\s*\(/g, "textureLod(")).replace(/textureCube\s*\(/g, "texture(")).replace(/gl_FragDepthEXT/g, "gl_FragDepth")).replace(/gl_FragColor/g, "glFragColor")).replace(/gl_FragData/g, "glFragData")).replace(/gl_FragCoord/g, "glFragCoord__")).replace(/void\s+?main\s*\(/g, (o ? "" : "layout(location = 0) out vec4 glFragColor;\n") + "void main(")).replace(/dFdy/g, "(-yFactor__)*dFdy")).replace("##INJECTCODE##", s),
- a && (e = this._injectStartingAndEndingCode(e, "void main", "\n glFragCoord__ = gl_FragCoord;\n if (yFactor__ == 1.) {\n glFragCoord__.y = textureOutputHeight__ - glFragCoord__.y;\n }\n "))
- } else if (e = (e = e.replace(/gl_InstanceID/g, "gl_InstanceIndex")).replace(/gl_VertexID/g, "gl_VertexIndex"),
- -1 !== t.indexOf("#define MULTIVIEW"))
- return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + e;
- if (!i) {
- var l = e.lastIndexOf("}");
- e = e.substring(0, l),
- e += "gl_Position.y *= yFactor__;\n",
- r.isNDCHalfZRange || (e += "gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;\n"),
- e += "}"
- }
- return e
- }
- ,
- t.prototype._applyTextureArrayProcessing = function(e, t) {
- for (var i = new RegExp(t + "\\s*\\[(.+)?\\]","gm"), n = i.exec(e); null != n; ) {
- var r = n[1]
- , o = +r;
- this._preProcessors && isNaN(o) && (o = +this._preProcessors[r.trim()]),
- e = e.replace(n[0], t + o),
- n = i.exec(e)
- }
- return e
- }
- ,
- t.prototype._generateLeftOverUBOCode = function(e, t) {
- for (var i = "layout(set = ".concat(t.binding.groupIndex, ", binding = ").concat(t.binding.bindingIndex, ") uniform ").concat(e, " {\n "), n = 0, r = this._webgpuProcessingContext.leftOverUniforms; n < r.length; n++) {
- var o = r[n];
- o.length > 0 ? i += " ".concat(o.type, " ").concat(o.name, "[").concat(o.length, "];\n") : i += " ".concat(o.type, " ").concat(o.name, ";\n")
- }
- return i + "};\n\n"
- }
- ,
- t.prototype.finalizeShaders = function(e, t) {
- for (var i = 0; i < this._textureArrayProcessing.length; ++i) {
- var n = this._textureArrayProcessing[i];
- e = this._applyTextureArrayProcessing(e, n),
- t = this._applyTextureArrayProcessing(t, n)
- }
- for (i = 0; i < this._missingVaryings.length; ++i) {
- var r = this._missingVaryings[i];
- r && r.length > 0 && (t = r + "\n" + t)
- }
- var o = this._buildLeftOverUBO();
- return e = o + e,
- t = o + t,
- this._collectBindingNames(),
- this._preCreateBindGroupEntries(),
- this._preProcessors = null,
- {
- vertexCode: e,
- fragmentCode: t
- }
- }
- ,
- t
- }(Qu);
- Pt.IncludesShadersStoreWGSL.bonesDeclaration = "#if NUM_BONE_INFLUENCERS>0\nattribute matricesIndices : vec4<f32>;\nattribute matricesWeights : vec4<f32>;\n#if NUM_BONE_INFLUENCERS>4\nattribute matricesIndicesExtra : vec4<f32>;\nattribute matricesWeightsExtra : vec4<f32>;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nvar boneSampler : texture_2d<f32>;\nuniform boneTextureWidth : f32;\n#else\nuniform mBones : array<mat4x4,BonesPerMesh>;\n#ifdef BONES_VELOCITY_ENABLED\nuniform mPreviousBones : array<mat4x4,BonesPerMesh>;\n#endif\n#endif\n#ifdef BONETEXTURE\nfn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32)->mat4x4<f32>\n{\nlet offset=i32(index) *4; \nlet m0=textureLoad(smp,vec2<i32>(offset+0,0),0);\nlet m1=textureLoad(smp,vec2<i32>(offset+1,0),0);\nlet m2=textureLoad(smp,vec2<i32>(offset+2,0),0);\nlet m3=textureLoad(smp,vec2<i32>(offset+3,0),0);\nreturn mat4x4<f32>(m0,m1,m2,m3);\n}\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.bonesVertex = "#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nvar influence : mat4x4<f32>;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif \n#else \ninfluence=uniforms.mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+uniforms.mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+uniforms.mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+uniforms.mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform bakedVertexAnimationTime: f32;\nuniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;\nuniform bakedVertexAnimationSettings: vec4<f32>;\nvar bakedVertexAnimationTexture : texture_2d<f32>;\n#ifdef INSTANCES\nattribute bakedVertexAnimationSettingsInstanced : vec4<f32>;\n#endif\nfn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32)->mat4x4<f32>\n{\nlet offset=i32(index)*4;\nlet frameUV=i32(frame);\nlet m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);\nlet m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);\nlet m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);\nlet m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);\nreturn mat4x4<f32>(m0,m1,m2,m3);\n}\n#endif\n";
- Pt.IncludesShadersStoreWGSL.bakedVertexAnimation = "#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\nlet VATStartFrame: f32=bakedVertexAnimationSettingsInstanced.x;\nlet VATEndFrame: f32=bakedVertexAnimationSettingsInstanced.y;\nlet VATOffsetFrame: f32=bakedVertexAnimationSettingsInstanced.z;\nlet VATSpeed: f32=bakedVertexAnimationSettingsInstanced.w;\n#else\nlet VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;\nlet VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;\nlet VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;\nlet VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;\n#endif\nlet totalFrames: f32=VATEndFrame-VATStartFrame+1.0;\nlet time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;\nlet frameCorrection: f32=select(1.0,0.0,time<1.0);\nlet numOfFrames: f32=totalFrames-frameCorrection;\nvar VATFrameNum: f32=fract(time)*numOfFrames;\nVATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;\nvar VATInfluence : mat4x4<f32>;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif\n";
- Pt.IncludesShadersStoreWGSL.clipPlaneFragment = "#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelseif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelseif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelseif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelseif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelseif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelseif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif\n";
- Pt.IncludesShadersStoreWGSL.clipPlaneFragmentDeclaration = "#ifdef CLIPPLANE\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nvarying fClipDistance6: f32;\n#endif\n";
- Pt.IncludesShadersStoreWGSL.clipPlaneVertex = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,uniforms.vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,uniforms.vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,uniforms.vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,uniforms.vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,uniforms.vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,uniforms.vClipPlane6);\n#endif\n";
- Pt.IncludesShadersStoreWGSL.clipPlaneVertexDeclaration = "#ifdef CLIPPLANE\nuniform vClipPlane: vec4<f32>;\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nuniform vClipPlane2: vec4<f32>;\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nuniform vClipPlane3: vec4<f32>;\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nuniform vClipPlane4: vec4<f32>;\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nuniform vClipPlane5: vec4<f32>;\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nuniform vClipPlane6: vec4<f32>;\nvarying fClipDistance6: f32;\n#endif\n";
- Pt.IncludesShadersStoreWGSL.instancesDeclaration = "#ifdef INSTANCES\nattribute world0 : vec4<f32>;\nattribute world1 : vec4<f32>;\nattribute world2 : vec4<f32>;\nattribute world3 : vec4<f32>;\n#ifdef INSTANCESCOLOR\nattribute instanceColor : vec4<f32>;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute previousWorld0 : vec4<f32>;\nattribute previousWorld1 : vec4<f32>;\nattribute previousWorld2 : vec4<f32>;\nattribute previousWorld3 : vec4<f32>;\n#ifdef THIN_INSTANCES\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform world : mat4x4<f32>;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform previousWorld : mat4x4<f32>;\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.instancesVertex = "#ifdef INSTANCES\nvar finalWorld=mat4x4<f32>(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=mat4x4<f32>(previousWorld0,previousWorld1,previousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\n#if !defined(WORLD_UBO)\nfinalWorld=uniforms.world*finalWorld;\n#else\nfinalWorld=mesh.world*finalWorld;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nvar finalWorld=uniforms.world;\n#else\nvar finalWorld=mesh.world;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=previousWorld;\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.meshUboDeclaration = "struct Mesh {\nworld : mat4x4<f32>;\nvisibility : f32;\n};\nvar<uniform> mesh : Mesh;\n#define WORLD_UBO\n";
- Pt.IncludesShadersStoreWGSL.morphTargetsVertex = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE \nvertexID=f32(gl_VertexID)*uniforms.morphTargetTextureInfo.x;\npositionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-position)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID) -normal)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-uv)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.morphTargetsVertexDeclaration = "#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute position{X} : vec3<f32>;\n#ifdef MORPHTARGETS_NORMAL\nattribute normal{X} : vec3<f32>;\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute tangent{X} : vec3<f32>;\n#endif\n#ifdef MORPHTARGETS_UV\nattribute uv_{X} : vec2<f32>;\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.morphTargetsVertexGlobal = "#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.morphTargetsVertexGlobalDeclaration = "#ifdef MORPHTARGETS\nuniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>;\n#ifdef MORPHTARGETS_TEXTURE \nuniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;\nuniform morphTargetTextureInfo : vec3<f32>;\nvar morphTargets : texture_2d_array<f32>;\nvar morphTargetsSampler : sampler;\nfn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3<f32>\n{ \nlet y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);\nlet x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;\nlet textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);\nreturn textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStoreWGSL.sceneUboDeclaration = "struct Scene {\nviewProjection : mat4x4<f32>;\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4<f32>;\n#endif \nview : mat4x4<f32>;\nprojection : mat4x4<f32>;\nvEyePosition : vec4<f32>;\n};\nvar<uniform> scene : Scene;\n";
- var eh, th = "gl_VertexID", ih = "gl_InstanceID", nh = "gl_Position", rh = "gl_FragCoord", oh = "gl_FrontFacing", ah = "gl_FragDepth", sh = "gl_FragColor", lh = {
- texture_1d: vu.E1d,
- texture_2d: vu.E2d,
- texture_2d_array: vu.E2dArray,
- texture_3d: vu.E3d,
- texture_cube: vu.Cube,
- texture_cube_array: vu.CubeArray,
- texture_multisampled_2d: vu.E2d,
- texture_depth_2d: vu.E2d,
- texture_depth_2d_array: vu.E2dArray,
- texture_depth_cube: vu.Cube,
- texture_depth_cube_array: vu.CubeArray,
- texture_depth_multisampled_2d: vu.E2d,
- texture_storage_1d: vu.E1d,
- texture_storage_2d: vu.E2d,
- texture_storage_2d_array: vu.E2dArray,
- texture_storage_3d: vu.E3d,
- texture_external: null
- }, ch = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.shaderLanguage = st.WGSL,
- t.uniformRegexp = /uniform\s+(\w+)\s*:\s*(.+)\s*;/,
- t.textureRegexp = /var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,
- t.noPrecision = !0,
- t
- }
- return U(t, e),
- t.prototype._getArraySize = function(e, t, i) {
- var n = 0
- , r = t.lastIndexOf(">");
- if (t.indexOf("array") >= 0 && r > 0) {
- for (var o = r; o > 0 && " " !== t.charAt(o) && "," !== t.charAt(o); )
- o--;
- var a = t.substring(o + 1, r);
- for (n = +a,
- isNaN(n) && (n = +i[a.trim()]); o > 0 && (" " === t.charAt(o) || "," === t.charAt(o)); )
- o--;
- t = t.substring(t.indexOf("<") + 1, o + 1)
- }
- return [e, t, n]
- }
- ,
- t.prototype.initializeShaders = function(e) {
- this._webgpuProcessingContext = e,
- this._attributesWGSL = [],
- this._attributesDeclWGSL = [],
- this._attributeNamesWGSL = [],
- this._varyingsWGSL = [],
- this._varyingsDeclWGSL = [],
- this._varyingNamesWGSL = []
- }
- ,
- t.prototype.preProcessShaderCode = function(e) {
- return "struct ".concat(Qu.InternalsUBOName, " {\nyFactor__: f32;\ntextureOutputHeight__: f32;\n};\nvar<uniform> ").concat("internals", " : ").concat(Qu.InternalsUBOName, ";\n") + $c(e)
- }
- ,
- t.prototype.varyingProcessor = function(e, t, i) {
- var n = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
- if (null !== n) {
- var r, o = n[2], a = n[1];
- t ? void 0 === (r = this._webgpuProcessingContext.availableVaryings[a]) && K.Warn('Invalid fragment shader: The varying named "'.concat(a, '" is not declared in the vertex shader! This declaration will be ignored.')) : (r = this._webgpuProcessingContext.getVaryingNextLocation(o, this._getArraySize(a, o, i)[2]),
- this._webgpuProcessingContext.availableVaryings[a] = r,
- this._varyingsWGSL.push("@location(".concat(r, ") ").concat(a, " : ").concat(o, ";")),
- this._varyingsDeclWGSL.push("var<private> ".concat(a, " : ").concat(o, ";")),
- this._varyingNamesWGSL.push(a)),
- e = ""
- }
- return e
- }
- ,
- t.prototype.attributeProcessor = function(e, t) {
- var i = /\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);
- if (null !== i) {
- var n = i[2]
- , r = i[1]
- , o = this._webgpuProcessingContext.getAttributeNextLocation(n, this._getArraySize(r, n, t)[2]);
- this._webgpuProcessingContext.availableAttributes[r] = o,
- this._webgpuProcessingContext.orderedAttributes[o] = r,
- this._attributesWGSL.push("@location(".concat(o, ") ").concat(r, " : ").concat(n, ";")),
- this._attributesDeclWGSL.push("var<private> ".concat(r, " : ").concat(n, ";")),
- this._attributeNamesWGSL.push(r),
- e = ""
- }
- return e
- }
- ,
- t.prototype.uniformProcessor = function(e, t, i) {
- var n = this.uniformRegexp.exec(e);
- if (null !== n) {
- var r = n[2]
- , o = n[1];
- this._addUniformToLeftOverUBO(o, r, i),
- e = ""
- }
- return e
- }
- ,
- t.prototype.textureProcessor = function(e, t, i) {
- var n = this.textureRegexp.exec(e);
- if (null !== n) {
- var r = n[1]
- , o = n[2]
- , a = !!n[3]
- , s = n[4]
- , l = s.indexOf("storage") > 0
- , c = n[6]
- , u = l ? c.substring(0, c.indexOf(",")).trim() : null
- , h = a ? this._getArraySize(r, o, i)[2] : 0
- , d = this._webgpuProcessingContext.availableTextures[r];
- if (d)
- h = d.textures.length;
- else {
- d = {
- isTextureArray: h > 0,
- isStorageTexture: l,
- textures: [],
- sampleType: Cu.Float
- },
- h = h || 1;
- for (var p = 0; p < h; ++p)
- d.textures.push(this._webgpuProcessingContext.getNextFreeUBOBinding())
- }
- this._webgpuProcessingContext.availableTextures[r] = d;
- var f = s.indexOf("depth") > 0
- , _ = lh[s]
- , m = f ? Cu.Depth : "u32" === c ? Cu.Uint : "i32" === c ? Cu.Sint : Cu.Float;
- if (d.sampleType = m,
- void 0 === _)
- throw "Can't get the texture dimension corresponding to the texture function \"".concat(s, '"!');
- for (p = 0; p < h; ++p) {
- var g = d.textures[p]
- , v = g.groupIndex
- , y = g.bindingIndex;
- 0 === p && (e = "@group(".concat(v, ") @binding(").concat(y, ") ").concat(e)),
- this._addTextureBindingDescription(r, d, p, _, u, !t)
- }
- }
- return e
- }
- ,
- t.prototype.postProcessor = function(e) {
- return e
- }
- ,
- t.prototype.finalizeShaders = function(e, t) {
- var i = t.indexOf("gl_FragCoord") >= 0 ? "\n if (internals.yFactor__ == 1.) {\n gl_FragCoord.y = internals.textureOutputHeight__ - gl_FragCoord.y;\n }\n " : "";
- e = this._processSamplers(e, !0),
- t = this._processSamplers(t, !1),
- e = this._processCustomBuffers(e, !0),
- t = this._processCustomBuffers(t, !1);
- var n = this._buildLeftOverUBO();
- t = n + t,
- e = (e = n + e).replace(/#define /g, "//#define ");
- var r = this._varyingsDeclWGSL.join("\n") + "\n"
- , o = "var<private> ".concat(th, " : u32;\nvar<private> ").concat(ih, " : u32;\nvar<private> ").concat(nh, " : vec4<f32>;\n")
- , a = this._attributesDeclWGSL.join("\n") + "\n"
- , s = "struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32;\n @builtin(instance_index) instanceIndex : u32;\n";
- this._attributesWGSL.length > 0 && (s += this._attributesWGSL.join("\n")),
- s += "\n};\n";
- var l = "struct FragmentInputs {\n @builtin(position) position : vec4<f32>;\n";
- this._varyingsWGSL.length > 0 && (l += this._varyingsWGSL.join("\n")),
- e = o + s + a + (l += "\n};\n") + r + e;
- for (var c = " var output : FragmentInputs;\n ".concat(th, " = input.vertexIndex;\n ").concat(ih, " = input.instanceIndex;\n"), u = 0; u < this._attributeNamesWGSL.length; ++u) {
- var h = this._attributeNamesWGSL[u];
- c += " ".concat(h, " = input.").concat(h, ";\n")
- }
- var d = " output.position = ".concat(nh, ";\n output.position.y = output.position.y * internals.yFactor__;\n");
- for (u = 0; u < this._varyingNamesWGSL.length; ++u) {
- var p = this._varyingNamesWGSL[u];
- d += " output.".concat(p, " = ").concat(p, ";\n")
- }
- d += " return output;",
- e = this._injectStartingAndEndingCode(e, "fn main", c, d),
- t = (t = t.replace(/#define /g, "//#define ")).replace(/dpdy/g, "(-internals.yFactor__)*dpdy");
- var f = "var<private> ".concat(rh, " : vec4<f32>;\nvar<private> ").concat(oh, " : bool;\nvar<private> ").concat(sh, " : vec4<f32>;\nvar<private> ").concat(ah, " : f32;\n")
- , _ = "struct FragmentInputs {\n @builtin(position) position : vec4<f32>;\n @builtin(front_facing) frontFacing : bool;\n";
- this._varyingsWGSL.length > 0 && (_ += this._varyingsWGSL.join("\n")),
- _ += "\n};\n";
- for (var m = "struct FragmentOutputs {\n @location(0) color : vec4<f32>;\n", g = !1, v = 0; !(g || (v = t.indexOf(ah, v)) < 0); ) {
- var y = v;
- for (g = !0; v > 1 && "\n" !== t.charAt(v); ) {
- if ("/" === t.charAt(v) && "/" === t.charAt(v - 1)) {
- g = !1;
- break
- }
- v--
- }
- v = y + ah.length
- }
- g && (m += " @builtin(frag_depth) fragDepth: f32;\n"),
- t = f + _ + r + (m += "};\n") + t;
- var b = " var output : FragmentOutputs;\n ".concat(rh, " = input.position;\n ").concat(oh, " = input.frontFacing;\n") + i;
- for (u = 0; u < this._varyingNamesWGSL.length; ++u) {
- var T = this._varyingNamesWGSL[u];
- b += " ".concat(T, " = input.").concat(T, ";\n")
- }
- var E = " output.color = ".concat(sh, ";\n");
- return g && (E += " output.fragDepth = ".concat(ah, ";\n")),
- E += " return output;",
- t = this._injectStartingAndEndingCode(t, "fn main", b, E),
- this._collectBindingNames(),
- this._preCreateBindGroupEntries(),
- {
- vertexCode: e,
- fragmentCode: t
- }
- }
- ,
- t.prototype._generateLeftOverUBOCode = function(e, t) {
- for (var i = "struct ".concat(e, " {\n"), n = 0, r = this._webgpuProcessingContext.leftOverUniforms; n < r.length; n++) {
- var o = r[n]
- , a = o.type.replace(/^(.*?)(<.*>)?$/, "$1")
- , s = Qu.UniformSizes[a];
- o.length > 0 ? i += s <= 2 ? " @align(16) ".concat(o.name, " : @stride(16) array<").concat(o.type, ", ").concat(o.length, ">;\n") : " ".concat(o.name, " : array<").concat(o.type, ", ").concat(o.length, ">;\n") : i += " ".concat(o.name, " : ").concat(o.type, ";\n")
- }
- return (i += "};\n") + "@group(".concat(t.binding.groupIndex, ") @binding(").concat(t.binding.bindingIndex, ") var<uniform> ").concat("uniforms", " : ").concat(e, ";\n")
- }
- ,
- t.prototype._processSamplers = function(e, t) {
- for (var i = /var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm; ; ) {
- var n = i.exec(e);
- if (null === n)
- break;
- var r = n[1]
- , o = n[2]
- , a = r.indexOf(Qu.AutoSamplerSuffix) === r.length - Qu.AutoSamplerSuffix.length ? r.substring(0, r.indexOf(Qu.AutoSamplerSuffix)) : null
- , s = "sampler_comparison" === o ? Ru.Comparison : Ru.Filtering;
- if (a) {
- var l = this._webgpuProcessingContext.availableTextures[a];
- l && (l.autoBindSampler = !0)
- }
- var c = this._webgpuProcessingContext.availableSamplers[r];
- c || (c = {
- binding: this._webgpuProcessingContext.getNextFreeUBOBinding(),
- type: s
- },
- this._webgpuProcessingContext.availableSamplers[r] = c),
- this._addSamplerBindingDescription(r, c, t);
- var u = e.substring(0, n.index)
- , h = "@group(".concat(c.binding.groupIndex, ") @binding(").concat(c.binding.bindingIndex, ") ")
- , d = e.substring(n.index);
- e = u + h + d,
- i.lastIndex += h.length
- }
- return e
- }
- ,
- t.prototype._processCustomBuffers = function(e, t) {
- for (var i = /var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm; ; ) {
- var n = i.exec(e);
- if (null === n)
- break;
- var r = n[1]
- , o = n[3]
- , a = n[4]
- , s = n[5]
- , l = this._webgpuProcessingContext.availableBuffers[a];
- if (!l) {
- var c = "uniform" === r ? Ju.KnownUBOs[s] : null
- , u = void 0;
- c ? (a = s,
- -1 === (u = c.binding).groupIndex && (u = this._webgpuProcessingContext.getNextFreeUBOBinding())) : u = this._webgpuProcessingContext.getNextFreeUBOBinding(),
- l = {
- binding: u
- },
- this._webgpuProcessingContext.availableBuffers[a] = l
- }
- this._addBufferBindingDescription(a, this._webgpuProcessingContext.availableBuffers[a], "read_write" === o ? xu.Storage : "storage" === r ? xu.ReadOnlyStorage : xu.Uniform, t);
- var h = l.binding.groupIndex
- , d = l.binding.bindingIndex
- , p = e.substring(0, n.index)
- , f = "@group(".concat(h, ") @binding(").concat(d, ") ")
- , _ = e.substring(n.index);
- e = p + f + _,
- i.lastIndex += f.length
- }
- return e
- }
- ,
- t
- }(Qu), uh = function() {
- function e(e) {
- void 0 === e && (e = null),
- this.format = bu.RGBA8Unorm,
- this.textureUsages = 0,
- this.textureAdditionalUsages = 0,
- this._webgpuTexture = e,
- this._webgpuMSAATexture = null,
- this.view = null,
- this.viewForWriting = null
- }
- return Object.defineProperty(e.prototype, "underlyingResource", {
- get: function() {
- return this._webgpuTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "msaaTexture", {
- get: function() {
- return this._webgpuMSAATexture
- },
- set: function(e) {
- this._webgpuMSAATexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.set = function(e) {
- this._webgpuTexture = e
- }
- ,
- e.prototype.setUsage = function(e, t, i, n, r) {
- t = e !== At.RenderTarget && t,
- this.createView({
- format: this.format,
- dimension: i ? vu.Cube : vu.E2d,
- mipLevelCount: t ? d.ILog2(Math.max(n, r)) + 1 : 1,
- baseArrayLayer: 0,
- baseMipLevel: 0,
- arrayLayerCount: i ? 6 : 1,
- aspect: yu.All
- })
- }
- ,
- e.prototype.createView = function(e, t) {
- if (void 0 === t && (t = !1),
- this.view = this._webgpuTexture.createView(e),
- t && e) {
- var i = e.mipLevelCount;
- e.mipLevelCount = 1,
- this.viewForWriting = this._webgpuTexture.createView(e),
- e.mipLevelCount = i
- }
- }
- ,
- e.prototype.reset = function() {
- this._webgpuTexture = null,
- this._webgpuMSAATexture = null,
- this.view = null,
- this.viewForWriting = null
- }
- ,
- e.prototype.release = function() {
- var e, t, i;
- null === (e = this._webgpuTexture) || void 0 === e || e.destroy(),
- null === (t = this._webgpuMSAATexture) || void 0 === t || t.destroy(),
- null === (i = this._copyInvertYTempTexture) || void 0 === i || i.destroy(),
- this.reset()
- }
- ,
- e
- }();
- !function(e) {
- e[e.MipMap = 0] = "MipMap",
- e[e.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha",
- e[e.Clear = 2] = "Clear",
- e[e.InvertYPremultiplyAlphaWithOfst = 3] = "InvertYPremultiplyAlphaWithOfst"
- }(eh || (eh = {}));
- var hh, dh = [{
- vertex: "\n 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));\n 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));\n\n layout(location = 0) out vec2 vTex;\n\n void main() {\n vTex = tex[gl_VertexIndex];\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
- fragment: "\n layout(set = 0, binding = 0) uniform sampler imgSampler;\n layout(set = 0, binding = 1) uniform texture2D img;\n\n layout(location = 0) in vec2 vTex;\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n }\n "
- }, {
- vertex: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n 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));\n 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));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
- fragment: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "
- }, {
- vertex: "\n 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));\n\n void main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
- fragment: "\n layout(set = 0, binding = 0) uniform Uniforms {\n uniform vec4 color;\n };\n\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = color;\n }\n "
- }, {
- vertex: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n 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));\n 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));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",
- fragment: "\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n layout(set = 0, binding = 1) uniform Params {\n float ofstX;\n float ofstY;\n float width;\n float height;\n };\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n if (gl_FragCoord.x < ofstX || gl_FragCoord.x >= ofstX + width) {\n discard;\n }\n if (gl_FragCoord.y < ofstY || gl_FragCoord.y >= ofstY + height) {\n discard;\n }\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, ofstY + height - (gl_FragCoord.y - ofstY)), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "
- }], ph = {
- "": 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
- }, fh = function() {
- function e(e, t, i, n) {
- this._pipelines = {},
- this._compiledShaders = [],
- this._deferredReleaseTextures = [],
- this._device = e,
- this._glslang = t,
- this._tintWASM = i,
- this._bufferManager = n,
- this._mipmapSampler = e.createSampler({
- minFilter: Eu.Linear
- }),
- this._ubCopyWithOfst = this._bufferManager.createBuffer(16, fu.Uniform | fu.CopyDst).underlyingResource,
- this._getPipeline(bu.RGBA8Unorm)
- }
- return e.ComputeNumMipmapLevels = function(e, t) {
- return d.ILog2(Math.max(e, t)) + 1
- }
- ,
- e.prototype._getPipeline = function(e, t, i) {
- void 0 === t && (t = eh.MipMap);
- var n = t === eh.MipMap ? 1 : t === eh.InvertYPremultiplyAlpha ? ((i.invertY ? 1 : 0) << 1) + ((i.premultiplyAlpha ? 1 : 0) << 2) : t === eh.Clear ? 8 : t === eh.InvertYPremultiplyAlphaWithOfst ? ((i.invertY ? 1 : 0) << 4) + ((i.premultiplyAlpha ? 1 : 0) << 5) : 0;
- this._pipelines[e] || (this._pipelines[e] = []);
- var r = this._pipelines[e][n];
- if (!r) {
- var o = "#version 450\r\n";
- t !== eh.InvertYPremultiplyAlpha && t !== eh.InvertYPremultiplyAlphaWithOfst || (i.invertY && (o += "#define INVERTY\r\n"),
- i.premultiplyAlpha && (o += "#define PREMULTIPLYALPHA\r\n"));
- var a = this._compiledShaders[n];
- if (!a) {
- var s = this._glslang.compileGLSL(o + dh[t].vertex, "vertex")
- , l = this._glslang.compileGLSL(o + dh[t].fragment, "fragment");
- this._tintWASM && (s = this._tintWASM.convertSpirV2WGSL(s),
- l = this._tintWASM.convertSpirV2WGSL(l));
- var c = this._device.createShaderModule({
- code: s
- })
- , u = this._device.createShaderModule({
- code: l
- });
- a = this._compiledShaders[n] = [c, u]
- }
- var h = this._device.createRenderPipeline({
- vertex: {
- module: a[0],
- entryPoint: "main"
- },
- fragment: {
- module: a[1],
- entryPoint: "main",
- targets: [{
- format: e
- }]
- },
- primitive: {
- topology: Iu.TriangleStrip,
- stripIndexFormat: Bu.Uint16
- }
- });
- r = this._pipelines[e][n] = [h, h.getBindGroupLayout(0)]
- }
- return r
- }
- ,
- e._GetTextureTypeFromFormat = function(e) {
- switch (e) {
- case bu.R8Unorm:
- case bu.R8Snorm:
- case bu.R8Uint:
- case bu.R8Sint:
- case bu.RG8Unorm:
- case bu.RG8Snorm:
- case bu.RG8Uint:
- case bu.RG8Sint:
- case bu.RGBA8Unorm:
- case bu.RGBA8UnormSRGB:
- case bu.RGBA8Snorm:
- case bu.RGBA8Uint:
- case bu.RGBA8Sint:
- case bu.BGRA8Unorm:
- case bu.BGRA8UnormSRGB:
- case bu.RGB10A2Unorm:
- case bu.RGB9E5UFloat:
- case bu.RG11B10UFloat:
- case bu.Depth24UnormStencil8:
- case bu.Depth32FloatStencil8:
- case bu.BC7RGBAUnorm:
- case bu.BC7RGBAUnormSRGB:
- case bu.BC6HRGBUFloat:
- case bu.BC6HRGBFloat:
- case bu.BC5RGUnorm:
- case bu.BC5RGSnorm:
- case bu.BC3RGBAUnorm:
- case bu.BC3RGBAUnormSRGB:
- case bu.BC2RGBAUnorm:
- case bu.BC2RGBAUnormSRGB:
- case bu.BC4RUnorm:
- case bu.BC4RSnorm:
- case bu.BC1RGBAUnorm:
- case bu.BC1RGBAUnormSRGB:
- case bu.ETC2RGB8Unorm:
- case bu.ETC2RGB8UnormSRGB:
- case bu.ETC2RGB8A1Unorm:
- case bu.ETC2RGB8A1UnormSRGB:
- case bu.ETC2RGBA8Unorm:
- case bu.ETC2RGBA8UnormSRGB:
- case bu.EACR11Unorm:
- case bu.EACR11Snorm:
- case bu.EACRG11Unorm:
- case bu.EACRG11Snorm:
- case bu.ASTC4x4Unorm:
- case bu.ASTC4x4UnormSRGB:
- case bu.ASTC5x4Unorm:
- case bu.ASTC5x4UnormSRGB:
- case bu.ASTC5x5Unorm:
- case bu.ASTC5x5UnormSRGB:
- case bu.ASTC6x5Unorm:
- case bu.ASTC6x5UnormSRGB:
- case bu.ASTC6x6Unorm:
- case bu.ASTC6x6UnormSRGB:
- case bu.ASTC8x5Unorm:
- case bu.ASTC8x5UnormSRGB:
- case bu.ASTC8x6Unorm:
- case bu.ASTC8x6UnormSRGB:
- case bu.ASTC8x8Unorm:
- case bu.ASTC8x8UnormSRGB:
- case bu.ASTC10x5Unorm:
- case bu.ASTC10x5UnormSRGB:
- case bu.ASTC10x6Unorm:
- case bu.ASTC10x6UnormSRGB:
- case bu.ASTC10x8Unorm:
- case bu.ASTC10x8UnormSRGB:
- case bu.ASTC10x10Unorm:
- case bu.ASTC10x10UnormSRGB:
- case bu.ASTC12x10Unorm:
- case bu.ASTC12x10UnormSRGB:
- case bu.ASTC12x12Unorm:
- case bu.ASTC12x12UnormSRGB:
- return a.TEXTURETYPE_UNSIGNED_BYTE;
- case bu.R16Uint:
- case bu.R16Sint:
- case bu.RG16Uint:
- case bu.RG16Sint:
- case bu.RGBA16Uint:
- case bu.RGBA16Sint:
- case bu.Depth16Unorm:
- return a.TEXTURETYPE_UNSIGNED_SHORT;
- case bu.R16Float:
- case bu.RG16Float:
- case bu.RGBA16Float:
- return a.TEXTURETYPE_HALF_FLOAT;
- case bu.R32Uint:
- case bu.R32Sint:
- case bu.RG32Uint:
- case bu.RG32Sint:
- case bu.RGBA32Uint:
- case bu.RGBA32Sint:
- return a.TEXTURETYPE_UNSIGNED_INTEGER;
- case bu.R32Float:
- case bu.RG32Float:
- case bu.RGBA32Float:
- case bu.Depth32Float:
- return a.TEXTURETYPE_FLOAT;
- case bu.Stencil8:
- throw "No fixed size for Stencil8 format!";
- case bu.Depth24Plus:
- throw "No fixed size for Depth24Plus format!";
- case bu.Depth24PlusStencil8:
- throw "No fixed size for Depth24PlusStencil8 format!"
- }
- return a.TEXTURETYPE_UNSIGNED_BYTE
- }
- ,
- e._GetBlockInformationFromFormat = function(e) {
- switch (e) {
- case bu.R8Unorm:
- case bu.R8Snorm:
- case bu.R8Uint:
- case bu.R8Sint:
- return {
- width: 1,
- height: 1,
- length: 1
- };
- case bu.R16Uint:
- case bu.R16Sint:
- case bu.R16Float:
- case bu.RG8Unorm:
- case bu.RG8Snorm:
- case bu.RG8Uint:
- case bu.RG8Sint:
- return {
- width: 1,
- height: 1,
- length: 2
- };
- case bu.R32Uint:
- case bu.R32Sint:
- case bu.R32Float:
- case bu.RG16Uint:
- case bu.RG16Sint:
- case bu.RG16Float:
- case bu.RGBA8Unorm:
- case bu.RGBA8UnormSRGB:
- case bu.RGBA8Snorm:
- case bu.RGBA8Uint:
- case bu.RGBA8Sint:
- case bu.BGRA8Unorm:
- case bu.BGRA8UnormSRGB:
- case bu.RGB9E5UFloat:
- case bu.RGB10A2Unorm:
- case bu.RG11B10UFloat:
- return {
- width: 1,
- height: 1,
- length: 4
- };
- case bu.RG32Uint:
- case bu.RG32Sint:
- case bu.RG32Float:
- case bu.RGBA16Uint:
- case bu.RGBA16Sint:
- case bu.RGBA16Float:
- return {
- width: 1,
- height: 1,
- length: 8
- };
- case bu.RGBA32Uint:
- case bu.RGBA32Sint:
- case bu.RGBA32Float:
- return {
- width: 1,
- height: 1,
- length: 16
- };
- case bu.Stencil8:
- throw "No fixed size for Stencil8 format!";
- case bu.Depth16Unorm:
- return {
- width: 1,
- height: 1,
- length: 2
- };
- case bu.Depth24Plus:
- throw "No fixed size for Depth24Plus format!";
- case bu.Depth24PlusStencil8:
- throw "No fixed size for Depth24PlusStencil8 format!";
- case bu.Depth32Float:
- case bu.Depth24UnormStencil8:
- return {
- width: 1,
- height: 1,
- length: 4
- };
- case bu.Depth32FloatStencil8:
- return {
- width: 1,
- height: 1,
- length: 5
- };
- case bu.BC7RGBAUnorm:
- case bu.BC7RGBAUnormSRGB:
- case bu.BC6HRGBUFloat:
- case bu.BC6HRGBFloat:
- case bu.BC5RGUnorm:
- case bu.BC5RGSnorm:
- case bu.BC3RGBAUnorm:
- case bu.BC3RGBAUnormSRGB:
- case bu.BC2RGBAUnorm:
- case bu.BC2RGBAUnormSRGB:
- return {
- width: 4,
- height: 4,
- length: 16
- };
- case bu.BC4RUnorm:
- case bu.BC4RSnorm:
- case bu.BC1RGBAUnorm:
- case bu.BC1RGBAUnormSRGB:
- case bu.ETC2RGB8Unorm:
- case bu.ETC2RGB8UnormSRGB:
- case bu.ETC2RGB8A1Unorm:
- case bu.ETC2RGB8A1UnormSRGB:
- case bu.EACR11Unorm:
- case bu.EACR11Snorm:
- return {
- width: 4,
- height: 4,
- length: 8
- };
- case bu.ETC2RGBA8Unorm:
- case bu.ETC2RGBA8UnormSRGB:
- case bu.EACRG11Unorm:
- case bu.EACRG11Snorm:
- case bu.ASTC4x4Unorm:
- case bu.ASTC4x4UnormSRGB:
- return {
- width: 4,
- height: 4,
- length: 16
- };
- case bu.ASTC5x4Unorm:
- case bu.ASTC5x4UnormSRGB:
- return {
- width: 5,
- height: 4,
- length: 16
- };
- case bu.ASTC5x5Unorm:
- case bu.ASTC5x5UnormSRGB:
- return {
- width: 5,
- height: 5,
- length: 16
- };
- case bu.ASTC6x5Unorm:
- case bu.ASTC6x5UnormSRGB:
- return {
- width: 6,
- height: 5,
- length: 16
- };
- case bu.ASTC6x6Unorm:
- case bu.ASTC6x6UnormSRGB:
- return {
- width: 6,
- height: 6,
- length: 16
- };
- case bu.ASTC8x5Unorm:
- case bu.ASTC8x5UnormSRGB:
- return {
- width: 8,
- height: 5,
- length: 16
- };
- case bu.ASTC8x6Unorm:
- case bu.ASTC8x6UnormSRGB:
- return {
- width: 8,
- height: 6,
- length: 16
- };
- case bu.ASTC8x8Unorm:
- case bu.ASTC8x8UnormSRGB:
- return {
- width: 8,
- height: 8,
- length: 16
- };
- case bu.ASTC10x5Unorm:
- case bu.ASTC10x5UnormSRGB:
- return {
- width: 10,
- height: 5,
- length: 16
- };
- case bu.ASTC10x6Unorm:
- case bu.ASTC10x6UnormSRGB:
- return {
- width: 10,
- height: 6,
- length: 16
- };
- case bu.ASTC10x8Unorm:
- case bu.ASTC10x8UnormSRGB:
- return {
- width: 10,
- height: 8,
- length: 16
- };
- case bu.ASTC10x10Unorm:
- case bu.ASTC10x10UnormSRGB:
- return {
- width: 10,
- height: 10,
- length: 16
- };
- case bu.ASTC12x10Unorm:
- case bu.ASTC12x10UnormSRGB:
- return {
- width: 12,
- height: 10,
- length: 16
- };
- case bu.ASTC12x12Unorm:
- case bu.ASTC12x12UnormSRGB:
- return {
- width: 12,
- height: 12,
- length: 16
- }
- }
- return {
- width: 1,
- height: 1,
- length: 4
- }
- }
- ,
- e._IsHardwareTexture = function(e) {
- return !!e.release
- }
- ,
- e._IsInternalTexture = function(e) {
- return !!e.dispose
- }
- ,
- e.IsImageBitmap = function(e) {
- return void 0 !== e.close
- }
- ,
- e.IsImageBitmapArray = function(e) {
- return Array.isArray(e) && void 0 !== e[0].close
- }
- ,
- e.prototype.setCommandEncoder = function(e) {
- this._commandEncoderForCreation = e
- }
- ,
- e.IsCompressedFormat = function(e) {
- switch (e) {
- case bu.BC7RGBAUnormSRGB:
- case bu.BC7RGBAUnorm:
- case bu.BC6HRGBFloat:
- case bu.BC6HRGBUFloat:
- case bu.BC5RGSnorm:
- case bu.BC5RGUnorm:
- case bu.BC4RSnorm:
- case bu.BC4RUnorm:
- case bu.BC3RGBAUnormSRGB:
- case bu.BC3RGBAUnorm:
- case bu.BC2RGBAUnormSRGB:
- case bu.BC2RGBAUnorm:
- case bu.BC1RGBAUnormSRGB:
- case bu.BC1RGBAUnorm:
- case bu.ETC2RGB8Unorm:
- case bu.ETC2RGB8UnormSRGB:
- case bu.ETC2RGB8A1Unorm:
- case bu.ETC2RGB8A1UnormSRGB:
- case bu.ETC2RGBA8Unorm:
- case bu.ETC2RGBA8UnormSRGB:
- case bu.EACR11Unorm:
- case bu.EACR11Snorm:
- case bu.EACRG11Unorm:
- case bu.EACRG11Snorm:
- case bu.ASTC4x4Unorm:
- case bu.ASTC4x4UnormSRGB:
- case bu.ASTC5x4Unorm:
- case bu.ASTC5x4UnormSRGB:
- case bu.ASTC5x5Unorm:
- case bu.ASTC5x5UnormSRGB:
- case bu.ASTC6x5Unorm:
- case bu.ASTC6x5UnormSRGB:
- case bu.ASTC6x6Unorm:
- case bu.ASTC6x6UnormSRGB:
- case bu.ASTC8x5Unorm:
- case bu.ASTC8x5UnormSRGB:
- case bu.ASTC8x6Unorm:
- case bu.ASTC8x6UnormSRGB:
- case bu.ASTC8x8Unorm:
- case bu.ASTC8x8UnormSRGB:
- case bu.ASTC10x5Unorm:
- case bu.ASTC10x5UnormSRGB:
- case bu.ASTC10x6Unorm:
- case bu.ASTC10x6UnormSRGB:
- case bu.ASTC10x8Unorm:
- case bu.ASTC10x8UnormSRGB:
- case bu.ASTC10x10Unorm:
- case bu.ASTC10x10UnormSRGB:
- case bu.ASTC12x10Unorm:
- case bu.ASTC12x10UnormSRGB:
- case bu.ASTC12x12Unorm:
- case bu.ASTC12x12UnormSRGB:
- return !0
- }
- return !1
- }
- ,
- e.GetWebGPUTextureFormat = function(e, t, i) {
- switch (void 0 === i && (i = !1),
- t) {
- case a.TEXTUREFORMAT_DEPTH16:
- return bu.Depth16Unorm;
- case a.TEXTUREFORMAT_DEPTH24:
- return bu.Depth24Plus;
- case a.TEXTUREFORMAT_DEPTH24_STENCIL8:
- return bu.Depth24PlusStencil8;
- case a.TEXTUREFORMAT_DEPTH32_FLOAT:
- return bu.Depth32Float;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
- return i ? bu.BC7RGBAUnormSRGB : bu.BC7RGBAUnorm;
- case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
- return bu.BC6HRGBUFloat;
- case a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
- return bu.BC6HRGBFloat;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
- return i ? bu.BC3RGBAUnormSRGB : bu.BC3RGBAUnorm;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:
- return i ? bu.BC2RGBAUnormSRGB : bu.BC2RGBAUnorm;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
- case a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
- return i ? bu.BC1RGBAUnormSRGB : bu.BC1RGBAUnorm;
- case a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
- return i ? bu.ASTC4x4UnormSRGB : bu.ASTC4x4Unorm;
- case a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
- return i ? bu.ETC2RGB8UnormSRGB : bu.ETC2RGB8Unorm
- }
- switch (e) {
- case a.TEXTURETYPE_BYTE:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return bu.R8Snorm;
- case a.TEXTUREFORMAT_RG:
- return bu.RG8Snorm;
- case a.TEXTUREFORMAT_RGB:
- throw "RGB format not supported in WebGPU";
- case a.TEXTUREFORMAT_RED_INTEGER:
- return bu.R8Sint;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return bu.RG8Sint;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- throw "RGB_INTEGER format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- return bu.RGBA8Sint;
- default:
- return bu.RGBA8Snorm
- }
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return bu.R8Unorm;
- case a.TEXTUREFORMAT_RG:
- return bu.RG8Unorm;
- case a.TEXTUREFORMAT_RGB:
- throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA:
- return i ? bu.RGBA8UnormSRGB : bu.RGBA8Unorm;
- case a.TEXTUREFORMAT_BGRA:
- return i ? bu.BGRA8UnormSRGB : bu.BGRA8Unorm;
- case a.TEXTUREFORMAT_RED_INTEGER:
- return bu.R8Uint;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return bu.RG8Uint;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- throw "RGB_INTEGER format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- return bu.RGBA8Uint;
- case a.TEXTUREFORMAT_ALPHA:
- throw "TEXTUREFORMAT_ALPHA format not supported in WebGPU";
- case a.TEXTUREFORMAT_LUMINANCE:
- throw "TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";
- case a.TEXTUREFORMAT_LUMINANCE_ALPHA:
- throw "TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";
- default:
- return bu.RGBA8Unorm
- }
- case a.TEXTURETYPE_SHORT:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return bu.R16Sint;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return bu.RG16Sint;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return bu.RGBA16Sint
- }
- case a.TEXTURETYPE_UNSIGNED_SHORT:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return bu.R16Uint;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return bu.RG16Uint;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return bu.RGBA16Uint
- }
- case a.TEXTURETYPE_INT:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return bu.R32Sint;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return bu.RG32Sint;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return bu.RGBA32Sint
- }
- case a.TEXTURETYPE_UNSIGNED_INTEGER:
- switch (t) {
- case a.TEXTUREFORMAT_RED_INTEGER:
- return bu.R32Uint;
- case a.TEXTUREFORMAT_RG_INTEGER:
- return bu.RG32Uint;
- case a.TEXTUREFORMAT_RGB_INTEGER:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- default:
- return bu.RGBA32Uint
- }
- case a.TEXTURETYPE_FLOAT:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return bu.R32Float;
- case a.TEXTUREFORMAT_RG:
- return bu.RG32Float;
- case a.TEXTUREFORMAT_RGB:
- throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA:
- default:
- return bu.RGBA32Float
- }
- case a.TEXTURETYPE_HALF_FLOAT:
- switch (t) {
- case a.TEXTUREFORMAT_RED:
- return bu.R16Float;
- case a.TEXTUREFORMAT_RG:
- return bu.RG16Float;
- case a.TEXTUREFORMAT_RGB:
- throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
- case a.TEXTUREFORMAT_RGBA:
- default:
- return bu.RGBA16Float
- }
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
- throw "TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";
- case a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
- throw "TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV format not supported in WebGPU";
- case a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
- throw "TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV format not supported in WebGPU";
- case a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
- throw "TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";
- case a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
- throw "TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";
- case a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
- switch (t) {
- case a.TEXTUREFORMAT_RGBA:
- return bu.RGB10A2Unorm;
- case a.TEXTUREFORMAT_RGBA_INTEGER:
- throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV";
- default:
- return bu.RGB10A2Unorm
- }
- }
- return i ? bu.RGBA8UnormSRGB : bu.RGBA8Unorm
- }
- ,
- e.GetNumChannelsFromWebGPUTextureFormat = function(e) {
- switch (e) {
- case bu.R8Unorm:
- case bu.R8Snorm:
- case bu.R8Uint:
- case bu.R8Sint:
- case bu.BC4RUnorm:
- case bu.BC4RSnorm:
- case bu.R16Uint:
- case bu.R16Sint:
- case bu.Depth16Unorm:
- case bu.R16Float:
- case bu.R32Uint:
- case bu.R32Sint:
- case bu.R32Float:
- case bu.Depth32Float:
- case bu.Stencil8:
- case bu.Depth24Plus:
- case bu.EACR11Unorm:
- case bu.EACR11Snorm:
- return 1;
- case bu.RG8Unorm:
- case bu.RG8Snorm:
- case bu.RG8Uint:
- case bu.RG8Sint:
- case bu.Depth24UnormStencil8:
- case bu.Depth32FloatStencil8:
- case bu.BC5RGUnorm:
- case bu.BC5RGSnorm:
- case bu.RG16Uint:
- case bu.RG16Sint:
- case bu.RG16Float:
- case bu.RG32Uint:
- case bu.RG32Sint:
- case bu.RG32Float:
- case bu.Depth24PlusStencil8:
- case bu.EACRG11Unorm:
- case bu.EACRG11Snorm:
- return 2;
- case bu.RGB9E5UFloat:
- case bu.RG11B10UFloat:
- case bu.BC6HRGBUFloat:
- case bu.BC6HRGBFloat:
- case bu.ETC2RGB8Unorm:
- case bu.ETC2RGB8UnormSRGB:
- return 3;
- case bu.RGBA8Unorm:
- case bu.RGBA8UnormSRGB:
- case bu.RGBA8Snorm:
- case bu.RGBA8Uint:
- case bu.RGBA8Sint:
- case bu.BGRA8Unorm:
- case bu.BGRA8UnormSRGB:
- case bu.RGB10A2Unorm:
- case bu.BC7RGBAUnorm:
- case bu.BC7RGBAUnormSRGB:
- case bu.BC3RGBAUnorm:
- case bu.BC3RGBAUnormSRGB:
- case bu.BC2RGBAUnorm:
- case bu.BC2RGBAUnormSRGB:
- case bu.BC1RGBAUnorm:
- case bu.BC1RGBAUnormSRGB:
- case bu.RGBA16Uint:
- case bu.RGBA16Sint:
- case bu.RGBA16Float:
- case bu.RGBA32Uint:
- case bu.RGBA32Sint:
- case bu.RGBA32Float:
- case bu.ETC2RGB8A1Unorm:
- case bu.ETC2RGB8A1UnormSRGB:
- case bu.ETC2RGBA8Unorm:
- case bu.ETC2RGBA8UnormSRGB:
- case bu.ASTC4x4Unorm:
- case bu.ASTC4x4UnormSRGB:
- case bu.ASTC5x4Unorm:
- case bu.ASTC5x4UnormSRGB:
- case bu.ASTC5x5Unorm:
- case bu.ASTC5x5UnormSRGB:
- case bu.ASTC6x5Unorm:
- case bu.ASTC6x5UnormSRGB:
- case bu.ASTC6x6Unorm:
- case bu.ASTC6x6UnormSRGB:
- case bu.ASTC8x5Unorm:
- case bu.ASTC8x5UnormSRGB:
- case bu.ASTC8x6Unorm:
- case bu.ASTC8x6UnormSRGB:
- case bu.ASTC8x8Unorm:
- case bu.ASTC8x8UnormSRGB:
- case bu.ASTC10x5Unorm:
- case bu.ASTC10x5UnormSRGB:
- case bu.ASTC10x6Unorm:
- case bu.ASTC10x6UnormSRGB:
- case bu.ASTC10x8Unorm:
- case bu.ASTC10x8UnormSRGB:
- case bu.ASTC10x10Unorm:
- case bu.ASTC10x10UnormSRGB:
- case bu.ASTC12x10Unorm:
- case bu.ASTC12x10UnormSRGB:
- case bu.ASTC12x12Unorm:
- case bu.ASTC12x12UnormSRGB:
- return 4
- }
- throw "Unknown format ".concat(e, "!")
- }
- ,
- e.HasStencilAspect = function(e) {
- switch (e) {
- case bu.Stencil8:
- case bu.Depth24UnormStencil8:
- case bu.Depth32FloatStencil8:
- case bu.Depth24PlusStencil8:
- return !0
- }
- return !1
- }
- ,
- e.prototype.invertYPreMultiplyAlpha = function(t, i, n, r, o, a, s, l, c, u, h, d, p, f, _) {
- var m, g, v, y, b, T;
- void 0 === o && (o = !1),
- void 0 === a && (a = !1),
- void 0 === s && (s = 0),
- void 0 === l && (l = 0),
- void 0 === c && (c = 1),
- void 0 === u && (u = 0),
- void 0 === h && (h = 0),
- void 0 === d && (d = 0),
- void 0 === p && (p = 0);
- var E, S = 0 !== d, A = void 0 === f, x = this._getPipeline(r, S ? eh.InvertYPremultiplyAlphaWithOfst : eh.InvertYPremultiplyAlpha, {
- invertY: o,
- premultiplyAlpha: a
- }), R = x[0], C = x[1];
- if (s = Math.max(s, 0),
- A && (f = this._device.createCommandEncoder({})),
- null === (g = (m = f).pushDebugGroup) || void 0 === g || g.call(m, "internal process texture - invertY=".concat(o, " premultiplyAlpha=").concat(a)),
- e._IsHardwareTexture(t) ? (E = t.underlyingResource,
- o && !a && 1 === c && 0 === s || (t = void 0)) : (E = t,
- t = void 0),
- E) {
- S && this._bufferManager.setRawData(this._ubCopyWithOfst, 0, new Float32Array([u, h, d, p]), 0, 16);
- var P = t
- , M = null !== (v = null == P ? void 0 : P._copyInvertYTempTexture) && void 0 !== v ? v : this.createTexture({
- width: i,
- height: n,
- layers: 1
- }, !1, !1, !1, !1, !1, r, 1, f, gu.CopySrc | gu.RenderAttachment | gu.TextureBinding)
- , I = null !== (y = null == P ? void 0 : P._copyInvertYRenderPassDescr) && void 0 !== y ? y : {
- colorAttachments: [{
- view: M.createView({
- format: r,
- dimension: vu.E2d,
- baseMipLevel: 0,
- mipLevelCount: 1,
- arrayLayerCount: 1,
- baseArrayLayer: 0
- }),
- loadOp: zu.Load,
- storeOp: Wu.Store
- }]
- }
- , O = f.beginRenderPass(I)
- , D = S ? null == P ? void 0 : P._copyInvertYBindGroupWithOfst : null == P ? void 0 : P._copyInvertYBindGroup;
- if (!D) {
- var N = {
- layout: C,
- entries: [{
- binding: 0,
- resource: E.createView({
- format: r,
- dimension: vu.E2d,
- baseMipLevel: l,
- mipLevelCount: 1,
- arrayLayerCount: c,
- baseArrayLayer: s
- })
- }]
- };
- S && N.entries.push({
- binding: 1,
- resource: {
- buffer: this._ubCopyWithOfst
- }
- }),
- D = this._device.createBindGroup(N)
- }
- O.setPipeline(R),
- O.setBindGroup(0, D),
- O.draw(4, 1, 0, 0),
- O.end(),
- f.copyTextureToTexture({
- texture: M
- }, {
- texture: E,
- mipLevel: l,
- origin: {
- x: 0,
- y: 0,
- z: s
- }
- }, {
- width: i,
- height: n,
- depthOrArrayLayers: 1
- }),
- P ? (P._copyInvertYTempTexture = M,
- P._copyInvertYRenderPassDescr = I,
- S ? P._copyInvertYBindGroupWithOfst = D : P._copyInvertYBindGroup = D) : this._deferredReleaseTextures.push([M, null]),
- null === (T = (b = f).popDebugGroup) || void 0 === T || T.call(b),
- A && (this._device.queue.submit([f.finish()]),
- f = null)
- }
- }
- ,
- e.prototype.copyWithInvertY = function(e, t, i, n) {
- var r, o, a, s, l = void 0 === n, c = this._getPipeline(t, eh.InvertYPremultiplyAlpha, {
- invertY: !0,
- premultiplyAlpha: !1
- }), u = c[0], h = c[1];
- l && (n = this._device.createCommandEncoder({})),
- null === (o = (r = n).pushDebugGroup) || void 0 === o || o.call(r, "internal copy texture with invertY");
- var d = n.beginRenderPass(i)
- , p = this._device.createBindGroup({
- layout: h,
- entries: [{
- binding: 0,
- resource: e
- }]
- });
- d.setPipeline(u),
- d.setBindGroup(0, p),
- d.draw(4, 1, 0, 0),
- d.end(),
- null === (s = (a = n).popDebugGroup) || void 0 === s || s.call(a),
- l && (this._device.queue.submit([n.finish()]),
- n = null)
- }
- ,
- e.prototype.createTexture = function(t, i, n, r, o, a, s, l, c, u, h) {
- void 0 === i && (i = !1),
- void 0 === n && (n = !1),
- void 0 === r && (r = !1),
- void 0 === o && (o = !1),
- void 0 === a && (a = !1),
- void 0 === s && (s = bu.RGBA8Unorm),
- void 0 === l && (l = 1),
- void 0 === u && (u = -1),
- void 0 === h && (h = 0),
- l > 1 && (l = 4);
- var d = t.layers || 1
- , p = {
- width: t.width,
- height: t.height,
- depthOrArrayLayers: d
- }
- , f = e.IsCompressedFormat(s)
- , _ = i ? e.ComputeNumMipmapLevels(t.width, t.height) : 1
- , m = u >= 0 ? u : gu.CopySrc | gu.CopyDst | gu.TextureBinding;
- h |= i && !f ? gu.CopySrc | gu.RenderAttachment : 0,
- f || (h |= gu.RenderAttachment | gu.CopyDst);
- var g = this._device.createTexture({
- size: p,
- dimension: a ? mu.E3d : mu.E2d,
- format: s,
- usage: m | h,
- sampleCount: l,
- mipLevelCount: _
- });
- return e.IsImageBitmap(t) && (this.updateTexture(t, g, t.width, t.height, d, s, 0, 0, r, o, 0, 0),
- i && n && this.generateMipmaps(g, s, _, 0, c)),
- g
- }
- ,
- e.prototype.createCubeTexture = function(t, i, n, r, o, a, s, l, c, u) {
- void 0 === i && (i = !1),
- void 0 === n && (n = !1),
- void 0 === r && (r = !1),
- void 0 === o && (o = !1),
- void 0 === a && (a = bu.RGBA8Unorm),
- void 0 === s && (s = 1),
- void 0 === c && (c = -1),
- void 0 === u && (u = 0),
- s > 1 && (s = 4);
- var h = e.IsImageBitmapArray(t) ? t[0].width : t.width
- , d = e.IsImageBitmapArray(t) ? t[0].height : t.height
- , p = e.IsCompressedFormat(a)
- , f = i ? e.ComputeNumMipmapLevels(h, d) : 1
- , _ = c >= 0 ? c : gu.CopySrc | gu.CopyDst | gu.TextureBinding;
- u |= i && !p ? gu.CopySrc | gu.RenderAttachment : 0,
- p || (u |= gu.RenderAttachment | gu.CopyDst);
- var m = this._device.createTexture({
- size: {
- width: h,
- height: d,
- depthOrArrayLayers: 6
- },
- dimension: mu.E2d,
- format: a,
- usage: _ | u,
- sampleCount: s,
- mipLevelCount: f
- });
- return e.IsImageBitmapArray(t) && (this.updateCubeTextures(t, m, h, d, a, r, o, 0, 0),
- i && n && this.generateCubeMipmaps(m, a, f, l)),
- m
- }
- ,
- e.prototype.generateCubeMipmaps = function(e, t, i, n) {
- var r, o, a, s, l = void 0 === n;
- l && (n = this._device.createCommandEncoder({})),
- null === (o = (r = n).pushDebugGroup) || void 0 === o || o.call(r, "create cube mipmaps - ".concat(i, " levels"));
- for (var c = 0; c < 6; ++c)
- this.generateMipmaps(e, t, i, c, n);
- null === (s = (a = n).popDebugGroup) || void 0 === s || s.call(a),
- l && (this._device.queue.submit([n.finish()]),
- n = null)
- }
- ,
- e.prototype.generateMipmaps = function(t, i, n, r, o) {
- var a, s, l, c, u, h, d, p;
- void 0 === r && (r = 0);
- var f, _ = void 0 === o, m = this._getPipeline(i), g = m[0], v = m[1];
- if (r = Math.max(r, 0),
- _ && (o = this._device.createCommandEncoder({})),
- null === (s = (a = o).pushDebugGroup) || void 0 === s || s.call(a, "create mipmaps for face #".concat(r, " - ").concat(n, " levels")),
- e._IsHardwareTexture(t) ? (f = t.underlyingResource,
- t._mipmapGenRenderPassDescr = t._mipmapGenRenderPassDescr || [],
- t._mipmapGenBindGroup = t._mipmapGenBindGroup || []) : (f = t,
- t = void 0),
- f) {
- for (var y = t, b = 1; b < n; ++b) {
- var T = null !== (c = null === (l = null == y ? void 0 : y._mipmapGenRenderPassDescr[r]) || void 0 === l ? void 0 : l[b - 1]) && void 0 !== c ? c : {
- colorAttachments: [{
- view: f.createView({
- format: i,
- dimension: vu.E2d,
- baseMipLevel: b,
- mipLevelCount: 1,
- arrayLayerCount: 1,
- baseArrayLayer: r
- }),
- loadOp: zu.Load,
- storeOp: Wu.Store
- }]
- };
- y && (y._mipmapGenRenderPassDescr[r] = y._mipmapGenRenderPassDescr[r] || [],
- y._mipmapGenRenderPassDescr[r][b - 1] = T);
- var E = o.beginRenderPass(T)
- , S = null !== (h = null === (u = null == y ? void 0 : y._mipmapGenBindGroup[r]) || void 0 === u ? void 0 : u[b - 1]) && void 0 !== h ? h : this._device.createBindGroup({
- layout: v,
- entries: [{
- binding: 0,
- resource: this._mipmapSampler
- }, {
- binding: 1,
- resource: f.createView({
- format: i,
- dimension: vu.E2d,
- baseMipLevel: b - 1,
- mipLevelCount: 1,
- arrayLayerCount: 1,
- baseArrayLayer: r
- })
- }]
- });
- y && (y._mipmapGenBindGroup[r] = y._mipmapGenBindGroup[r] || [],
- y._mipmapGenBindGroup[r][b - 1] = S),
- E.setPipeline(g),
- E.setBindGroup(0, S),
- E.draw(4, 1, 0, 0),
- E.end()
- }
- null === (p = (d = o).popDebugGroup) || void 0 === p || p.call(d),
- _ && (this._device.queue.submit([o.finish()]),
- o = null)
- }
- }
- ,
- e.prototype.createGPUTextureForInternalTexture = function(t, i, n, r, o) {
- t._hardwareTexture || (t._hardwareTexture = new uh),
- void 0 === i && (i = t.width),
- void 0 === n && (n = t.height),
- void 0 === r && (r = t.depth);
- var s = t._hardwareTexture
- , l = 0 != ((null != o ? o : 0) & a.TEXTURE_CREATIONFLAG_STORAGE);
- s.format = e.GetWebGPUTextureFormat(t.type, t.format, t._useSRGBBuffer),
- s.textureUsages = t._source === At.RenderTarget || t.source === At.MultiRenderTarget ? gu.TextureBinding | gu.CopySrc | gu.RenderAttachment : t._source === At.DepthStencil ? gu.TextureBinding | gu.RenderAttachment : -1,
- s.textureAdditionalUsages = l ? gu.StorageBinding : 0;
- var c, u = t.generateMipMaps, h = r || 1;
- if (c = null !== t._maxLodLevel ? t._maxLodLevel : u ? e.ComputeNumMipmapLevels(i, n) : 1,
- t.isCube) {
- var d = this.createCubeTexture({
- width: i,
- height: n
- }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages);
- s.set(d),
- s.createView({
- format: s.format,
- dimension: vu.Cube,
- mipLevelCount: c,
- baseArrayLayer: 0,
- baseMipLevel: 0,
- arrayLayerCount: 6,
- aspect: yu.All
- }, l)
- } else
- d = this.createTexture({
- width: i,
- height: n,
- layers: h
- }, t.generateMipMaps, t.generateMipMaps, t.invertY, !1, t.is3D, s.format, 1, this._commandEncoderForCreation, s.textureUsages, s.textureAdditionalUsages),
- s.set(d),
- s.createView({
- format: s.format,
- dimension: t.is2DArray ? vu.E2dArray : t.is3D ? mu.E3d : vu.E2d,
- mipLevelCount: c,
- baseArrayLayer: 0,
- baseMipLevel: 0,
- arrayLayerCount: t.is3D ? 1 : h,
- aspect: yu.All
- }, l);
- return t.width = t.baseWidth = i,
- t.height = t.baseHeight = n,
- t.depth = t.baseDepth = r,
- this.createMSAATexture(t, t.samples),
- s
- }
- ,
- e.prototype.createMSAATexture = function(e, t) {
- var i = e._hardwareTexture;
- if ((null == i ? void 0 : i.msaaTexture) && (this.releaseTexture(i.msaaTexture),
- i.msaaTexture = null),
- i && !((null != t ? t : 1) <= 1)) {
- var n = e.width
- , r = e.height
- , o = e.depth || 1;
- if (e.isCube) {
- var a = this.createCubeTexture({
- width: n,
- height: r
- }, !1, !1, e.invertY, !1, i.format, t, this._commandEncoderForCreation, i.textureUsages, i.textureAdditionalUsages);
- i.msaaTexture = a
- } else
- a = this.createTexture({
- width: n,
- height: r,
- layers: o
- }, !1, !1, e.invertY, !1, e.is3D, i.format, t, this._commandEncoderForCreation, i.textureUsages, i.textureAdditionalUsages),
- i.msaaTexture = a
- }
- }
- ,
- e.prototype.updateCubeTextures = function(e, t, i, n, r, o, a, s, l) {
- void 0 === o && (o = !1),
- void 0 === a && (a = !1),
- void 0 === s && (s = 0),
- void 0 === l && (l = 0);
- for (var c = [0, 3, 1, 4, 2, 5], u = 0; u < c.length; ++u) {
- var h = e[c[u]];
- this.updateTexture(h, t, i, n, 1, r, u, 0, o, a, s, l)
- }
- }
- ,
- e.prototype.updateTexture = function(t, i, n, r, o, a, s, l, c, u, h, d, p) {
- void 0 === s && (s = 0),
- void 0 === l && (l = 0),
- void 0 === c && (c = !1),
- void 0 === u && (u = !1),
- void 0 === h && (h = 0),
- void 0 === d && (d = 0);
- var f = e._IsInternalTexture(i) ? i._hardwareTexture.underlyingResource : i
- , _ = e._GetBlockInformationFromFormat(a)
- , m = e._IsInternalTexture(i) ? i._hardwareTexture : i
- , g = {
- texture: f,
- origin: {
- x: h,
- y: d,
- z: Math.max(s, 0)
- },
- mipLevel: l,
- premultipliedAlpha: u
- }
- , v = {
- width: Math.ceil(n / _.width) * _.width,
- height: Math.ceil(r / _.height) * _.height,
- depthOrArrayLayers: o || 1
- };
- if (void 0 !== t.byteLength) {
- t = t;
- var y = Math.ceil(n / _.width) * _.length;
- if (256 * Math.ceil(y / 256) === y) {
- var b = this._device.createCommandEncoder({})
- , T = this._bufferManager.createRawBuffer(t.byteLength, fu.MapWrite | fu.CopySrc, !0)
- , E = T.getMappedRange();
- new Uint8Array(E).set(t),
- T.unmap(),
- b.copyBufferToTexture({
- buffer: T,
- offset: 0,
- bytesPerRow: y,
- rowsPerImage: r
- }, g, v),
- this._device.queue.submit([b.finish()]),
- this._bufferManager.releaseBuffer(T)
- } else
- this._device.queue.writeTexture(g, t, {
- offset: 0,
- bytesPerRow: y,
- rowsPerImage: r
- }, v);
- if (c || u) {
- if (!e._IsInternalTexture(i))
- throw "updateTexture: Can't process the texture data because a GPUTexture was provided instead of an InternalTexture!";
- var S = 0 === h && 0 === d && n === i.width && r === i.height;
- this.invertYPreMultiplyAlpha(m, i.width, i.height, a, c, u, s, l, o || 1, h, d, S ? 0 : n, S ? 0 : r, void 0, p)
- }
- } else if (t = t,
- c)
- if (g.premultipliedAlpha = !1,
- e._IsInternalTexture(i) && 0 === h && 0 === d && n === i.width && r === i.height)
- this._device.queue.copyExternalImageToTexture({
- source: t
- }, g, v),
- this.invertYPreMultiplyAlpha(m, n, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, void 0, p);
- else {
- b = this._device.createCommandEncoder({});
- var A = this.createTexture({
- width: n,
- height: r,
- layers: 1
- }, !1, !1, !1, !1, !1, a, 1, b, gu.CopySrc | gu.TextureBinding);
- this._deferredReleaseTextures.push([A, null]),
- v.depthOrArrayLayers = 1,
- this._device.queue.copyExternalImageToTexture({
- source: t
- }, {
- texture: A
- }, v),
- v.depthOrArrayLayers = o || 1,
- this.invertYPreMultiplyAlpha(A, n, r, a, c, u, s, l, o || 1, 0, 0, 0, 0, b, p),
- b.copyTextureToTexture({
- texture: A
- }, g, v),
- this._device.queue.submit([b.finish()])
- }
- else
- this._device.queue.copyExternalImageToTexture({
- source: t
- }, g, v)
- }
- ,
- e.prototype.readPixels = function(t, i, n, r, o, a, s, l, c, u) {
- void 0 === s && (s = 0),
- void 0 === l && (l = 0),
- void 0 === c && (c = null),
- void 0 === u && (u = !1);
- var h = e._GetBlockInformationFromFormat(a)
- , d = Math.ceil(r / h.width) * h.length
- , p = 256 * Math.ceil(d / 256)
- , f = p * o
- , _ = this._bufferManager.createRawBuffer(f, fu.MapRead | fu.CopyDst)
- , m = this._device.createCommandEncoder({});
- return m.copyTextureToBuffer({
- texture: t,
- mipLevel: l,
- origin: {
- x: i,
- y: n,
- z: Math.max(s, 0)
- }
- }, {
- buffer: _,
- offset: 0,
- bytesPerRow: p
- }, {
- width: r,
- height: o,
- depthOrArrayLayers: 1
- }),
- this._device.queue.submit([m.finish()]),
- this._bufferManager.readDataFromBuffer(_, f, r, o, d, p, e._GetTextureTypeFromFormat(a), 0, c, !0, u)
- }
- ,
- e.prototype.releaseTexture = function(t) {
- if (e._IsInternalTexture(t)) {
- var i = t._hardwareTexture
- , n = t._irradianceTexture;
- this._deferredReleaseTextures.push([i, n])
- } else
- this._deferredReleaseTextures.push([t, null])
- }
- ,
- e.prototype.destroyDeferredTextures = function() {
- for (var t = 0; t < this._deferredReleaseTextures.length; ++t) {
- var i = this._deferredReleaseTextures[t]
- , n = i[0]
- , r = i[1];
- n && (e._IsHardwareTexture(n) ? n.release() : n.destroy()),
- null == r || r.dispose()
- }
- this._deferredReleaseTextures.length = 0
- }
- ,
- e
- }(), _h = function(e) {
- function t(t) {
- var i = e.call(this) || this;
- return i._buffer = t,
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "underlyingResource", {
- get: function() {
- return this._buffer
- },
- enumerable: !1,
- configurable: !0
- }),
- t
- }(Bt), mh = function() {
- function e(e) {
- this._deferredReleaseBuffers = [],
- this._device = e
- }
- return e._IsGPUBuffer = function(e) {
- return void 0 === e.underlyingResource
- }
- ,
- e.prototype.createRawBuffer = function(e, t, i) {
- void 0 === i && (i = !1);
- var n = {
- mappedAtCreation: i,
- size: void 0 !== e.byteLength ? e.byteLength + 3 & -4 : e + 3 & -4,
- usage: t
- };
- return this._device.createBuffer(n)
- }
- ,
- e.prototype.createBuffer = function(e, t) {
- var i = void 0 !== e.byteLength
- , n = this.createRawBuffer(e, t)
- , r = new _h(n);
- return r.references = 1,
- r.capacity = i ? e.byteLength : e,
- i && this.setSubData(r, 0, e),
- r
- }
- ,
- e.prototype.setRawData = function(e, t, i, n, r) {
- this._device.queue.writeBuffer(e, t, i.buffer, n, r)
- }
- ,
- e.prototype.setSubData = function(e, t, i, n, r) {
- void 0 === n && (n = 0),
- void 0 === r && (r = 0);
- var o = e.underlyingResource;
- r = r || i.byteLength,
- r = Math.min(r, e.capacity - t);
- var a = i.byteOffset + n
- , s = a + r
- , l = r + 3 & -4;
- if (l !== r) {
- var c = new Uint8Array(i.buffer.slice(a, s));
- (i = new Uint8Array(l)).set(c),
- n = 0,
- a = 0,
- s = l,
- r = l
- }
- for (var u = 15728640, h = 0; s - (a + h) > u; )
- this._device.queue.writeBuffer(o, t + h, i.buffer, a + h, u),
- h += u;
- this._device.queue.writeBuffer(o, t + h, i.buffer, a + h, r - h)
- }
- ,
- e.prototype._getHalfFloatAsFloatRGBAArrayBuffer = function(e, t, i) {
- i || (i = new Float32Array(e));
- for (var n = new Uint16Array(t); e--; )
- i[e] = Dc(n[e]);
- return i
- }
- ,
- e.prototype.readDataFromBuffer = function(e, t, i, n, r, o, s, l, c, u, h) {
- var d = this;
- void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_BYTE),
- void 0 === l && (l = 0),
- void 0 === c && (c = null),
- void 0 === u && (u = !0),
- void 0 === h && (h = !1);
- var p = s === a.TEXTURETYPE_FLOAT ? 2 : s === a.TEXTURETYPE_HALF_FLOAT ? 1 : 0;
- return new Promise((function(i, a) {
- e.mapAsync(_u.Read, l, t).then((function() {
- var a = e.getMappedRange(l, t)
- , f = c;
- if (h)
- f = null === f ? gr(s, t, !0, a) : gr(s, f.buffer, void 0, a);
- else if (null === f)
- switch (p) {
- case 0:
- (f = new Uint8Array(t)).set(new Uint8Array(a));
- break;
- case 1:
- f = d._getHalfFloatAsFloatRGBAArrayBuffer(t / 2, a);
- break;
- case 2:
- (f = new Float32Array(t / 4)).set(new Float32Array(a))
- }
- else
- switch (p) {
- case 0:
- (f = new Uint8Array(f.buffer)).set(new Uint8Array(a));
- break;
- case 1:
- f = d._getHalfFloatAsFloatRGBAArrayBuffer(t / 2, a, c);
- break;
- case 2:
- (f = new Float32Array(f.buffer)).set(new Float32Array(a))
- }
- if (r !== o) {
- 1 !== p || h || (r *= 2,
- o *= 2);
- for (var _ = new Uint8Array(f.buffer), m = r, g = 0, v = 1; v < n; ++v) {
- g = v * o;
- for (var y = 0; y < r; ++y)
- _[m++] = _[g++]
- }
- f = 0 === p || h ? new Uint8Array(_.buffer,0,m) : new Float32Array(_.buffer,0,m / 4)
- }
- e.unmap(),
- u && d.releaseBuffer(e),
- i(f)
- }
- ), (function(e) {
- return a(e)
- }
- ))
- }
- ))
- }
- ,
- e.prototype.releaseBuffer = function(t) {
- return e._IsGPUBuffer(t) ? (this._deferredReleaseBuffers.push(t),
- !0) : (t.references--,
- 0 === t.references && (this._deferredReleaseBuffers.push(t.underlyingResource),
- !0))
- }
- ,
- e.prototype.destroyDeferredBuffers = function() {
- for (var e = 0; e < this._deferredReleaseBuffers.length; ++e)
- this._deferredReleaseBuffers[e].destroy();
- this._deferredReleaseBuffers.length = 0
- }
- ,
- e
- }(), gh = function() {
- function e() {
- this.colorAttachmentGPUTextures = [],
- this.reset()
- }
- return e.prototype.reset = function(e) {
- void 0 === e && (e = !1),
- this.renderPass = null,
- e && (this.renderPassDescriptor = null,
- this.colorAttachmentViewDescriptor = null,
- this.depthAttachmentViewDescriptor = null,
- this.colorAttachmentGPUTextures = [],
- this.depthTextureFormat = void 0)
- }
- ,
- e
- }(), vh = [0, 0, 3, 7, 0, 2, 6, 2, 4, 1, 5, 3, 1], yh = [0, 64, 32, 96, 16, 80, 48, 112, 8], bh = [0, 128, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128], Th = function() {
- function e(e) {
- this._samplers = {},
- this._device = e,
- this.disabled = !1
- }
- return e.GetSamplerHashCode = function(e) {
- var t, i, n, r = e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1;
- return vh[e.samplingMode] + yh[(e._comparisonFunction || 514) - 512 + 1] + bh[e.samplingMode] + ((null !== (t = e._cachedWrapU) && void 0 !== t ? t : 1) << 8) + ((null !== (i = e._cachedWrapV) && void 0 !== i ? i : 1) << 10) + ((null !== (n = e._cachedWrapR) && void 0 !== n ? n : 1) << 12) + ((e.useMipMaps ? 1 : 0) << 14) + (r << 15)
- }
- ,
- e._GetSamplerFilterDescriptor = function(e, t) {
- var i, n, r, o, s, l = e.useMipMaps;
- switch (e.samplingMode) {
- case a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
- i = Eu.Linear,
- n = Eu.Linear,
- r = Eu.Nearest,
- l || (o = s = 0);
- break;
- case a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
- case a.TEXTURE_TRILINEAR_SAMPLINGMODE:
- i = Eu.Linear,
- n = Eu.Linear,
- l ? r = Eu.Linear : (r = Eu.Nearest,
- o = s = 0);
- break;
- case a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
- i = Eu.Nearest,
- n = Eu.Nearest,
- l ? r = Eu.Linear : (r = Eu.Nearest,
- o = s = 0);
- break;
- case a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
- i = Eu.Nearest,
- n = Eu.Nearest,
- r = Eu.Nearest,
- l || (o = s = 0);
- break;
- case a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
- i = Eu.Nearest,
- n = Eu.Linear,
- r = Eu.Nearest,
- l || (o = s = 0);
- break;
- case a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
- i = Eu.Nearest,
- n = Eu.Linear,
- l ? r = Eu.Linear : (r = Eu.Nearest,
- o = s = 0);
- break;
- case a.TEXTURE_NEAREST_LINEAR:
- i = Eu.Nearest,
- n = Eu.Linear,
- r = Eu.Nearest,
- o = s = 0;
- break;
- case a.TEXTURE_NEAREST_NEAREST:
- case a.TEXTURE_NEAREST_SAMPLINGMODE:
- i = Eu.Nearest,
- n = Eu.Nearest,
- r = Eu.Nearest,
- o = s = 0;
- break;
- case a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
- i = Eu.Linear,
- n = Eu.Nearest,
- r = Eu.Nearest,
- l || (o = s = 0);
- break;
- case a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
- i = Eu.Linear,
- n = Eu.Nearest,
- l ? r = Eu.Linear : (r = Eu.Nearest,
- o = s = 0);
- break;
- case a.TEXTURE_LINEAR_LINEAR:
- case a.TEXTURE_BILINEAR_SAMPLINGMODE:
- i = Eu.Linear,
- n = Eu.Linear,
- r = Eu.Nearest,
- o = s = 0;
- break;
- case a.TEXTURE_LINEAR_NEAREST:
- i = Eu.Linear,
- n = Eu.Nearest,
- r = Eu.Nearest,
- o = s = 0;
- break;
- default:
- i = Eu.Nearest,
- n = Eu.Nearest,
- r = Eu.Nearest,
- o = s = 0
- }
- return t > 1 && (0 !== o || 0 !== s) ? {
- magFilter: Eu.Linear,
- minFilter: Eu.Linear,
- mipmapFilter: Eu.Linear,
- anisotropyEnabled: !0
- } : {
- magFilter: i,
- minFilter: n,
- mipmapFilter: r,
- lodMinClamp: o,
- lodMaxClamp: s
- }
- }
- ,
- e._GetWrappingMode = function(e) {
- switch (e) {
- case a.TEXTURE_WRAP_ADDRESSMODE:
- return Tu.Repeat;
- case a.TEXTURE_CLAMP_ADDRESSMODE:
- return Tu.ClampToEdge;
- case a.TEXTURE_MIRROR_ADDRESSMODE:
- return Tu.MirrorRepeat
- }
- return Tu.Repeat
- }
- ,
- e._GetSamplerWrappingDescriptor = function(e) {
- return {
- addressModeU: this._GetWrappingMode(e._cachedWrapU),
- addressModeV: this._GetWrappingMode(e._cachedWrapV),
- addressModeW: this._GetWrappingMode(e._cachedWrapR)
- }
- }
- ,
- e._GetSamplerDescriptor = function(t) {
- var i = t.useMipMaps && t._cachedAnisotropicFilteringLevel && t._cachedAnisotropicFilteringLevel > 1 ? 4 : 1
- , n = this._GetSamplerFilterDescriptor(t, i);
- return V(V(V({}, n), this._GetSamplerWrappingDescriptor(t)), {
- compare: t._comparisonFunction ? e.GetCompareFunction(t._comparisonFunction) : void 0,
- maxAnisotropy: n.anisotropyEnabled ? i : 1
- })
- }
- ,
- e.GetCompareFunction = function(e) {
- switch (e) {
- case a.ALWAYS:
- return Su.Always;
- case a.EQUAL:
- return Su.Equal;
- case a.GREATER:
- return Su.Greater;
- case a.GEQUAL:
- return Su.GreaterEqual;
- case a.LESS:
- return Su.Less;
- case a.LEQUAL:
- return Su.LessEqual;
- case a.NEVER:
- return Su.Never;
- case a.NOTEQUAL:
- return Su.NotEqual;
- default:
- return Su.Less
- }
- }
- ,
- e.prototype.getSampler = function(t, i, n) {
- if (void 0 === i && (i = !1),
- void 0 === n && (n = 0),
- this.disabled)
- return this._device.createSampler(e._GetSamplerDescriptor(t));
- i ? n = 0 : 0 === n && (n = e.GetSamplerHashCode(t));
- var r = i ? void 0 : this._samplers[n];
- return r || (r = this._device.createSampler(e._GetSamplerDescriptor(t)),
- i || (this._samplers[n] = r)),
- r
- }
- ,
- e
- }();
- !function(e) {
- e[e.StencilReadMask = 0] = "StencilReadMask",
- e[e.StencilWriteMask = 1] = "StencilWriteMask",
- e[e.DepthBias = 2] = "DepthBias",
- e[e.DepthBiasSlopeScale = 3] = "DepthBiasSlopeScale",
- e[e.DepthStencilState = 4] = "DepthStencilState",
- e[e.MRTAttachments1 = 5] = "MRTAttachments1",
- e[e.MRTAttachments2 = 6] = "MRTAttachments2",
- e[e.RasterizationState = 7] = "RasterizationState",
- e[e.ColorStates = 8] = "ColorStates",
- e[e.ShaderStage = 9] = "ShaderStage",
- e[e.TextureStage = 10] = "TextureStage",
- e[e.VertexState = 11] = "VertexState",
- e[e.NumStates = 12] = "NumStates"
- }(hh || (hh = {}));
- var Eh = {
- 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
- }
- , Sh = {
- 0: 0,
- 7680: 1,
- 7681: 2,
- 7682: 3,
- 7683: 4,
- 5386: 5,
- 34055: 6,
- 34056: 7
- }
- , Ah = function() {
- function e(e, t, i) {
- this.mrtTextureCount = 0,
- this._device = e,
- this._useTextureStage = i,
- this._states = new Array(30),
- this._statesLength = 0,
- this._stateDirtyLowestIndex = 0,
- this._emptyVertexBuffer = t,
- this._mrtFormats = [],
- this._parameter = {
- token: void 0,
- pipeline: null
- },
- this.disabled = !1,
- this.vertexBuffers = [],
- this._kMaxVertexBufferStride = e.limits.maxVertexBufferArrayStride || 2048,
- this.reset()
- }
- return e.prototype.reset = function() {
- this._isDirty = !0,
- this.vertexBuffers.length = 0,
- this.setAlphaToCoverage(!1),
- this.resetDepthCullingState(),
- this.setClampDepth(!1),
- this.setDepthBias(0),
- this._webgpuColorFormat = [bu.BGRA8Unorm],
- this.setColorFormat(bu.BGRA8Unorm),
- this.setMRT([]),
- this.setAlphaBlendEnabled(!1),
- this.setAlphaBlendFactors([null, null, null, null], [null, null]),
- this.setWriteMask(15),
- this.setDepthStencilFormat(bu.Depth24PlusStencil8),
- this.setStencilEnabled(!1),
- this.resetStencilState(),
- this.setBuffers(null, null, null),
- this._setTextureState(0)
- }
- ,
- Object.defineProperty(e.prototype, "colorFormats", {
- get: function() {
- return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getRenderPipeline = function(t, i, n, r) {
- if (void 0 === r && (r = 0),
- n > 1 && (n = 4),
- this.disabled) {
- var o = e._GetTopology(t);
- return this._setVertexState(i),
- this._parameter.pipeline = this._createRenderPipeline(i, o, n),
- e.NumCacheMiss++,
- e._NumPipelineCreationCurrentFrame++,
- this._parameter.pipeline
- }
- if (this._setShaderStage(i.uniqueId),
- this._setRasterizationState(t, n),
- this._setColorStates(),
- this._setDepthStencilState(),
- this._setVertexState(i),
- this._setTextureState(r),
- this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex,
- !this._isDirty && this._parameter.pipeline)
- return this._stateDirtyLowestIndex = this._statesLength,
- e.NumCacheHitWithoutHash++,
- this._parameter.pipeline;
- if (this._getRenderPipeline(this._parameter),
- this._isDirty = !1,
- this._stateDirtyLowestIndex = this._statesLength,
- this._parameter.pipeline)
- return e.NumCacheHitWithHash++,
- this._parameter.pipeline;
- var a = e._GetTopology(t);
- return this._parameter.pipeline = this._createRenderPipeline(i, a, n),
- this._setRenderPipeline(this._parameter),
- e.NumCacheMiss++,
- e._NumPipelineCreationCurrentFrame++,
- this._parameter.pipeline
- }
- ,
- e.prototype.endFrame = function() {
- e.NumPipelineCreationLastFrame = e._NumPipelineCreationCurrentFrame,
- e._NumPipelineCreationCurrentFrame = 0
- }
- ,
- e.prototype.setAlphaToCoverage = function(e) {
- this._alphaToCoverageEnabled = e
- }
- ,
- e.prototype.setFrontFace = function(e) {
- this._frontFace = e
- }
- ,
- e.prototype.setCullEnabled = function(e) {
- this._cullEnabled = e
- }
- ,
- e.prototype.setCullFace = function(e) {
- this._cullFace = e
- }
- ,
- e.prototype.setClampDepth = function(e) {
- this._clampDepth = e
- }
- ,
- e.prototype.resetDepthCullingState = function() {
- this.setDepthCullingState(!1, 2, 1, 0, 0, !0, !0, a.ALWAYS)
- }
- ,
- e.prototype.setDepthCullingState = function(e, t, i, n, r, o, s, l) {
- this._depthWriteEnabled = s,
- this._depthTestEnabled = o,
- this._depthCompare = (null != l ? l : a.ALWAYS) - 512,
- this._cullFace = i,
- this._cullEnabled = e,
- this._frontFace = t,
- this.setDepthBiasSlopeScale(n),
- this.setDepthBias(r)
- }
- ,
- e.prototype.setDepthBias = function(e) {
- this._depthBias !== e && (this._depthBias = e,
- this._states[hh.DepthBias] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthBias))
- }
- ,
- e.prototype.setDepthBiasSlopeScale = function(e) {
- this._depthBiasSlopeScale !== e && (this._depthBiasSlopeScale = e,
- this._states[hh.DepthBiasSlopeScale] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthBiasSlopeScale))
- }
- ,
- e.prototype.setColorFormat = function(e) {
- this._webgpuColorFormat[0] = e,
- this._colorFormat = ph[e]
- }
- ,
- e.prototype.setMRTAttachments = function(e) {
- this.mrtAttachments = e;
- for (var t = 0, i = 0; i < e.length; ++i)
- 0 !== e[i] && (t += 1 << i);
- this._mrtEnabledMask !== t && (this._mrtEnabledMask = t,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.MRTAttachments1))
- }
- ,
- e.prototype.setMRT = function(e, t) {
- var i;
- if ((t = null != t ? t : e.length) > 10)
- throw "Can't handle more than 10 attachments for a MRT in cache render pipeline!";
- this.mrtTextureArray = e,
- this.mrtTextureCount = t,
- this._mrtEnabledMask = 65535;
- for (var n = [0, 0], r = 0, o = 0, a = 0, s = 0; s < t; ++s) {
- var l = e[s]
- , c = null == l ? void 0 : l._hardwareTexture;
- this._mrtFormats[a] = null !== (i = null == c ? void 0 : c.format) && void 0 !== i ? i : this._webgpuColorFormat[0],
- n[r] += ph[this._mrtFormats[a]] << o,
- a++,
- (o += 6) >= 32 && (o = 0,
- r++)
- }
- this._mrtFormats.length = a,
- this._mrtAttachments1 === n[0] && this._mrtAttachments2 === n[1] || (this._mrtAttachments1 = n[0],
- this._mrtAttachments2 = n[1],
- this._states[hh.MRTAttachments1] = n[0],
- this._states[hh.MRTAttachments2] = n[1],
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.MRTAttachments1))
- }
- ,
- e.prototype.setAlphaBlendEnabled = function(e) {
- this._alphaBlendEnabled = e
- }
- ,
- e.prototype.setAlphaBlendFactors = function(e, t) {
- this._alphaBlendFuncParams = e,
- this._alphaBlendEqParams = t
- }
- ,
- e.prototype.setWriteMask = function(e) {
- this._writeMask = e
- }
- ,
- e.prototype.setDepthStencilFormat = function(e) {
- this._webgpuDepthStencilFormat = e,
- this._depthStencilFormat = void 0 === e ? 0 : ph[e]
- }
- ,
- e.prototype.setDepthTestEnabled = function(e) {
- this._depthTestEnabled = e
- }
- ,
- e.prototype.setDepthWriteEnabled = function(e) {
- this._depthWriteEnabled = e
- }
- ,
- e.prototype.setDepthCompare = function(e) {
- this._depthCompare = (null != e ? e : a.ALWAYS) - 512
- }
- ,
- e.prototype.setStencilEnabled = function(e) {
- this._stencilEnabled = e
- }
- ,
- e.prototype.setStencilCompare = function(e) {
- this._stencilFrontCompare = (null != e ? e : a.ALWAYS) - 512
- }
- ,
- e.prototype.setStencilDepthFailOp = function(e) {
- this._stencilFrontDepthFailOp = null === e ? 1 : Sh[e]
- }
- ,
- e.prototype.setStencilPassOp = function(e) {
- this._stencilFrontPassOp = null === e ? 2 : Sh[e]
- }
- ,
- e.prototype.setStencilFailOp = function(e) {
- this._stencilFrontFailOp = null === e ? 1 : Sh[e]
- }
- ,
- e.prototype.setStencilReadMask = function(e) {
- this._stencilReadMask !== e && (this._stencilReadMask = e,
- this._states[hh.StencilReadMask] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.StencilReadMask))
- }
- ,
- e.prototype.setStencilWriteMask = function(e) {
- this._stencilWriteMask !== e && (this._stencilWriteMask = e,
- this._states[hh.StencilWriteMask] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.StencilWriteMask))
- }
- ,
- e.prototype.resetStencilState = function() {
- this.setStencilState(!1, a.ALWAYS, a.KEEP, a.REPLACE, a.KEEP, 255, 255)
- }
- ,
- e.prototype.setStencilState = function(e, t, i, n, r, o, s) {
- this._stencilEnabled = e,
- this._stencilFrontCompare = (null != t ? t : a.ALWAYS) - 512,
- this._stencilFrontDepthFailOp = null === i ? 1 : Sh[i],
- this._stencilFrontPassOp = null === n ? 2 : Sh[n],
- this._stencilFrontFailOp = null === r ? 1 : Sh[r],
- this.setStencilReadMask(o),
- this.setStencilWriteMask(s)
- }
- ,
- e.prototype.setBuffers = function(e, t, i) {
- this._vertexBuffers = e,
- this._overrideVertexBuffers = i,
- this._indexBuffer = t
- }
- ,
- e._GetTopology = function(e) {
- switch (e) {
- case a.MATERIAL_TriangleFillMode:
- return Iu.TriangleList;
- case a.MATERIAL_PointFillMode:
- return Iu.PointList;
- case a.MATERIAL_WireFrameFillMode:
- return Iu.LineList;
- case a.MATERIAL_PointListDrawMode:
- return Iu.PointList;
- case a.MATERIAL_LineListDrawMode:
- return Iu.LineList;
- case a.MATERIAL_LineLoopDrawMode:
- throw "LineLoop is an unsupported fillmode in WebGPU";
- case a.MATERIAL_LineStripDrawMode:
- return Iu.LineStrip;
- case a.MATERIAL_TriangleStripDrawMode:
- return Iu.TriangleStrip;
- case a.MATERIAL_TriangleFanDrawMode:
- throw "TriangleFan is an unsupported fillmode in WebGPU";
- default:
- return Iu.TriangleList
- }
- }
- ,
- e._GetAphaBlendOperation = function(e) {
- switch (e) {
- case a.GL_ALPHA_EQUATION_ADD:
- return Fu.Add;
- case a.GL_ALPHA_EQUATION_SUBTRACT:
- return Fu.Subtract;
- case a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:
- return Fu.ReverseSubtract;
- case a.GL_ALPHA_EQUATION_MIN:
- return Fu.Min;
- case a.GL_ALPHA_EQUATION_MAX:
- return Fu.Max;
- default:
- return Fu.Add
- }
- }
- ,
- e._GetAphaBlendFactor = function(e) {
- switch (e) {
- case 0:
- return Lu.Zero;
- case 1:
- return Lu.One;
- case a.GL_ALPHA_FUNCTION_SRC:
- return Lu.Src;
- case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:
- return Lu.OneMinusSrc;
- case a.GL_ALPHA_FUNCTION_SRC_ALPHA:
- return Lu.SrcAlpha;
- case a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:
- return Lu.OneMinusSrcAlpha;
- case a.GL_ALPHA_FUNCTION_DST_ALPHA:
- return Lu.DstAlpha;
- case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:
- return Lu.OneMinusDstAlpha;
- case a.GL_ALPHA_FUNCTION_DST_COLOR:
- return Lu.Dst;
- case a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:
- return Lu.OneMinusDst;
- case a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:
- return Lu.SrcAlphaSaturated;
- case a.GL_ALPHA_FUNCTION_CONSTANT_COLOR:
- return Lu.Constant;
- case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:
- return Lu.OneMinusConstant;
- case a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:
- return Lu.Constant;
- case a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:
- return Lu.OneMinusConstant;
- default:
- return Lu.One
- }
- }
- ,
- e._GetCompareFunction = function(e) {
- switch (e) {
- case 0:
- return Su.Never;
- case 1:
- return Su.Less;
- case 2:
- return Su.Equal;
- case 3:
- return Su.LessEqual;
- case 4:
- return Su.Greater;
- case 5:
- return Su.NotEqual;
- case 6:
- return Su.GreaterEqual;
- case 7:
- return Su.Always
- }
- return Su.Never
- }
- ,
- e._GetStencilOpFunction = function(e) {
- switch (e) {
- case 0:
- return wu.Zero;
- case 1:
- return wu.Keep;
- case 2:
- return wu.Replace;
- case 3:
- return wu.IncrementClamp;
- case 4:
- return wu.DecrementClamp;
- case 5:
- return wu.Invert;
- case 6:
- return wu.IncrementWrap;
- case 7:
- return wu.DecrementWrap
- }
- return wu.Keep
- }
- ,
- e._GetVertexInputDescriptorFormat = function(e) {
- var t = e.type
- , i = e.normalized
- , n = e.getSize();
- switch (t) {
- case Bi.BYTE:
- switch (n) {
- case 1:
- case 2:
- return i ? Uu.Snorm8x2 : Uu.Sint8x2;
- case 3:
- case 4:
- return i ? Uu.Snorm8x4 : Uu.Sint8x4
- }
- break;
- case Bi.UNSIGNED_BYTE:
- switch (n) {
- case 1:
- case 2:
- return i ? Uu.Unorm8x2 : Uu.Uint8x2;
- case 3:
- case 4:
- return i ? Uu.Unorm8x4 : Uu.Uint8x4
- }
- break;
- case Bi.SHORT:
- switch (n) {
- case 1:
- case 2:
- return i ? Uu.Snorm16x2 : Uu.Sint16x2;
- case 3:
- case 4:
- return i ? Uu.Snorm16x4 : Uu.Sint16x4
- }
- break;
- case Bi.UNSIGNED_SHORT:
- switch (n) {
- case 1:
- case 2:
- return i ? Uu.Unorm16x2 : Uu.Uint16x2;
- case 3:
- case 4:
- return i ? Uu.Unorm16x4 : Uu.Uint16x4
- }
- break;
- case Bi.INT:
- switch (n) {
- case 1:
- return Uu.Sint32;
- case 2:
- return Uu.Sint32x2;
- case 3:
- return Uu.Sint32x3;
- case 4:
- return Uu.Sint32x4
- }
- break;
- case Bi.UNSIGNED_INT:
- switch (n) {
- case 1:
- return Uu.Uint32;
- case 2:
- return Uu.Uint32x2;
- case 3:
- return Uu.Uint32x3;
- case 4:
- return Uu.Uint32x4
- }
- break;
- case Bi.FLOAT:
- switch (n) {
- case 1:
- return Uu.Float32;
- case 2:
- return Uu.Float32x2;
- case 3:
- return Uu.Float32x3;
- case 4:
- return Uu.Float32x4
- }
- }
- throw new Error("Invalid Format '".concat(e.getKind(), "' - type=").concat(t, ", normalized=").concat(i, ", size=").concat(n))
- }
- ,
- e.prototype._getAphaBlendState = function() {
- return this._alphaBlendEnabled ? {
- srcFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),
- dstFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),
- operation: e._GetAphaBlendOperation(this._alphaBlendEqParams[1])
- } : null
- }
- ,
- e.prototype._getColorBlendState = function() {
- return this._alphaBlendEnabled ? {
- srcFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),
- dstFactor: e._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),
- operation: e._GetAphaBlendOperation(this._alphaBlendEqParams[0])
- } : null
- }
- ,
- e.prototype._setShaderStage = function(e) {
- this._shaderId !== e && (this._shaderId = e,
- this._states[hh.ShaderStage] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.ShaderStage))
- }
- ,
- e.prototype._setRasterizationState = function(e, t) {
- var i = this._frontFace - 1 + ((this._cullEnabled ? this._cullFace : 0) << 1) + ((this._clampDepth ? 1 : 0) << 3) + ((this._alphaToCoverageEnabled ? 1 : 0) << 4) + (e << 5) + (t << 8);
- this._rasterizationState !== i && (this._rasterizationState = i,
- this._states[hh.RasterizationState] = this._rasterizationState,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.RasterizationState))
- }
- ,
- e.prototype._setColorStates = function() {
- var e = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29);
- this._alphaBlendEnabled && (e += ((null === this._alphaBlendFuncParams[0] ? 2 : Eh[this._alphaBlendFuncParams[0]]) << 0) + ((null === this._alphaBlendFuncParams[1] ? 2 : Eh[this._alphaBlendFuncParams[1]]) << 4) + ((null === this._alphaBlendFuncParams[2] ? 2 : Eh[this._alphaBlendFuncParams[2]]) << 8) + ((null === this._alphaBlendFuncParams[3] ? 2 : Eh[this._alphaBlendFuncParams[3]]) << 12) + ((null === this._alphaBlendEqParams[0] ? 1 : this._alphaBlendEqParams[0] - 32773) << 16) + ((null === this._alphaBlendEqParams[1] ? 1 : this._alphaBlendEqParams[1] - 32773) << 19)),
- e !== this._colorStates && (this._colorStates = e,
- this._states[hh.ColorStates] = this._colorStates,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.ColorStates))
- }
- ,
- e.prototype._setDepthStencilState = function() {
- var e = this._stencilEnabled ? this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9) : 591
- , t = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) << 6) + (e << 10);
- this._depthStencilState !== t && (this._depthStencilState = t,
- this._states[hh.DepthStencilState] = this._depthStencilState,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.DepthStencilState))
- }
- ,
- e.prototype._setVertexState = function(e) {
- for (var t, i, n, r = this._statesLength, o = hh.VertexState, a = e._pipelineContext, s = a.shaderProcessingContext.attributeNamesFromEffect, l = a.shaderProcessingContext.attributeLocationsFromEffect, c = 0, u = 0; u < s.length; u++) {
- var h = l[u]
- , d = null !== (t = this._overrideVertexBuffers && this._overrideVertexBuffers[s[u]]) && void 0 !== t ? t : this._vertexBuffers[s[u]];
- d || (d = this._emptyVertexBuffer);
- var p = null === (i = d.getBuffer()) || void 0 === i ? void 0 : i.underlyingResource;
- if (void 0 === d._validOffsetRange) {
- var f = d.byteOffset
- , _ = d.getSize(!0)
- , m = d.byteStride;
- d._validOffsetRange = f <= this._kMaxVertexBufferStride - _ && (0 === m || f + _ <= m)
- }
- n && n === p && d._validOffsetRange || (this.vertexBuffers[c++] = d,
- n = d._validOffsetRange ? p : null);
- var g = d.hashCode + (h << 7);
- this._isDirty = this._isDirty || this._states[o] !== g,
- this._states[o++] = g
- }
- this.vertexBuffers.length = c,
- this._statesLength = o,
- this._isDirty = this._isDirty || o !== r,
- this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.VertexState))
- }
- ,
- e.prototype._setTextureState = function(e) {
- this._textureState !== e && (this._textureState = e,
- this._states[hh.TextureStage] = this._textureState,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, hh.TextureStage))
- }
- ,
- e.prototype._createPipelineLayout = function(e) {
- if (this._useTextureStage)
- return this._createPipelineLayoutWithTextureStage(e);
- for (var t = [], i = e.shaderProcessingContext.bindGroupLayoutEntries, n = 0; n < i.length; n++) {
- var r = i[n];
- t[n] = this._device.createBindGroupLayout({
- entries: r
- })
- }
- return e.bindGroupLayouts = t,
- this._device.createPipelineLayout({
- bindGroupLayouts: t
- })
- }
- ,
- e.prototype._createPipelineLayoutWithTextureStage = function(e) {
- for (var t, i = e.shaderProcessingContext, n = i.bindGroupLayoutEntries, r = 1, o = 0; o < n.length; o++)
- for (var a = n[o], s = 0; s < a.length; s++) {
- var l = n[o][s];
- if (l.texture) {
- var c = i.bindGroupLayoutEntryInfo[o][l.binding].name
- , u = i.availableTextures[c]
- , h = u.autoBindSampler ? i.availableSamplers[c + Qu.AutoSamplerSuffix] : null
- , d = u.sampleType
- , p = null !== (t = null == h ? void 0 : h.type) && void 0 !== t ? t : Ru.Filtering;
- if (this._textureState & r && d !== Cu.Depth && (u.autoBindSampler && (p = Ru.NonFiltering),
- d = Cu.UnfilterableFloat),
- l.texture.sampleType = d,
- h) {
- var f = i.bindGroupLayoutEntryInfo[h.binding.groupIndex][h.binding.bindingIndex].index;
- n[h.binding.groupIndex][f].sampler.type = p
- }
- r <<= 1
- }
- }
- var _ = [];
- for (o = 0; o < n.length; ++o)
- _[o] = this._device.createBindGroupLayout({
- entries: n[o]
- });
- return e.bindGroupLayouts = _,
- this._device.createPipelineLayout({
- bindGroupLayouts: _
- })
- }
- ,
- e.prototype._getVertexInputDescriptor = function(t) {
- for (var i, n, r, o, a = [], s = t._pipelineContext, l = s.shaderProcessingContext.attributeNamesFromEffect, c = s.shaderProcessingContext.attributeLocationsFromEffect, u = 0; u < l.length; u++) {
- var h = c[u]
- , d = null !== (i = this._overrideVertexBuffers && this._overrideVertexBuffers[l[u]]) && void 0 !== i ? i : this._vertexBuffers[l[u]];
- d || (d = this._emptyVertexBuffer);
- var p = null === (n = d.getBuffer()) || void 0 === n ? void 0 : n.underlyingResource
- , f = d.byteOffset
- , _ = !d._validOffsetRange;
- if (!r || !o || r !== p || _) {
- var m = {
- arrayStride: d.byteStride,
- stepMode: d.getIsInstanced() ? Vu.Instance : Vu.Vertex,
- attributes: []
- };
- a.push(m),
- o = m.attributes,
- _ && (f = 0,
- p = null)
- }
- o.push({
- shaderLocation: h,
- offset: f,
- format: e._GetVertexInputDescriptorFormat(d)
- }),
- r = p
- }
- return a
- }
- ,
- e.prototype._createRenderPipeline = function(t, i, n) {
- var r = t._pipelineContext
- , o = this._getVertexInputDescriptor(t)
- , a = this._createPipelineLayout(r)
- , s = []
- , l = this._getAphaBlendState()
- , c = this._getColorBlendState();
- if (this._mrtAttachments1 > 0)
- for (var u = 0; u < this._mrtFormats.length; ++u) {
- var h = {
- format: this._mrtFormats[u],
- writeMask: 0 != (this._mrtEnabledMask & 1 << u) ? this._writeMask : 0
- };
- l && c && (h.blend = {
- alpha: l,
- color: c
- }),
- s.push(h)
- }
- else
- h = {
- format: this._webgpuColorFormat[0],
- writeMask: this._writeMask
- },
- l && c && (h.blend = {
- alpha: l,
- color: c
- }),
- s.push(h);
- var d = {
- compare: e._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7),
- depthFailOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1),
- failOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1),
- passOp: e._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1)
- }
- , p = void 0;
- i !== Iu.LineStrip && i !== Iu.TriangleStrip || (p = !this._indexBuffer || this._indexBuffer.is32Bits ? Bu.Uint32 : Bu.Uint16);
- var f = !!this._webgpuDepthStencilFormat && fh.HasStencilAspect(this._webgpuDepthStencilFormat);
- return this._device.createRenderPipeline({
- layout: a,
- vertex: {
- module: r.stages.vertexStage.module,
- entryPoint: r.stages.vertexStage.entryPoint,
- buffers: o
- },
- primitive: {
- topology: i,
- stripIndexFormat: p,
- frontFace: 1 === this._frontFace ? Ou.CCW : Ou.CW,
- cullMode: this._cullEnabled ? 2 === this._cullFace ? Du.Front : Du.Back : Du.None
- },
- fragment: r.stages.fragmentStage ? {
- module: r.stages.fragmentStage.module,
- entryPoint: r.stages.fragmentStage.entryPoint,
- targets: s
- } : void 0,
- multisample: {
- count: n
- },
- depthStencil: void 0 === this._webgpuDepthStencilFormat ? void 0 : {
- depthWriteEnabled: this._depthWriteEnabled,
- depthCompare: this._depthTestEnabled ? e._GetCompareFunction(this._depthCompare) : Su.Always,
- format: this._webgpuDepthStencilFormat,
- stencilFront: this._stencilEnabled && f ? d : void 0,
- stencilBack: this._stencilEnabled && f ? d : void 0,
- stencilReadMask: this._stencilEnabled && f ? this._stencilReadMask : void 0,
- stencilWriteMask: this._stencilEnabled && f ? this._stencilWriteMask : void 0,
- depthBias: this._depthBias,
- depthBiasClamp: this._depthBiasClamp,
- depthBiasSlopeScale: this._depthBiasSlopeScale
- }
- })
- }
- ,
- e.NumCacheHitWithoutHash = 0,
- e.NumCacheHitWithHash = 0,
- e.NumCacheMiss = 0,
- e.NumPipelineCreationLastFrame = 0,
- e._NumPipelineCreationCurrentFrame = 0,
- e
- }()
- , xh = function() {
- function e() {
- this.values = {}
- }
- return e.prototype.count = function() {
- var e = 0
- , t = this.pipeline ? 1 : 0;
- for (var i in this.values) {
- var n = this.values[i].count();
- e += n[0],
- t += n[1],
- e++
- }
- return [e, t]
- }
- ,
- e
- }()
- , Rh = function(e) {
- function t(i, n, r) {
- var o = e.call(this, i, n, r) || this;
- return o._nodeStack = [],
- o._nodeStack[0] = t._Cache,
- o
- }
- return U(t, e),
- t.GetNodeCounts = function() {
- var e = t._Cache.count();
- return {
- nodeCount: e[0],
- pipelineCount: e[1]
- }
- }
- ,
- t._GetPipelines = function(e, i, n, r) {
- if (e.pipeline) {
- var o = n.slice();
- o.length = r,
- i.push(o)
- }
- for (var a in e.values) {
- var s = e.values[a];
- n[r] = parseInt(a),
- t._GetPipelines(s, i, n, r + 1)
- }
- }
- ,
- t.GetPipelines = function() {
- var e = [];
- return t._GetPipelines(t._Cache, e, [], 0),
- e
- }
- ,
- t.prototype._getRenderPipeline = function(e) {
- for (var t = this._nodeStack[this._stateDirtyLowestIndex], i = this._stateDirtyLowestIndex; i < this._statesLength; ++i) {
- var n = t.values[this._states[i]];
- n || (n = new xh,
- t.values[this._states[i]] = n),
- t = n,
- this._nodeStack[i + 1] = t
- }
- e.token = t,
- e.pipeline = t.pipeline
- }
- ,
- t.prototype._setRenderPipeline = function(e) {
- e.token.pipeline = e.pipeline
- }
- ,
- t._Cache = new xh,
- t
- }(Ah)
- , Ch = function(e) {
- function t(t) {
- var i = e.call(this, !1) || this;
- return i._cache = t,
- i.reset(),
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "func", {
- get: function() {
- return this._func
- },
- set: function(e) {
- this._func !== e && (this._func = e,
- this._cache.setStencilCompare(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "funcMask", {
- get: function() {
- return this._funcMask
- },
- set: function(e) {
- this._funcMask !== e && (this._funcMask = e,
- this._cache.setStencilReadMask(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "opStencilFail", {
- get: function() {
- return this._opStencilFail
- },
- set: function(e) {
- this._opStencilFail !== e && (this._opStencilFail = e,
- this._cache.setStencilFailOp(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "opDepthFail", {
- get: function() {
- return this._opDepthFail
- },
- set: function(e) {
- this._opDepthFail !== e && (this._opDepthFail = e,
- this._cache.setStencilDepthFailOp(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "opStencilDepthPass", {
- get: function() {
- return this._opStencilDepthPass
- },
- set: function(e) {
- this._opStencilDepthPass !== e && (this._opStencilDepthPass = e,
- this._cache.setStencilPassOp(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "mask", {
- get: function() {
- return this._mask
- },
- set: function(e) {
- this._mask !== e && (this._mask = e,
- this._cache.setStencilWriteMask(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled !== e && (this._enabled = e,
- this._cache.setStencilEnabled(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.reset = function() {
- e.prototype.reset.call(this),
- this._cache.resetStencilState()
- }
- ,
- t.prototype.apply = function() {
- var e, t = null === (e = this.stencilMaterial) || void 0 === e ? void 0 : e.enabled;
- this.enabled = t ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
- this.enabled && (this.func = t ? this.stencilMaterial.func : this.stencilGlobal.func,
- this.funcRef = t ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
- this.funcMask = t ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
- this.opStencilFail = t ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
- this.opDepthFail = t ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
- this.opStencilDepthPass = t ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
- this.mask = t ? this.stencilMaterial.mask : this.stencilGlobal.mask)
- }
- ,
- t
- }(zt)
- , Ph = function(e) {
- function t(t) {
- var i = e.call(this, !1) || this;
- return i._cache = t,
- i.reset(),
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "zOffset", {
- get: function() {
- return this._zOffset
- },
- set: function(e) {
- this._zOffset !== e && (this._zOffset = e,
- this._isZOffsetDirty = !0,
- this._cache.setDepthBiasSlopeScale(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "zOffsetUnits", {
- get: function() {
- return this._zOffsetUnits
- },
- set: function(e) {
- this._zOffsetUnits !== e && (this._zOffsetUnits = e,
- this._isZOffsetDirty = !0,
- this._cache.setDepthBias(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cullFace", {
- get: function() {
- return this._cullFace
- },
- set: function(e) {
- this._cullFace !== e && (this._cullFace = e,
- this._isCullFaceDirty = !0,
- this._cache.setCullFace(null != e ? e : 1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cull", {
- get: function() {
- return this._cull
- },
- set: function(e) {
- this._cull !== e && (this._cull = e,
- this._isCullDirty = !0,
- this._cache.setCullEnabled(!!e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthFunc", {
- get: function() {
- return this._depthFunc
- },
- set: function(e) {
- this._depthFunc !== e && (this._depthFunc = e,
- this._isDepthFuncDirty = !0,
- this._cache.setDepthCompare(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthMask", {
- get: function() {
- return this._depthMask
- },
- set: function(e) {
- this._depthMask !== e && (this._depthMask = e,
- this._isDepthMaskDirty = !0,
- this._cache.setDepthWriteEnabled(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthTest", {
- get: function() {
- return this._depthTest
- },
- set: function(e) {
- this._depthTest !== e && (this._depthTest = e,
- this._isDepthTestDirty = !0,
- this._cache.setDepthTestEnabled(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "frontFace", {
- get: function() {
- return this._frontFace
- },
- set: function(e) {
- this._frontFace !== e && (this._frontFace = e,
- this._isFrontFaceDirty = !0,
- this._cache.setFrontFace(null != e ? e : 2))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.reset = function() {
- e.prototype.reset.call(this),
- this._cache.resetDepthCullingState()
- }
- ,
- t.prototype.apply = function() {}
- ,
- t
- }(It)
- , Mh = function() {
- function e(e) {
- this.useMipMaps = !1,
- this.type = a.TEXTURETYPE_UNDEFINED,
- this._video = e,
- this.uniqueId = Lt._Counter++
- }
- return e.IsExternalTexture = function(e) {
- return void 0 !== e.underlyingResource
- }
- ,
- e.prototype.getClassName = function() {
- return "ExternalTexture"
- }
- ,
- Object.defineProperty(e.prototype, "underlyingResource", {
- get: function() {
- return this._video
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function() {
- return this._video.readyState >= this._video.HAVE_CURRENT_DATA
- }
- ,
- e.prototype.dispose = function() {}
- ,
- e
- }()
- , Ih = function() {
- function e() {
- this.uniqueId = e._Counter++,
- this.updateId = 0,
- this.reset()
- }
- return Object.defineProperty(e.prototype, "forceBindGroupCreation", {
- get: function() {
- return this._numExternalTextures > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasFloatTextures", {
- get: function() {
- return this._numFloatTextures > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reset = function() {
- this.samplers = {},
- this.textures = {},
- this.isDirty = !0,
- this._numFloatTextures = 0,
- this._numExternalTextures = 0
- }
- ,
- e.prototype.setSampler = function(e, t) {
- var i = this.samplers[e]
- , n = -1;
- i ? n = i.hashCode : this.samplers[e] = i = {
- sampler: t,
- hashCode: 0
- },
- i.sampler = t,
- i.hashCode = t ? Th.GetSamplerHashCode(t) : 0;
- var r = n !== i.hashCode;
- r && this.updateId++,
- this.isDirty || (this.isDirty = r)
- }
- ,
- e.prototype.setTexture = function(e, t) {
- var i, n, r, o = this.textures[e], s = -1;
- o ? s = null !== (n = null === (i = o.texture) || void 0 === i ? void 0 : i.uniqueId) && void 0 !== n ? n : -1 : this.textures[e] = o = {
- texture: t,
- isFloatTexture: !1,
- isExternalTexture: !1
- },
- o.isExternalTexture && this._numExternalTextures--,
- o.isFloatTexture && this._numFloatTextures--,
- t ? (o.isFloatTexture = t.type === a.TEXTURETYPE_FLOAT,
- o.isExternalTexture = Mh.IsExternalTexture(t),
- o.isFloatTexture && this._numFloatTextures++,
- o.isExternalTexture && this._numExternalTextures++) : (o.isFloatTexture = !1,
- o.isExternalTexture = !1),
- o.texture = t;
- var l = s !== (null !== (r = null == t ? void 0 : t.uniqueId) && void 0 !== r ? r : -1);
- l && this.updateId++,
- this.isDirty || (this.isDirty = l)
- }
- ,
- e._Counter = 0,
- e
- }()
- , Oh = function() {
- function e(t) {
- this._bufferManager = t,
- this.uniqueId = e._Counter++,
- this._useInstancing = !1,
- this._currentInstanceCount = 0,
- this.reset()
- }
- return e.prototype.isDirty = function(e) {
- return this._isDirty || this._materialContextUpdateId !== e
- }
- ,
- e.prototype.resetIsDirty = function(e) {
- this._isDirty = !1,
- this._materialContextUpdateId = e
- }
- ,
- Object.defineProperty(e.prototype, "useInstancing", {
- get: function() {
- return this._useInstancing
- },
- set: function(e) {
- this._useInstancing !== e && (e ? (this.indirectDrawBuffer = this._bufferManager.createRawBuffer(40, fu.CopyDst | fu.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
- }),
- e.prototype.reset = function() {
- this.buffers = {},
- this._isDirty = !0,
- this._materialContextUpdateId = 0,
- this.fastBundle = void 0,
- this.bindGroups = void 0
- }
- ,
- e.prototype.setBuffer = function(e, t) {
- var i;
- this._isDirty || (this._isDirty = (null == t ? void 0 : t.uniqueId) !== (null === (i = this.buffers[e]) || void 0 === i ? void 0 : i.uniqueId)),
- this.buffers[e] = t
- }
- ,
- e.prototype.setIndirectData = function(e, t, i) {
- t !== this._currentInstanceCount && this.indirectDrawBuffer && this._indirectDrawData && (this._currentInstanceCount = t,
- this._indirectDrawData[0] = e,
- this._indirectDrawData[1] = t,
- this._indirectDrawData[2] = i,
- this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20))
- }
- ,
- e.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
- }
- ,
- e._Counter = 0,
- e
- }()
- , Dh = function() {
- this.values = {}
- }
- , Nh = function() {
- function e(e, t, i) {
- this.disabled = !1,
- this._device = e,
- this._cacheSampler = t,
- this._engine = i
- }
- return Object.defineProperty(e, "Statistics", {
- get: function() {
- return {
- totalCreated: e.NumBindGroupsCreatedTotal,
- lastFrameCreated: e.NumBindGroupsCreatedLastFrame,
- lookupLastFrame: e.NumBindGroupsLookupLastFrame,
- noLookupLastFrame: e.NumBindGroupsNoLookupLastFrame
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.endFrame = function() {
- e.NumBindGroupsCreatedLastFrame = e._NumBindGroupsCreatedCurrentFrame,
- e.NumBindGroupsLookupLastFrame = e._NumBindGroupsLookupCurrentFrame,
- e.NumBindGroupsNoLookupLastFrame = e._NumBindGroupsNoLookupCurrentFrame,
- e._NumBindGroupsCreatedCurrentFrame = 0,
- e._NumBindGroupsLookupCurrentFrame = 0,
- e._NumBindGroupsNoLookupCurrentFrame = 0
- }
- ,
- e.prototype.getBindGroups = function(t, i, n) {
- var r, o, a, s, l, c, u, h, d, p, f = void 0, _ = e._Cache, m = this.disabled || n.forceBindGroupCreation;
- if (!m) {
- if (!i.isDirty(n.updateId) && !n.isDirty)
- return e._NumBindGroupsNoLookupCurrentFrame++,
- i.bindGroups;
- for (var g = 0, v = t.shaderProcessingContext.bufferNames; g < v.length; g++) {
- var y = v[g]
- , b = null !== (o = null === (r = i.buffers[y]) || void 0 === r ? void 0 : r.uniqueId) && void 0 !== o ? o : 0;
- (C = _.values[b]) || (C = new Dh,
- _.values[b] = C),
- _ = C
- }
- for (var T = 0, E = t.shaderProcessingContext.samplerNames; T < E.length; T++) {
- var S = E[T]
- , A = null !== (s = null === (a = n.samplers[S]) || void 0 === a ? void 0 : a.hashCode) && void 0 !== s ? s : 0;
- (C = _.values[A]) || (C = new Dh,
- _.values[A] = C),
- _ = C
- }
- for (var x = 0, R = t.shaderProcessingContext.textureNames; x < R.length; x++) {
- var C, P = R[x], M = null !== (u = null === (c = null === (l = n.textures[P]) || void 0 === l ? void 0 : l.texture) || void 0 === c ? void 0 : c.uniqueId) && void 0 !== u ? u : 0;
- (C = _.values[M]) || (C = new Dh,
- _.values[M] = C),
- _ = C
- }
- f = _.bindGroups
- }
- if (i.resetIsDirty(n.updateId),
- n.isDirty = !1,
- f)
- return i.bindGroups = f,
- e._NumBindGroupsLookupCurrentFrame++,
- f;
- f = [],
- i.bindGroups = f,
- m || (_.bindGroups = f),
- e.NumBindGroupsCreatedTotal++,
- e._NumBindGroupsCreatedCurrentFrame++;
- for (var I = t.bindGroupLayouts, O = 0; O < t.shaderProcessingContext.bindGroupLayoutEntries.length; O++) {
- for (var D = t.shaderProcessingContext.bindGroupLayoutEntries[O], N = t.shaderProcessingContext.bindGroupEntries[O], L = 0; L < D.length; L++) {
- var F = t.shaderProcessingContext.bindGroupLayoutEntries[O][L]
- , w = t.shaderProcessingContext.bindGroupLayoutEntryInfo[O][F.binding]
- , B = null !== (h = w.nameInArrayOfTexture) && void 0 !== h ? h : w.name;
- if (F.sampler)
- if (k = n.samplers[B]) {
- var U = k.sampler;
- if (!U) {
- this._engine.dbgSanityChecks && K.Error("Trying to bind a null sampler! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
- return "texture" === e ? "<no dump>" : t
- }
- )), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
- continue
- }
- N[L].resource = this._cacheSampler.getSampler(U, !1, k.hashCode)
- } else
- K.Error('Sampler "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
- return "texture" === e || "sampler" === e ? "<no dump>" : t
- }
- ))), 50);
- else if (F.texture || F.storageTexture)
- if (k = n.textures[B]) {
- if (this._engine.dbgSanityChecks && null === k.texture) {
- K.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(F), ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
- return "texture" === e ? "<no dump>" : t
- }
- )), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
- continue
- }
- var V = k.texture._hardwareTexture;
- if (this._engine.dbgSanityChecks && (!V || F.texture && !V.view || F.storageTexture && !V.viewForWriting)) {
- K.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
- return "texture" === e ? "<no dump>" : t
- }
- )), ", isReady=").concat(null === (d = k.texture) || void 0 === d ? void 0 : d.isReady, ", materialContext.uniqueId=").concat(n.uniqueId), 50);
- continue
- }
- N[L].resource = F.storageTexture ? V.viewForWriting : V.view
- } else
- K.Error('Texture "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
- return "texture" === e || "sampler" === e ? "<no dump>" : t
- }
- ))), 50);
- else if (F.externalTexture) {
- var k;
- if (k = n.textures[B]) {
- if (this._engine.dbgSanityChecks && null === k.texture) {
- K.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
- return "texture" === e ? "<no dump>" : t
- }
- )), ", materialContext.uniqueId=").concat(n.uniqueId), 50);
- continue
- }
- var G = k.texture.underlyingResource;
- if (this._engine.dbgSanityChecks && !G) {
- K.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(F), ", name=").concat(B, ", bindingInfo=").concat(JSON.stringify(k, (function(e, t) {
- return "texture" === e ? "<no dump>" : t
- }
- )), ", isReady=").concat(null === (p = k.texture) || void 0 === p ? void 0 : p.isReady, ", materialContext.uniqueId=").concat(n.uniqueId), 50);
- continue
- }
- N[L].resource = this._device.importExternalTexture({
- source: G
- })
- } else
- K.Error('Texture "'.concat(B, '" could not be bound. entry=').concat(JSON.stringify(F), ", materialContext=").concat(JSON.stringify(n, (function(e, t) {
- return "texture" === e || "sampler" === e ? "<no dump>" : t
- }
- ))), 50)
- } else if (F.buffer) {
- var z = i.buffers[B];
- if (z) {
- var W = z.underlyingResource;
- N[L].resource.buffer = W,
- N[L].resource.size = z.capacity
- } else
- K.Error("Can't find buffer \"".concat(B, '". entry=').concat(JSON.stringify(F), ", buffers=").concat(JSON.stringify(i.buffers), ", drawContext.uniqueId=").concat(i.uniqueId), 50)
- }
- }
- var H = I[O];
- f[O] = this._device.createBindGroup({
- layout: H,
- entries: N
- })
- }
- return f
- }
- ,
- e.NumBindGroupsCreatedTotal = 0,
- e.NumBindGroupsCreatedLastFrame = 0,
- e.NumBindGroupsLookupLastFrame = 0,
- e.NumBindGroupsNoLookupLastFrame = 0,
- e._Cache = new Dh,
- e._NumBindGroupsCreatedCurrentFrame = 0,
- e._NumBindGroupsLookupCurrentFrame = 0,
- e._NumBindGroupsNoLookupCurrentFrame = 0,
- e
- }();
- Pt.ShadersStore.clearQuadVertexShader = "uniform float depthValue;\nconst vec2 pos[4]={\nvec2(-1.0,1.0),\nvec2(1.0,1.0),\nvec2(-1.0,-1.0),\nvec2(1.0,-1.0)\n};\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=vec4(pos[gl_VertexID],depthValue,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
- Pt.ShadersStore.clearQuadPixelShader = "uniform vec4 color;\nvoid main() {\ngl_FragColor=color;\n}\n";
- var Lh = function() {
- function e(e, t, i) {
- this._bindGroups = {},
- this._bundleCache = {},
- this._keyTemp = [],
- this._device = e,
- this._engine = t,
- this._cacheRenderPipeline = new Rh(this._device,i,!t._caps.textureFloatLinearFiltering),
- this._cacheRenderPipeline.setDepthTestEnabled(!1),
- this._cacheRenderPipeline.setStencilReadMask(255),
- this._effect = t.createEffect("clearQuad", [], ["color", "depthValue"])
- }
- return e.prototype.setDepthStencilFormat = function(e) {
- this._depthTextureFormat = e,
- this._cacheRenderPipeline.setDepthStencilFormat(e)
- }
- ,
- e.prototype.setColorFormat = function(e) {
- this._cacheRenderPipeline.setColorFormat(e)
- }
- ,
- e.prototype.setMRTAttachments = function(e, t, i) {
- this._cacheRenderPipeline.setMRT(t, i),
- this._cacheRenderPipeline.setMRTAttachments(e)
- }
- ,
- e.prototype.clear = function(e, t, i, n, r) {
- var o, s;
- void 0 === r && (r = 1);
- var l, c = null, u = !!this._engine._currentRenderTarget;
- if (e)
- s = e;
- else {
- var h = 0;
- this._keyTemp.length = 0;
- for (var d = 0; d < this._cacheRenderPipeline.colorFormats.length; ++d)
- this._keyTemp[h++] = ph[this._cacheRenderPipeline.colorFormats[d]];
- var p = ph[null !== (o = this._depthTextureFormat) && void 0 !== o ? o : 0];
- if (this._keyTemp[h] = (t ? t.r + 256 * t.g + 256 * t.b * 256 + 256 * t.a * 256 * 256 : 0) + (i ? Math.pow(2, 32) : 0) + (n ? Math.pow(2, 33) : 0) + (this._engine.useReverseDepthBuffer ? Math.pow(2, 34) : 0) + (u ? Math.pow(2, 35) : 0) + (r > 1 ? Math.pow(2, 36) : 0) + p * Math.pow(2, 37),
- l = this._keyTemp.join("_"),
- c = this._bundleCache[l])
- return c;
- s = this._device.createRenderBundleEncoder({
- colorFormats: this._cacheRenderPipeline.colorFormats,
- depthStencilFormat: this._depthTextureFormat,
- sampleCount: r
- })
- }
- this._cacheRenderPipeline.setDepthWriteEnabled(!!i),
- this._cacheRenderPipeline.setStencilEnabled(!!n && !!this._depthTextureFormat && fh.HasStencilAspect(this._depthTextureFormat)),
- this._cacheRenderPipeline.setStencilWriteMask(n ? 255 : 0),
- this._cacheRenderPipeline.setStencilCompare(n ? a.ALWAYS : a.NEVER),
- this._cacheRenderPipeline.setStencilPassOp(n ? a.REPLACE : a.KEEP),
- this._cacheRenderPipeline.setWriteMask(t ? 15 : 0);
- var f = this._cacheRenderPipeline.getRenderPipeline(a.MATERIAL_TriangleStripDrawMode, this._effect, r)
- , _ = this._effect._pipelineContext;
- t && this._effect.setDirectColor4("color", t),
- this._effect.setFloat("depthValue", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue),
- _.uniformBuffer.update();
- var m = u ? this._engine._ubInvertY : this._engine._ubDontInvertY
- , g = _.uniformBuffer.getBuffer()
- , v = g.uniqueId + "-" + m.uniqueId
- , y = this._bindGroups[v];
- if (!y) {
- var b = _.bindGroupLayouts;
- (y = this._bindGroups[v] = []).push(this._device.createBindGroup({
- layout: b[0],
- entries: []
- })),
- Ju._SimplifiedKnownBindings || y.push(this._device.createBindGroup({
- layout: b[1],
- entries: []
- })),
- y.push(this._device.createBindGroup({
- layout: b[Ju._SimplifiedKnownBindings ? 1 : 2],
- entries: [{
- binding: 0,
- resource: {
- buffer: m.underlyingResource,
- size: m.capacity
- }
- }, {
- binding: 1,
- resource: {
- buffer: g.underlyingResource,
- size: g.capacity
- }
- }]
- }))
- }
- for (s.setPipeline(f),
- d = 0; d < y.length; ++d)
- s.setBindGroup(d, y[d]);
- return s.draw(4, 1, 0, 0),
- e || (c = s.finish(),
- this._bundleCache[l] = c),
- c
- }
- ,
- e
- }()
- , Fh = function() {
- function e(e, t, i, n) {
- this.x = Math.floor(e),
- this.y = Math.floor(t),
- this.w = Math.floor(i),
- this.h = Math.floor(n)
- }
- return e.prototype.run = function(e) {
- e.setViewport(this.x, this.y, this.w, this.h, 0, 1)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.x,this.y,this.w,this.h)
- }
- ,
- e
- }()
- , wh = function() {
- function e(e, t, i, n) {
- this.x = e,
- this.y = t,
- this.w = i,
- this.h = n
- }
- return e.prototype.run = function(e) {
- e.setScissorRect(this.x, this.y, this.w, this.h)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.x,this.y,this.w,this.h)
- }
- ,
- e
- }()
- , Bh = function() {
- function e(e) {
- this.ref = e
- }
- return e.prototype.run = function(e) {
- e.setStencilReference(this.ref)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.ref)
- }
- ,
- e
- }()
- , Uh = function() {
- function e(e) {
- this.color = e
- }
- return e.prototype.run = function(e) {
- e.setBlendConstant(this.color)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.color)
- }
- ,
- e
- }()
- , Vh = function() {
- function e(e) {
- this.query = e
- }
- return e.prototype.run = function(e) {
- e.beginOcclusionQuery(this.query)
- }
- ,
- e.prototype.clone = function() {
- return new e(this.query)
- }
- ,
- e
- }()
- , kh = function() {
- function e() {}
- return e.prototype.run = function(e) {
- e.endOcclusionQuery()
- }
- ,
- e.prototype.clone = function() {
- return new e
- }
- ,
- e
- }()
- , Gh = function() {
- function e() {
- this.bundles = []
- }
- return e.prototype.run = function(e) {
- e.executeBundles(this.bundles)
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return t.bundles = this.bundles,
- t
- }
- ,
- e
- }()
- , zh = function() {
- function e(e) {
- this.numDrawCalls = 0,
- this._device = e,
- this._list = new Array(10),
- this._listLength = 0
- }
- return e.prototype.addBundle = function(e) {
- if (!this._currentItemIsBundle) {
- var t = new Gh;
- this._list[this._listLength++] = t,
- this._currentBundleList = t.bundles,
- this._currentItemIsBundle = !0
- }
- e && this._currentBundleList.push(e)
- }
- ,
- e.prototype._finishBundle = function() {
- this._currentItemIsBundle && this._bundleEncoder && (this._currentBundleList.push(this._bundleEncoder.finish()),
- this._bundleEncoder = void 0,
- this._currentItemIsBundle = !1)
- }
- ,
- e.prototype.addItem = function(e) {
- this._finishBundle(),
- this._list[this._listLength++] = e,
- this._currentItemIsBundle = !1
- }
- ,
- e.prototype.getBundleEncoder = function(e, t, i) {
- return this._currentItemIsBundle || (this.addBundle(),
- this._bundleEncoder = this._device.createRenderBundleEncoder({
- colorFormats: e,
- depthStencilFormat: t,
- sampleCount: i
- })),
- this._bundleEncoder
- }
- ,
- e.prototype.close = function() {
- this._finishBundle()
- }
- ,
- e.prototype.run = function(e) {
- this.close();
- for (var t = 0; t < this._listLength; ++t)
- this._list[t].run(e)
- }
- ,
- e.prototype.reset = function() {
- this._listLength = 0,
- this._currentItemIsBundle = !1,
- this.numDrawCalls = 0
- }
- ,
- e.prototype.clone = function() {
- this.close();
- var t = new e(this._device);
- t._list = new Array(this._listLength),
- t._listLength = this._listLength,
- t.numDrawCalls = this.numDrawCalls;
- for (var i = 0; i < this._listLength; ++i)
- t._list[i] = this._list[i].clone();
- return t
- }
- ,
- e
- }()
- , Wh = function() {
- function e(e, t, i, n, r) {
- void 0 === r && (r = !0),
- this._dstBuffers = [],
- this._device = i,
- this._bufferManager = n,
- this._count = e,
- this._canUseMultipleBuffers = r,
- this._querySet = i.createQuerySet({
- type: t,
- count: e
- }),
- this._queryBuffer = n.createRawBuffer(8 * e, fu.QueryResolve | fu.CopySrc),
- r || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, fu.MapRead | fu.CopyDst))
- }
- return Object.defineProperty(e.prototype, "querySet", {
- get: function() {
- return this._querySet
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getBuffer = function(e, t) {
- if (!this._canUseMultipleBuffers && 0 === this._dstBuffers.length)
- return null;
- var i, n = this._device.createCommandEncoder();
- return 0 === this._dstBuffers.length ? i = this._bufferManager.createRawBuffer(8 * this._count, fu.MapRead | fu.CopyDst) : (i = this._dstBuffers[this._dstBuffers.length - 1],
- this._dstBuffers.length--),
- n.resolveQuerySet(this._querySet, e, t, this._queryBuffer, 0),
- n.copyBufferToBuffer(this._queryBuffer, 0, i, 0, 8 * t),
- this._device.queue.submit([n.finish()]),
- i
- }
- ,
- e.prototype.readValues = function(e, t) {
- return void 0 === e && (e = 0),
- void 0 === t && (t = 1),
- G(this, void 0, void 0, (function() {
- var i, n;
- return z(this, (function(r) {
- switch (r.label) {
- case 0:
- return null === (i = this._getBuffer(e, t)) ? [2, null] : [4, i.mapAsync(_u.Read)];
- case 1:
- return r.sent(),
- n = new BigUint64Array(i.getMappedRange()).slice(),
- i.unmap(),
- this._dstBuffers[this._dstBuffers.length] = i,
- [2, n]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype.readValue = function(e) {
- return void 0 === e && (e = 0),
- G(this, void 0, void 0, (function() {
- var t, i, n;
- return z(this, (function(r) {
- switch (r.label) {
- case 0:
- return null === (t = this._getBuffer(e, 1)) ? [2, null] : [4, t.mapAsync(_u.Read)];
- case 1:
- return r.sent(),
- i = new BigUint64Array(t.getMappedRange()),
- n = Number(i[0]),
- t.unmap(),
- this._dstBuffers[this._dstBuffers.length] = t,
- [2, n]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype.readTwoValuesAndSubtract = function(e) {
- return void 0 === e && (e = 0),
- G(this, void 0, void 0, (function() {
- var t, i, n;
- return z(this, (function(r) {
- switch (r.label) {
- case 0:
- return null === (t = this._getBuffer(e, 2)) ? [2, null] : [4, t.mapAsync(_u.Read)];
- case 1:
- return r.sent(),
- i = new BigUint64Array(t.getMappedRange()),
- n = Number(i[1] - i[0]),
- t.unmap(),
- this._dstBuffers[this._dstBuffers.length] = t,
- [2, n]
- }
- }
- ))
- }
- ))
- }
- ,
- e.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])
- }
- ,
- e
- }()
- , Hh = function() {
- function e(e, t) {
- this._enabled = !1,
- this._gpuFrameTimeCounter = new un,
- this._measureDurationState = 0,
- this._device = e,
- this._bufferManager = t
- }
- return Object.defineProperty(e.prototype, "gpuFrameTimeCounter", {
- get: function() {
- return this._gpuFrameTimeCounter
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enable", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled !== e && (this._enabled = e,
- this._measureDurationState = 0,
- e ? this._measureDuration = new Xh(this._device,this._bufferManager) : this._measureDuration.dispose())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.startFrame = function(e) {
- this._enabled && 0 === this._measureDurationState && (this._measureDuration.start(e),
- this._measureDurationState = 1)
- }
- ,
- e.prototype.endFrame = function(e) {
- var t = this;
- 1 === this._measureDurationState && (this._measureDurationState = 2,
- this._measureDuration.stop(e).then((function(e) {
- null !== e && e >= 0 && (t._gpuFrameTimeCounter.fetchNewFrame(),
- t._gpuFrameTimeCounter.addCount(e, !0)),
- t._measureDurationState = 0
- }
- )))
- }
- ,
- e
- }()
- , Xh = function() {
- function e(e, t) {
- this._querySet = new Wh(2,Hu.Timestamp,e,t)
- }
- return e.prototype.start = function(e) {
- e.writeTimestamp(this._querySet.querySet, 0)
- }
- ,
- e.prototype.stop = function(e) {
- return G(this, void 0, void 0, (function() {
- return z(this, (function(t) {
- return e.writeTimestamp(this._querySet.querySet, 1),
- [2, this._querySet.readTwoValuesAndSubtract(0)]
- }
- ))
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- this._querySet.dispose()
- }
- ,
- e
- }()
- , jh = function() {
- function e(e, t, i, n, r) {
- void 0 === n && (n = 50),
- void 0 === r && (r = 100),
- this._availableIndices = [],
- this._engine = e,
- this._device = t,
- this._bufferManager = i,
- this._frameLastBuffer = -1,
- this._currentTotalIndices = 0,
- this._countIncrement = r,
- this._allocateNewIndices(n)
- }
- return Object.defineProperty(e.prototype, "querySet", {
- get: function() {
- return this._querySet.querySet
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasQueries", {
- get: function() {
- return this._currentTotalIndices !== this._availableIndices.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "canBeginQuery", {
- get: function() {
- switch (this._engine._getCurrentRenderPassIndex()) {
- case 0:
- return void 0 !== this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet;
- case 1:
- return void 0 !== this._engine._rttRenderPassWrapper.renderPassDescriptor.occlusionQuerySet
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.createQuery = function() {
- 0 === this._availableIndices.length && this._allocateNewIndices();
- var e = this._availableIndices[this._availableIndices.length - 1];
- return this._availableIndices.length--,
- e
- }
- ,
- e.prototype.deleteQuery = function(e) {
- this._availableIndices[this._availableIndices.length - 1] = e
- }
- ,
- e.prototype.isQueryResultAvailable = function(e) {
- return this._retrieveQueryBuffer(),
- !!this._lastBuffer && e < this._lastBuffer.length
- }
- ,
- e.prototype.getQueryResult = function(e) {
- var t, i;
- return Number(null !== (i = null === (t = this._lastBuffer) || void 0 === t ? void 0 : t[e]) && void 0 !== i ? i : -1)
- }
- ,
- e.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(t) {
- e._lastBuffer = t
- }
- )))
- }
- ,
- e.prototype._allocateNewIndices = function(e) {
- e = null != e ? e : this._countIncrement,
- this._delayQuerySetDispose();
- for (var t = 0; t < e; ++t)
- this._availableIndices.push(this._currentTotalIndices + t);
- this._currentTotalIndices += e,
- this._querySet = new Wh(this._currentTotalIndices,Hu.Occlusion,this._device,this._bufferManager,!1)
- }
- ,
- e.prototype._delayQuerySetDispose = function() {
- var e = this._querySet;
- e && setTimeout((function() {
- return e.dispose
- }
- ), 1e3)
- }
- ,
- e.prototype.dispose = function() {
- var e;
- null === (e = this._querySet) || void 0 === e || e.dispose(),
- this._availableIndices = []
- }
- ,
- e
- }()
- , Yh = function() {
- function e() {
- this._twgsl = null
- }
- return e.prototype.initTwgsl = function(t) {
- return G(this, void 0, void 0, (function() {
- var i;
- return z(this, (function(n) {
- switch (n.label) {
- case 0:
- return t = t || {},
- (t = V(V({}, e._TWgslDefaultOptions), t)).twgsl ? (this._twgsl = t.twgsl,
- [2, Promise.resolve()]) : t.jsPath && t.wasmPath ? nt() ? [4, gi.LoadScriptAsync(t.jsPath)] : [3, 2] : [3, 3];
- case 1:
- return n.sent(),
- [3, 3];
- case 2:
- importScripts(t.jsPath),
- n.label = 3;
- case 3:
- return self.twgsl ? (i = this,
- [4, self.twgsl(t.wasmPath)]) : [3, 5];
- case 4:
- return i._twgsl = n.sent(),
- [2, Promise.resolve()];
- case 5:
- return [2, Promise.reject("twgsl is not available.")]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype.convertSpirV2WGSL = function(e) {
- return this._twgsl.convertSpirV2WGSL(e)
- }
- ,
- e._TWgslDefaultOptions = {
- jsPath: "https://preview.babylonjs.com/twgsl/twgsl.js",
- wasmPath: "https://preview.babylonjs.com/twgsl/twgsl.wasm"
- },
- e
- }()
- , Kh = function() {
- function e(e, t, i, n) {
- this._record = !1,
- this._play = !1,
- this._mainPassBundleList = [],
- this._enabled = !1,
- this._engine = e,
- this._mode = t,
- this._bundleList = i,
- this._bundleListRenderTarget = n
- }
- return Object.defineProperty(e.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 = a.SNAPSHOTRENDERING_STANDARD)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "play", {
- get: function() {
- return this._play
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "record", {
- get: function() {
- return this._record
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mode", {
- get: function() {
- return this._mode
- },
- set: function(e) {
- this._record ? this._modeSaved = e : this._mode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.endMainRenderPass = function() {
- this._record && this._mainPassBundleList.push(this._bundleList.clone())
- }
- ,
- e.prototype.endRenderTargetPass = function(e, t) {
- var i, n, r, o;
- if (this._play)
- null === (n = null === (i = t._bundleLists) || void 0 === i ? void 0 : i[t._currentLayer]) || void 0 === n || n.run(e),
- this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(null === (o = null === (r = t._bundleLists) || void 0 === r ? void 0 : r[t._currentLayer]) || void 0 === o ? void 0 : o.numDrawCalls);
- else {
- if (!this._record)
- return !1;
- t._bundleLists || (t._bundleLists = []),
- t._bundleLists[t._currentLayer] = this._bundleListRenderTarget.clone(),
- t._bundleLists[t._currentLayer].run(e),
- this._bundleListRenderTarget.reset()
- }
- return !0
- }
- ,
- e.prototype.endFrame = function(e) {
- if (this._record && (this._mainPassBundleList.push(this._bundleList.clone()),
- this._record = !1,
- this._play = !0,
- this._mode = this._modeSaved),
- null !== e && this._play)
- for (var t = 0; t < this._mainPassBundleList.length; ++t)
- this._mainPassBundleList[t].run(e),
- this._mode === a.SNAPSHOTRENDERING_FAST && this._engine._reportDrawCall(this._mainPassBundleList[t].numDrawCalls)
- }
- ,
- e.prototype.reset = function() {
- this.enabled = !1,
- this.enabled = !0
- }
- ,
- e
- }()
- , Qh = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n, r, o, a, s = this;
- if ((s = e.call(this, null) || this)._uploadEncoderDescriptor = {
- label: "upload"
- },
- s._renderEncoderDescriptor = {
- label: "render"
- },
- s._renderTargetEncoderDescriptor = {
- label: "renderTarget"
- },
- s._clearDepthValue = 1,
- s._clearReverseDepthValue = 0,
- s._clearStencilValue = 0,
- s._defaultSampleCount = 4,
- s._glslang = null,
- s._tintWASM = null,
- s._compiledComputeEffects = {},
- s._counters = {
- numEnableEffects: 0,
- numEnableDrawWrapper: 0,
- numBundleCreationNonCompatMode: 0,
- numBundleReuseNonCompatMode: 0
- },
- s.countersLastFrame = {
- numEnableEffects: 0,
- numEnableDrawWrapper: 0,
- numBundleCreationNonCompatMode: 0,
- numBundleReuseNonCompatMode: 0
- },
- s.numMaxUncapturedErrors = 20,
- s._commandBuffers = [null, null, null],
- s._currentRenderPass = null,
- s._mainRenderPassWrapper = new gh,
- s._rttRenderPassWrapper = new gh,
- s._pendingDebugCommands = [],
- s._onAfterUnbindFrameBufferObservable = new h,
- s._currentOverrideVertexBuffers = null,
- s._currentIndexBuffer = null,
- s._colorWriteLocal = !0,
- s._forceEnableEffect = !1,
- s.dbgShowShaderCode = !1,
- s.dbgSanityChecks = !0,
- s.dbgVerboseLogsForFirstFrames = !1,
- s.dbgVerboseLogsNumFrames = 10,
- s.dbgLogIfNotDrawWrapper = !0,
- s.dbgShowEmptyEnableEffectCalls = !0,
- s._viewportsCurrent = [{
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }, {
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }],
- s._scissorsCurrent = [{
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }, {
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }],
- s._scissorCached = {
- x: 0,
- y: 0,
- z: 0,
- w: 0
- },
- s._stencilRefsCurrent = [-1, -1],
- s._blendColorsCurrent = [[null, null, null, null], [null, null, null, null]],
- s._name = "WebGPU",
- s.isNDCHalfZRange = !0,
- s.hasOriginBottomLeft = !1,
- i.deviceDescriptor = i.deviceDescriptor || {},
- i.swapChainFormat = i.swapChainFormat || bu.BGRA8Unorm,
- i.antialiasing = void 0 === i.antialiasing || i.antialiasing,
- i.stencil = null === (n = i.stencil) || void 0 === n || n,
- i.enableGPUDebugMarkers = null !== (r = i.enableGPUDebugMarkers) && void 0 !== r && r,
- K.Log("Babylon.js v".concat(vr.Version, " - ").concat(s.description, " engine")),
- !navigator.gpu)
- return K.Error("WebGPU is not supported by your browser."),
- s;
- s._isWebGPU = !0,
- s._shaderPlatformName = "WEBGPU",
- void 0 === i.deterministicLockstep && (i.deterministicLockstep = !1),
- void 0 === i.lockstepMaxSteps && (i.lockstepMaxSteps = 4),
- void 0 === i.audioEngine && (i.audioEngine = !0),
- s._deterministicLockstep = i.deterministicLockstep,
- s._lockstepMaxSteps = i.lockstepMaxSteps,
- s._timeStep = i.timeStep || 1 / 60,
- s._doNotHandleContextLost = !!i.doNotHandleContextLost,
- s._canvas = t,
- s._options = i,
- s.premultipliedAlpha = null === (o = i.premultipliedAlpha) || void 0 === o || o;
- var l = nt() && window.devicePixelRatio || 1
- , c = i.limitDeviceRatio || l
- , u = null !== (a = i.adaptToDeviceRatio) && void 0 !== a && a;
- return s._hardwareScalingLevel = u ? 1 / Math.min(c, l) : 1,
- s._mainPassSampleCount = i.antialiasing ? s._defaultSampleCount : 1,
- s._isStencilEnable = i.stencil,
- s._sharedInit(t, !!i.doNotHandleTouchAction, i.audioEngine),
- s._shaderProcessor = new $u,
- s._shaderProcessorWGSL = new ch,
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "snapshotRenderingMode", {
- get: function() {
- return this._snapshotRendering.mode
- },
- set: function(e) {
- this._snapshotRendering.mode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.snapshotRenderingReset = function() {
- this._snapshotRendering.reset()
- }
- ,
- Object.defineProperty(t.prototype, "snapshotRendering", {
- get: function() {
- return this._snapshotRendering.enabled
- },
- set: function(e) {
- this._snapshotRendering.enabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "disableCacheSamplers", {
- get: function() {
- return !!this._cacheSampler && this._cacheSampler.disabled
- },
- set: function(e) {
- this._cacheSampler && (this._cacheSampler.disabled = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "disableCacheRenderPipelines", {
- get: function() {
- return !!this._cacheRenderPipeline && this._cacheRenderPipeline.disabled
- },
- set: function(e) {
- this._cacheRenderPipeline && (this._cacheRenderPipeline.disabled = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "disableCacheBindGroups", {
- get: function() {
- return !!this._cacheBindGroups && this._cacheBindGroups.disabled
- },
- set: function(e) {
- this._cacheBindGroups && (this._cacheBindGroups.disabled = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "IsSupportedAsync", {
- get: function() {
- return navigator.gpu ? navigator.gpu.requestAdapter().then((function(e) {
- return !!e
- }
- ), (function() {
- return !1
- }
- )).catch((function() {
- return !1
- }
- )) : Promise.resolve(!1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "IsSupported", {
- get: function() {
- return K.Warn("You must call IsSupportedAsync for WebGPU!"),
- !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "supportsUniformBuffers", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "supportedExtensions", {
- get: function() {
- return this._adapterSupportedExtensions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "enabledExtensions", {
- get: function() {
- return this._deviceEnabledExtensions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "description", {
- get: function() {
- return this.name + this.version
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "version", {
- get: function() {
- return 1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getInfo = function() {
- return {
- vendor: "unknown vendor",
- renderer: "unknown renderer",
- version: "unknown version"
- }
- }
- ,
- Object.defineProperty(t.prototype, "compatibilityMode", {
- get: function() {
- return this._compatibilityMode
- },
- set: function(e) {
- this._compatibilityMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "currentSampleCount", {
- get: function() {
- return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount
- },
- enumerable: !1,
- configurable: !0
- }),
- t.CreateAsync = function(e, i) {
- void 0 === i && (i = {});
- var n = new t(e,i);
- return new Promise((function(e) {
- n.initAsync(i.glslangOptions, i.twgslOptions).then((function() {
- return e(n)
- }
- ))
- }
- ))
- }
- ,
- t.prototype.initAsync = function(e, i) {
- var n, r = this;
- return this._initGlslang(null != e ? e : null === (n = this._options) || void 0 === n ? void 0 : n.glslangOptions).then((function(e) {
- var n;
- return r._glslang = e,
- r._tintWASM = t.UseTWGSL ? new Yh : null,
- r._tintWASM ? r._tintWASM.initTwgsl(null != i ? i : null === (n = r._options) || void 0 === n ? void 0 : n.twgslOptions).then((function() {
- return navigator.gpu.requestAdapter(r._options)
- }
- ), (function(e) {
- throw K.Error("Can not initialize twgsl!"),
- K.Error(e),
- Error("WebGPU initializations stopped.")
- }
- )) : navigator.gpu.requestAdapter(r._options)
- }
- ), (function(e) {
- throw K.Error("Can not initialize glslang!"),
- K.Error(e),
- Error("WebGPU initializations stopped.")
- }
- )).then((function(e) {
- var t;
- if (e) {
- r._adapter = e,
- r._adapterSupportedExtensions = [],
- null === (t = r._adapter.features) || void 0 === t || t.forEach((function(e) {
- return r._adapterSupportedExtensions.push(e)
- }
- ));
- var i = r._options.deviceDescriptor;
- if (null == i ? void 0 : i.requiredFeatures) {
- for (var n = [], o = 0, a = i.requiredFeatures; o < a.length; o++) {
- var s = a[o];
- -1 !== r._adapterSupportedExtensions.indexOf(s) && n.push(s)
- }
- i.requiredFeatures = n
- }
- return r._adapter.requestDevice(r._options.deviceDescriptor)
- }
- throw "Could not retrieve a WebGPU adapter (adapter is null)."
- }
- )).then((function(e) {
- var t, i;
- r._device = e,
- r._deviceEnabledExtensions = [],
- null === (t = r._device.features) || void 0 === t || t.forEach((function(e) {
- return r._deviceEnabledExtensions.push(e)
- }
- ));
- var n = -1;
- r._device.addEventListener("uncapturederror", (function(e) {
- ++n < r.numMaxUncapturedErrors ? K.Warn("WebGPU uncaptured error (".concat(n + 1, "): ").concat(e.error, " - ").concat(e.error.message)) : n++ === r.numMaxUncapturedErrors && K.Warn("WebGPU uncaptured error: too many warnings (".concat(r.numMaxUncapturedErrors, "), no more warnings will be reported to the console for this engine."))
- }
- )),
- r._doNotHandleContextLost || null === (i = r._device.lost) || void 0 === i || i.then((function(e) {
- r._contextWasLost = !0,
- K.Warn("WebGPU context lost. " + e),
- r.onContextLostObservable.notifyObservers(r),
- r._restoreEngineAfterContextLost(r.initAsync.bind(r))
- }
- ))
- }
- ), (function(e) {
- K.Error("Could not retrieve a WebGPU device."),
- K.Error(e)
- }
- )).then((function() {
- r._bufferManager = new mh(r._device),
- r._textureHelper = new fh(r._device,r._glslang,r._tintWASM,r._bufferManager),
- r._cacheSampler = new Th(r._device),
- r._cacheBindGroups = new Nh(r._device,r._cacheSampler,r),
- r._timestampQuery = new Hh(r._device,r._bufferManager),
- r._occlusionQuery = r._device.createQuerySet ? new jh(r,r._device,r._bufferManager) : void 0,
- r._bundleList = new zh(r._device),
- r._bundleListRenderTarget = new zh(r._device),
- r._snapshotRendering = new Kh(r,r._snapshotRenderingMode,r._bundleList,r._bundleListRenderTarget),
- r._ubInvertY = r._bufferManager.createBuffer(new Float32Array([-1, 0]), fu.Uniform | fu.CopyDst),
- r._ubDontInvertY = r._bufferManager.createBuffer(new Float32Array([1, 0]), fu.Uniform | fu.CopyDst),
- r.dbgVerboseLogsForFirstFrames && void 0 === r._count && (r._count = 0,
- console.log("%c frame #" + r._count + " - begin", "background: #ffff00")),
- r._uploadEncoder = r._device.createCommandEncoder(r._uploadEncoderDescriptor),
- r._renderEncoder = r._device.createCommandEncoder(r._renderEncoderDescriptor),
- r._renderTargetEncoder = r._device.createCommandEncoder(r._renderTargetEncoderDescriptor),
- r._emptyVertexBuffer = new Bi(r,[0],"",!1,!1,1,!1,0,1),
- r._initializeLimits(),
- r._cacheRenderPipeline = new Rh(r._device,r._emptyVertexBuffer,!r._caps.textureFloatLinearFiltering),
- r._depthCullingState = new Ph(r._cacheRenderPipeline),
- r._stencilStateComposer = new Ch(r._cacheRenderPipeline),
- r._stencilStateComposer.stencilGlobal = r._stencilState,
- r._depthCullingState.depthTest = !0,
- r._depthCullingState.depthFunc = a.LEQUAL,
- r._depthCullingState.depthMask = !0,
- r._textureHelper.setCommandEncoder(r._uploadEncoder),
- r._clearQuad = new Lh(r._device,r,r._emptyVertexBuffer),
- r._defaultDrawContext = r.createDrawContext(),
- r._currentDrawContext = r._defaultDrawContext,
- r._defaultMaterialContext = r.createMaterialContext(),
- r._currentMaterialContext = r._defaultMaterialContext,
- r._initializeContextAndSwapChain(),
- r._initializeMainAttachments(),
- r.resize()
- }
- )).catch((function(e) {
- K.Error("Can not create WebGPU Device and/or context."),
- K.Error(e),
- console.trace && console.trace()
- }
- ))
- }
- ,
- t.prototype._initGlslang = function(e) {
- return e = e || {},
- (e = V(V({}, t._GLSLslangDefaultOptions), e)).glslang ? Promise.resolve(e.glslang) : self.glslang ? self.glslang(e.wasmPath) : e.jsPath && e.wasmPath ? nt() ? gi.LoadScriptAsync(e.jsPath).then((function() {
- return self.glslang(e.wasmPath)
- }
- )) : (importScripts(e.jsPath),
- self.glslang(e.wasmPath)) : Promise.reject("gslang is not available.")
- }
- ,
- t.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: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionASTC) >= 0 || void 0,
- s3tc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionBC) >= 0 || void 0,
- pvrtc: null,
- etc1: null,
- etc2: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionETC2) >= 0 || void 0,
- bptc: this._deviceEnabledExtensions.indexOf(pu.TextureCompressionBC) >= 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: "undefined" != typeof BigUint64Array && -1 !== this.enabledExtensions.indexOf(pu.TimestampQuery) || void 0,
- supportOcclusionQuery: "undefined" != typeof BigUint64Array,
- canUseTimestampForTimerQuery: !0,
- multiview: !1,
- oculusMultiview: !1,
- parallelShaderCompile: void 0,
- blendMinMax: !0,
- maxMSAASamples: 4,
- canUseGLInstanceID: !0,
- canUseGLVertexID: !0,
- supportComputeShaders: !0,
- supportSRGBBuffers: !0,
- supportTransformFeedbacks: !1,
- textureMaxLevel: !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
- }
- }
- ,
- t.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 uh],
- this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat
- }
- ,
- t.prototype._initializeMainAttachments = function() {
- var e;
- this._mainTextureExtends = {
- width: this.getRenderWidth(),
- height: this.getRenderHeight(),
- depthOrArrayLayers: 1
- };
- var t, i = new Float32Array([this.getRenderHeight()]);
- if (this._bufferManager.setSubData(this._ubInvertY, 4, i),
- this._bufferManager.setSubData(this._ubDontInvertY, 4, i),
- this._options.antialiasing) {
- var n = {
- size: this._mainTextureExtends,
- mipLevelCount: 1,
- sampleCount: this._mainPassSampleCount,
- dimension: mu.E2d,
- format: this._options.swapChainFormat,
- usage: gu.RenderAttachment
- };
- null === (e = this._mainTexture) || void 0 === e || e.destroy(),
- this._mainTexture = this._device.createTexture(n),
- t = [{
- view: this._mainTexture.createView(),
- clearValue: new N(0,0,0,1),
- loadOp: zu.Clear,
- storeOp: Wu.Store
- }]
- } else
- t = [{
- view: void 0,
- clearValue: new N(0,0,0,1),
- loadOp: zu.Clear,
- storeOp: Wu.Store
- }];
- this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? bu.Depth24PlusStencil8 : bu.Depth32Float,
- this._setDepthTextureFormat(this._mainRenderPassWrapper);
- var r = {
- size: this._mainTextureExtends,
- mipLevelCount: 1,
- sampleCount: this._mainPassSampleCount,
- dimension: mu.E2d,
- format: this._mainRenderPassWrapper.depthTextureFormat,
- usage: gu.RenderAttachment
- };
- this._depthTexture && this._depthTexture.destroy(),
- this._depthTexture = this._device.createTexture(r);
- var o = {
- view: this._depthTexture.createView(),
- depthClearValue: this._clearDepthValue,
- depthLoadOp: zu.Clear,
- depthStoreOp: Wu.Store,
- stencilClearValue: this._clearStencilValue,
- stencilLoadOp: zu.Clear,
- stencilStoreOp: Wu.Store
- };
- this._mainRenderPassWrapper.renderPassDescriptor = {
- colorAttachments: t,
- depthStencilAttachment: o
- },
- null !== this._mainRenderPassWrapper.renderPass && this._endMainRenderPass()
- }
- ,
- t.prototype._configureContext = function(e, t) {
- this._context.configure({
- device: this._device,
- format: this._options.swapChainFormat,
- usage: gu.RenderAttachment | gu.CopySrc,
- compositingAlphaMode: this.premultipliedAlpha ? Xu.Premultiplied : Xu.Opaque,
- size: {
- width: e,
- height: t,
- depthOrArrayLayers: 1
- }
- })
- }
- ,
- t.prototype.setSize = function(t, i, n) {
- return void 0 === n && (n = !1),
- !!e.prototype.setSize.call(this, t, i, n) && (this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - setSize called -", t, i)),
- this._configureContext(t, i),
- this._initializeMainAttachments(),
- this.snapshotRendering && this.snapshotRenderingReset(),
- !0)
- }
- ,
- t.prototype._getShaderProcessor = function(e) {
- return e === st.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor
- }
- ,
- t.prototype._getShaderProcessingContext = function(e) {
- return new Ju(e)
- }
- ,
- t.prototype.applyStates = function() {
- this._stencilStateComposer.apply(),
- this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend)
- }
- ,
- t.prototype.wipeCaches = function(e) {
- this.preventCacheWipeBetweenFrames && !e || (this._forceEnableEffect = !0,
- this._currentIndexBuffer = null,
- this._currentOverrideVertexBuffers = null,
- this._cacheRenderPipeline.setBuffers(null, null, null),
- e && (this._stencilStateComposer.reset(),
- this._depthCullingState.reset(),
- this._depthCullingState.depthFunc = a.LEQUAL,
- this._alphaState.reset(),
- this._alphaMode = a.ALPHA_ADD,
- this._alphaEquation = a.ALPHA_DISABLE,
- 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)
- }
- ,
- t.prototype.setColorWrite = function(e) {
- this._colorWriteLocal = e,
- this._cacheRenderPipeline.setWriteMask(e ? 15 : 0)
- }
- ,
- t.prototype.getColorWrite = function() {
- return this._colorWriteLocal
- }
- ,
- t.prototype._resetCurrentViewport = function(e) {
- this._viewportsCurrent[e].x = 0,
- this._viewportsCurrent[e].y = 0,
- this._viewportsCurrent[e].w = 0,
- this._viewportsCurrent[e].h = 0,
- 1 === e && (this._viewportCached.x = 0,
- this._viewportCached.y = 0,
- this._viewportCached.z = 0,
- this._viewportCached.w = 0)
- }
- ,
- t.prototype._mustUpdateViewport = function(e) {
- var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , i = this._viewportCached.x
- , n = this._viewportCached.y
- , r = this._viewportCached.z
- , o = this._viewportCached.w
- , a = this._viewportsCurrent[t].x !== i || this._viewportsCurrent[t].y !== n || this._viewportsCurrent[t].w !== r || this._viewportsCurrent[t].h !== o;
- return a && (this._viewportsCurrent[t].x = this._viewportCached.x,
- this._viewportsCurrent[t].y = this._viewportCached.y,
- this._viewportsCurrent[t].w = this._viewportCached.z,
- this._viewportsCurrent[t].h = this._viewportCached.w),
- a
- }
- ,
- t.prototype._applyViewport = function(e) {
- var t = Math.floor(this._viewportCached.y)
- , i = Math.floor(this._viewportCached.w);
- this._currentRenderTarget || (t = this.getRenderHeight() - t - i),
- e.setViewport(Math.floor(this._viewportCached.x), t, Math.floor(this._viewportCached.z), i, 0, 1),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (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=" + (e === this._mainRenderPassWrapper.renderPass)))
- }
- ,
- t.prototype._viewport = function(e, t, i, n) {
- this._viewportCached.x = e,
- this._viewportCached.y = t,
- this._viewportCached.z = i,
- this._viewportCached.w = n
- }
- ,
- t.prototype._resetCurrentScissor = function(e) {
- this._scissorsCurrent[e].x = 0,
- this._scissorsCurrent[e].y = 0,
- this._scissorsCurrent[e].w = 0,
- this._scissorsCurrent[e].h = 0
- }
- ,
- t.prototype._mustUpdateScissor = function(e) {
- var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , i = this._scissorCached.x
- , n = this._scissorCached.y
- , r = this._scissorCached.z
- , o = this._scissorCached.w
- , a = this._scissorsCurrent[t].x !== i || this._scissorsCurrent[t].y !== n || this._scissorsCurrent[t].w !== r || this._scissorsCurrent[t].h !== o;
- return a && (this._scissorsCurrent[t].x = this._scissorCached.x,
- this._scissorsCurrent[t].y = this._scissorCached.y,
- this._scissorsCurrent[t].w = this._scissorCached.z,
- this._scissorsCurrent[t].h = this._scissorCached.w),
- a
- }
- ,
- t.prototype._applyScissor = function(e) {
- e.setScissorRect(this._scissorCached.x, this._currentRenderTarget ? this._scissorCached.y : this.getRenderHeight() - this._scissorCached.w - this._scissorCached.y, this._scissorCached.z, this._scissorCached.w),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (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=" + (e === this._mainRenderPassWrapper.renderPass)))
- }
- ,
- t.prototype._scissorIsActive = function() {
- return 0 !== this._scissorCached.x || 0 !== this._scissorCached.y || 0 !== this._scissorCached.z || 0 !== this._scissorCached.w
- }
- ,
- t.prototype.enableScissor = function(e, t, i, n) {
- this._scissorCached.x = e,
- this._scissorCached.y = t,
- this._scissorCached.z = i,
- this._scissorCached.w = n
- }
- ,
- t.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)
- }
- ,
- t.prototype._resetCurrentStencilRef = function(e) {
- this._stencilRefsCurrent[e] = -1
- }
- ,
- t.prototype._mustUpdateStencilRef = function(e) {
- var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , i = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent[t];
- return i && (this._stencilRefsCurrent[t] = this._stencilStateComposer.funcRef),
- i
- }
- ,
- t.prototype._applyStencilRef = function(e) {
- var t;
- e.setStencilReference(null !== (t = this._stencilStateComposer.funcRef) && void 0 !== t ? t : 0)
- }
- ,
- t.prototype._resetCurrentColorBlend = function(e) {
- this._blendColorsCurrent[e][0] = this._blendColorsCurrent[e][1] = this._blendColorsCurrent[e][2] = this._blendColorsCurrent[e][3] = null
- }
- ,
- t.prototype._mustUpdateBlendColor = function(e) {
- var t = e === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , i = this._alphaState._blendConstants
- , n = i[0] !== this._blendColorsCurrent[t][0] || i[1] !== this._blendColorsCurrent[t][1] || i[2] !== this._blendColorsCurrent[t][2] || i[3] !== this._blendColorsCurrent[t][3];
- return n && (this._blendColorsCurrent[t][0] = i[0],
- this._blendColorsCurrent[t][1] = i[1],
- this._blendColorsCurrent[t][2] = i[2],
- this._blendColorsCurrent[t][3] = i[3]),
- n
- }
- ,
- t.prototype._applyBlendColor = function(e) {
- e.setBlendConstant(this._alphaState._blendConstants)
- }
- ,
- t.prototype.clear = function(e, t, i, n) {
- void 0 === n && (n = !1),
- e && void 0 === e.a && (e.a = 1);
- var r = this._scissorIsActive();
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - clear called - backBuffer=", t, " depth=", i, " stencil=", n, " scissor is active=", r)),
- this._currentRenderTarget ? r ? (this._rttRenderPassWrapper.renderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, t ? e : null, i, n),
- this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleListRenderTarget.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
- this._clearFullQuad(t ? e : null, i, n)) : (this._currentRenderPass && this._endRenderTargetRenderPass(),
- this._startRenderTargetRenderPass(this._currentRenderTarget, !0, t ? e : null, i, n)) : (this._mainRenderPassWrapper.renderPass && r || this._startMainRenderPass(!r, t ? e : null, i, n),
- r && (this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleList.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
- this._clearFullQuad(t ? e : null, i, n)))
- }
- ,
- t.prototype._clearFullQuad = function(e, t, i) {
- var n, r, o, a = this.compatibilityMode ? this._getCurrentRenderPass() : null, s = 0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget;
- this._clearQuad.setColorFormat(this._colorFormat),
- this._clearQuad.setDepthStencilFormat(this._depthTextureFormat),
- this._clearQuad.setMRTAttachments(null !== (n = this._cacheRenderPipeline.mrtAttachments) && void 0 !== n ? n : [], null !== (r = this._cacheRenderPipeline.mrtTextureArray) && void 0 !== r ? r : [], this._cacheRenderPipeline.mrtTextureCount),
- this.compatibilityMode ? a.setStencilReference(this._clearStencilValue) : s.addItem(new Bh(this._clearStencilValue));
- var l = this._clearQuad.clear(a, e, t, i, this.currentSampleCount);
- this.compatibilityMode ? this._applyStencilRef(a) : (s.addBundle(l),
- s.addItem(new Bh(null !== (o = this._stencilStateComposer.funcRef) && void 0 !== o ? o : 0)),
- this._reportDrawCall())
- }
- ,
- t.prototype.createVertexBuffer = function(e) {
- var t;
- return t = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e,
- this._bufferManager.createBuffer(t, fu.Vertex | fu.CopyDst)
- }
- ,
- t.prototype.createDynamicVertexBuffer = function(e) {
- return this.createVertexBuffer(e)
- }
- ,
- t.prototype.createIndexBuffer = function(e) {
- var t, i = !0;
- e instanceof Uint32Array || e instanceof Int32Array ? t = e : e instanceof Uint16Array ? (t = e,
- i = !1) : e.length > 65535 ? t = new Uint32Array(e) : (t = new Uint16Array(e),
- i = !1);
- var n = this._bufferManager.createBuffer(t, fu.Index | fu.CopyDst);
- return n.is32Bits = i,
- n
- }
- ,
- t.prototype._createBuffer = function(e, t) {
- var i;
- i = e instanceof Array ? new Float32Array(e) : e instanceof ArrayBuffer ? new Uint8Array(e) : e;
- var n = 0;
- return t & a.BUFFER_CREATIONFLAG_READ && (n |= fu.CopySrc),
- t & a.BUFFER_CREATIONFLAG_WRITE && (n |= fu.CopyDst),
- t & a.BUFFER_CREATIONFLAG_UNIFORM && (n |= fu.Uniform),
- t & a.BUFFER_CREATIONFLAG_VERTEX && (n |= fu.Vertex),
- t & a.BUFFER_CREATIONFLAG_INDEX && (n |= fu.Index),
- t & a.BUFFER_CREATIONFLAG_STORAGE && (n |= fu.Storage),
- this._bufferManager.createBuffer(i, n)
- }
- ,
- t.prototype.bindBuffersDirectly = function() {
- throw "Not implemented on WebGPU"
- }
- ,
- t.prototype.updateAndBindInstancesBuffer = function() {
- throw "Not implemented on WebGPU"
- }
- ,
- t.prototype.bindBuffers = function(e, t, i, n) {
- this._currentIndexBuffer = t,
- this._currentOverrideVertexBuffers = null != n ? n : null,
- this._cacheRenderPipeline.setBuffers(e, t, this._currentOverrideVertexBuffers)
- }
- ,
- t.prototype._releaseBuffer = function(e) {
- return this._bufferManager.releaseBuffer(e)
- }
- ,
- t.prototype.createEffect = function(e, t, i, n, r, o, a, s, l, c) {
- var u;
- void 0 === c && (c = st.GLSL);
- var h = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
- , d = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
- , p = this._getGlobalDefines()
- , f = null !== (u = null != r ? r : t.defines) && void 0 !== u ? u : "";
- p && (f += "\n" + p);
- var _ = h + "+" + d + "@" + f;
- if (this._compiledEffects[_]) {
- var m = this._compiledEffects[_];
- return a && m.isReady() && a(m),
- m
- }
- var g = new Mt(e,t,i,n,this,r,o,a,s,l,_,c);
- return this._compiledEffects[_] = g,
- g
- }
- ,
- t.prototype._compileRawShaderToSpirV = function(e, t) {
- return this._glslang.compileGLSL(e, t)
- }
- ,
- t.prototype._compileShaderToSpirV = function(e, t, i, n) {
- return this._compileRawShaderToSpirV(n + (i ? i + "\n" : "") + e, t)
- }
- ,
- t.prototype._getWGSLShader = function(e, t, i) {
- return (i = i ? "//" + i.split("\n").join("\n//") + "\n" : "") + e
- }
- ,
- t.prototype._createPipelineStageDescriptor = function(e, t, i) {
- return this._tintWASM && i === st.GLSL && (e = this._tintWASM.convertSpirV2WGSL(e),
- t = this._tintWASM.convertSpirV2WGSL(t)),
- {
- vertexStage: {
- module: this._device.createShaderModule({
- code: e
- }),
- entryPoint: "main"
- },
- fragmentStage: {
- module: this._device.createShaderModule({
- code: t
- }),
- entryPoint: "main"
- }
- }
- }
- ,
- t.prototype._compileRawPipelineStageDescriptor = function(e, t, i) {
- var n = i === st.GLSL ? this._compileRawShaderToSpirV(e, "vertex") : e
- , r = i === st.GLSL ? this._compileRawShaderToSpirV(t, "fragment") : t;
- return this._createPipelineStageDescriptor(n, r, i)
- }
- ,
- t.prototype._compilePipelineStageDescriptor = function(e, t, i, n) {
- this.onBeforeShaderCompilationObservable.notifyObservers(this);
- var r = "#version 450\n"
- , o = n === st.GLSL ? this._compileShaderToSpirV(e, "vertex", i, r) : this._getWGSLShader(e, "vertex", i)
- , a = n === st.GLSL ? this._compileShaderToSpirV(t, "fragment", i, r) : this._getWGSLShader(t, "fragment", i)
- , s = this._createPipelineStageDescriptor(o, a, n);
- return this.onAfterShaderCompilationObservable.notifyObservers(this),
- s
- }
- ,
- t.prototype.createRawShaderProgram = function() {
- throw "Not available on WebGPU"
- }
- ,
- t.prototype.createShaderProgram = function() {
- throw "Not available on WebGPU"
- }
- ,
- t.prototype.inlineShaderCode = function(e) {
- var t = new iu(e);
- return t.debug = !1,
- t.processCode(),
- t.code
- }
- ,
- t.prototype.createPipelineContext = function(e) {
- return new qu(e,this)
- }
- ,
- t.prototype.createMaterialContext = function() {
- return new Ih
- }
- ,
- t.prototype.createDrawContext = function() {
- return new Oh(this._bufferManager)
- }
- ,
- t.prototype._preparePipelineContext = function(e, t, i, n, r, o, a, s) {
- var l = e
- , c = l.shaderProcessingContext.shaderLanguage;
- this.dbgShowShaderCode && (console.log(s),
- console.log(t),
- console.log(i)),
- l.sources = {
- fragment: i,
- vertex: t,
- rawVertex: r,
- rawFragment: o
- },
- l.stages = n ? this._compileRawPipelineStageDescriptor(t, i, c) : this._compilePipelineStageDescriptor(t, i, s, c)
- }
- ,
- t.prototype.getAttributes = function(e, t) {
- for (var i = new Array(t.length), n = e, r = 0; r < t.length; r++) {
- var o = t[r]
- , a = n.shaderProcessingContext.availableAttributes[o];
- void 0 !== a && (i[r] = a)
- }
- return i
- }
- ,
- t.prototype.enableEffect = function(e) {
- if (e) {
- var t = !0;
- if (Gt.IsWrapper(e)) {
- if (!e.effect || e.effect === this._currentEffect && e.materialContext === this._currentMaterialContext && e.drawContext === this._currentDrawContext && !this._forceEnableEffect) {
- if (!e.effect && this.dbgShowEmptyEnableEffectCalls)
- throw console.error("drawWrapper=", e),
- "Invalid call to enableEffect: the effect property is empty!";
- return
- }
- if (t = e.effect !== this._currentEffect,
- this._currentEffect = e.effect,
- this._currentMaterialContext = e.materialContext,
- this._currentDrawContext = e.drawContext,
- this._counters.numEnableDrawWrapper++,
- !this._currentMaterialContext)
- throw console.error("drawWrapper=", e),
- "Invalid call to enableEffect: the materialContext property is empty!"
- } else
- t = e !== this._currentEffect,
- this._currentEffect = e,
- this._currentMaterialContext = this._defaultMaterialContext,
- this._currentDrawContext = this._defaultDrawContext,
- this._counters.numEnableEffects++,
- this.dbgLogIfNotDrawWrapper && K.Warn("enableEffect has been called with an Effect and not a Wrapper! effect.uniqueId=".concat(e.uniqueId, ", effect.name=").concat(e.name, ", effect.name.vertex=").concat(e.name.vertex, ", effect.name.fragment=").concat(e.name.fragment), 10);
- this._stencilStateComposer.stencilMaterial = void 0,
- this._forceEnableEffect = !t && !this._forceEnableEffect && this._forceEnableEffect,
- t && (this._currentEffect.onBind && this._currentEffect.onBind(this._currentEffect),
- this._currentEffect._onBindObservable && this._currentEffect._onBindObservable.notifyObservers(this._currentEffect))
- }
- }
- ,
- t.prototype._releaseEffect = function(e) {
- this._compiledEffects[e._key] && (delete this._compiledEffects[e._key],
- this._deletePipelineContext(e.getPipelineContext()))
- }
- ,
- t.prototype.releaseEffects = function() {
- for (var e in this._compiledEffects) {
- var t = this._compiledEffects[e].getPipelineContext();
- this._deletePipelineContext(t)
- }
- this._compiledEffects = {}
- }
- ,
- t.prototype._deletePipelineContext = function(e) {
- e && e.dispose()
- }
- ,
- Object.defineProperty(t.prototype, "needPOTTextures", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._createHardwareTexture = function() {
- return new uh
- }
- ,
- t.prototype._releaseTexture = function(e) {
- var t = this._internalTexturesCache.indexOf(e);
- -1 !== t && this._internalTexturesCache.splice(t, 1),
- this._textureHelper.releaseTexture(e)
- }
- ,
- t.prototype._getRGBABufferInternalSizedFormat = function() {
- return a.TEXTUREFORMAT_RGBA
- }
- ,
- t.prototype.updateTextureComparisonFunction = function(e, t) {
- e._comparisonFunction = t
- }
- ,
- t.prototype._createInternalTexture = function(e, t, i, n) {
- var r, o;
- void 0 === i && (i = !0),
- void 0 === n && (n = At.Unknown);
- var s = {};
- void 0 !== t && "object" == typeof t ? (s.generateMipMaps = t.generateMipMaps,
- s.type = void 0 === t.type ? a.TEXTURETYPE_UNSIGNED_INT : t.type,
- s.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
- s.format = void 0 === t.format ? a.TEXTUREFORMAT_RGBA : t.format,
- s.samples = null !== (r = t.samples) && void 0 !== r ? r : 1,
- s.creationFlags = null !== (o = t.creationFlags) && void 0 !== o ? o : 0) : (s.generateMipMaps = t,
- s.type = a.TEXTURETYPE_UNSIGNED_INT,
- s.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- s.format = a.TEXTUREFORMAT_RGBA,
- s.samples = 1,
- s.creationFlags = 0),
- (s.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (s.type !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (s.samplingMode = a.TEXTURE_NEAREST_SAMPLINGMODE),
- s.type !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (s.type = a.TEXTURETYPE_UNSIGNED_INT,
- K.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
- var l = new Lt(this,n)
- , c = e.width || e
- , u = e.height || e
- , h = e.layers || 0;
- return l.baseWidth = c,
- l.baseHeight = u,
- l.width = c,
- l.height = u,
- l.depth = h,
- l.isReady = !0,
- l.samples = s.samples,
- l.generateMipMaps = !!s.generateMipMaps,
- l.samplingMode = s.samplingMode,
- l.type = s.type,
- l.format = s.format,
- l.is2DArray = h > 0,
- l._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- l._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
- this._internalTexturesCache.push(l),
- i || this._textureHelper.createGPUTextureForInternalTexture(l, c, u, h || 1, s.creationFlags),
- l
- }
- ,
- t.prototype.createTexture = function(e, t, i, n, r, o, s, l, c, u, h, d, p, f, _) {
- var m = this;
- return void 0 === r && (r = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = null),
- this._createTextureBase(e, t, i, n, r, o, s, (function(e, t, i, n, r, o, a, s) {
- var l, c = n;
- if (e.baseWidth = c.width,
- e.baseHeight = c.height,
- e.width = c.width,
- e.height = c.height,
- e.format = null != u ? u : -1,
- s(e.width, e.height, c, t, e, (function() {}
- )),
- null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource)
- o || a || m._generateMipmaps(e, m._uploadEncoder);
- else {
- var h = m._textureHelper.createGPUTextureForInternalTexture(e, c.width, c.height, void 0, f);
- fh.IsImageBitmap(c) && (m._textureHelper.updateTexture(c, e, c.width, c.height, e.depth, h.format, 0, 0, r, !1, 0, 0),
- o || a || m._generateMipmaps(e, m._uploadEncoder))
- }
- i && i._removePendingData(e),
- e.isReady = !0,
- e.onLoadedObservable.notifyObservers(e),
- e.onLoadedObservable.clear()
- }
- ), (function() {
- return !1
- }
- ), l, c, u, h, d, p, _)
- }
- ,
- t.prototype.generateMipMapsForCubemap = function(e) {
- var t;
- e.generateMipMaps && ((null === (t = e._hardwareTexture) || void 0 === t ? void 0 : t.underlyingResource) || this._textureHelper.createGPUTextureForInternalTexture(e),
- this._generateMipmaps(e, e.source === At.RenderTarget || e.source === At.MultiRenderTarget ? this._renderTargetEncoder : void 0))
- }
- ,
- t.prototype.updateTextureSamplingMode = function(e, t, i) {
- void 0 === i && (i = !1),
- i && (t.generateMipMaps = !0,
- this._generateMipmaps(t)),
- t.samplingMode = e
- }
- ,
- t.prototype.updateTextureWrappingMode = function(e, t, i, n) {
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- null !== t && (e._cachedWrapU = t),
- null !== i && (e._cachedWrapV = i),
- (e.is2DArray || e.is3D) && null !== n && (e._cachedWrapR = n)
- }
- ,
- t.prototype.updateTextureDimensions = function(e, t, i, n) {
- if (void 0 === n && (n = 1),
- e._hardwareTexture && (e.width !== t || e.height !== i || e.depth !== n)) {
- var r = e._hardwareTexture.textureAdditionalUsages;
- e._hardwareTexture.release(),
- this._textureHelper.createGPUTextureForInternalTexture(e, t, i, n, r)
- }
- }
- ,
- t.prototype._setInternalTexture = function(e, t, i) {
- if (i = null != i ? i : e,
- this._currentEffect) {
- var n = this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[i];
- if (this._currentMaterialContext.setTexture(e, t),
- n && n.autoBindSampler) {
- var r = i + Qu.AutoSamplerSuffix;
- this._currentMaterialContext.setSampler(r, t)
- }
- }
- }
- ,
- t.prototype.setTexture = function(e, t, i, n) {
- this._setTexture(e, i, !1, !1, n, n)
- }
- ,
- t.prototype.setTextureArray = function(e, t, i, n) {
- for (var r = 0; r < i.length; r++)
- this._setTexture(-1, i[r], !0, !1, n + r.toString(), n)
- }
- ,
- t.prototype._setTexture = function(e, t, i, n, r, o) {
- if (void 0 === i && (i = !1),
- void 0 === n && (n = !1),
- void 0 === r && (r = ""),
- o = null != o ? o : r,
- this._currentEffect) {
- if (!t)
- return this._currentMaterialContext.setTexture(r, null),
- !1;
- if (t.video)
- t.update();
- else if (t.delayLoadState === a.DELAYLOADSTATE_NOTLOADED)
- return t.delayLoad(),
- !1;
- var s = null;
- if ((s = n ? t.depthStencilTexture : t.isReady() ? t.getInternalTexture() : t.isCube ? this.emptyCubeTexture : t.is3D ? this.emptyTexture3D : t.is2DArray ? this.emptyTexture2DArray : this.emptyTexture) && !s.isMultiview) {
- if (s.isCube && s._cachedCoordinatesMode !== t.coordinatesMode) {
- s._cachedCoordinatesMode = t.coordinatesMode;
- var l = t.coordinatesMode !== a.TEXTURE_CUBIC_MODE && t.coordinatesMode !== a.TEXTURE_SKYBOX_MODE ? a.TEXTURE_WRAP_ADDRESSMODE : a.TEXTURE_CLAMP_ADDRESSMODE;
- t.wrapU = l,
- t.wrapV = l
- }
- s._cachedWrapU = t.wrapU,
- s._cachedWrapV = t.wrapV,
- s.is3D && (s._cachedWrapR = t.wrapR),
- this._setAnisotropicLevel(0, s, t.anisotropicFilteringLevel)
- }
- this._setInternalTexture(r, s, o)
- } else
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - _setTexture called with a null _currentEffect! texture=", t));
- return !0
- }
- ,
- t.prototype._setAnisotropicLevel = function(e, t, i) {
- t._cachedAnisotropicFilteringLevel !== i && (t._cachedAnisotropicFilteringLevel = Math.min(i, this._caps.maxAnisotropy))
- }
- ,
- t.prototype._bindTexture = function(e, t, i) {
- void 0 !== e && this._setInternalTexture(i, t)
- }
- ,
- t.prototype.generateMipmaps = function(e) {
- this._generateMipmaps(e, this._renderTargetEncoder)
- }
- ,
- t.prototype._generateMipmaps = function(e, t) {
- var i = e._hardwareTexture;
- if (i) {
- t = null != t ? t : this._currentRenderTarget && !this._currentRenderPass ? this._renderTargetEncoder : this._currentRenderPass ? this._uploadEncoder : this._renderEncoder;
- var n = e._hardwareTexture.format
- , r = fh.ComputeNumMipmapLevels(e.width, e.height);
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - generate mipmaps called - width=", e.width, "height=", e.height, "isCube=", e.isCube)),
- e.isCube ? this._textureHelper.generateCubeMipmaps(i, n, r, t) : this._textureHelper.generateMipmaps(i, n, r, 0, t)
- }
- }
- ,
- t.prototype.updateTextureData = function(e, t, i, n, r, o, a, s) {
- var l;
- void 0 === a && (a = 0),
- void 0 === s && (s = 0);
- var c = e._hardwareTexture;
- (null === (l = e._hardwareTexture) || void 0 === l ? void 0 : l.underlyingResource) || (c = this._textureHelper.createGPUTextureForInternalTexture(e));
- var u = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
- this._textureHelper.updateTexture(u, e, r, o, e.depth, c.format, a, s, e.invertY, !1, i, n)
- }
- ,
- t.prototype._uploadCompressedDataToTextureDirectly = function(e, t, i, n, r, o, a) {
- var s;
- void 0 === o && (o = 0),
- void 0 === a && (a = 0);
- var l = e._hardwareTexture;
- (null === (s = e._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource) || (e.format = t,
- l = this._textureHelper.createGPUTextureForInternalTexture(e, i, n));
- var c = new Uint8Array(r.buffer,r.byteOffset,r.byteLength);
- this._textureHelper.updateTexture(c, e, i, n, e.depth, l.format, o, a, !1, !1, 0, 0)
- }
- ,
- t.prototype._uploadDataToTextureDirectly = function(e, t, i, n, r, o) {
- var a;
- void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- void 0 === o && (o = !1);
- var s = Math.round(Math.log(e.width) * Math.LOG2E)
- , l = Math.round(Math.log(e.height) * Math.LOG2E)
- , c = o ? e.width : Math.pow(2, Math.max(s - n, 0))
- , u = o ? e.height : Math.pow(2, Math.max(l - n, 0))
- , h = e._hardwareTexture;
- (null === (a = e._hardwareTexture) || void 0 === a ? void 0 : a.underlyingResource) || (h = this._textureHelper.createGPUTextureForInternalTexture(e, c, u));
- var d = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
- this._textureHelper.updateTexture(d, e, c, u, e.depth, h.format, i, n, e.invertY, !1, 0, 0)
- }
- ,
- t.prototype._uploadArrayBufferViewToTexture = function(e, t, i, n) {
- void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- this._uploadDataToTextureDirectly(e, t, i, n)
- }
- ,
- t.prototype._uploadImageToTexture = function(e, t, i, n) {
- var r;
- void 0 === i && (i = 0),
- void 0 === n && (n = 0);
- var o = e._hardwareTexture;
- (null === (r = e._hardwareTexture) || void 0 === r ? void 0 : r.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e));
- var a = t
- , s = Math.ceil(e.width / (1 << n))
- , l = Math.ceil(e.height / (1 << n));
- this._textureHelper.updateTexture(a, e, s, l, e.depth, o.format, i, n, e.invertY, !1, 0, 0)
- }
- ,
- t.prototype.readPixels = function(e, t, i, n, r, o) {
- void 0 === r && (r = !0),
- void 0 === o && (o = !0);
- var a = this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper
- , s = a.colorAttachmentGPUTextures[0].underlyingResource
- , l = a.colorAttachmentGPUTextures[0].format;
- return s ? (o && this.flushFramebuffer(),
- this._textureHelper.readPixels(s, e, t, i, n, l)) : Promise.resolve(new Uint8Array(0))
- }
- ,
- t.prototype.beginFrame = function() {
- e.prototype.beginFrame.call(this)
- }
- ,
- t.prototype.endFrame = function() {
- if (this._snapshotRendering.endFrame(this._mainRenderPassWrapper.renderPass),
- this._endMainRenderPass(),
- this._timestampQuery.endFrame(this._renderEncoder),
- this.flushFramebuffer(!1),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (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 && (void 0 === this._count && (this._count = 0),
- !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
- var t = [];
- for (var i in Fi._UpdatedUbosInFrame)
- t.push(i + ":" + Fi._UpdatedUbosInFrame[i]);
- console.log("frame #" + this._count + " - updated ubos -", t.join(", "))
- }
- Fi._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,
- e.prototype.endFrame.call(this),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (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")))
- }
- ,
- t.prototype.flushFramebuffer = function(e) {
- void 0 === e && (e = !0);
- var t = !this._currentRenderPass
- , i = 0;
- this._currentRenderPass && this._currentRenderTarget && (i |= 1,
- this._endRenderTargetRenderPass()),
- this._mainRenderPassWrapper.renderPass && (i |= 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(),
- e && (2 & i && this._startMainRenderPass(!1),
- 1 & i && this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1),
- t && this._currentRenderTarget && (this._currentRenderPass = null))
- }
- ,
- t.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
- return null === this._currentRenderTarget
- }
- ,
- t.prototype._startRenderTargetRenderPass = function(e, t, i, n, r) {
- var o, a, s, l = e, c = l._depthStencilTexture, u = null == c ? void 0 : c._hardwareTexture, h = null == u ? void 0 : u.underlyingResource, d = null == u ? void 0 : u.msaaTexture, p = null == h ? void 0 : h.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), f = null == d ? void 0 : d.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor), _ = [];
- this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
- var m = t && i
- , g = t && n
- , v = t && r;
- if (l._attachments && l.isMulti) {
- this._mrtAttachments && 0 !== this._mrtAttachments.length || (this._mrtAttachments = l._defaultAttachments);
- for (var y = 0; y < this._mrtAttachments.length; ++y) {
- var b = this._mrtAttachments[y]
- , T = l.textures[y]
- , E = null == T ? void 0 : T._hardwareTexture
- , S = null == E ? void 0 : E.underlyingResource;
- if (E && S) {
- var A = V(V({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), {
- format: E.format
- })
- , x = E.msaaTexture
- , R = S.createView(A)
- , C = null == x ? void 0 : x.createView(A);
- _.push({
- view: C || R,
- resolveTarget: x ? R : void 0,
- clearValue: 0 !== b && m ? i : void 0,
- loadOp: 0 !== b && m ? zu.Clear : zu.Load,
- storeOp: Wu.Store
- })
- }
- }
- this._cacheRenderPipeline.setMRT(l.textures, this._mrtAttachments.length),
- this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)
- } else {
- var P = (I = l.texture)._hardwareTexture
- , M = P.underlyingResource;
- x = P.msaaTexture,
- R = M.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),
- C = null == x ? void 0 : x.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor),
- _.push({
- view: C || R,
- resolveTarget: x ? R : void 0,
- clearValue: m ? i : void 0,
- loadOp: m ? zu.Clear : zu.Load,
- storeOp: Wu.Store
- })
- }
- if (null === (o = this._debugPushGroup) || void 0 === o || o.call(this, "render target pass", 1),
- this._rttRenderPassWrapper.renderPassDescriptor = {
- colorAttachments: _,
- depthStencilAttachment: c && h ? {
- view: f || p,
- depthClearValue: g ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0,
- depthLoadOp: g ? zu.Clear : zu.Load,
- depthStoreOp: Wu.Store,
- stencilClearValue: l._depthStencilTextureWithStencil && v ? this._clearStencilValue : void 0,
- stencilLoadOp: l._depthStencilTextureWithStencil && v ? zu.Clear : zu.Load,
- stencilStoreOp: Wu.Store
- } : void 0,
- occlusionQuerySet: (null === (a = this._occlusionQuery) || void 0 === a ? void 0 : a.hasQueries) ? this._occlusionQuery.querySet : void 0
- },
- this._rttRenderPassWrapper.renderPass = this._renderTargetEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
- var I = l.texture;
- console.log("frame #" + this._count + " - render target begin pass - internalTexture.uniqueId=", I.uniqueId, "width=", I.width, "height=", I.height, this._rttRenderPassWrapper.renderPassDescriptor)
- }
- this._currentRenderPass = this._rttRenderPassWrapper.renderPass,
- null === (s = this._debugFlushPendingCommands) || void 0 === s || s.call(this),
- this._resetCurrentViewport(1),
- this._resetCurrentScissor(1),
- this._resetCurrentStencilRef(1),
- this._resetCurrentColorBlend(1),
- u && fh.HasStencilAspect(u.format) || (this._stencilStateComposer.enabled = !1)
- }
- ,
- t.prototype._endRenderTargetRenderPass = function() {
- var e, t, i;
- if (this._currentRenderPass) {
- var n = this._currentRenderTarget.texture._hardwareTexture;
- this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, n) || this.compatibilityMode || (this._bundleListRenderTarget.run(this._currentRenderPass),
- this._bundleListRenderTarget.reset()),
- this._currentRenderPass.end(),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - render target end pass - internalTexture.uniqueId=", null === (t = null === (e = this._currentRenderTarget) || void 0 === e ? void 0 : e.texture) || void 0 === t ? void 0 : t.uniqueId)),
- null === (i = this._debugPopGroup) || void 0 === i || i.call(this, 1),
- this._resetCurrentViewport(1),
- this._resetCurrentScissor(1),
- this._resetCurrentStencilRef(1),
- this._resetCurrentColorBlend(1),
- this._currentRenderPass = null,
- this._rttRenderPassWrapper.reset()
- }
- }
- ,
- t.prototype._getCurrentRenderPass = function() {
- return this._currentRenderTarget && !this._currentRenderPass ? this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1) : this._currentRenderPass || this._startMainRenderPass(!1),
- this._currentRenderPass
- }
- ,
- t.prototype._getCurrentRenderPassIndex = function() {
- return null === this._currentRenderPass ? -1 : this._currentRenderPass === this._mainRenderPassWrapper.renderPass ? 0 : 1
- }
- ,
- t.prototype._startMainRenderPass = function(e, t, i, n) {
- var r, o, a;
- this._mainRenderPassWrapper.renderPass && this._endMainRenderPass(),
- this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
- var s = e && t
- , l = e && i
- , c = e && n;
- this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].clearValue = s ? t : void 0,
- this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadOp = s ? zu.Clear : zu.Load,
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthClearValue = l ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : void 0,
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadOp = l ? zu.Clear : zu.Load,
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilClearValue = c ? this._clearStencilValue : void 0,
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadOp = c ? zu.Clear : zu.Load,
- this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = (null === (r = this._occlusionQuery) || void 0 === r ? void 0 : r.hasQueries) ? this._occlusionQuery.querySet : void 0,
- this._swapChainTexture = this._context.getCurrentTexture(),
- this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].set(this._swapChainTexture),
- this._options.antialiasing ? this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].resolveTarget = this._swapChainTexture.createView() : this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].view = this._swapChainTexture.createView(),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (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)),
- null === (o = this._debugPushGroup) || void 0 === o || o.call(this, "main pass", 0),
- this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor),
- this._mainRenderPassWrapper.renderPass = this._currentRenderPass,
- null === (a = this._debugFlushPendingCommands) || void 0 === a || a.call(this),
- this._resetCurrentViewport(0),
- this._resetCurrentScissor(0),
- this._resetCurrentStencilRef(0),
- this._resetCurrentColorBlend(0),
- this._isStencilEnable || (this._stencilStateComposer.enabled = !1)
- }
- ,
- t.prototype._endMainRenderPass = function() {
- var e;
- null !== this._mainRenderPassWrapper.renderPass && (this._snapshotRendering.endMainRenderPass(),
- this.compatibilityMode || this._snapshotRendering.play || (this._bundleList.run(this._mainRenderPassWrapper.renderPass),
- this._bundleList.reset()),
- this._mainRenderPassWrapper.renderPass.end(),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main end pass")),
- null === (e = this._debugPopGroup) || void 0 === e || e.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))
- }
- ,
- t.prototype.bindFramebuffer = function(e, t, i, n, r, o, s) {
- var l, c;
- void 0 === t && (t = 0),
- void 0 === o && (o = 0),
- void 0 === s && (s = 0);
- var u = null === (l = e.texture) || void 0 === l ? void 0 : l._hardwareTexture;
- u ? (this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
- this._currentRenderTarget = e,
- u._currentLayer = e.isCube ? 6 * s + t : s,
- this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = u,
- this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? fh.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0,
- this._setDepthTextureFormat(this._rttRenderPassWrapper),
- this._setColorFormat(this._rttRenderPassWrapper),
- this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
- format: this._colorFormat,
- dimension: vu.E2d,
- mipLevelCount: 1,
- baseArrayLayer: e.isCube ? 6 * s + t : s,
- baseMipLevel: o,
- arrayLayerCount: 1,
- aspect: yu.All
- },
- this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
- format: this._depthTextureFormat,
- dimension: vu.E2d,
- mipLevelCount: 1,
- baseArrayLayer: e.isCube ? 6 * s + t : s,
- baseMipLevel: 0,
- arrayLayerCount: 1,
- aspect: yu.All
- },
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - bindFramebuffer called - internalTexture.uniqueId=", null === (c = e.texture) || void 0 === c ? void 0 : c.uniqueId, "face=", t, "lodLevel=", o, "layer=", s, this._rttRenderPassWrapper.colorAttachmentViewDescriptor, this._rttRenderPassWrapper.depthAttachmentViewDescriptor)),
- this._currentRenderPass = null,
- this.snapshotRendering && this.snapshotRenderingMode === a.SNAPSHOTRENDERING_FAST && this._getCurrentRenderPass(),
- this._cachedViewport && !r ? this.setViewport(this._cachedViewport, i, n) : (i || (i = e.width,
- o && (i /= Math.pow(2, o))),
- n || (n = e.height,
- o && (n /= Math.pow(2, o))),
- this._viewport(0, 0, i, n)),
- this.wipeCaches()) : this.dbgSanityChecks && console.error("bindFramebuffer: Trying to bind a texture that does not have a hardware texture!", e, u)
- }
- ,
- t.prototype.unBindFramebuffer = function(e, t, i) {
- var n, r;
- void 0 === t && (t = !1);
- var o = this._currentRenderTarget;
- this._currentRenderTarget = null,
- i && i(),
- this._currentRenderTarget = o,
- this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass(),
- !(null === (n = e.texture) || void 0 === n ? void 0 : n.generateMipMaps) || t || e.isCube || this._generateMipmaps(e.texture),
- this._currentRenderTarget = null,
- this._onAfterUnbindFrameBufferObservable.notifyObservers(this),
- this.dbgVerboseLogsForFirstFrames && (void 0 === this._count && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - unBindFramebuffer called - internalTexture.uniqueId=", null === (r = e.texture) || void 0 === r ? void 0 : r.uniqueId)),
- this._mrtAttachments = [],
- this._cacheRenderPipeline.setMRT([]),
- this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments),
- this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
- this._setDepthTextureFormat(this._mainRenderPassWrapper),
- this._setColorFormat(this._mainRenderPassWrapper)
- }
- ,
- t.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()
- }
- ,
- t.prototype._setColorFormat = function(e) {
- var t = e.colorAttachmentGPUTextures[0].format;
- this._cacheRenderPipeline.setColorFormat(t),
- this._colorFormat !== t && (this._colorFormat = t)
- }
- ,
- t.prototype._setDepthTextureFormat = function(e) {
- this._cacheRenderPipeline.setDepthStencilFormat(e.depthTextureFormat),
- this._depthTextureFormat !== e.depthTextureFormat && (this._depthTextureFormat = e.depthTextureFormat)
- }
- ,
- t.prototype.setDitheringState = function() {}
- ,
- t.prototype.setRasterizerState = function() {}
- ,
- t.prototype.setState = function(e, t, i, n, r, o, a) {
- var s, l;
- void 0 === t && (t = 0),
- void 0 === n && (n = !1),
- void 0 === a && (a = 0),
- (this._depthCullingState.cull !== e || i) && (this._depthCullingState.cull = e);
- var c = null === (l = null !== (s = this.cullBackFaces) && void 0 !== s ? s : r) || void 0 === l || l ? 1 : 2;
- (this._depthCullingState.cullFace !== c || i) && (this._depthCullingState.cullFace = c),
- this.setZOffset(t),
- this.setZOffsetUnits(a);
- var u = n ? this._currentRenderTarget ? 1 : 2 : this._currentRenderTarget ? 2 : 1;
- (this._depthCullingState.frontFace !== u || i) && (this._depthCullingState.frontFace = u),
- this._stencilStateComposer.stencilMaterial = o
- }
- ,
- t.prototype._applyRenderPassChanges = function(e, t) {
- var i, n = this._mustUpdateViewport(e), r = this._mustUpdateScissor(e), o = !!this._stencilStateComposer.enabled && this._mustUpdateStencilRef(e), a = !!this._alphaState.alphaBlend && this._mustUpdateBlendColor(e);
- t ? (n && t.addItem(new Fh(this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w)),
- r && t.addItem(new wh(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
- o && t.addItem(new Bh(null !== (i = this._stencilStateComposer.funcRef) && void 0 !== i ? i : 0)),
- a && t.addItem(new Uh(this._alphaState._blendConstants.slice()))) : (n && this._applyViewport(e),
- r && this._applyScissor(e),
- o && this._applyStencilRef(e),
- a && this._applyBlendColor(e))
- }
- ,
- t.prototype._draw = function(e, t, i, n, r) {
- var o, s = this._getCurrentRenderPass(), l = 0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget;
- this.applyStates();
- var c = this._currentEffect._pipelineContext;
- if (this.bindUniformBufferBase(this._currentRenderTarget ? this._ubInvertY : this._ubDontInvertY, 0, Qu.InternalsUBOName),
- c.uniformBuffer && (c.uniformBuffer.update(),
- this.bindUniformBufferBase(c.uniformBuffer.getBuffer(), 0, Qu.LeftOvertUBOName)),
- this._snapshotRendering.play)
- this._reportDrawCall();
- else {
- !this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation) && (this._currentDrawContext.fastBundle = void 0);
- var u = s;
- if (!this.compatibilityMode && this._currentDrawContext.fastBundle || this._snapshotRendering.record) {
- if (this._applyRenderPassChanges(s, l),
- !this._snapshotRendering.record)
- return this._counters.numBundleReuseNonCompatMode++,
- this._currentDrawContext.indirectDrawBuffer && this._currentDrawContext.setIndirectData(n, r || 1, i),
- l.addBundle(this._currentDrawContext.fastBundle),
- void this._reportDrawCall();
- u = l.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount),
- l.numDrawCalls++
- }
- var h = 0;
- if (!this._caps.textureFloatLinearFiltering && this._currentMaterialContext.hasFloatTextures)
- for (var d = 1, p = 0; p < c.shaderProcessingContext.textureNames.length; ++p) {
- var f = c.shaderProcessingContext.textureNames[p]
- , _ = null === (o = this._currentMaterialContext.textures[f]) || void 0 === o ? void 0 : o.texture;
- (null == _ ? void 0 : _.type) === a.TEXTURETYPE_FLOAT && (h |= d),
- d <<= 1
- }
- var m = this._cacheRenderPipeline.getRenderPipeline(t, this._currentEffect, this.currentSampleCount, h)
- , g = this._cacheBindGroups.getBindGroups(c, this._currentDrawContext, this._currentMaterialContext);
- this._snapshotRendering.record || (this._applyRenderPassChanges(s, this.compatibilityMode ? null : l),
- this.compatibilityMode || (this._counters.numBundleCreationNonCompatMode++,
- u = this._device.createRenderBundleEncoder({
- colorFormats: this._cacheRenderPipeline.colorFormats,
- depthStencilFormat: this._depthTextureFormat,
- sampleCount: this.currentSampleCount
- }))),
- u.setPipeline(m),
- this._currentIndexBuffer && u.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? Bu.Uint32 : Bu.Uint16, 0);
- for (var v = this._cacheRenderPipeline.vertexBuffers, y = 0; y < v.length; y++) {
- var b = v[y]
- , T = b.getBuffer();
- T && u.setVertexBuffer(y, T.underlyingResource, b._validOffsetRange ? 0 : b.byteOffset)
- }
- for (p = 0; p < g.length; p++)
- u.setBindGroup(p, g[p]);
- var E = !this.compatibilityMode && !this._snapshotRendering.record;
- E && this._currentDrawContext.indirectDrawBuffer ? (this._currentDrawContext.setIndirectData(n, r || 1, i),
- 0 === e ? u.drawIndexedIndirect(this._currentDrawContext.indirectDrawBuffer, 0) : u.drawIndirect(this._currentDrawContext.indirectDrawBuffer, 0)) : 0 === e ? u.drawIndexed(n, r || 1, i, 0, 0) : u.draw(n, r || 1, i, 0),
- E && (this._currentDrawContext.fastBundle = u.finish(),
- l.addBundle(this._currentDrawContext.fastBundle)),
- this._reportDrawCall()
- }
- }
- ,
- t.prototype.drawElementsType = function(e, t, i, n) {
- void 0 === n && (n = 1),
- this._draw(0, e, t, i, n)
- }
- ,
- t.prototype.drawArraysType = function(e, t, i, n) {
- void 0 === n && (n = 1),
- this._currentIndexBuffer = null,
- this._draw(1, e, t, i, n)
- }
- ,
- t.prototype.dispose = function() {
- var t, i, n;
- null === (t = this._mainTexture) || void 0 === t || t.destroy(),
- null === (i = this._mainTextureLastCopy) || void 0 === i || i.destroy(),
- null === (n = this._depthTexture) || void 0 === n || n.destroy(),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.getRenderWidth = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._canvas.width
- }
- ,
- t.prototype.getRenderHeight = function(e) {
- return void 0 === e && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._canvas.height
- }
- ,
- t.prototype.getRenderingCanvas = function() {
- return this._canvas
- }
- ,
- t.prototype.getError = function() {
- return 0
- }
- ,
- t.prototype.bindSamplers = function() {}
- ,
- t.prototype._bindTextureDirectly = function() {
- return !1
- }
- ,
- t.prototype.areAllEffectsReady = function() {
- return !0
- }
- ,
- t.prototype._executeWhenRenderingStateIsCompiled = function(e, t) {
- t()
- }
- ,
- t.prototype._isRenderingStateCompiled = function() {
- return !0
- }
- ,
- t.prototype._getUnpackAlignement = function() {
- return 1
- }
- ,
- t.prototype._unpackFlipY = function() {}
- ,
- t.prototype._bindUnboundFramebuffer = function() {
- throw "_bindUnboundFramebuffer is not implementedin WebGPU! You probably want to use restoreDefaultFramebuffer or unBindFramebuffer instead"
- }
- ,
- t.prototype._getSamplingParameters = function() {
- throw "_getSamplingParameters is not available in WebGPU"
- }
- ,
- t.prototype.getUniforms = function() {
- return []
- }
- ,
- t.prototype.setIntArray = function() {
- return !1
- }
- ,
- t.prototype.setIntArray2 = function() {
- return !1
- }
- ,
- t.prototype.setIntArray3 = function() {
- return !1
- }
- ,
- t.prototype.setIntArray4 = function() {
- return !1
- }
- ,
- t.prototype.setArray = function() {
- return !1
- }
- ,
- t.prototype.setArray2 = function() {
- return !1
- }
- ,
- t.prototype.setArray3 = function() {
- return !1
- }
- ,
- t.prototype.setArray4 = function() {
- return !1
- }
- ,
- t.prototype.setMatrices = function() {
- return !1
- }
- ,
- t.prototype.setMatrix3x3 = function() {
- return !1
- }
- ,
- t.prototype.setMatrix2x2 = function() {
- return !1
- }
- ,
- t.prototype.setFloat = function() {
- return !1
- }
- ,
- t.prototype.setFloat2 = function() {
- return !1
- }
- ,
- t.prototype.setFloat3 = function() {
- return !1
- }
- ,
- t.prototype.setFloat4 = function() {
- return !1
- }
- ,
- t._GLSLslangDefaultOptions = {
- jsPath: "https://preview.babylonjs.com/glslang/glslang.js",
- wasmPath: "https://preview.babylonjs.com/glslang/glslang.wasm"
- },
- t.UseTWGSL = !0,
- t
- }(vr);
- Qh.prototype.setAlphaMode = function(e, t) {
- if (void 0 === t && (t = !1),
- this._alphaMode !== e || !(e === a.ALPHA_DISABLE && !this._alphaState.alphaBlend || e !== a.ALPHA_DISABLE && this._alphaState.alphaBlend)) {
- switch (e) {
- case a.ALPHA_DISABLE:
- this._alphaState.alphaBlend = !1;
- break;
- case a.ALPHA_PREMULTIPLIED:
- this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_PREMULTIPLIED_PORTERDUFF:
- this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_COMBINE:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ONEONE:
- this._alphaState.setAlphaBlendFunctionParameters(1, 1, 0, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ADD:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, 1, 0, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_SUBTRACT:
- this._alphaState.setAlphaBlendFunctionParameters(0, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_MULTIPLY:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_DST_COLOR, 0, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_MAXIMIZED:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_INTERPOLATE:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_CONSTANT_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR, a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_SCREENMODE:
- this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ONEONE_ONEONE:
- this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ALPHATOCOLOR:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_DST_ALPHA, 1, 0, 0),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_REVERSEONEMINUS:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_SRC_DSTONEMINUSSRCALPHA:
- this._alphaState.setAlphaBlendFunctionParameters(1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_ONEONE_ONEZERO:
- this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 0),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_EXCLUSION:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR, 0, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case a.ALPHA_LAYER_ACCUMULATE:
- this._alphaState.setAlphaBlendFunctionParameters(a.GL_ALPHA_FUNCTION_SRC_ALPHA, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA, 1, a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0
- }
- t || (this.setDepthWrite(e === vr.ALPHA_DISABLE),
- this._cacheRenderPipeline.setDepthWriteEnabled(e === vr.ALPHA_DISABLE)),
- this._alphaMode = e,
- this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),
- this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
- }
- }
- ,
- Qh.prototype.setAlphaEquation = function(e) {
- vr.prototype.setAlphaEquation.call(this, e),
- this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
- }
- ;
- var qh = function() {
- function e(t, i) {
- this._device = t,
- this._cacheSampler = i,
- this.uniqueId = e._Counter++,
- this._bindGroupEntries = [],
- this.clear()
- }
- return e.prototype.getBindGroups = function(e, t, i) {
- if (!i)
- throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");
- if (0 === this._bindGroups.length) {
- var n = this._bindGroupEntries.length > 0;
- for (var r in e) {
- var o = e[r]
- , a = i[r]
- , s = a.group
- , l = a.binding
- , c = o.type
- , u = o.object
- , h = o.indexInGroupEntries;
- switch ((v = this._bindGroupEntries[s]) || (v = this._bindGroupEntries[s] = []),
- c) {
- case _l.Sampler:
- var d = u;
- void 0 !== h && n ? v[h].resource = this._cacheSampler.getSampler(d) : (o.indexInGroupEntries = v.length,
- v.push({
- binding: l,
- resource: this._cacheSampler.getSampler(d)
- }));
- break;
- case _l.Texture:
- case _l.TextureWithoutSampler:
- var p = (f = u)._texture._hardwareTexture;
- void 0 !== h && n ? (c === _l.Texture && (v[h++].resource = this._cacheSampler.getSampler(f._texture)),
- v[h].resource = p.view) : (o.indexInGroupEntries = v.length,
- c === _l.Texture && v.push({
- binding: l - 1,
- resource: this._cacheSampler.getSampler(f._texture)
- }),
- v.push({
- binding: l,
- resource: p.view
- }));
- break;
- case _l.StorageTexture:
- var f;
- 0 == ((p = (f = u)._texture._hardwareTexture).textureAdditionalUsages & gu.StorageBinding) && K.Error("computeDispatch: The texture (name=".concat(f.name, ", uniqueId=").concat(f.uniqueId, ") is not a storage texture!"), 50),
- void 0 !== h && n ? v[h].resource = p.viewForWriting : (o.indexInGroupEntries = v.length,
- v.push({
- binding: l,
- resource: p.viewForWriting
- }));
- break;
- case _l.UniformBuffer:
- case _l.StorageBuffer:
- var _ = (_l.UniformBuffer,
- u).getBuffer()
- , m = _.underlyingResource;
- void 0 !== h && n ? (v[h].resource.buffer = m,
- v[h].resource.size = _.capacity) : (o.indexInGroupEntries = v.length,
- v.push({
- binding: l,
- resource: {
- buffer: m,
- offset: 0,
- size: _.capacity
- }
- }))
- }
- }
- for (var g = 0; g < this._bindGroupEntries.length; ++g) {
- var v;
- (v = this._bindGroupEntries[g]) ? this._bindGroups[g] = this._device.createBindGroup({
- layout: t.getBindGroupLayout(g),
- entries: v
- }) : this._bindGroups[g] = void 0
- }
- this._bindGroups.length = this._bindGroupEntries.length
- }
- return this._bindGroups
- }
- ,
- e.prototype.clear = function() {
- this._bindGroups = []
- }
- ,
- e._Counter = 0,
- e
- }()
- , Zh = function() {
- function e(e) {
- this._name = "unnamed",
- this.engine = e
- }
- return Object.defineProperty(e.prototype, "isAsync", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isReady", {
- get: function() {
- return !!this.stage
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getComputeShaderCode = function() {
- var e;
- return null === (e = this.sources) || void 0 === e ? void 0 : e.compute
- }
- ,
- e.prototype.dispose = function() {}
- ,
- e
- }();
- Qh.prototype.createComputeContext = function() {
- return new qh(this._device,this._cacheSampler)
- }
- ,
- Qh.prototype.createComputeEffect = function(e, t) {
- var i = (e.computeElement || e.compute || e.computeToken || e.computeSource || e) + "@" + t.defines;
- if (this._compiledComputeEffects[i]) {
- var n = this._compiledComputeEffects[i];
- return t.onCompiled && n.isReady() && t.onCompiled(n),
- n
- }
- var r = new ml(e,t,this,i);
- return this._compiledComputeEffects[i] = r,
- r
- }
- ,
- Qh.prototype.createComputePipelineContext = function() {
- return new Zh(this)
- }
- ,
- Qh.prototype.areAllComputeEffectsReady = function() {
- for (var e in this._compiledComputeEffects)
- if (!this._compiledComputeEffects[e].isReady())
- return !1;
- return !0
- }
- ,
- Qh.prototype.computeDispatch = function(e, t, i, n, r, o, a) {
- var s = this;
- if (this._currentRenderTarget)
- this._onAfterUnbindFrameBufferObservable.addOnce((function() {
- s.computeDispatch(e, t, i, n, r, o, a)
- }
- ));
- else {
- var l = e._pipelineContext
- , c = t;
- l.computePipeline || (l.computePipeline = this._device.createComputePipeline({
- compute: l.stage
- }));
- var u = this._renderTargetEncoder.beginComputePass();
- u.setPipeline(l.computePipeline);
- for (var h = c.getBindGroups(i, l.computePipeline, a), d = 0; d < h.length; ++d) {
- var p = h[d];
- p && u.setBindGroup(d, p)
- }
- u.dispatch(n, r, o),
- u.end()
- }
- }
- ,
- Qh.prototype.releaseComputeEffects = function() {
- for (var e in this._compiledComputeEffects) {
- var t = this._compiledComputeEffects[e].getPipelineContext();
- this._deleteComputePipelineContext(t)
- }
- this._compiledComputeEffects = {}
- }
- ,
- Qh.prototype._prepareComputePipelineContext = function(e, t, i, n, r) {
- var o = e;
- this.dbgShowShaderCode && (console.log(n),
- console.log(t)),
- o.sources = {
- compute: t,
- rawCompute: i
- },
- o.stage = this._createComputePipelineStageDescriptor(t, n, r)
- }
- ,
- Qh.prototype._releaseComputeEffect = function(e) {
- this._compiledComputeEffects[e._key] && (delete this._compiledComputeEffects[e._key],
- this._deleteComputePipelineContext(e.getPipelineContext()))
- }
- ,
- Qh.prototype._rebuildComputeEffects = function() {
- for (var e in this._compiledComputeEffects) {
- var t = this._compiledComputeEffects[e];
- t._pipelineContext = null,
- t._wasPreviouslyReady = !1,
- t._prepareEffect()
- }
- }
- ,
- Qh.prototype._deleteComputePipelineContext = function(e) {
- e && e.dispose()
- }
- ,
- Qh.prototype._createComputePipelineStageDescriptor = function(e, t, i) {
- return t = t ? "//" + t.split("\n").join("\n//") + "\n" : "",
- {
- module: this._device.createShaderModule({
- code: t + e
- }),
- entryPoint: i
- }
- }
- ,
- Qh.prototype._createDepthStencilCubeTexture = function(e, t) {
- var i = new Lt(this,At.DepthStencil);
- i.isCube = !0;
- var n = V({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1,
- samples: 1
- }, t);
- return i.format = n.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : a.TEXTUREFORMAT_DEPTH32_FLOAT,
- this._setupDepthStencilTexture(i, e, n.generateStencil, n.bilinearFiltering, n.comparisonFunction, n.samples),
- this._textureHelper.createGPUTextureForInternalTexture(i),
- this._internalTexturesCache.push(i),
- i
- }
- ,
- Qh.prototype.createCubeTexture = function(e, t, i, n, r, o, a, s, l, c, u, h, d) {
- var p = this;
- return void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = !1),
- void 0 === c && (c = 0),
- void 0 === u && (u = 0),
- void 0 === h && (h = null),
- void 0 === d && (d = !1),
- this.createCubeTextureBase(e, t, i, !!n, r, o, a, s, l, c, u, h, null, (function(e, t) {
- var i = t
- , o = i[0].width
- , s = o;
- p._setCubeMapTextureParams(e, !n),
- e.format = null != a ? a : -1;
- var l = p._textureHelper.createGPUTextureForInternalTexture(e, o, s);
- p._textureHelper.updateCubeTextures(i, l.underlyingResource, o, s, l.format, !1, !1, 0, 0),
- n || p._generateMipmaps(e, p._uploadEncoder),
- e.isReady = !0,
- e.onLoadedObservable.notifyObservers(e),
- e.onLoadedObservable.clear(),
- r && r()
- }
- ), !!d)
- }
- ,
- Qh.prototype._setCubeMapTextureParams = function(e, t, i) {
- e.samplingMode = t ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : a.TEXTURE_BILINEAR_SAMPLINGMODE,
- e._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- e._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
- i && (e._maxLodLevel = i)
- }
- ,
- Qh.prototype._debugPushGroup = function(e, t) {
- this._options.enableGPUDebugMarkers && (0 === t || 1 === t ? (0 === t ? this._renderEncoder : this._renderTargetEncoder).pushDebugGroup(e) : this._currentRenderPass ? this._currentRenderPass.pushDebugGroup(e) : this._pendingDebugCommands.push(["push", e]))
- }
- ,
- Qh.prototype._debugPopGroup = function(e) {
- this._options.enableGPUDebugMarkers && (0 === e || 1 === e ? (0 === e ? this._renderEncoder : this._renderTargetEncoder).popDebugGroup() : this._currentRenderPass ? this._currentRenderPass.popDebugGroup() : this._pendingDebugCommands.push(["pop", null]))
- }
- ,
- Qh.prototype._debugInsertMarker = function(e, t) {
- this._options.enableGPUDebugMarkers && (0 === t || 1 === t ? (0 === t ? this._renderEncoder : this._renderTargetEncoder).insertDebugMarker(e) : this._currentRenderPass ? this._currentRenderPass.insertDebugMarker(e) : this._pendingDebugCommands.push(["insert", e]))
- }
- ,
- Qh.prototype._debugFlushPendingCommands = function() {
- for (var e = 0; e < this._pendingDebugCommands.length; ++e) {
- var t = this._pendingDebugCommands[e]
- , i = t[0]
- , n = t[1];
- switch (i) {
- case "push":
- this._debugPushGroup(n);
- break;
- case "pop":
- this._debugPopGroup();
- break;
- case "insert":
- this._debugInsertMarker(n)
- }
- }
- this._pendingDebugCommands.length = 0
- }
- ,
- Qh.prototype.updateDynamicIndexBuffer = function(e, t, i) {
- void 0 === i && (i = 0);
- var n, r = e;
- n = t instanceof Uint16Array ? e.is32Bits ? Uint32Array.from(t) : t : t instanceof Uint32Array ? e.is32Bits ? t : Uint16Array.from(t) : e.is32Bits ? new Uint32Array(t) : new Uint16Array(t),
- this._bufferManager.setSubData(r, i, n)
- }
- ,
- Qh.prototype.updateDynamicVertexBuffer = function(e, t, i, n) {
- var r, o = e;
- void 0 === i && (i = 0),
- void 0 === n ? n = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t,
- this._bufferManager.setSubData(o, i, r, 0, n)
- }
- ,
- Qh.prototype.updateDynamicTexture = function(e, t, i, n, r, o, a) {
- var s;
- if (void 0 === n && (n = !1),
- e) {
- var l = t.width
- , c = t.height
- , u = e._hardwareTexture;
- (null === (s = e._hardwareTexture) || void 0 === s ? void 0 : s.underlyingResource) || (u = this._textureHelper.createGPUTextureForInternalTexture(e, l, c)),
- this._textureHelper.updateTexture(t, e, l, c, e.depth, u.format, 0, 0, i, n, 0, 0, a),
- e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder),
- e.isReady = !0
- }
- }
- ;
- var Jh = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- t
- }(Mh);
- function $h(e, t, i, n) {
- var r, o = 1;
- n === a.TEXTURETYPE_FLOAT ? r = new Float32Array(t * i * 4) : n === a.TEXTURETYPE_HALF_FLOAT ? (r = new Uint16Array(t * i * 4),
- o = 15360) : r = n === a.TEXTURETYPE_UNSIGNED_INTEGER ? new Uint32Array(t * i * 4) : new Uint8Array(t * i * 4);
- for (var s = 0; s < t; s++)
- for (var l = 0; l < i; l++) {
- var c = 3 * (l * t + s)
- , u = 4 * (l * t + s);
- r[u + 0] = e[c + 0],
- r[u + 1] = e[c + 1],
- r[u + 2] = e[c + 2],
- r[u + 3] = o
- }
- return r
- }
- Mt.prototype.setExternalTexture = function(e, t) {
- this._engine.setExternalTexture(e, t)
- }
- ,
- Qh.prototype.createExternalTexture = function(e) {
- return new Jh(e)
- }
- ,
- Qh.prototype.setExternalTexture = function(e, t) {
- t ? this._setInternalTexture(e, t) : this._currentMaterialContext.setTexture(e, null)
- }
- ,
- Qh.prototype.unBindMultiColorAttachmentFramebuffer = function(e, t, i) {
- void 0 === t && (t = !1),
- i && i();
- var n = e._attachments.length;
- this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass();
- for (var r = 0; r < n; r++) {
- var o = e.textures[r];
- !o.generateMipMaps || t || o.isCube || this._generateMipmaps(o)
- }
- this._currentRenderTarget = null,
- this._mrtAttachments = [],
- this._cacheRenderPipeline.setMRT([]),
- this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments),
- this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
- this._setDepthTextureFormat(this._mainRenderPassWrapper),
- this._setColorFormat(this._mainRenderPassWrapper)
- }
- ,
- Qh.prototype.createMultipleRenderTarget = function(e, t, i) {
- var n, r = !1, o = !0, s = !1, l = !1, c = a.TEXTUREFORMAT_DEPTH16, u = 1, h = a.TEXTURETYPE_UNSIGNED_INT, d = a.TEXTURE_TRILINEAR_SAMPLINGMODE, p = new Array, f = new Array, _ = this._createHardwareRenderTargetWrapper(!0, !1, e);
- void 0 !== t && (r = void 0 !== t.generateMipMaps && t.generateMipMaps,
- o = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
- s = void 0 !== t.generateStencilBuffer && t.generateStencilBuffer,
- l = void 0 !== t.generateDepthTexture && t.generateDepthTexture,
- u = t.textureCount || 1,
- c = null !== (n = t.depthTextureFormat) && void 0 !== n ? n : a.TEXTUREFORMAT_DEPTH16,
- t.types && (p = t.types),
- t.samplingModes && (f = t.samplingModes));
- var m = e.width || e
- , g = e.height || e
- , v = null;
- (o || s || l) && (v = _.createDepthStencilTexture(0, !1, s, 1, c));
- var y = []
- , b = []
- , T = [];
- _._generateDepthBuffer = o,
- _._generateStencilBuffer = s,
- _._attachments = b,
- _._defaultAttachments = T;
- for (var E = 0; E < u; E++) {
- var S = f[E] || d
- , A = p[E] || h;
- (A !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering) && (A !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering) || (S = a.TEXTURE_NEAREST_SAMPLINGMODE),
- A !== a.TEXTURETYPE_FLOAT || this._caps.textureFloat || (A = a.TEXTURETYPE_UNSIGNED_INT,
- K.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
- var x = new Lt(this,At.MultiRenderTarget);
- y.push(x),
- b.push(E + 1),
- T.push(i ? E + 1 : 0 === E ? 1 : 0),
- x.baseWidth = m,
- x.baseHeight = g,
- x.width = m,
- x.height = g,
- x.isReady = !0,
- x.samples = 1,
- x.generateMipMaps = r,
- x.samplingMode = S,
- x.type = A,
- x._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- x._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
- this._internalTexturesCache.push(x),
- this._textureHelper.createGPUTextureForInternalTexture(x)
- }
- return v && (v.incrementReferences(),
- y.push(v),
- this._internalTexturesCache.push(v)),
- _.setTextures(y),
- _
- }
- ,
- Qh.prototype.updateMultipleRenderTargetTextureSampleCount = function(e, t) {
- if (!e || !e.textures || e.textures[0].samples === t)
- return t;
- var i = e.textures.length;
- if (0 === i)
- return 1;
- t = Math.min(t, this.getCaps().maxMSAASamples);
- for (var n = 0; n < i; ++n) {
- var r = e.textures[n];
- this._textureHelper.createMSAATexture(r, t),
- r.samples = t
- }
- return e._depthStencilTexture && e._depthStencilTexture !== e.textures[e.textures.length - 1] && (this._textureHelper.createMSAATexture(e._depthStencilTexture, t),
- e._depthStencilTexture.samples = t),
- t
- }
- ,
- Qh.prototype.bindAttachments = function(e) {
- 0 !== e.length && this._currentRenderTarget && (this._mrtAttachments = e,
- this._currentRenderPass && this._cacheRenderPipeline.setMRTAttachments(e))
- }
- ,
- Qh.prototype.buildTextureLayout = function(e) {
- for (var t = [], i = 0; i < e.length; i++)
- e[i] ? t.push(i + 1) : t.push(0);
- return t
- }
- ,
- Qh.prototype.restoreSingleAttachment = function() {}
- ,
- Qh.prototype.restoreSingleAttachmentForRenderTarget = function() {}
- ,
- Qh.prototype.getGPUFrameTimeCounter = function() {
- return this._timestampQuery.gpuFrameTimeCounter
- }
- ,
- Qh.prototype.captureGPUFrameTime = function(e) {
- this._timestampQuery.enable = e && !!this._caps.timerQuery
- }
- ,
- Qh.prototype.createQuery = function() {
- return this._occlusionQuery.createQuery()
- }
- ,
- Qh.prototype.deleteQuery = function(e) {
- return this._occlusionQuery.deleteQuery(e),
- this
- }
- ,
- Qh.prototype.isQueryResultAvailable = function(e) {
- return this._occlusionQuery.isQueryResultAvailable(e)
- }
- ,
- Qh.prototype.getQueryResult = function(e) {
- return this._occlusionQuery.getQueryResult(e)
- }
- ,
- Qh.prototype.beginOcclusionQuery = function(e, t) {
- var i;
- return this.compatibilityMode ? !!this._occlusionQuery.canBeginQuery && (null === (i = this._currentRenderPass) || void 0 === i || i.beginOcclusionQuery(t),
- !0) : ((0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget).addItem(new Vh(t)),
- !0)
- }
- ,
- Qh.prototype.endOcclusionQuery = function() {
- var e;
- return this.compatibilityMode ? null === (e = this._currentRenderPass) || void 0 === e || e.endOcclusionQuery() : (0 === this._getCurrentRenderPassIndex() ? this._bundleList : this._bundleListRenderTarget).addItem(new kh),
- this
- }
- ,
- Qh.prototype.createRawTexture = function(e, t, i, n, r, o, s, l, c, u) {
- void 0 === l && (l = null),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = 0);
- var h = new Lt(this,At.Raw);
- return h.baseWidth = t,
- h.baseHeight = i,
- h.width = t,
- h.height = i,
- h.format = n,
- h.generateMipMaps = r,
- h.samplingMode = s,
- h.invertY = o,
- h._compression = l,
- h.type = c,
- this._doNotHandleContextLost || (h._bufferView = e),
- this._textureHelper.createGPUTextureForInternalTexture(h, t, i, void 0, u),
- this.updateRawTexture(h, e, n, o, l, c),
- this._internalTexturesCache.push(h),
- h
- }
- ,
- Qh.prototype.updateRawTexture = function(e, t, i, n, r, o) {
- if (void 0 === r && (r = null),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- e) {
- if (this._doNotHandleContextLost || (e._bufferView = t,
- e.invertY = n,
- e._compression = r),
- t) {
- var s = e._hardwareTexture;
- i === a.TEXTUREFORMAT_RGB && (t = $h(t, e.width, e.height, o));
- var l = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
- this._textureHelper.updateTexture(l, e, e.width, e.height, e.depth, s.format, 0, 0, n, !1, 0, 0),
- e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
- }
- e.isReady = !0
- }
- }
- ,
- Qh.prototype.createRawCubeTexture = function(e, t, i, n, r, o, s, l) {
- void 0 === l && (l = null);
- var c = new Lt(this,At.CubeRaw);
- return n !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatLinearFiltering ? n !== a.TEXTURETYPE_HALF_FLOAT || this._caps.textureHalfFloatLinearFiltering ? n !== a.TEXTURETYPE_FLOAT || this._caps.textureFloatRender ? n !== a.TEXTURETYPE_HALF_FLOAT || this._caps.colorBufferFloat || (r = !1,
- K.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
- K.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : (r = !1,
- s = a.TEXTURE_NEAREST_SAMPLINGMODE,
- K.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")) : (r = !1,
- s = a.TEXTURE_NEAREST_SAMPLINGMODE,
- K.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")),
- c.isCube = !0,
- c.format = i === a.TEXTUREFORMAT_RGB ? a.TEXTUREFORMAT_RGBA : i,
- c.type = n,
- c.generateMipMaps = r,
- c.width = t,
- c.height = t,
- c.samplingMode = s,
- this._doNotHandleContextLost || (c._bufferViewArray = e),
- c._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- c._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
- this._textureHelper.createGPUTextureForInternalTexture(c),
- e && this.updateRawCubeTexture(c, e, i, n, o, l),
- c
- }
- ,
- Qh.prototype.updateRawCubeTexture = function(e, t, i, n, r, o) {
- void 0 === o && (o = null),
- e._bufferViewArray = t,
- e.invertY = r,
- e._compression = o;
- for (var s = e._hardwareTexture, l = i === a.TEXTUREFORMAT_RGB, c = [], u = 0; u < t.length; ++u) {
- var h = t[u];
- l && (h = $h(t[u], e.width, e.height, n)),
- c.push(new Uint8Array(h.buffer,h.byteOffset,h.byteLength))
- }
- this._textureHelper.updateCubeTextures(c, s.underlyingResource, e.width, e.height, s.format, r, !1, 0, 0),
- e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder),
- e.isReady = !0
- }
- ,
- Qh.prototype.createRawCubeTextureFromUrl = function(e, t, i, n, r, o, s, l, c, u, h, d) {
- var p = this;
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- void 0 === h && (h = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === d && (d = !1);
- var f = this.createRawCubeTexture(null, i, n, r, !o, d, h, null);
- return null == t || t._addPendingData(f),
- f.url = e,
- this._internalTexturesCache.push(f),
- this._loadFile(e, (function(e) {
- !function(e) {
- var i = f.width
- , o = s(e);
- if (o) {
- var u = [0, 2, 4, 1, 3, 5];
- if (l)
- for (var h = n === a.TEXTUREFORMAT_RGB, _ = l(o), m = f._hardwareTexture, g = [0, 1, 2, 3, 4, 5], v = 0; v < _.length; v++) {
- for (var y = i >> v, b = [], T = 0; T < 6; T++) {
- var E = _[v][g[T]];
- h && (E = $h(E, y, y, r)),
- b.push(new Uint8Array(E.buffer,E.byteOffset,E.byteLength))
- }
- p._textureHelper.updateCubeTextures(b, m.underlyingResource, y, y, m.format, d, !1, 0, 0)
- }
- else {
- for (b = [],
- T = 0; T < 6; T++)
- b.push(o[u[T]]);
- p.updateRawCubeTexture(f, b, n, r, d)
- }
- f.isReady = !0,
- null == t || t._removePendingData(f),
- c && c()
- }
- }(e)
- }
- ), void 0, null == t ? void 0 : t.offlineProvider, !0, (function(e, i) {
- null == t || t._removePendingData(f),
- u && e && u(e.status + " " + e.statusText, i)
- }
- )),
- f
- }
- ,
- Qh.prototype.createRawTexture3D = function(e, t, i, n, r, o, s, l, c, u, h) {
- void 0 === c && (c = null),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === h && (h = 0);
- var d = At.Raw3D
- , p = new Lt(this,d);
- return p.baseWidth = t,
- p.baseHeight = i,
- p.baseDepth = n,
- p.width = t,
- p.height = i,
- p.depth = n,
- p.format = r,
- p.type = u,
- p.generateMipMaps = o,
- p.samplingMode = l,
- p.is3D = !0,
- this._doNotHandleContextLost || (p._bufferView = e),
- this._textureHelper.createGPUTextureForInternalTexture(p, t, i, void 0, h),
- this.updateRawTexture3D(p, e, r, s, c, u),
- this._internalTexturesCache.push(p),
- p
- }
- ,
- Qh.prototype.updateRawTexture3D = function(e, t, i, n, r, o) {
- if (void 0 === r && (r = null),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- this._doNotHandleContextLost || (e._bufferView = t,
- e.format = i,
- e.invertY = n,
- e._compression = r),
- t) {
- var s = e._hardwareTexture;
- i === a.TEXTUREFORMAT_RGB && (t = $h(t, e.width, e.height, o));
- var l = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
- this._textureHelper.updateTexture(l, e, e.width, e.height, e.depth, s.format, 0, 0, n, !1, 0, 0),
- e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
- }
- e.isReady = !0
- }
- ,
- Qh.prototype.createRawTexture2DArray = function(e, t, i, n, r, o, s, l, c, u, h) {
- void 0 === c && (c = null),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === h && (h = 0);
- var d = At.Raw2DArray
- , p = new Lt(this,d);
- return p.baseWidth = t,
- p.baseHeight = i,
- p.baseDepth = n,
- p.width = t,
- p.height = i,
- p.depth = n,
- p.format = r,
- p.type = u,
- p.generateMipMaps = o,
- p.samplingMode = l,
- p.is2DArray = !0,
- this._doNotHandleContextLost || (p._bufferView = e),
- this._textureHelper.createGPUTextureForInternalTexture(p, t, i, n, h),
- this.updateRawTexture2DArray(p, e, r, s, c, u),
- this._internalTexturesCache.push(p),
- p
- }
- ,
- Qh.prototype.updateRawTexture2DArray = function(e, t, i, n, r, o) {
- if (void 0 === r && (r = null),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- this._doNotHandleContextLost || (e._bufferView = t,
- e.format = i,
- e.invertY = n,
- e._compression = r),
- t) {
- var s = e._hardwareTexture;
- i === a.TEXTUREFORMAT_RGB && (t = $h(t, e.width, e.height, o));
- var l = new Uint8Array(t.buffer,t.byteOffset,t.byteLength);
- this._textureHelper.updateTexture(l, e, e.width, e.height, e.depth, s.format, 0, 0, n, !1, 0, 0),
- e.generateMipMaps && this._generateMipmaps(e, this._uploadEncoder)
- }
- e.isReady = !0
- }
- ,
- Qh.prototype._readTexturePixels = function(e, t, i, n, r, o, a, s) {
- void 0 === n && (n = -1),
- void 0 === r && (r = 0),
- void 0 === o && (o = null),
- void 0 === a && (a = !0),
- void 0 === s && (s = !1);
- var l = e._hardwareTexture;
- return a && this.flushFramebuffer(),
- this._textureHelper.readPixels(l.underlyingResource, 0, 0, t, i, l.format, n, r, o, s)
- }
- ,
- Qh.prototype._readTexturePixelsSync = function() {
- throw "_readTexturePixelsSync is unsupported in WebGPU!"
- }
- ;
- var ed = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t
- }(Fa);
- Qh.prototype._createHardwareRenderTargetWrapper = function(e, t, i) {
- var n = new ed(e,t,i,this);
- return this._renderTargetWrapperCache.push(n),
- n
- }
- ,
- Qh.prototype.createRenderTargetTexture = function(e, t) {
- var i, n = this._createHardwareRenderTargetWrapper(!1, !1, e), r = {};
- void 0 !== t && "object" == typeof t ? (r.generateMipMaps = t.generateMipMaps,
- r.generateDepthBuffer = void 0 === t.generateDepthBuffer || t.generateDepthBuffer,
- r.generateStencilBuffer = r.generateDepthBuffer && t.generateStencilBuffer,
- r.samplingMode = void 0 === t.samplingMode ? a.TEXTURE_TRILINEAR_SAMPLINGMODE : t.samplingMode,
- r.creationFlags = null !== (i = t.creationFlags) && void 0 !== i ? i : 0) : (r.generateMipMaps = t,
- r.generateDepthBuffer = !0,
- r.generateStencilBuffer = !1,
- r.samplingMode = a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- r.creationFlags = 0);
- var o = this._createInternalTexture(e, t, !0, At.RenderTarget);
- return n._generateDepthBuffer = r.generateDepthBuffer,
- n._generateStencilBuffer = !!r.generateStencilBuffer,
- n.setTextures(o),
- (n._generateDepthBuffer || n._generateStencilBuffer) && n.createDepthStencilTexture(0, void 0 === r.samplingMode || r.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || r.samplingMode === a.TEXTURE_LINEAR_LINEAR || r.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || r.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || r.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || r.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || r.samplingMode === a.TEXTURE_NEAREST_LINEAR || r.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, n._generateStencilBuffer, n.samples),
- void 0 !== t && "object" == typeof t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !0),
- this._textureHelper.createGPUTextureForInternalTexture(o, void 0, void 0, void 0, r.creationFlags),
- void 0 !== t && "object" == typeof t && t.createMipMaps && !r.generateMipMaps && (o.generateMipMaps = !1),
- n
- }
- ,
- Qh.prototype._createDepthStencilTexture = function(e, t) {
- var i = new Lt(this,At.DepthStencil)
- , n = V({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1,
- samples: 1,
- depthTextureFormat: a.TEXTUREFORMAT_DEPTH32_FLOAT
- }, t);
- return i.format = n.generateStencil ? a.TEXTUREFORMAT_DEPTH24_STENCIL8 : n.depthTextureFormat,
- this._setupDepthStencilTexture(i, e, n.generateStencil, n.bilinearFiltering, n.comparisonFunction, n.samples),
- this._textureHelper.createGPUTextureForInternalTexture(i),
- this._internalTexturesCache.push(i),
- i
- }
- ,
- Qh.prototype._setupDepthStencilTexture = function(e, t, i, n, r, o) {
- void 0 === o && (o = 1);
- var s = t.width || t
- , l = t.height || t
- , c = t.layers || 0;
- e.baseWidth = s,
- e.baseHeight = l,
- e.width = s,
- e.height = l,
- e.is2DArray = c > 0,
- e.depth = c,
- e.isReady = !0,
- e.samples = o,
- e.generateMipMaps = !1,
- e.samplingMode = n ? a.TEXTURE_BILINEAR_SAMPLINGMODE : a.TEXTURE_NEAREST_SAMPLINGMODE,
- e.type = a.TEXTURETYPE_FLOAT,
- e._comparisonFunction = r,
- e._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- e._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE
- }
- ,
- Qh.prototype.updateRenderTargetTextureSampleCount = function(e, t) {
- return e && e.texture && e.samples !== t ? (t = Math.min(t, this.getCaps().maxMSAASamples),
- this._textureHelper.createMSAATexture(e.texture, t),
- e._depthStencilTexture && (this._textureHelper.createMSAATexture(e._depthStencilTexture, t),
- e._depthStencilTexture.samples = t),
- e.texture.samples = t,
- t) : t
- }
- ,
- Qh.prototype.createRenderTargetCubeTexture = function(e, t) {
- var i = this._createHardwareRenderTargetWrapper(!1, !0, e)
- , n = V({
- generateMipMaps: !0,
- generateDepthBuffer: !0,
- generateStencilBuffer: !1,
- type: a.TEXTURETYPE_UNSIGNED_INT,
- samplingMode: a.TEXTURE_TRILINEAR_SAMPLINGMODE,
- format: a.TEXTUREFORMAT_RGBA,
- samples: 1
- }, t);
- n.generateStencilBuffer = n.generateDepthBuffer && n.generateStencilBuffer,
- i._generateDepthBuffer = n.generateDepthBuffer,
- i._generateStencilBuffer = n.generateStencilBuffer;
- var r = new Lt(this,At.RenderTarget);
- return r.width = e,
- r.height = e,
- r.depth = 0,
- r.isReady = !0,
- r.isCube = !0,
- r.samples = n.samples,
- r.generateMipMaps = n.generateMipMaps,
- r.samplingMode = n.samplingMode,
- r.type = n.type,
- r.format = n.format,
- this._internalTexturesCache.push(r),
- i.setTextures(r),
- (i._generateDepthBuffer || i._generateStencilBuffer) && i.createDepthStencilTexture(0, void 0 === n.samplingMode || n.samplingMode === a.TEXTURE_BILINEAR_SAMPLINGMODE || n.samplingMode === a.TEXTURE_LINEAR_LINEAR || n.samplingMode === a.TEXTURE_TRILINEAR_SAMPLINGMODE || n.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPLINEAR || n.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPNEAREST || n.samplingMode === a.TEXTURE_NEAREST_LINEAR_MIPLINEAR || n.samplingMode === a.TEXTURE_NEAREST_LINEAR || n.samplingMode === a.TEXTURE_LINEAR_LINEAR_MIPNEAREST, i._generateStencilBuffer, i.samples),
- t && t.createMipMaps && !n.generateMipMaps && (r.generateMipMaps = !0),
- this._textureHelper.createGPUTextureForInternalTexture(r),
- t && t.createMipMaps && !n.generateMipMaps && (r.generateMipMaps = !1),
- i
- }
- ,
- Mt.prototype.setTextureSampler = function(e, t) {
- this._engine.setTextureSampler(e, t)
- }
- ,
- Qh.prototype.setTextureSampler = function(e, t) {
- var i;
- null === (i = this._currentMaterialContext) || void 0 === i || i.setSampler(e, t)
- }
- ,
- Mt.prototype.setStorageBuffer = function(e, t) {
- this._engine.setStorageBuffer(e, t)
- }
- ,
- Qh.prototype.createStorageBuffer = function(e, t) {
- return this._createBuffer(e, t | a.BUFFER_CREATIONFLAG_STORAGE)
- }
- ,
- Qh.prototype.updateStorageBuffer = function(e, t, i, n) {
- var r, o = e;
- void 0 === i && (i = 0),
- void 0 === n ? n = (r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t).byteLength : r = t instanceof Array ? new Float32Array(t) : t instanceof ArrayBuffer ? new Uint8Array(t) : t,
- this._bufferManager.setSubData(o, i, r, 0, n)
- }
- ,
- Qh.prototype.readFromStorageBuffer = function(e, t, i, n) {
- var r = this;
- i = i || e.capacity;
- var o = this._bufferManager.createRawBuffer(i, fu.MapRead | fu.CopyDst);
- return this._renderTargetEncoder.copyBufferToBuffer(e.underlyingResource, null != t ? t : 0, o, 0, i),
- new Promise((function(e, t) {
- r.onEndFrameObservable.addOnce((function() {
- o.mapAsync(_u.Read, 0, i).then((function() {
- var t = o.getMappedRange(0, i)
- , a = n;
- if (void 0 === a)
- (a = new Uint8Array(i)).set(new Uint8Array(t));
- else {
- var s = a.constructor;
- (a = new s(a.buffer)).set(new s(t))
- }
- o.unmap(),
- r._bufferManager.releaseBuffer(o),
- e(a)
- }
- ), (function(e) {
- return t(e)
- }
- ))
- }
- ))
- }
- ))
- }
- ,
- Qh.prototype.setStorageBuffer = function(e, t) {
- var i, n;
- null === (i = this._currentDrawContext) || void 0 === i || i.setBuffer(e, null !== (n = null == t ? void 0 : t.getBuffer()) && void 0 !== n ? n : null)
- }
- ,
- Qh.prototype.createUniformBuffer = function(e) {
- var t;
- return t = e instanceof Array ? new Float32Array(e) : e,
- this._bufferManager.createBuffer(t, fu.Uniform | fu.CopyDst)
- }
- ,
- Qh.prototype.createDynamicUniformBuffer = function(e) {
- return this.createUniformBuffer(e)
- }
- ,
- Qh.prototype.updateUniformBuffer = function(e, t, i, n) {
- void 0 === i && (i = 0);
- var r, o = e;
- void 0 === n ? n = (r = t instanceof Float32Array ? t : new Float32Array(t)).byteLength : r = t instanceof Float32Array ? t : new Float32Array(t),
- this._bufferManager.setSubData(o, i, r, 0, n)
- }
- ,
- Qh.prototype.bindUniformBufferBase = function(e, t, i) {
- this._currentDrawContext.setBuffer(i, e)
- }
- ,
- Qh.prototype.bindUniformBlock = function() {}
- ,
- Qh.prototype.updateVideoTexture = function(e, t, i) {
- var n, r = this;
- if (e && !e._isDisabled) {
- void 0 === this._videoTextureSupported && (this._videoTextureSupported = !0);
- var o = e._hardwareTexture;
- (null === (n = e._hardwareTexture) || void 0 === n ? void 0 : n.underlyingResource) || (o = this._textureHelper.createGPUTextureForInternalTexture(e)),
- this.createImageBitmap(t).then((function(t) {
- r._textureHelper.updateTexture(t, e, e.width, e.height, e.depth, o.format, 0, 0, !i, !1, 0, 0),
- e.generateMipMaps && r._generateMipmaps(e, r._uploadEncoder),
- e.isReady = !0
- }
- )).catch((function() {
- e.isReady = !0
- }
- ))
- }
- }
- ;
- var td, id = function() {
- function e() {}
- return e.CreateAsync = function(e, t) {
- return Qh.IsSupportedAsync.then((function(i) {
- return i ? Qh.CreateAsync(e, t) : vr.IsSupported ? new Promise((function(i) {
- i(new vr(e,void 0,t))
- }
- )) : new Promise((function(e) {
- e(new dc(t))
- }
- ))
- }
- ))
- }
- ,
- e
- }(), nd = function() {
- function e() {}
- return e.COPY = 1,
- e.CUT = 2,
- e.PASTE = 3,
- e
- }(), rd = function() {
- function e(e, t) {
- this.type = e,
- this.event = t
- }
- return e.GetTypeFromCharacter = function(e) {
- switch (e) {
- case 67:
- return nd.COPY;
- case 86:
- return nd.PASTE;
- case 88:
- return nd.CUT;
- default:
- return -1
- }
- }
- ,
- e
- }();
- !function(e) {
- e[e.Clean = 0] = "Clean",
- e[e.Stop = 1] = "Stop",
- e[e.Sync = 2] = "Sync",
- e[e.NoSync = 3] = "NoSync"
- }(td || (td = {}));
- var od = function() {
- function e() {}
- return Object.defineProperty(e, "ForceFullSceneLoadingForIncremental", {
- get: function() {
- return dr.ForceFullSceneLoadingForIncremental
- },
- set: function(e) {
- dr.ForceFullSceneLoadingForIncremental = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ShowLoadingScreen", {
- get: function() {
- return dr.ShowLoadingScreen
- },
- set: function(e) {
- dr.ShowLoadingScreen = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "loggingLevel", {
- get: function() {
- return dr.loggingLevel
- },
- set: function(e) {
- dr.loggingLevel = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "CleanBoneMatrixWeights", {
- get: function() {
- return dr.CleanBoneMatrixWeights
- },
- set: function(e) {
- dr.CleanBoneMatrixWeights = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.GetDefaultPlugin = function() {
- return e._RegisteredPlugins[".babylon"]
- }
- ,
- e._GetPluginForExtension = function(t) {
- return e._RegisteredPlugins[t] || (K.Warn("Unable to find a plugin to load " + t + " 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"),
- e.GetDefaultPlugin())
- }
- ,
- e._GetPluginForDirectLoad = function(t) {
- for (var i in e._RegisteredPlugins) {
- var n = e._RegisteredPlugins[i].plugin;
- if (n.canDirectLoad && n.canDirectLoad(t))
- return e._RegisteredPlugins[i]
- }
- return e.GetDefaultPlugin()
- }
- ,
- e._GetPluginForFilename = function(t) {
- var i = t.indexOf("?");
- -1 !== i && (t = t.substring(0, i));
- var n = t.lastIndexOf(".")
- , r = t.substring(n, t.length).toLowerCase();
- return e._GetPluginForExtension(r)
- }
- ,
- e._GetDirectLoad = function(e) {
- return "data:" === e.substr(0, 5) ? e.substr(5) : null
- }
- ,
- e._FormatErrorMessage = function(e, t, i) {
- var n = "Unable to load from " + e.url;
- return t ? n += ": ".concat(t) : i && (n += ": ".concat(i)),
- n
- }
- ,
- e._LoadData = function(t, i, n, r, o, a, s) {
- var l, c = e._GetDirectLoad(t.url), u = s ? e._GetPluginForExtension(s) : c ? e._GetPluginForDirectLoad(t.url) : e._GetPluginForFilename(t.url);
- if (!(l = void 0 !== u.plugin.createPlugin ? u.plugin.createPlugin() : u.plugin))
- 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 (e.OnPluginActivatedObservable.notifyObservers(l),
- c && (l.canDirectLoad && l.canDirectLoad(t.url) || !ri(t.url))) {
- if (l.directLoad) {
- var h = l.directLoad(i, c);
- h.then ? h.then((function(e) {
- n(l, e)
- }
- )).catch((function(e) {
- o("Error in directLoad of _loadData: " + e, e)
- }
- )) : n(l, h)
- } else
- n(l, c);
- return l
- }
- var d = u.isBinary
- , p = function(e, t) {
- i.isDisposed ? o("Scene has been disposed") : n(l, e, t)
- }
- , f = null
- , _ = !1
- , m = l.onDisposeObservable;
- m && m.add((function() {
- _ = !0,
- f && (f.abort(),
- f = null),
- a()
- }
- ));
- var g = function() {
- if (!_) {
- var e = function(e, t) {
- o(null == e ? void 0 : e.statusText, t)
- }
- , n = t.file || t.url;
- f = l.loadFile ? l.loadFile(i, n, p, r, d, e) : i._loadFile(n, p, r, !0, d, e)
- }
- }
- , v = i.getEngine()
- , y = v.enableOfflineSupport;
- if (y) {
- for (var b = !1, T = 0, E = i.disableOfflineSupportExceptionRules; T < E.length; T++)
- if (E[T].test(t.url)) {
- b = !0;
- break
- }
- y = !b
- }
- return y && vr.OfflineProviderFactory ? i.offlineProvider = vr.OfflineProviderFactory(t.url, g, v.disableManifestCheck) : g(),
- l
- }
- ,
- e._GetFileInfo = function(e, t) {
- var i, n, r = null;
- if (t)
- if (t.name) {
- var o = t;
- i = "file:".concat(o.name),
- n = o.name,
- r = o
- } else if ("string" == typeof t && ae(t, "data:"))
- i = t,
- n = "";
- else {
- var a = t;
- if ("/" === a.substr(0, 1))
- return gi.Error("Wrong sceneFilename parameter"),
- null;
- i = e + a,
- n = a
- }
- else
- i = e,
- n = gi.GetFilename(e),
- e = gi.GetFolderPath(e);
- return {
- url: i,
- rootUrl: e,
- name: n,
- file: r
- }
- }
- ,
- e.GetPluginForExtension = function(t) {
- return e._GetPluginForExtension(t).plugin
- }
- ,
- e.IsPluginForExtensionAvailable = function(t) {
- return !!e._RegisteredPlugins[t]
- }
- ,
- e.RegisterPlugin = function(t) {
- if ("string" == typeof t.extensions) {
- var i = t.extensions;
- e._RegisteredPlugins[i.toLowerCase()] = {
- plugin: t,
- isBinary: !1
- }
- } else {
- var n = t.extensions;
- Object.keys(n).forEach((function(i) {
- e._RegisteredPlugins[i.toLowerCase()] = {
- plugin: t,
- isBinary: n[i].isBinary
- }
- }
- ))
- }
- }
- ,
- e.ImportMesh = function(t, i, n, r, o, a, s, l) {
- if (void 0 === n && (n = ""),
- void 0 === r && (r = E.LastCreatedScene),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- !r)
- return K.Error("No scene available to import mesh to"),
- null;
- var c = e._GetFileInfo(i, n);
- if (!c)
- return null;
- var u = {};
- r._addPendingData(u);
- var h = function() {
- r._removePendingData(u)
- }
- , d = function(t, i) {
- var n = e._FormatErrorMessage(c, t, i);
- s ? s(r, n, new ft(n,pt.SceneLoaderError,i)) : K.Error(n),
- h()
- }
- , p = a ? function(e) {
- try {
- a(e)
- } catch (e) {
- d("Error in onProgress callback: " + e, e)
- }
- }
- : void 0
- , f = function(e, t, i, n, a, s, l) {
- if (r.importedMeshesFiles.push(c.url),
- o)
- try {
- o(e, t, i, n, a, s, l)
- } catch (e) {
- d("Error in onSuccess callback: " + e, e)
- }
- r._removePendingData(u)
- };
- return e._LoadData(c, r, (function(e, i, n) {
- if (e.rewriteRootURL && (c.rootUrl = e.rewriteRootURL(c.rootUrl, n)),
- e.importMesh) {
- var o = e
- , a = new Array
- , s = new Array
- , l = new Array;
- if (!o.importMesh(t, r, i, c.rootUrl, a, s, l, d))
- return;
- r.loadingPluginName = e.name,
- f(a, s, l, [], [], [], [])
- } else
- e.importMeshAsync(t, r, i, c.rootUrl, p, c.name).then((function(t) {
- r.loadingPluginName = e.name,
- f(t.meshes, t.particleSystems, t.skeletons, t.animationGroups, t.transformNodes, t.geometries, t.lights)
- }
- )).catch((function(e) {
- d(e.message, e)
- }
- ))
- }
- ), p, d, h, l)
- }
- ,
- e.ImportMeshAsync = function(t, i, n, r, o, a) {
- return void 0 === n && (n = ""),
- void 0 === r && (r = E.LastCreatedScene),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- new Promise((function(s, l) {
- e.ImportMesh(t, i, n, r, (function(e, t, i, n, r, o, a) {
- s({
- meshes: e,
- particleSystems: t,
- skeletons: i,
- animationGroups: n,
- transformNodes: r,
- geometries: o,
- lights: a
- })
- }
- ), o, (function(e, t, i) {
- l(i || new Error(t))
- }
- ), a)
- }
- ))
- }
- ,
- e.Load = function(t, i, n, r, o, a, s) {
- return void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedEngine),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- n ? e.Append(t, i, new mn(n), r, o, a, s) : (gi.Error("No engine available"),
- null)
- }
- ,
- e.LoadAsync = function(t, i, n, r, o) {
- return void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedEngine),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- new Promise((function(a, s) {
- e.Load(t, i, n, (function(e) {
- a(e)
- }
- ), r, (function(e, t, i) {
- s(i || new Error(t))
- }
- ), o)
- }
- ))
- }
- ,
- e.Append = function(t, i, n, r, o, a, s) {
- var l = this;
- if (void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedScene),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- !n)
- return K.Error("No scene available to append to"),
- null;
- var c = e._GetFileInfo(t, i);
- if (!c)
- return null;
- e.ShowLoadingScreen && !this._ShowingLoadingScreen && (this._ShowingLoadingScreen = !0,
- n.getEngine().displayLoadingUI(),
- n.executeWhenReady((function() {
- n.getEngine().hideLoadingUI(),
- l._ShowingLoadingScreen = !1
- }
- )));
- var u = {};
- n._addPendingData(u);
- var h = function() {
- n._removePendingData(u)
- }
- , d = function(t, i) {
- var r = e._FormatErrorMessage(c, t, i);
- a ? a(n, r, new ft(r,pt.SceneLoaderError,i)) : K.Error(r),
- h()
- }
- , p = o ? function(e) {
- try {
- o(e)
- } catch (e) {
- d("Error in onProgress callback", e)
- }
- }
- : void 0
- , f = function() {
- if (r)
- try {
- r(n)
- } catch (e) {
- d("Error in onSuccess callback", e)
- }
- n._removePendingData(u)
- };
- return e._LoadData(c, n, (function(e, t) {
- if (e.load) {
- if (!e.load(n, t, c.rootUrl, d))
- return;
- n.loadingPluginName = e.name,
- f()
- } else
- e.loadAsync(n, t, c.rootUrl, p, c.name).then((function() {
- n.loadingPluginName = e.name,
- f()
- }
- )).catch((function(e) {
- d(e.message, e)
- }
- ))
- }
- ), p, d, h, s)
- }
- ,
- e.AppendAsync = function(t, i, n, r, o) {
- return void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedScene),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- new Promise((function(a, s) {
- e.Append(t, i, n, (function(e) {
- a(e)
- }
- ), r, (function(e, t, i) {
- s(i || new Error(t))
- }
- ), o)
- }
- ))
- }
- ,
- e.LoadAssetContainer = function(t, i, n, r, o, a, s) {
- if (void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedScene),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- !n)
- return K.Error("No scene available to load asset container to"),
- null;
- var l = e._GetFileInfo(t, i);
- if (!l)
- return null;
- var c = {};
- n._addPendingData(c);
- var u = function() {
- n._removePendingData(c)
- }
- , h = function(t, i) {
- var r = e._FormatErrorMessage(l, t, i);
- a ? a(n, r, new ft(r,pt.SceneLoaderError,i)) : K.Error(r),
- u()
- }
- , d = o ? function(e) {
- try {
- o(e)
- } catch (e) {
- h("Error in onProgress callback", e)
- }
- }
- : void 0
- , p = function(e) {
- if (r)
- try {
- r(e)
- } catch (e) {
- h("Error in onSuccess callback", e)
- }
- n._removePendingData(c)
- };
- return e._LoadData(l, n, (function(e, t) {
- if (e.loadAssetContainer) {
- var i = e.loadAssetContainer(n, t, l.rootUrl, h);
- if (!i)
- return;
- n.loadingPluginName = e.name,
- p(i)
- } else
- e.loadAssetContainerAsync ? e.loadAssetContainerAsync(n, t, l.rootUrl, d, l.name).then((function(t) {
- n.loadingPluginName = e.name,
- p(t)
- }
- )).catch((function(e) {
- h(e.message, e)
- }
- )) : h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")
- }
- ), d, h, u, s)
- }
- ,
- e.LoadAssetContainerAsync = function(t, i, n, r, o) {
- return void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedScene),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- new Promise((function(a, s) {
- e.LoadAssetContainer(t, i, n, (function(e) {
- a(e)
- }
- ), r, (function(e, t, i) {
- s(i || new Error(t))
- }
- ), o)
- }
- ))
- }
- ,
- e.ImportAnimations = function(e, t, i, n, r, o, a, s, l, c) {
- if (void 0 === t && (t = ""),
- void 0 === i && (i = E.LastCreatedScene),
- void 0 === n && (n = !0),
- void 0 === r && (r = td.Clean),
- void 0 === o && (o = null),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- i) {
- if (n) {
- for (var u = 0, h = i.animatables; u < h.length; u++)
- h[u].reset();
- i.stopAllAnimations(),
- i.animationGroups.slice().forEach((function(e) {
- e.dispose()
- }
- )),
- i.getNodes().forEach((function(e) {
- e.animations && (e.animations = [])
- }
- ))
- } else
- switch (r) {
- case td.Clean:
- i.animationGroups.slice().forEach((function(e) {
- e.dispose()
- }
- ));
- break;
- case td.Stop:
- i.animationGroups.forEach((function(e) {
- e.stop()
- }
- ));
- break;
- case td.Sync:
- i.animationGroups.forEach((function(e) {
- e.reset(),
- e.restart()
- }
- ));
- break;
- case td.NoSync:
- break;
- default:
- return void K.Error("Unknown animation group loading mode value '" + r + "'")
- }
- var d = i.animatables.length;
- this.LoadAssetContainer(e, t, i, (function(e) {
- e.mergeAnimationsTo(i, i.animatables.slice(d), o),
- e.dispose(),
- i.onAnimationFileImportedObservable.notifyObservers(i),
- a && a(i)
- }
- ), s, l, c)
- } else
- K.Error("No scene available to load animations to")
- }
- ,
- e.ImportAnimationsAsync = function(t, i, n, r, o, a, s, l, c, u) {
- return void 0 === i && (i = ""),
- void 0 === n && (n = E.LastCreatedScene),
- void 0 === r && (r = !0),
- void 0 === o && (o = td.Clean),
- void 0 === a && (a = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- void 0 === u && (u = null),
- new Promise((function(s, c) {
- e.ImportAnimations(t, i, n, r, o, a, (function(e) {
- s(e)
- }
- ), l, (function(e, t, i) {
- c(i || new Error(t))
- }
- ), u)
- }
- ))
- }
- ,
- e.NO_LOGGING = a.SCENELOADER_NO_LOGGING,
- e.MINIMAL_LOGGING = a.SCENELOADER_MINIMAL_LOGGING,
- e.SUMMARY_LOGGING = a.SCENELOADER_SUMMARY_LOGGING,
- e.DETAILED_LOGGING = a.SCENELOADER_DETAILED_LOGGING,
- e.OnPluginActivatedObservable = new h,
- e._RegisteredPlugins = {},
- e._ShowingLoadingScreen = !1,
- e
- }()
- , ad = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i.controllerType = ba.DAYDREAM,
- i
- }
- return U(t, e),
- t.prototype.initControllerMesh = function(e, i) {
- var n = this;
- od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
- n._defaultModel = e[1],
- n.attachToMesh(n._defaultModel),
- i && i(n._defaultModel)
- }
- ))
- }
- ,
- t.prototype._handleButtonChange = function(e, t) {
- if (0 === e) {
- var i = this.onTriggerStateChangedObservable;
- i && i.notifyObservers(t)
- } else
- K.Warn("Unrecognized Daydream button index: ".concat(e))
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/",
- t.MODEL_FILENAME = "generic.babylon",
- t.GAMEPAD_ID_PREFIX = "Daydream",
- t
- }(_s);
- xa._ControllerFactories.push({
- canCreate: function(e) {
- return 0 === e.id.indexOf(ad.GAMEPAD_ID_PREFIX)
- },
- create: function(e) {
- return new ad(e)
- }
- });
- var sd = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i._buttonIndexToObservableNameMap = ["onPadStateChangedObservable", "onTriggerStateChangedObservable"],
- i.controllerType = ba.GEAR_VR,
- i._calculatedPosition = new x("left" == i.hand ? -.15 : .15,-.5,.25),
- i._disableTrackPosition(i._calculatedPosition),
- i
- }
- return U(t, e),
- t.prototype.initControllerMesh = function(e, i) {
- var n = this;
- od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(t) {
- var r = new Vr("",e);
- t[1].parent = r,
- t[1].position.z = -.15,
- n._defaultModel = r,
- n.attachToMesh(n._defaultModel),
- i && i(n._defaultModel)
- }
- ))
- }
- ,
- t.prototype._handleButtonChange = function(e, t) {
- if (e < this._buttonIndexToObservableNameMap.length) {
- var i = this[this._buttonIndexToObservableNameMap[e]];
- i && i.notifyObservers(t)
- }
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/",
- t.MODEL_FILENAME = "generic.babylon",
- t.GAMEPAD_ID_PREFIX = "Gear VR",
- t
- }(_s);
- xa._ControllerFactories.push({
- canCreate: function(e) {
- return 0 === e.id.indexOf(sd.GAMEPAD_ID_PREFIX) || -1 !== e.id.indexOf("Oculus Go") || -1 !== e.id.indexOf("Vive Focus")
- },
- create: function(e) {
- return new sd(e)
- }
- });
- var ld = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- t.prototype.initControllerMesh = function(e, i) {
- var n = this;
- od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
- n._defaultModel = e[1],
- n.attachToMesh(n._defaultModel),
- i && i(n._defaultModel)
- }
- ))
- }
- ,
- t.prototype._handleButtonChange = function(e, t) {
- console.log("Button id: " + e + "state: "),
- console.dir(t)
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/generic/",
- t.MODEL_FILENAME = "generic.babylon",
- t
- }(_s);
- xa._DefaultControllerFactory = function(e) {
- return new ld(e)
- }
- ;
- var cd = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i.onSecondaryTriggerStateChangedObservable = new h,
- i.onThumbRestChangedObservable = new h,
- i.controllerType = ba.OCULUS,
- i
- }
- return U(t, e),
- t.prototype.initControllerMesh = function(e, i) {
- var n, r = this;
- n = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
- od.ImportMesh("", t._IsQuest ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL, n, e, (function(e) {
- r._defaultModel = t._IsQuest ? e[0] : e[1],
- r.attachToMesh(r._defaultModel),
- i && i(r._defaultModel)
- }
- ))
- }
- ,
- Object.defineProperty(t.prototype, "onAButtonStateChangedObservable", {
- get: function() {
- if ("right" === this.hand)
- return this.onMainButtonStateChangedObservable;
- throw new Error("No A button on left hand")
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onBButtonStateChangedObservable", {
- get: function() {
- if ("right" === this.hand)
- return this.onSecondaryButtonStateChangedObservable;
- throw new Error("No B button on left hand")
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onXButtonStateChangedObservable", {
- get: function() {
- if ("left" === this.hand)
- return this.onMainButtonStateChangedObservable;
- throw new Error("No X button on right hand")
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onYButtonStateChangedObservable", {
- get: function() {
- if ("left" === this.hand)
- return this.onSecondaryButtonStateChangedObservable;
- throw new Error("No Y button on right hand")
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._handleButtonChange = function(e, i) {
- var n = i
- , r = "right" === this.hand ? -1 : 1;
- switch (e) {
- case 0:
- return void this.onPadStateChangedObservable.notifyObservers(n);
- case 1:
- return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[3].rotation.x = .2 * -n.value,
- this._defaultModel.getChildren()[3].position.y = .005 * -n.value,
- this._defaultModel.getChildren()[3].position.z = .005 * -n.value),
- void this.onTriggerStateChangedObservable.notifyObservers(n);
- case 2:
- return !t._IsQuest && this._defaultModel && (this._defaultModel.getChildren()[4].position.x = r * n.value * .0035),
- void this.onSecondaryTriggerStateChangedObservable.notifyObservers(n);
- case 3:
- return !t._IsQuest && this._defaultModel && (n.pressed ? this._defaultModel.getChildren()[1].position.y = -.001 : this._defaultModel.getChildren()[1].position.y = 0),
- void this.onMainButtonStateChangedObservable.notifyObservers(n);
- case 4:
- return !t._IsQuest && this._defaultModel && (n.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0),
- void this.onSecondaryButtonStateChangedObservable.notifyObservers(n);
- case 5:
- return void this.onThumbRestChangedObservable.notifyObservers(n)
- }
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/",
- t.MODEL_LEFT_FILENAME = "left.babylon",
- t.MODEL_RIGHT_FILENAME = "right.babylon",
- t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/",
- t._IsQuest = !1,
- t
- }(_s);
- xa._ControllerFactories.push({
- canCreate: function(e) {
- return E.LastCreatedEngine && E.LastCreatedEngine._vrDisplay && "Oculus Quest" === E.LastCreatedEngine._vrDisplay.displayName && (cd._IsQuest = !0),
- -1 !== e.id.indexOf("Oculus Touch")
- },
- create: function(e) {
- return new cd(e)
- }
- });
- var ud = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i.controllerType = ba.VIVE,
- i._invertLeftStickY = !0,
- i
- }
- return U(t, e),
- t.prototype.initControllerMesh = function(e, i) {
- var n = this;
- od.ImportMesh("", t.MODEL_BASE_URL, t.MODEL_FILENAME, e, (function(e) {
- n._defaultModel = e[1],
- n.attachToMesh(n._defaultModel),
- i && i(n._defaultModel)
- }
- ))
- }
- ,
- Object.defineProperty(t.prototype, "onLeftButtonStateChangedObservable", {
- get: function() {
- return this.onMainButtonStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onRightButtonStateChangedObservable", {
- get: function() {
- return this.onMainButtonStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", {
- get: function() {
- return this.onSecondaryButtonStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._handleButtonChange = function(e, t) {
- var i = t;
- switch (e) {
- case 0:
- return void this.onPadStateChangedObservable.notifyObservers(i);
- case 1:
- return this._defaultModel && (this._defaultModel.getChildren()[6].rotation.x = .15 * -i.value),
- void this.onTriggerStateChangedObservable.notifyObservers(i);
- case 2:
- return void this.onMainButtonStateChangedObservable.notifyObservers(i);
- case 3:
- return this._defaultModel && (i.pressed ? this._defaultModel.getChildren()[2].position.y = -.001 : this._defaultModel.getChildren()[2].position.y = 0),
- void this.onSecondaryButtonStateChangedObservable.notifyObservers(i)
- }
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/",
- t.MODEL_FILENAME = "wand.babylon",
- t
- }(_s);
- xa._ControllerFactories.push({
- canCreate: function(e) {
- return -1 !== e.id.toLowerCase().indexOf("openvr")
- },
- create: function(e) {
- return new ud(e)
- }
- });
- var hd = function() {
- this.buttonMeshes = {},
- this.axisMeshes = {}
- }
- , dd = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i._mapping = {
- buttons: ["thumbstick", "trigger", "grip", "menu", "trackpad"],
- buttonMeshNames: {
- trigger: "SELECT",
- menu: "MENU",
- grip: "GRASP",
- thumbstick: "THUMBSTICK_PRESS",
- trackpad: "TOUCHPAD_PRESS"
- },
- buttonObservableNames: {
- trigger: "onTriggerStateChangedObservable",
- menu: "onSecondaryButtonStateChangedObservable",
- grip: "onMainButtonStateChangedObservable",
- thumbstick: "onPadStateChangedObservable",
- trackpad: "onTrackpadChangedObservable"
- },
- axisMeshNames: ["THUMBSTICK_X", "THUMBSTICK_Y", "TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y"],
- pointingPoseMeshName: Ra.POINTING_POSE
- },
- i.onTrackpadChangedObservable = new h,
- i.onTrackpadValuesChangedObservable = new h,
- i.trackpad = {
- x: 0,
- y: 0
- },
- i.controllerType = ba.WINDOWS,
- i._loadedMeshInfo = null,
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "onTriggerButtonStateChangedObservable", {
- get: function() {
- return this.onTriggerStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onMenuButtonStateChangedObservable", {
- get: function() {
- return this.onSecondaryButtonStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onGripButtonStateChangedObservable", {
- get: function() {
- return this.onMainButtonStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", {
- get: function() {
- return this.onPadStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onTouchpadButtonStateChangedObservable", {
- get: function() {
- return this.onTrackpadChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "onTouchpadValuesChangedObservable", {
- get: function() {
- return this.onTrackpadValuesChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._updateTrackpad = function() {
- !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.trackpad.x && this.browserGamepad.axes[3] == this.trackpad.y || (this.trackpad.x = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")],
- this.trackpad.y = this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")],
- this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad))
- }
- ,
- t.prototype.update = function() {
- if (e.prototype.update.call(this),
- this.browserGamepad.axes && (this._updateTrackpad(),
- this._loadedMeshInfo))
- for (var t = 0; t < this._mapping.axisMeshNames.length; t++)
- this._lerpAxisTransform(t, this.browserGamepad.axes[t])
- }
- ,
- t.prototype._handleButtonChange = function(e, t) {
- var i = this._mapping.buttons[e];
- if (i) {
- this._updateTrackpad();
- var n = this[this._mapping.buttonObservableNames[i]];
- n && n.notifyObservers(t),
- this._lerpButtonTransform(i, t.value)
- }
- }
- ,
- t.prototype._lerpButtonTransform = function(e, t) {
- if (this._loadedMeshInfo) {
- var i = this._loadedMeshInfo.buttonMeshes[e];
- i && i.unpressed.rotationQuaternion && i.pressed.rotationQuaternion && i.value.rotationQuaternion && (C.SlerpToRef(i.unpressed.rotationQuaternion, i.pressed.rotationQuaternion, t, i.value.rotationQuaternion),
- x.LerpToRef(i.unpressed.position, i.pressed.position, t, i.value.position))
- }
- }
- ,
- t.prototype._lerpAxisTransform = function(e, t) {
- if (this._loadedMeshInfo) {
- var i = this._loadedMeshInfo.axisMeshes[e];
- if (i && i.min.rotationQuaternion && i.max.rotationQuaternion && i.value.rotationQuaternion) {
- var n = .5 * t + .5;
- C.SlerpToRef(i.min.rotationQuaternion, i.max.rotationQuaternion, n, i.value.rotationQuaternion),
- x.LerpToRef(i.min.position, i.max.position, n, i.value.position)
- }
- }
- }
- ,
- t.prototype.initControllerMesh = function(e, i, n) {
- var r, o, a = this;
- if (void 0 === n && (n = !1),
- od.IsPluginForExtensionAvailable(".glb")) {
- var s = "default";
- if (this.id && !n) {
- var l = this.id.match(t.GAMEPAD_ID_PATTERN);
- s = l && l[0] || s
- }
- o = "left" === this.hand ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
- r = t.MODEL_BASE_URL + s + "/"
- } else
- K.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),
- r = ld.MODEL_BASE_URL,
- o = ld.MODEL_FILENAME;
- od.ImportMesh("", r, o, e, (function(t) {
- a._loadedMeshInfo = a._processModel(e, t),
- a._loadedMeshInfo && (a._defaultModel = a._loadedMeshInfo.rootNode,
- a.attachToMesh(a._defaultModel),
- i && i(a._defaultModel))
- }
- ), null, (function(e, t) {
- K.Log(t),
- K.Warn("Failed to retrieve controller model from the remote server: " + r + o),
- n || a.initControllerMesh(e, i, !0)
- }
- ))
- }
- ,
- t.prototype._processModel = function(e, t) {
- for (var i = null, n = new Vr(this.id + " " + this.hand,e), r = null, o = 0; o < t.length; o++) {
- var a = t[o];
- if (!a.parent) {
- a.isPickable = !1,
- r = a;
- break
- }
- }
- return r ? (r.setParent(n),
- i = this._createMeshInfo(n)) : K.Warn("Could not find root node in model file."),
- i
- }
- ,
- t.prototype._createMeshInfo = function(e) {
- var t, i = new hd;
- for (i.rootNode = e,
- i.buttonMeshes = {},
- i.axisMeshes = {},
- t = 0; t < this._mapping.buttons.length; t++) {
- var n = this._mapping.buttonMeshNames[this._mapping.buttons[t]];
- if (n) {
- var r = c(e, n);
- if (r) {
- var o = {
- index: t,
- value: u(r, "VALUE"),
- pressed: u(r, "PRESSED"),
- unpressed: u(r, "UNPRESSED")
- };
- o.value && o.pressed && o.unpressed ? i.buttonMeshes[this._mapping.buttons[t]] = o : K.Warn("Missing button submesh under mesh with name: " + n + "(VALUE: " + !!o.value + ", PRESSED: " + !!o.pressed + ", UNPRESSED:" + !!o.unpressed + ")")
- } else
- K.Warn("Missing button mesh with name: " + n)
- } else
- K.Log("Skipping unknown button at index: " + t + " with mapped name: " + this._mapping.buttons[t])
- }
- for (t = 0; t < this._mapping.axisMeshNames.length; t++) {
- var a = this._mapping.axisMeshNames[t];
- if (a) {
- var s = c(e, a);
- if (s) {
- var l = {
- index: t,
- value: u(s, "VALUE"),
- min: u(s, "MIN"),
- max: u(s, "MAX")
- };
- l.value && l.min && l.max ? i.axisMeshes[t] = l : K.Warn("Missing axis submesh under mesh with name: " + a + "(VALUE: " + !!l.value + ", MIN: " + !!l.min + ", MAX:" + !!l.max + ")")
- } else
- K.Warn("Missing axis mesh with name: " + a)
- } else
- K.Log("Skipping unknown axis at index: " + t)
- }
- return i.pointingPoseNode = c(e, this._mapping.pointingPoseMeshName),
- i.pointingPoseNode ? this._pointingPoseNode = i.pointingPoseNode : K.Warn("Missing pointing pose mesh with name: " + this._mapping.pointingPoseMeshName),
- i;
- function c(e, t) {
- return e.getChildren((function(e) {
- return e.name === t
- }
- ), !1)[0]
- }
- function u(e, t) {
- return e.getChildren((function(e) {
- return e.name == t
- }
- ), !0)[0]
- }
- }
- ,
- t.prototype.getForwardRay = function(t) {
- if (void 0 === t && (t = 100),
- !this._loadedMeshInfo || !this._loadedMeshInfo.pointingPoseNode)
- return e.prototype.getForwardRay.call(this, t);
- var i = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix()
- , n = i.getTranslation()
- , r = new x(0,0,-1)
- , o = x.TransformNormal(r, i)
- , a = x.Normalize(o);
- return new _o(n,a,t)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onTrackpadChangedObservable.clear(),
- this.onTrackpadValuesChangedObservable.clear()
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/",
- t.MODEL_LEFT_FILENAME = "left.glb",
- t.MODEL_RIGHT_FILENAME = "right.glb",
- t.GAMEPAD_ID_PREFIX = "Spatial Controller (Spatial Interaction Source) ",
- t.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/,
- t
- }(_s)
- , pd = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i._mapping = {
- buttons: ["trigger", "grip", "trackpad", "thumbstick", "menu"],
- buttonMeshNames: {
- trigger: "SELECT",
- menu: "MENU",
- grip: "GRASP",
- thumbstick: "THUMBSTICK_PRESS",
- trackpad: "TOUCHPAD_PRESS"
- },
- buttonObservableNames: {
- trigger: "onTriggerStateChangedObservable",
- menu: "onSecondaryButtonStateChangedObservable",
- grip: "onMainButtonStateChangedObservable",
- thumbstick: "onThumbstickStateChangedObservable",
- trackpad: "onTrackpadChangedObservable"
- },
- axisMeshNames: ["TOUCHPAD_TOUCH_X", "TOUCHPAD_TOUCH_Y", "THUMBSTICK_X", "THUMBSTICK_Y"],
- pointingPoseMeshName: Ra.POINTING_POSE
- },
- i.thumbstickValues = {
- x: 0,
- y: 0
- },
- i.onThumbstickStateChangedObservable = new h,
- i.onThumbstickValuesChangedObservable = new h,
- i.onTrackpadChangedObservable = i.onPadStateChangedObservable,
- i.onTrackpadValuesChangedObservable = i.onPadValuesChangedObservable,
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "onThumbstickButtonStateChangedObservable", {
- get: function() {
- return this.onThumbstickStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._updateTrackpad = function() {
- !this.browserGamepad.axes || this.browserGamepad.axes[2] == this.thumbstickValues.x && this.browserGamepad.axes[3] == this.thumbstickValues.y || (this.trackpad.x = this.browserGamepad.axes[2],
- this.trackpad.y = this.browserGamepad.axes[3],
- this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad))
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onThumbstickStateChangedObservable.clear(),
- this.onThumbstickValuesChangedObservable.clear()
- }
- ,
- t
- }(dd);
- xa._ControllerFactories.push({
- canCreate: function(e) {
- return 0 === e.id.indexOf(dd.GAMEPAD_ID_PREFIX)
- },
- create: function(e) {
- return new dd(e)
- }
- });
- var fd = function(e) {
- function t(t, i, n, r, o) {
- void 0 === i && (i = D.Gray()),
- void 0 === n && (n = El.DefaultUtilityLayer),
- void 0 === r && (r = null),
- void 0 === o && (o = 1);
- var a, s, l, c, u, d, p, f = this;
- (f = e.call(this, n) || this)._pointerObserver = null,
- f.snapDistance = 0,
- f.onSnapObservable = new h,
- f.uniformScaling = !1,
- f.sensitivity = 1,
- f.dragScale = 1,
- f._isEnabled = !0,
- f._parent = null,
- f._dragging = !1,
- f._tmpVector = new x,
- f._tmpMatrix = new P,
- f._tmpMatrix2 = new P,
- f._parent = r,
- f._coloredMaterial = new Os("",n.utilityLayerScene),
- f._coloredMaterial.diffuseColor = i,
- f._coloredMaterial.specularColor = i.subtract(new D(.1,.1,.1)),
- f._hoverMaterial = new Os("",n.utilityLayerScene),
- f._hoverMaterial.diffuseColor = D.Yellow(),
- f._disableMaterial = new Os("",n.utilityLayerScene),
- f._disableMaterial.diffuseColor = D.Gray(),
- f._disableMaterial.alpha = .4,
- f._gizmoMesh = new Vr("axis",n.utilityLayerScene);
- var _ = f._createGizmoMesh(f._gizmoMesh, o)
- , m = _.arrowMesh
- , g = _.arrowTail
- , v = f._createGizmoMesh(f._gizmoMesh, o + 4, !0);
- f._gizmoMesh.lookAt(f._rootMesh.position.add(t)),
- f._rootMesh.addChild(f._gizmoMesh),
- f._gizmoMesh.scaling.scaleInPlace(1 / 3);
- var y = m.position.clone()
- , b = g.position.clone()
- , T = g.scaling.clone()
- , E = function(e) {
- var t = e * (3 / f._rootMesh.scaling.length()) * 6;
- m.position.z += t / 3.5,
- g.scaling.y += t,
- f.dragScale = g.scaling.y,
- g.position.z = m.position.z / 2
- }
- , S = function() {
- m.position.set(y.x, y.y, y.z),
- g.position.set(b.x, b.y, b.z),
- g.scaling.set(T.x, T.y, T.z),
- f.dragScale = g.scaling.y,
- f._dragging = !1
- };
- f.dragBehavior = new Ao({
- dragAxis: t
- }),
- f.dragBehavior.moveAttached = !1,
- f._rootMesh.addBehavior(f.dragBehavior);
- var A = 0
- , R = new x
- , C = {
- snapDistance: 0
- };
- f.dragBehavior.onDragObservable.add((function(e) {
- if (f.attachedNode) {
- f._handlePivot();
- var i = f.sensitivity * e.dragDistance * (3 * f.scaleRatio / f._rootMesh.scaling.length())
- , n = !1
- , r = 0;
- f.uniformScaling ? R.setAll(.57735) : R.copyFrom(t),
- 0 == f.snapDistance ? R.scaleToRef(i, R) : (A += i,
- Math.abs(A) > f.snapDistance ? (r = Math.floor(Math.abs(A) / f.snapDistance),
- A < 0 && (r *= -1),
- A %= f.snapDistance,
- R.scaleToRef(f.snapDistance * r, R),
- n = !0) : R.scaleInPlace(0)),
- P.ScalingToRef(1 + R.x, 1 + R.y, 1 + R.z, f._tmpMatrix2),
- f._tmpMatrix2.multiplyToRef(f.attachedNode.getWorldMatrix(), f._tmpMatrix),
- f._tmpMatrix.decompose(f._tmpVector);
- var o = 1e5;
- Math.abs(f._tmpVector.x) < o && Math.abs(f._tmpVector.y) < o && Math.abs(f._tmpVector.z) < o && f.attachedNode.getWorldMatrix().copyFrom(f._tmpMatrix),
- n && (C.snapDistance = f.snapDistance * r,
- f.onSnapObservable.notifyObservers(C)),
- f._matrixChanged()
- }
- }
- )),
- f.dragBehavior.onDragStartObservable.add((function() {
- f._dragging = !0
- }
- )),
- f.dragBehavior.onDragObservable.add((function(e) {
- return E(e.dragDistance)
- }
- )),
- f.dragBehavior.onDragEndObservable.add(S),
- null === (l = null === (s = null === (a = null == r ? void 0 : r.uniformScaleGizmo) || void 0 === a ? void 0 : a.dragBehavior) || void 0 === s ? void 0 : s.onDragObservable) || void 0 === l || l.add((function(e) {
- return E(e.delta.y)
- }
- )),
- null === (d = null === (u = null === (c = null == r ? void 0 : r.uniformScaleGizmo) || void 0 === c ? void 0 : c.dragBehavior) || void 0 === u ? void 0 : u.onDragEndObservable) || void 0 === d || d.add(S);
- var M = {
- gizmoMeshes: [m, g],
- colliderMeshes: [v.arrowMesh, v.arrowTail],
- material: f._coloredMaterial,
- hoverMaterial: f._hoverMaterial,
- disableMaterial: f._disableMaterial,
- active: !1,
- dragBehavior: f.dragBehavior
- };
- null === (p = f._parent) || void 0 === p || p.addToAxisCache(f._gizmoMesh, M),
- f._pointerObserver = n.utilityLayerScene.onPointerObservable.add((function(e) {
- var t;
- if (!f._customMeshSet && (f._isHovered = !(-1 == M.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)),
- !f._parent)) {
- var i = f.dragBehavior.enabled ? f._isHovered || f._dragging ? f._hoverMaterial : f._coloredMaterial : f._disableMaterial;
- f._setGizmoMeshMaterial(M.gizmoMeshes, i)
- }
- }
- )),
- f.dragBehavior.onEnabledObservable.add((function(e) {
- f._setGizmoMeshMaterial(M.gizmoMeshes, e ? f._coloredMaterial : f._disableMaterial)
- }
- ));
- var I = n._getSharedGizmoLight();
- return I.includedOnlyMeshes = I.includedOnlyMeshes.concat(f._rootMesh.getChildMeshes()),
- f
- }
- return U(t, e),
- t.prototype._createGizmoMesh = function(e, t, i) {
- void 0 === i && (i = !1);
- var n = Ml("yPosMesh", {
- size: .4 * (1 + (t - 1) / 4)
- }, this.gizmoLayer.utilityLayerScene)
- , r = Ys("cylinder", {
- diameterTop: .005 * t,
- height: .275,
- diameterBottom: .005 * t,
- tessellation: 96
- }, this.gizmoLayer.utilityLayerScene);
- return n.scaling.scaleInPlace(.1),
- n.material = this._coloredMaterial,
- n.rotation.x = Math.PI / 2,
- n.position.z += .3,
- r.material = this._coloredMaterial,
- r.position.z += .1375,
- r.rotation.x = Math.PI / 2,
- i && (n.visibility = 0,
- r.visibility = 0),
- e.addChild(n),
- e.addChild(r),
- {
- arrowMesh: n,
- arrowTail: r
- }
- }
- ,
- t.prototype._attachedNodeChanged = function(e) {
- this.dragBehavior && (this.dragBehavior.enabled = !!e)
- }
- ,
- Object.defineProperty(t.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled = e,
- e ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
- this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
- this.attachedNode = null)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.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(e) {
- e && e.dispose()
- }
- )),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.setCustomMesh = function(t, i) {
- var n = this;
- void 0 === i && (i = !1),
- e.prototype.setCustomMesh.call(this, t),
- i && (this._rootMesh.getChildMeshes().forEach((function(e) {
- e.material = n._coloredMaterial,
- e.color && (e.color = n._coloredMaterial.diffuseColor)
- }
- )),
- this._customMeshSet = !1)
- }
- ,
- t
- }(Sl)
- , _d = function(e) {
- function t(t, i) {
- void 0 === t && (t = D.Gray()),
- void 0 === i && (i = El.DefaultKeepDepthUtilityLayer);
- var n = e.call(this, i) || this;
- n._boundingDimensions = new x(1,1,1),
- n._renderObserver = null,
- n._pointerObserver = null,
- n._scaleDragSpeed = .2,
- n._tmpQuaternion = new C,
- n._tmpVector = new x(0,0,0),
- n._tmpRotationMatrix = new P,
- n.ignoreChildren = !1,
- n.includeChildPredicate = null,
- n.rotationSphereSize = .1,
- n.scaleBoxSize = .1,
- n.fixedDragMeshScreenSize = !1,
- n.fixedDragMeshBoundsSize = !1,
- n.fixedDragMeshScreenSizeDistanceFactor = 10,
- n.onDragStartObservable = new h,
- n.onScaleBoxDragObservable = new h,
- n.onScaleBoxDragEndObservable = new h,
- n.onRotationSphereDragObservable = new h,
- n.onRotationSphereDragEndObservable = new h,
- n.scalePivot = null,
- n._axisFactor = new x(1,1,1),
- n._existingMeshScale = new x,
- n._dragMesh = null,
- n._pointerDragBehavior = new Ao,
- n.updateScale = !1,
- n._anchorMesh = new Sr("anchor",i.utilityLayerScene),
- n._coloredMaterial = new Os("",i.utilityLayerScene),
- n._coloredMaterial.disableLighting = !0,
- n._hoverColoredMaterial = new Os("",i.utilityLayerScene),
- n._hoverColoredMaterial.disableLighting = !0,
- n._lineBoundingBox = new Sr("",i.utilityLayerScene),
- n._lineBoundingBox.rotationQuaternion = new C;
- var r = [];
- r.push(Jl("lines", {
- points: [new x(0,0,0), new x(n._boundingDimensions.x,0,0)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(0,0,0), new x(0,n._boundingDimensions.y,0)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(0,0,0), new x(0,0,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(n._boundingDimensions.x,0,0), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(n._boundingDimensions.x,0,0), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(0,n._boundingDimensions.y,0), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(0,n._boundingDimensions.y,0), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(0,0,n._boundingDimensions.z), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(0,0,n._boundingDimensions.z), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(0,n._boundingDimensions.y,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(n._boundingDimensions.x,0,n._boundingDimensions.z)]
- }, i.utilityLayerScene)),
- r.push(Jl("lines", {
- points: [new x(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z), new x(n._boundingDimensions.x,n._boundingDimensions.y,0)]
- }, i.utilityLayerScene)),
- r.forEach((function(e) {
- e.color = t,
- e.position.addInPlace(new x(-n._boundingDimensions.x / 2,-n._boundingDimensions.y / 2,-n._boundingDimensions.z / 2)),
- e.isPickable = !1,
- n._lineBoundingBox.addChild(e)
- }
- )),
- n._rootMesh.addChild(n._lineBoundingBox),
- n.setColor(t),
- n._rotateSpheresParent = new Sr("",i.utilityLayerScene),
- n._rotateSpheresParent.rotationQuaternion = new C;
- for (var o = function(e) {
- var t = Dl("", {
- diameter: 1
- }, i.utilityLayerScene);
- t.rotationQuaternion = new C,
- t.material = a._coloredMaterial,
- t.isNearGrabbable = !0;
- var r = new Ao({});
- r.moveAttached = !1,
- r.updateDragPlane = !1,
- t.addBehavior(r);
- var o = new x(1,0,0)
- , s = 0;
- r.onDragStartObservable.add((function() {
- o.copyFrom(t.forward),
- s = 0
- }
- )),
- r.onDragObservable.add((function(t) {
- if (n.onRotationSphereDragObservable.notifyObservers({}),
- n.attachedMesh) {
- var i = n.attachedMesh.parent;
- if (i && i.scaling && i.scaling.isNonUniformWithinEpsilon(.001))
- return void K.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
- mo._RemoveAndStorePivotPoint(n.attachedMesh);
- var r = o
- , a = t.dragPlaneNormal.scale(x.Dot(t.dragPlaneNormal, r))
- , l = r.subtract(a).normalizeToNew()
- , c = x.Dot(l, t.delta) < 0 ? Math.abs(t.delta.length()) : -Math.abs(t.delta.length());
- c = c / n._boundingDimensions.length() * n._anchorMesh.scaling.length(),
- n.attachedMesh.rotationQuaternion || (n.attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(n.attachedMesh.rotation.y, n.attachedMesh.rotation.x, n.attachedMesh.rotation.z)),
- n._anchorMesh.rotationQuaternion || (n._anchorMesh.rotationQuaternion = C.RotationYawPitchRoll(n._anchorMesh.rotation.y, n._anchorMesh.rotation.x, n._anchorMesh.rotation.z)),
- s += c,
- Math.abs(s) <= 2 * Math.PI && (e >= 8 ? C.RotationYawPitchRollToRef(0, 0, c, n._tmpQuaternion) : e >= 4 ? C.RotationYawPitchRollToRef(c, 0, 0, n._tmpQuaternion) : C.RotationYawPitchRollToRef(0, c, 0, n._tmpQuaternion),
- n._anchorMesh.addChild(n.attachedMesh),
- n._anchorMesh.rotationQuaternion.multiplyToRef(n._tmpQuaternion, n._anchorMesh.rotationQuaternion),
- n._anchorMesh.removeChild(n.attachedMesh),
- n.attachedMesh.setParent(i)),
- n.updateBoundingBox(),
- mo._RestorePivotPoint(n.attachedMesh)
- }
- n._updateDummy()
- }
- )),
- r.onDragStartObservable.add((function() {
- n.onDragStartObservable.notifyObservers({}),
- n._selectNode(t)
- }
- )),
- r.onDragEndObservable.add((function() {
- n.onRotationSphereDragEndObservable.notifyObservers({}),
- n._selectNode(null),
- n._updateDummy()
- }
- )),
- a._rotateSpheresParent.addChild(t)
- }, a = this, s = 0; s < 12; s++)
- o(s);
- for (n._rootMesh.addChild(n._rotateSpheresParent),
- n._scaleBoxesParent = new Sr("",i.utilityLayerScene),
- n._scaleBoxesParent.rotationQuaternion = new C,
- s = 0; s < 3; s++)
- for (var l = 0; l < 3; l++)
- for (var c = function(e) {
- var t = (1 === s ? 1 : 0) + (1 === l ? 1 : 0) + (1 === e ? 1 : 0);
- if (1 === t || 3 === t)
- return "continue";
- var r = Ml("", {
- size: 1
- }, i.utilityLayerScene);
- r.material = u._coloredMaterial,
- r.metadata = 2 === t,
- r.isNearGrabbable = !0;
- var o = new x(s - 1,l - 1,e - 1).normalize()
- , a = new Ao({
- dragAxis: o
- });
- a.updateDragPlane = !1,
- a.moveAttached = !1,
- r.addBehavior(a),
- a.onDragObservable.add((function(e) {
- if (n.onScaleBoxDragObservable.notifyObservers({}),
- n.attachedMesh) {
- var i = n.attachedMesh.parent;
- if (i && i.scaling && i.scaling.isNonUniformWithinEpsilon(.001))
- return void K.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
- mo._RemoveAndStorePivotPoint(n.attachedMesh);
- var a = e.dragDistance / n._boundingDimensions.length() * n._anchorMesh.scaling.length()
- , s = new x(a,a,a);
- 2 === t && (s.x *= Math.abs(o.x),
- s.y *= Math.abs(o.y),
- s.z *= Math.abs(o.z)),
- s.scaleInPlace(n._scaleDragSpeed),
- s.multiplyInPlace(n._axisFactor),
- n.updateBoundingBox(),
- n.scalePivot ? (n.attachedMesh.getWorldMatrix().getRotationMatrixToRef(n._tmpRotationMatrix),
- n._boundingDimensions.scaleToRef(.5, n._tmpVector),
- x.TransformCoordinatesToRef(n._tmpVector, n._tmpRotationMatrix, n._tmpVector),
- n._anchorMesh.position.subtractInPlace(n._tmpVector),
- n._boundingDimensions.multiplyToRef(n.scalePivot, n._tmpVector),
- x.TransformCoordinatesToRef(n._tmpVector, n._tmpRotationMatrix, n._tmpVector),
- n._anchorMesh.position.addInPlace(n._tmpVector)) : (r.absolutePosition.subtractToRef(n._anchorMesh.position, n._tmpVector),
- n._anchorMesh.position.subtractInPlace(n._tmpVector)),
- n._anchorMesh.addChild(n.attachedMesh),
- n._anchorMesh.scaling.addInPlace(s),
- (n._anchorMesh.scaling.x < 0 || n._anchorMesh.scaling.y < 0 || n._anchorMesh.scaling.z < 0) && n._anchorMesh.scaling.subtractInPlace(s),
- n._anchorMesh.removeChild(n.attachedMesh),
- n.attachedMesh.setParent(i),
- mo._RestorePivotPoint(n.attachedMesh)
- }
- n._updateDummy()
- }
- )),
- a.onDragStartObservable.add((function() {
- n.onDragStartObservable.notifyObservers({}),
- n._selectNode(r)
- }
- )),
- a.onDragEndObservable.add((function() {
- n.onScaleBoxDragEndObservable.notifyObservers({}),
- n._selectNode(null),
- n._updateDummy()
- }
- )),
- u._scaleBoxesParent.addChild(r)
- }, u = this, d = 0; d < 3; d++)
- c(d);
- n._rootMesh.addChild(n._scaleBoxesParent);
- var p = new Array;
- return n._pointerObserver = i.utilityLayerScene.onPointerObservable.add((function(e) {
- p[e.event.pointerId] ? e.pickInfo && e.pickInfo.pickedMesh != p[e.event.pointerId] && (p[e.event.pointerId].material = n._coloredMaterial,
- delete p[e.event.pointerId]) : n._rotateSpheresParent.getChildMeshes().concat(n._scaleBoxesParent.getChildMeshes()).forEach((function(t) {
- e.pickInfo && e.pickInfo.pickedMesh == t && (p[e.event.pointerId] = t,
- t.material = n._hoverColoredMaterial)
- }
- ))
- }
- )),
- n._renderObserver = n.gizmoLayer.originalScene.onBeforeRenderObservable.add((function() {
- n.attachedMesh && !n._existingMeshScale.equals(n.attachedMesh.scaling) ? n.updateBoundingBox() : (n.fixedDragMeshScreenSize || n.fixedDragMeshBoundsSize) && (n._updateRotationSpheres(),
- n._updateScaleBoxes()),
- n._dragMesh && n.attachedMesh && n._pointerDragBehavior.dragging && (n._lineBoundingBox.position.rotateByQuaternionToRef(n._rootMesh.rotationQuaternion, n._tmpVector),
- n.attachedMesh.setAbsolutePosition(n._dragMesh.position.add(n._tmpVector.scale(-1))))
- }
- )),
- n.updateBoundingBox(),
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "axisFactor", {
- get: function() {
- return this._axisFactor
- },
- set: function(e) {
- this._axisFactor = e;
- for (var t = this._scaleBoxesParent.getChildMeshes(), i = 0, n = 0; n < 3; n++)
- for (var r = 0; r < 3; r++)
- for (var o = 0; o < 3; o++) {
- var a = (1 === n ? 1 : 0) + (1 === r ? 1 : 0) + (1 === o ? 1 : 0);
- if (1 !== a && 3 !== a) {
- if (t[i]) {
- var s = new x(n - 1,r - 1,o - 1);
- s.multiplyInPlace(this._axisFactor),
- t[i].setEnabled(s.lengthSquared() > m)
- }
- i++
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scaleDragSpeed", {
- get: function() {
- return this._scaleDragSpeed
- },
- set: function(e) {
- this._scaleDragSpeed = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setColor = function(e) {
- this._coloredMaterial.emissiveColor = e,
- this._hoverColoredMaterial.emissiveColor = e.clone().add(new D(.3,.3,.3)),
- this._lineBoundingBox.getChildren().forEach((function(t) {
- t.color && (t.color = e)
- }
- ))
- }
- ,
- t.prototype._attachedNodeChanged = function(e) {
- var t = this;
- if (e) {
- this._anchorMesh.scaling.setAll(1),
- mo._RemoveAndStorePivotPoint(e);
- var i = e.parent;
- this._anchorMesh.addChild(e),
- this._anchorMesh.removeChild(e),
- e.setParent(i),
- mo._RestorePivotPoint(e),
- this.updateBoundingBox(),
- e.getChildMeshes(!1).forEach((function(e) {
- e.markAsDirty("scaling")
- }
- )),
- this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce((function() {
- t._updateDummy()
- }
- ))
- }
- }
- ,
- t.prototype._selectNode = function(e) {
- this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(t) {
- t.isVisible = !e || t == e
- }
- ))
- }
- ,
- t.prototype.updateBoundingBox = function() {
- if (this.attachedMesh) {
- mo._RemoveAndStorePivotPoint(this.attachedMesh);
- var e = this.attachedMesh.parent;
- this.attachedMesh.setParent(null),
- this._update(),
- this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = C.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)),
- this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = C.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 t = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
- t.max.subtractToRef(t.min, this._boundingDimensions),
- this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),
- this._lineBoundingBox.position.set((t.max.x + t.min.x) / 2, (t.max.y + t.min.y) / 2, (t.max.z + t.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(e)
- }
- this._updateRotationSpheres(),
- this._updateScaleBoxes(),
- this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling),
- mo._RestorePivotPoint(this.attachedMesh))
- }
- ,
- t.prototype._updateRotationSpheres = function() {
- for (var e = this._rotateSpheresParent.getChildMeshes(), t = 0; t < 3; t++)
- for (var i = 0; i < 2; i++)
- for (var n = 0; n < 2; n++) {
- var r = 4 * t + 2 * i + n;
- if (0 == t && (e[r].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * i, this._boundingDimensions.z * n),
- e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Right()).normalizeToNew().add(e[r].position))),
- 1 == t && (e[r].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y / 2, this._boundingDimensions.z * n),
- e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Up()).normalizeToNew().add(e[r].position))),
- 2 == t && (e[r].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * n, this._boundingDimensions.z / 2),
- e[r].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- e[r].lookAt(x.Cross(e[r].position.normalizeToNew(), x.Forward()).normalizeToNew().add(e[r].position))),
- this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
- e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
- var o = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
- e[r].scaling.set(o, o, o)
- } else
- this.fixedDragMeshBoundsSize ? e[r].scaling.set(this.rotationSphereSize * this._boundingDimensions.x, this.rotationSphereSize * this._boundingDimensions.y, this.rotationSphereSize * this._boundingDimensions.z) : e[r].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize)
- }
- }
- ,
- t.prototype._updateScaleBoxes = function() {
- for (var e = this._scaleBoxesParent.getChildMeshes(), t = 0, i = 0; i < 3; i++)
- for (var n = 0; n < 3; n++)
- for (var r = 0; r < 3; r++) {
- var o = (1 === i ? 1 : 0) + (1 === n ? 1 : 0) + (1 === r ? 1 : 0);
- if (1 !== o && 3 !== o) {
- if (e[t])
- if (e[t].position.set(this._boundingDimensions.x * (i / 2), this._boundingDimensions.y * (n / 2), this._boundingDimensions.z * (r / 2)),
- e[t].position.addInPlace(new x(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
- e[t].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
- var a = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
- e[t].scaling.set(a, a, a)
- } else
- this.fixedDragMeshBoundsSize ? e[t].scaling.set(this.scaleBoxSize * this._boundingDimensions.x, this.scaleBoxSize * this._boundingDimensions.y, this.scaleBoxSize * this._boundingDimensions.z) : e[t].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
- t++
- }
- }
- }
- ,
- t.prototype.setEnabledRotationAxis = function(e) {
- this._rotateSpheresParent.getChildMeshes().forEach((function(t, i) {
- i < 4 ? t.setEnabled(-1 != e.indexOf("x")) : i < 8 ? t.setEnabled(-1 != e.indexOf("y")) : t.setEnabled(-1 != e.indexOf("z"))
- }
- ))
- }
- ,
- t.prototype.setEnabledScaling = function(e, t) {
- void 0 === t && (t = !1),
- this._scaleBoxesParent.getChildMeshes().forEach((function(i) {
- var n = e;
- t && !0 === i.metadata && (n = !1),
- i.setEnabled(n)
- }
- ))
- }
- ,
- t.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))
- }
- ,
- t.prototype.enableDragBehavior = function() {
- this._dragMesh = Ml("dummy", {
- size: 1
- }, this.gizmoLayer.utilityLayerScene),
- this._dragMesh.visibility = 0,
- this._dragMesh.rotationQuaternion = new C,
- this._pointerDragBehavior.useObjectOrientationForDragging = !1,
- this._dragMesh.addBehavior(this._pointerDragBehavior)
- }
- ,
- t.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(),
- e.prototype.dispose.call(this)
- }
- ,
- t.MakeNotPickableAndWrapInBoundingBox = function(e) {
- var t = function(e) {
- e.isPickable = !1,
- e.getChildMeshes().forEach((function(e) {
- t(e)
- }
- ))
- };
- t(e),
- e.rotationQuaternion || (e.rotationQuaternion = C.RotationYawPitchRoll(e.rotation.y, e.rotation.x, e.rotation.z));
- var i = e.position.clone()
- , n = e.rotationQuaternion.clone();
- e.rotationQuaternion.set(0, 0, 0, 1),
- e.position.set(0, 0, 0);
- var r = Ml("box", {
- size: 1
- }, e.getScene())
- , o = e.getHierarchyBoundingVectors();
- return o.max.subtractToRef(o.min, r.scaling),
- 0 === r.scaling.y && (r.scaling.y = m),
- 0 === r.scaling.x && (r.scaling.x = m),
- 0 === r.scaling.z && (r.scaling.z = m),
- r.position.set((o.max.x + o.min.x) / 2, (o.max.y + o.min.y) / 2, (o.max.z + o.min.z) / 2),
- e.addChild(r),
- e.rotationQuaternion.copyFrom(n),
- e.position.copyFrom(i),
- e.removeChild(r),
- r.addChild(e),
- r.visibility = 0,
- r
- }
- ,
- t.prototype.setCustomMesh = function() {
- K.Error("Custom meshes are not supported on this gizmo")
- }
- ,
- t
- }(Sl)
- , md = function(e) {
- function t(i, n, r, o, a, s, l) {
- void 0 === n && (n = D.Gray()),
- void 0 === r && (r = El.DefaultUtilityLayer),
- void 0 === o && (o = 32),
- void 0 === a && (a = null),
- void 0 === s && (s = !1),
- void 0 === l && (l = 1);
- var c, u = this;
- (u = e.call(this, r) || this)._pointerObserver = null,
- u.snapDistance = 0,
- u.onSnapObservable = new h,
- u.angle = 0,
- u._isEnabled = !0,
- u._parent = null,
- u._dragging = !1,
- u._angles = new x,
- u._parent = a,
- u._coloredMaterial = new Os("",r.utilityLayerScene),
- u._coloredMaterial.diffuseColor = n,
- u._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
- u._hoverMaterial = new Os("",r.utilityLayerScene),
- u._hoverMaterial.diffuseColor = D.Yellow(),
- u._disableMaterial = new Os("",r.utilityLayerScene),
- u._disableMaterial.diffuseColor = D.Gray(),
- u._disableMaterial.alpha = .4,
- u._gizmoMesh = new Vr("",r.utilityLayerScene);
- var d = u._createGizmoMesh(u._gizmoMesh, l, o)
- , p = d.rotationMesh
- , f = d.collider;
- u._rotationDisplayPlane = vo("rotationDisplay", {
- size: .6,
- updatable: !1
- }, u.gizmoLayer.utilityLayerScene),
- u._rotationDisplayPlane.rotation.z = .5 * Math.PI,
- u._rotationDisplayPlane.parent = u._gizmoMesh,
- u._rotationDisplayPlane.setEnabled(!1),
- Mt.ShadersStore.rotationGizmoVertexShader = t._RotationGizmoVertexShader,
- Mt.ShadersStore.rotationGizmoFragmentShader = t._RotationGizmoFragmentShader,
- u._rotationShaderMaterial = new jl("shader",u.gizmoLayer.utilityLayerScene,{
- vertex: "rotationGizmo",
- fragment: "rotationGizmo"
- },{
- attributes: ["position", "uv"],
- uniforms: ["worldViewProjection", "angles"]
- }),
- u._rotationShaderMaterial.backFaceCulling = !1,
- u._rotationDisplayPlane.material = u._rotationShaderMaterial,
- u._rotationDisplayPlane.visibility = .999,
- u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),
- u._rootMesh.addChild(u._gizmoMesh),
- u._gizmoMesh.scaling.scaleInPlace(1 / 3),
- u.dragBehavior = new Ao({
- dragPlaneNormal: i
- }),
- u.dragBehavior.moveAttached = !1,
- u.dragBehavior.maxDragAngle = t.MaxDragAngle,
- u.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0,
- u._rootMesh.addBehavior(u.dragBehavior);
- var _ = new x
- , m = new P
- , g = new x
- , v = new x;
- u.dragBehavior.onDragStartObservable.add((function(e) {
- u.attachedNode && (_.copyFrom(e.dragPlanePoint),
- u._rotationDisplayPlane.setEnabled(!0),
- u._rotationDisplayPlane.getWorldMatrix().invertToRef(m),
- x.TransformCoordinatesToRef(e.dragPlanePoint, m, _),
- u._angles.x = Math.atan2(_.y, _.x) + Math.PI,
- u._angles.y = 0,
- u._angles.z = u.updateGizmoRotationToMatchAttachedMesh ? 1 : 0,
- u._dragging = !0,
- _.copyFrom(e.dragPlanePoint),
- u._rotationShaderMaterial.setVector3("angles", u._angles),
- u.angle = 0)
- }
- )),
- u.dragBehavior.onDragEndObservable.add((function() {
- u._dragging = !1,
- u._rotationDisplayPlane.setEnabled(!1)
- }
- ));
- var y = {
- snapDistance: 0
- }
- , b = 0
- , T = new P
- , E = new C;
- u.dragBehavior.onDragObservable.add((function(e) {
- if (u.attachedNode) {
- var t = new x(1,1,1)
- , n = new C(0,0,0,1)
- , o = new x(0,0,0);
- u._handlePivot(),
- u.attachedNode.getWorldMatrix().decompose(t, n, o);
- var a = e.dragPlanePoint.subtract(o).normalize()
- , s = _.subtract(o).normalize()
- , l = x.Cross(a, s)
- , c = x.Dot(a, s)
- , h = Math.atan2(l.length(), c);
- g.copyFrom(i),
- v.copyFrom(i),
- u.updateGizmoRotationToMatchAttachedMesh && (n.toRotationMatrix(m),
- v = x.TransformCoordinates(g, m));
- var d = !1;
- if (r.utilityLayerScene.activeCamera) {
- var p = r.utilityLayerScene.activeCamera.position.subtract(o).normalize();
- x.Dot(p, v) > 0 && (g.scaleInPlace(-1),
- v.scaleInPlace(-1),
- d = !0)
- }
- x.Dot(v, l) > 0 && (h = -h);
- var f = !1;
- if (0 != u.snapDistance)
- if (b += h,
- Math.abs(b) > u.snapDistance) {
- var S = Math.floor(Math.abs(b) / u.snapDistance);
- b < 0 && (S *= -1),
- b %= u.snapDistance,
- h = u.snapDistance * S,
- f = !0
- } else
- h = 0;
- var A = Math.sin(h / 2);
- if (E.set(g.x * A, g.y * A, g.z * A, Math.cos(h / 2)),
- T.determinant() > 0) {
- var R = new x;
- E.toEulerAnglesToRef(R),
- C.RotationYawPitchRollToRef(R.y, -R.x, -R.z, E)
- }
- u.updateGizmoRotationToMatchAttachedMesh ? n.multiplyToRef(E, n) : E.multiplyToRef(n, n),
- u.attachedNode.getWorldMatrix().copyFrom(P.Compose(t, n, o)),
- _.copyFrom(e.dragPlanePoint),
- f && (y.snapDistance = h,
- u.onSnapObservable.notifyObservers(y)),
- u._angles.y += h,
- u.angle += d ? -h : h,
- u._rotationShaderMaterial.setVector3("angles", u._angles),
- u._matrixChanged()
- }
- }
- ));
- var S = r._getSharedGizmoLight();
- S.includedOnlyMeshes = S.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));
- var A = {
- colliderMeshes: [f],
- gizmoMeshes: [p],
- material: u._coloredMaterial,
- hoverMaterial: u._hoverMaterial,
- disableMaterial: u._disableMaterial,
- active: !1,
- dragBehavior: u.dragBehavior
- };
- return null === (c = u._parent) || void 0 === c || c.addToAxisCache(u._gizmoMesh, A),
- u._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
- var i;
- if (!u._customMeshSet && (u.dragBehavior.maxDragAngle = t.MaxDragAngle,
- u._isHovered = !(-1 == A.colliderMeshes.indexOf(null === (i = null == e ? void 0 : e.pickInfo) || void 0 === i ? void 0 : i.pickedMesh)),
- !u._parent)) {
- var n = A.dragBehavior.enabled ? u._isHovered || u._dragging ? u._hoverMaterial : u._coloredMaterial : u._disableMaterial;
- u._setGizmoMeshMaterial(A.gizmoMeshes, n)
- }
- }
- )),
- u.dragBehavior.onEnabledObservable.add((function(e) {
- u._setGizmoMeshMaterial(A.gizmoMeshes, e ? u._coloredMaterial : u._disableMaterial)
- }
- )),
- u
- }
- return U(t, e),
- t.prototype._createGizmoMesh = function(e, t, i) {
- var n = qs("ignore", {
- diameter: .6,
- thickness: .03 * t,
- tessellation: i
- }, this.gizmoLayer.utilityLayerScene);
- n.visibility = 0;
- var r = qs("", {
- diameter: .6,
- thickness: .005 * t,
- tessellation: i
- }, this.gizmoLayer.utilityLayerScene);
- return r.material = this._coloredMaterial,
- r.rotation.x = Math.PI / 2,
- n.rotation.x = Math.PI / 2,
- e.addChild(r),
- e.addChild(n),
- {
- rotationMesh: r,
- collider: n
- }
- }
- ,
- t.prototype._attachedNodeChanged = function(e) {
- this.dragBehavior && (this.dragBehavior.enabled = !!e)
- }
- ,
- Object.defineProperty(t.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled = e,
- e ? this._parent && (this.attachedMesh = this._parent.attachedMesh) : this.attachedMesh = null
- },
- enumerable: !1,
- configurable: !0
- }),
- t.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(e) {
- e && e.dispose()
- }
- )),
- e.prototype.dispose.call(this)
- }
- ,
- t.MaxDragAngle = 9 * Math.PI / 20,
- t._RotationGizmoVertexShader = "\n precision highp float;\n attribute vec3 position;\n attribute vec2 uv;\n uniform mat4 worldViewProjection;\n varying vec3 vPosition;\n varying vec2 vUV;\n void main(void) {\n gl_Position = worldViewProjection * vec4(position, 1.0);\n vUV = uv;\n }",
- t._RotationGizmoFragmentShader = "\n precision highp float;\n varying vec2 vUV;\n varying vec3 vPosition;\n uniform vec3 angles;\n #define twopi 6.283185307\n void main(void) {\n vec2 uv = vUV - vec2(0.5);\n float angle = atan(uv.y, uv.x) + 3.141592;\n float delta = gl_FrontFacing ? angles.y : -angles.y;\n float begin = angles.x - delta * angles.z;\n float start = (begin < (begin + delta)) ? begin : (begin + delta);\n float end = (begin > (begin + delta)) ? begin : (begin + delta);\n float len = sqrt(dot(uv,uv));\n float opacity = 1. - step(0.5, len);\n\n float base = abs(floor(start / twopi)) * twopi;\n start += base;\n end += base;\n\n float intensity = 0.;\n for (int i = 0; i < 5; i++)\n {\n intensity += max(step(start, angle) - step(end, angle), 0.);\n angle += twopi;\n }\n gl_FragColor = vec4(1.,1.,0., min(intensity * 0.25, 0.8)) * opacity;\n }",
- t
- }(Sl)
- , gd = function(e) {
- function t(t, i, n, r, o, a) {
- void 0 === t && (t = El.DefaultUtilityLayer),
- void 0 === i && (i = 32),
- void 0 === n && (n = !1),
- void 0 === r && (r = 1);
- var s = e.call(this, t) || this;
- s.onDragStartObservable = new h,
- s.onDragEndObservable = new h,
- s._observables = [],
- s._gizmoAxisCache = new Map;
- var l = a && a.xOptions && a.xOptions.color ? a.xOptions.color : D.Red().scale(.5)
- , c = a && a.yOptions && a.yOptions.color ? a.yOptions.color : D.Green().scale(.5)
- , u = a && a.zOptions && a.zOptions.color ? a.zOptions.color : D.Blue().scale(.5);
- return s.xGizmo = new md(new x(1,0,0),l,t,i,s,n,r),
- s.yGizmo = new md(new x(0,1,0),c,t,i,s,n,r),
- s.zGizmo = new md(new x(0,0,1),u,t,i,s,n,r),
- [s.xGizmo, s.yGizmo, s.zGizmo].forEach((function(e) {
- a && null != a.updateScale && (e.updateScale = a.updateScale),
- e.dragBehavior.onDragStartObservable.add((function() {
- s.onDragStartObservable.notifyObservers({})
- }
- )),
- e.dragBehavior.onDragEndObservable.add((function() {
- s.onDragEndObservable.notifyObservers({})
- }
- ))
- }
- )),
- s.attachedMesh = null,
- s.attachedNode = null,
- o ? o.addToAxisCache(s._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, s._gizmoAxisCache),
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "attachedMesh", {
- get: function() {
- return this._meshAttached
- },
- set: function(e) {
- this._meshAttached = e,
- this._nodeAttached = e,
- this._checkBillboardTransform(),
- [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
- t.isEnabled ? t.attachedMesh = e : t.attachedMesh = null
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "attachedNode", {
- get: function() {
- return this._nodeAttached
- },
- set: function(e) {
- this._meshAttached = null,
- this._nodeAttached = e,
- this._checkBillboardTransform(),
- [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
- t.isEnabled ? t.attachedNode = e : t.attachedNode = null
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._checkBillboardTransform = function() {
- this._nodeAttached && this._nodeAttached.billboardMode && console.log("Rotation Gizmo will not work with transforms in billboard mode.")
- }
- ,
- Object.defineProperty(t.prototype, "isHovered", {
- get: function() {
- var e = !1;
- return [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
- e = e || t.isHovered
- }
- )),
- e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this.xGizmo.updateGizmoRotationToMatchAttachedMesh
- },
- set: function(e) {
- this.xGizmo && (this.xGizmo.updateGizmoRotationToMatchAttachedMesh = e,
- this.yGizmo.updateGizmoRotationToMatchAttachedMesh = e,
- this.zGizmo.updateGizmoRotationToMatchAttachedMesh = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "snapDistance", {
- get: function() {
- return this.xGizmo.snapDistance
- },
- set: function(e) {
- this.xGizmo && (this.xGizmo.snapDistance = e,
- this.yGizmo.snapDistance = e,
- this.zGizmo.snapDistance = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scaleRatio", {
- get: function() {
- return this.xGizmo.scaleRatio
- },
- set: function(e) {
- this.xGizmo && (this.xGizmo.scaleRatio = e,
- this.yGizmo.scaleRatio = e,
- this.zGizmo.scaleRatio = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addToAxisCache = function(e, t) {
- this._gizmoAxisCache.set(e, t)
- }
- ,
- t.prototype.dispose = function() {
- var e = this;
- this.xGizmo.dispose(),
- this.yGizmo.dispose(),
- this.zGizmo.dispose(),
- this.onDragStartObservable.clear(),
- this.onDragEndObservable.clear(),
- this._observables.forEach((function(t) {
- e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)
- }
- ))
- }
- ,
- t.prototype.setCustomMesh = function() {
- K.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)")
- }
- ,
- t
- }(Sl)
- , vd = function(e) {
- function t(i, n, r, o) {
- void 0 === n && (n = D.Gray()),
- void 0 === r && (r = El.DefaultUtilityLayer),
- void 0 === o && (o = null);
- var a, s = this;
- (s = e.call(this, r) || this)._pointerObserver = null,
- s.snapDistance = 0,
- s.onSnapObservable = new h,
- s._isEnabled = !1,
- s._parent = null,
- s._dragging = !1,
- s._parent = o,
- s._coloredMaterial = new Os("",r.utilityLayerScene),
- s._coloredMaterial.diffuseColor = n,
- s._coloredMaterial.specularColor = n.subtract(new D(.1,.1,.1)),
- s._hoverMaterial = new Os("",r.utilityLayerScene),
- s._hoverMaterial.diffuseColor = D.Yellow(),
- s._disableMaterial = new Os("",r.utilityLayerScene),
- s._disableMaterial.diffuseColor = D.Gray(),
- s._disableMaterial.alpha = .4,
- s._gizmoMesh = t._CreatePlane(r.utilityLayerScene, s._coloredMaterial),
- s._gizmoMesh.lookAt(s._rootMesh.position.add(i)),
- s._gizmoMesh.scaling.scaleInPlace(1 / 3),
- s._gizmoMesh.parent = s._rootMesh;
- var l = 0
- , c = new x
- , u = {
- snapDistance: 0
- };
- s.dragBehavior = new Ao({
- dragPlaneNormal: i
- }),
- s.dragBehavior.moveAttached = !1,
- s._rootMesh.addBehavior(s.dragBehavior),
- s.dragBehavior.onDragObservable.add((function(e) {
- if (s.attachedNode) {
- if (s._handlePivot(),
- 0 == s.snapDistance)
- s.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x, e.delta.y, e.delta.z);
- else if (l += e.dragDistance,
- Math.abs(l) > s.snapDistance) {
- var t = Math.floor(Math.abs(l) / s.snapDistance);
- l %= s.snapDistance,
- e.delta.normalizeToRef(c),
- c.scaleInPlace(s.snapDistance * t),
- s.attachedNode.getWorldMatrix().addTranslationFromFloats(c.x, c.y, c.z),
- u.snapDistance = s.snapDistance * t,
- s.onSnapObservable.notifyObservers(u)
- }
- s._matrixChanged()
- }
- }
- )),
- s.dragBehavior.onDragStartObservable.add((function() {
- s._dragging = !0
- }
- )),
- s.dragBehavior.onDragEndObservable.add((function() {
- s._dragging = !1
- }
- ));
- var d = r._getSharedGizmoLight();
- d.includedOnlyMeshes = d.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1));
- var p = {
- gizmoMeshes: s._gizmoMesh.getChildMeshes(),
- colliderMeshes: s._gizmoMesh.getChildMeshes(),
- material: s._coloredMaterial,
- hoverMaterial: s._hoverMaterial,
- disableMaterial: s._disableMaterial,
- active: !1,
- dragBehavior: s.dragBehavior
- };
- return null === (a = s._parent) || void 0 === a || a.addToAxisCache(s._gizmoMesh, p),
- s._pointerObserver = r.utilityLayerScene.onPointerObservable.add((function(e) {
- var t;
- if (!s._customMeshSet && (s._isHovered = !(-1 == p.colliderMeshes.indexOf(null === (t = null == e ? void 0 : e.pickInfo) || void 0 === t ? void 0 : t.pickedMesh)),
- !s._parent)) {
- var i = p.dragBehavior.enabled ? s._isHovered || s._dragging ? s._hoverMaterial : s._coloredMaterial : s._disableMaterial;
- s._setGizmoMeshMaterial(p.gizmoMeshes, i)
- }
- }
- )),
- s.dragBehavior.onEnabledObservable.add((function(e) {
- s._setGizmoMeshMaterial(p.gizmoMeshes, e ? s._coloredMaterial : s._disableMaterial)
- }
- )),
- s
- }
- return U(t, e),
- t._CreatePlane = function(e, t) {
- var i = new yr("plane",e)
- , n = vo("dragPlane", {
- width: .1375,
- height: .1375,
- sideOrientation: 2
- }, e);
- return n.material = t,
- n.parent = i,
- i
- }
- ,
- t.prototype._attachedNodeChanged = function(e) {
- this.dragBehavior && (this.dragBehavior.enabled = !!e)
- }
- ,
- Object.defineProperty(t.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled = e,
- e ? this._parent && (this.attachedNode = this._parent.attachedNode) : this.attachedNode = null
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.dispose = function() {
- this.onSnapObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this.dragBehavior.detach(),
- e.prototype.dispose.call(this),
- this._gizmoMesh && this._gizmoMesh.dispose(),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
- e && e.dispose()
- }
- ))
- }
- ,
- t
- }(Sl)
- , yd = function(e) {
- function t(t, i, n) {
- void 0 === t && (t = El.DefaultUtilityLayer),
- void 0 === i && (i = 1);
- var r = e.call(this, t) || this;
- return r._meshAttached = null,
- r._nodeAttached = null,
- r._observables = [],
- r._gizmoAxisCache = new Map,
- r.onDragStartObservable = new h,
- r.onDragEndObservable = new h,
- r._planarGizmoEnabled = !1,
- r.xGizmo = new Al(new x(1,0,0),D.Red().scale(.5),t,r,i),
- r.yGizmo = new Al(new x(0,1,0),D.Green().scale(.5),t,r,i),
- r.zGizmo = new Al(new x(0,0,1),D.Blue().scale(.5),t,r,i),
- r.xPlaneGizmo = new vd(new x(1,0,0),D.Red().scale(.5),r.gizmoLayer,r),
- r.yPlaneGizmo = new vd(new x(0,1,0),D.Green().scale(.5),r.gizmoLayer,r),
- r.zPlaneGizmo = new vd(new x(0,0,1),D.Blue().scale(.5),r.gizmoLayer,r),
- [r.xGizmo, r.yGizmo, r.zGizmo, r.xPlaneGizmo, r.yPlaneGizmo, r.zPlaneGizmo].forEach((function(e) {
- e.dragBehavior.onDragStartObservable.add((function() {
- r.onDragStartObservable.notifyObservers({})
- }
- )),
- e.dragBehavior.onDragEndObservable.add((function() {
- r.onDragEndObservable.notifyObservers({})
- }
- ))
- }
- )),
- r.attachedMesh = null,
- n ? n.addToAxisCache(r._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, r._gizmoAxisCache),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "attachedMesh", {
- get: function() {
- return this._meshAttached
- },
- set: function(e) {
- this._meshAttached = e,
- this._nodeAttached = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
- t.isEnabled ? t.attachedMesh = e : t.attachedMesh = null
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "attachedNode", {
- get: function() {
- return this._nodeAttached
- },
- set: function(e) {
- this._meshAttached = null,
- this._nodeAttached = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
- t.isEnabled ? t.attachedNode = e : t.attachedNode = null
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isHovered", {
- get: function() {
- var e = !1;
- return [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
- e = e || t.isHovered
- }
- )),
- e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "planarGizmoEnabled", {
- get: function() {
- return this._planarGizmoEnabled
- },
- set: function(e) {
- var t = this;
- this._planarGizmoEnabled = e,
- [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(i) {
- i && (i.isEnabled = e,
- e && (i.attachedMesh ? i.attachedMesh = t.attachedMesh : i.attachedNode = t.attachedNode))
- }
- ), this)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this._updateGizmoRotationToMatchAttachedMesh
- },
- set: function(e) {
- this._updateGizmoRotationToMatchAttachedMesh = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
- t && (t.updateGizmoRotationToMatchAttachedMesh = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "snapDistance", {
- get: function() {
- return this._snapDistance
- },
- set: function(e) {
- this._snapDistance = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
- t && (t.snapDistance = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(e) {
- this._scaleRatio = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(t) {
- t && (t.scaleRatio = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addToAxisCache = function(e, t) {
- this._gizmoAxisCache.set(e, t)
- }
- ,
- t.prototype.dispose = function() {
- var e = this;
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach((function(e) {
- e && e.dispose()
- }
- )),
- this._observables.forEach((function(t) {
- e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)
- }
- )),
- this.onDragStartObservable.clear(),
- this.onDragEndObservable.clear()
- }
- ,
- t.prototype.setCustomMesh = function() {
- K.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)")
- }
- ,
- t
- }(Sl);
- function bd(e) {
- var t = [];
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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]]
- },
- t[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, n, r, o, a, s, l = e.type && (e.type < 0 || e.type >= t.length) ? 0 : e.type || 0, c = e.size, u = e.sizeX || c || 1, h = e.sizeY || c || 1, d = e.sizeZ || c || 1, p = e.custom || t[l], f = p.face.length, _ = e.faceUV || new Array(f), m = e.faceColors, g = void 0 === e.flat || e.flat, v = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, y = new Array, b = new Array, T = new Array, E = new Array, S = new Array, A = 0, x = 0, C = new Array, P = 0, M = 0;
- if (g)
- for (M = 0; M < f; M++)
- m && void 0 === m[M] && (m[M] = new N(1,1,1,1)),
- _ && void 0 === _[M] && (_[M] = new R(0,0,1,1));
- if (g)
- for (M = 0; M < f; M++) {
- var I = p.face[M].length;
- for (r = 2 * Math.PI / I,
- o = .5 * Math.tan(r / 2),
- a = .5,
- P = 0; P < I; P++)
- y.push(p.vertex[p.face[M][P]][0] * u, p.vertex[p.face[M][P]][1] * h, p.vertex[p.face[M][P]][2] * d),
- C.push(A),
- A++,
- i = _[M].x + (_[M].z - _[M].x) * (.5 + o),
- n = _[M].y + (_[M].w - _[M].y) * (a - .5),
- E.push(i, pr.UseOpenGLOrientationForUV ? 1 - n : n),
- s = o * Math.cos(r) - a * Math.sin(r),
- a = o * Math.sin(r) + a * Math.cos(r),
- o = s,
- m && S.push(m[M].r, m[M].g, m[M].b, m[M].a);
- for (P = 0; P < I - 2; P++)
- b.push(C[0 + x], C[P + 2 + x], C[P + 1 + x]);
- x += I
- }
- else {
- for (P = 0; P < p.vertex.length; P++)
- y.push(p.vertex[P][0] * u, p.vertex[P][1] * h, p.vertex[P][2] * d),
- E.push(0, pr.UseOpenGLOrientationForUV ? 1 : 0);
- for (M = 0; M < f; M++)
- for (P = 0; P < p.face[M].length - 2; P++)
- b.push(p.face[M][0], p.face[M][P + 2], p.face[M][P + 1])
- }
- $n.ComputeNormals(y, b, T),
- $n._ComputeSides(v, y, b, T, E, e.frontUVs, e.backUVs);
- var O = new $n;
- return O.positions = y,
- O.indices = b,
- O.normals = T,
- O.uvs = E,
- m && g && (O.colors = S),
- O
- }
- function Td(e, t, i) {
- void 0 === t && (t = {}),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- bd(t).applyToMesh(n, t.updatable),
- n
- }
- var Ed = {
- CreatePolyhedron: Td
- };
- $n.CreatePolyhedron = bd,
- Vr.CreatePolyhedron = function(e, t, i) {
- return Td(e, t, i)
- }
- ;
- var Sd = function(e) {
- function t(t, i, n) {
- void 0 === t && (t = El.DefaultUtilityLayer),
- void 0 === i && (i = 1);
- var r = e.call(this, t) || this;
- return r._meshAttached = null,
- r._nodeAttached = null,
- r._sensitivity = 1,
- r._observables = [],
- r._gizmoAxisCache = new Map,
- r.onDragStartObservable = new h,
- r.onDragEndObservable = new h,
- r.uniformScaleGizmo = r._createUniformScaleMesh(),
- r.xGizmo = new fd(new x(1,0,0),D.Red().scale(.5),t,r,i),
- r.yGizmo = new fd(new x(0,1,0),D.Green().scale(.5),t,r,i),
- r.zGizmo = new fd(new x(0,0,1),D.Blue().scale(.5),t,r,i),
- [r.xGizmo, r.yGizmo, r.zGizmo, r.uniformScaleGizmo].forEach((function(e) {
- e.dragBehavior.onDragStartObservable.add((function() {
- r.onDragStartObservable.notifyObservers({})
- }
- )),
- e.dragBehavior.onDragEndObservable.add((function() {
- r.onDragEndObservable.notifyObservers({})
- }
- ))
- }
- )),
- r.attachedMesh = null,
- r.attachedNode = null,
- n ? n.addToAxisCache(r._gizmoAxisCache) : Sl.GizmoAxisPointerObserver(t, r._gizmoAxisCache),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "attachedMesh", {
- get: function() {
- return this._meshAttached
- },
- set: function(e) {
- this._meshAttached = e,
- this._nodeAttached = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
- t.isEnabled ? t.attachedMesh = e : t.attachedMesh = null
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "attachedNode", {
- get: function() {
- return this._nodeAttached
- },
- set: function(e) {
- this._meshAttached = null,
- this._nodeAttached = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
- t.isEnabled ? t.attachedNode = e : t.attachedNode = null
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isHovered", {
- get: function() {
- var e = !1;
- return [this.xGizmo, this.yGizmo, this.zGizmo].forEach((function(t) {
- e = e || t.isHovered
- }
- )),
- e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._createUniformScaleMesh = function() {
- this._coloredMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
- this._coloredMaterial.diffuseColor = D.Gray(),
- this._hoverMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
- this._hoverMaterial.diffuseColor = D.Yellow(),
- this._disableMaterial = new Os("",this.gizmoLayer.utilityLayerScene),
- this._disableMaterial.diffuseColor = D.Gray(),
- this._disableMaterial.alpha = .4;
- var e = new fd(new x(0,1,0),D.Gray().scale(.5),this.gizmoLayer,this);
- e.updateGizmoRotationToMatchAttachedMesh = !1,
- e.uniformScaling = !0,
- this._uniformScalingMesh = Td("uniform", {
- type: 1
- }, e.gizmoLayer.utilityLayerScene),
- this._uniformScalingMesh.scaling.scaleInPlace(.01),
- this._uniformScalingMesh.visibility = 0,
- this._octahedron = Td("", {
- type: 1
- }, e.gizmoLayer.utilityLayerScene),
- this._octahedron.scaling.scaleInPlace(.007),
- this._uniformScalingMesh.addChild(this._octahedron),
- e.setCustomMesh(this._uniformScalingMesh, !0);
- var t = this.gizmoLayer._getSharedGizmoLight();
- t.includedOnlyMeshes = t.includedOnlyMeshes.concat(this._octahedron);
- var i = {
- gizmoMeshes: [this._octahedron, this._uniformScalingMesh],
- colliderMeshes: [this._uniformScalingMesh],
- material: this._coloredMaterial,
- hoverMaterial: this._hoverMaterial,
- disableMaterial: this._disableMaterial,
- active: !1,
- dragBehavior: e.dragBehavior
- };
- return this.addToAxisCache(e._rootMesh, i),
- e
- }
- ,
- Object.defineProperty(t.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this._updateGizmoRotationToMatchAttachedMesh
- },
- set: function(e) {
- e ? (this._updateGizmoRotationToMatchAttachedMesh = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
- t && (t.updateGizmoRotationToMatchAttachedMesh = e)
- }
- ))) : K.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "snapDistance", {
- get: function() {
- return this._snapDistance
- },
- set: function(e) {
- this._snapDistance = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
- t && (t.snapDistance = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(e) {
- this._scaleRatio = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
- t && (t.scaleRatio = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sensitivity", {
- get: function() {
- return this._sensitivity
- },
- set: function(e) {
- this._sensitivity = e,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(t) {
- t && (t.sensitivity = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addToAxisCache = function(e, t) {
- this._gizmoAxisCache.set(e, t)
- }
- ,
- t.prototype.dispose = function() {
- var e = this;
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((function(e) {
- e && e.dispose()
- }
- )),
- this._observables.forEach((function(t) {
- e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)
- }
- )),
- this.onDragStartObservable.clear(),
- this.onDragEndObservable.clear(),
- [this._uniformScalingMesh, this._octahedron].forEach((function(e) {
- e && e.dispose()
- }
- )),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((function(e) {
- e && e.dispose()
- }
- ))
- }
- ,
- t
- }(Sl)
- , Ad = function() {
- function e(e, t, i, n) {
- void 0 === t && (t = 1),
- void 0 === i && (i = El.DefaultUtilityLayer),
- void 0 === n && (n = El.DefaultKeepDepthUtilityLayer),
- this._scene = e,
- this.clearGizmoOnEmptyPointerEvent = !1,
- this.enableAutoPicking = !0,
- this.onAttachedToMeshObservable = new h,
- this.onAttachedToNodeObservable = new h,
- this._gizmosEnabled = {
- positionGizmo: !1,
- rotationGizmo: !1,
- scaleGizmo: !1,
- boundingBoxGizmo: !1
- },
- this._pointerObservers = [],
- this._attachedMesh = null,
- this._attachedNode = null,
- this._boundingBoxColor = D.FromHexString("#0984e3"),
- this._thickness = 1,
- this._scaleRatio = 1,
- this._gizmoAxisCache = new Map,
- this.boundingBoxDragBehavior = new Co,
- this.attachableMeshes = null,
- this.attachableNodes = null,
- this.usePointerToAttachGizmos = !0,
- this._defaultUtilityLayer = i,
- this._defaultKeepDepthUtilityLayer = n,
- this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
- this._thickness = t,
- this.gizmos = {
- positionGizmo: null,
- rotationGizmo: null,
- scaleGizmo: null,
- boundingBoxGizmo: null
- };
- var r = this._attachToMeshPointerObserver(e)
- , o = Sl.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
- this._pointerObservers = [r, o]
- }
- return Object.defineProperty(e.prototype, "keepDepthUtilityLayer", {
- get: function() {
- return this._defaultKeepDepthUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "utilityLayer", {
- get: function() {
- return this._defaultUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isHovered", {
- get: function() {
- var e = !1;
- for (var t in this.gizmos) {
- var i = this.gizmos[t];
- if (i && i.isHovered) {
- e = !0;
- break
- }
- }
- return e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(e) {
- this._scaleRatio = e,
- [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach((function(t) {
- t && (t.scaleRatio = e)
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachToMeshPointerObserver = function(e) {
- var t = this;
- return e.onPointerObservable.add((function(e) {
- if (t.usePointerToAttachGizmos && e.type == Xi.POINTERDOWN)
- if (e.pickInfo && e.pickInfo.pickedMesh) {
- if (t.enableAutoPicking) {
- var i = e.pickInfo.pickedMesh;
- if (null == t.attachableMeshes)
- for (; i && null != i.parent; )
- i = i.parent;
- else {
- var n = !1;
- t.attachableMeshes.forEach((function(e) {
- i && (i == e || i.isDescendantOf(e)) && (i = e,
- n = !0)
- }
- )),
- n || (i = null)
- }
- i instanceof Sr ? t._attachedMesh != i && t.attachToMesh(i) : t.clearGizmoOnEmptyPointerEvent && t.attachToMesh(null)
- }
- } else
- t.clearGizmoOnEmptyPointerEvent && t.attachToMesh(null)
- }
- ))
- }
- ,
- e.prototype.attachToMesh = function(e) {
- for (var t in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedMesh = e,
- this._attachedNode = null,
- this.gizmos) {
- var i = this.gizmos[t];
- i && this._gizmosEnabled[t] && (i.attachedMesh = e)
- }
- this.boundingBoxGizmoEnabled && this._attachedMesh && this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),
- this.onAttachedToMeshObservable.notifyObservers(e)
- }
- ,
- e.prototype.attachToNode = function(e) {
- for (var t in this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedMesh = null,
- this._attachedNode = e,
- this.gizmos) {
- var i = this.gizmos[t];
- i && this._gizmosEnabled[t] && (i.attachedNode = e)
- }
- this.boundingBoxGizmoEnabled && this._attachedNode && this._attachedNode.addBehavior(this.boundingBoxDragBehavior),
- this.onAttachedToNodeObservable.notifyObservers(e)
- }
- ,
- Object.defineProperty(e.prototype, "positionGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.positionGizmo
- },
- set: function(e) {
- e ? (this.gizmos.positionGizmo || (this.gizmos.positionGizmo = new yd(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(e.prototype, "rotationGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.rotationGizmo
- },
- set: function(e) {
- e ? (this.gizmos.rotationGizmo || (this.gizmos.rotationGizmo = new gd(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(e.prototype, "scaleGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.scaleGizmo
- },
- set: function(e) {
- e ? (this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new Sd(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(e.prototype, "boundingBoxGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.boundingBoxGizmo
- },
- set: function(e) {
- e ? (this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _d(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
- }),
- e.prototype.addToAxisCache = function(e) {
- var t = this;
- e.size > 0 && e.forEach((function(e, i) {
- t._gizmoAxisCache.set(i, e)
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- var e, t, i = this;
- for (var n in this._pointerObservers.forEach((function(e) {
- i._scene.onPointerObservable.remove(e)
- }
- )),
- this.gizmos) {
- var r = this.gizmos[n];
- r && r.dispose()
- }
- this._defaultKeepDepthUtilityLayer !== El._DefaultKeepDepthUtilityLayer && (null === (e = this._defaultKeepDepthUtilityLayer) || void 0 === e || e.dispose()),
- this._defaultUtilityLayer !== El._DefaultUtilityLayer && (null === (t = this._defaultUtilityLayer) || void 0 === t || t.dispose()),
- this.boundingBoxDragBehavior.detach(),
- this.onAttachedToMeshObservable.clear()
- }
- ,
- e
- }()
- , xd = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t._needProjectionMatrixCompute = !0,
- t
- }
- return U(t, e),
- t.prototype._setPosition = function(e) {
- this._position = e
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(e) {
- this._setPosition(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._setDirection = function(e) {
- this._direction = e
- }
- ,
- Object.defineProperty(t.prototype, "direction", {
- get: function() {
- return this._direction
- },
- set: function(e) {
- this._setDirection(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadowMinZ", {
- get: function() {
- return this._shadowMinZ
- },
- set: function(e) {
- this._shadowMinZ = e,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadowMaxZ", {
- get: function() {
- return this._shadowMaxZ
- },
- set: function(e) {
- this._shadowMaxZ = e,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.computeTransformedInformation = function() {
- return !(!this.parent || !this.parent.getWorldMatrix || (this.transformedPosition || (this.transformedPosition = x.Zero()),
- x.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition),
- this.direction && (this.transformedDirection || (this.transformedDirection = x.Zero()),
- x.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)),
- 0))
- }
- ,
- t.prototype.getDepthScale = function() {
- return 50
- }
- ,
- t.prototype.getShadowDirection = function(e) {
- return this.transformedDirection ? this.transformedDirection : this.direction
- }
- ,
- t.prototype.getAbsolutePosition = function() {
- return this.transformedPosition ? this.transformedPosition : this.position
- }
- ,
- t.prototype.setDirectionToTarget = function(e) {
- return this.direction = x.Normalize(e.subtract(this.position)),
- this.direction
- }
- ,
- t.prototype.getRotation = function() {
- this.direction.normalize();
- var e = x.Cross(this.direction, vn.Y)
- , t = x.Cross(e, this.direction);
- return x.RotationFromAxis(e, t, this.direction)
- }
- ,
- t.prototype.needCube = function() {
- return !1
- }
- ,
- t.prototype.needProjectionMatrixCompute = function() {
- return this._needProjectionMatrixCompute
- }
- ,
- t.prototype.forceProjectionMatrixCompute = function() {
- this._needProjectionMatrixCompute = !0
- }
- ,
- t.prototype._initCache = function() {
- e.prototype._initCache.call(this),
- this._cache.position = x.Zero()
- }
- ,
- t.prototype._isSynchronized = function() {
- return !!this._cache.position.equals(this.position)
- }
- ,
- t.prototype.computeWorldMatrix = function(e) {
- return !e && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(),
- this._worldMatrix) : (this._updateCache(),
- this._cache.position.copyFrom(this.position),
- this._worldMatrix || (this._worldMatrix = P.Identity()),
- P.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)
- }
- ,
- t.prototype.getDepthMinZ = function(e) {
- return void 0 !== this.shadowMinZ ? this.shadowMinZ : e.minZ
- }
- ,
- t.prototype.getDepthMaxZ = function(e) {
- return void 0 !== this.shadowMaxZ ? this.shadowMaxZ : e.maxZ
- }
- ,
- t.prototype.setShadowProjectionMatrix = function(e, t, i) {
- return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(t, i, e) : this._setDefaultShadowProjectionMatrix(e, t, i),
- this
- }
- ,
- k([De()], t.prototype, "position", null),
- k([De()], t.prototype, "direction", null),
- k([Ce()], t.prototype, "shadowMinZ", null),
- k([Ce()], t.prototype, "shadowMaxZ", null),
- t
- }(Cr);
- Xe.AddNodeConstructor("Light_Type_1", (function(e, t) {
- return function() {
- return new Rd(e,x.Zero(),t)
- }
- }
- ));
- var Rd = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r._shadowFrustumSize = 0,
- r._shadowOrthoScale = .1,
- r.autoUpdateExtends = !0,
- r.autoCalcShadowZBounds = !1,
- r._orthoLeft = Number.MAX_VALUE,
- r._orthoRight = Number.MIN_VALUE,
- r._orthoTop = Number.MIN_VALUE,
- r._orthoBottom = Number.MAX_VALUE,
- r.position = i.scale(-1),
- r.direction = i,
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "shadowFrustumSize", {
- get: function() {
- return this._shadowFrustumSize
- },
- set: function(e) {
- this._shadowFrustumSize = e,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadowOrthoScale", {
- get: function() {
- return this._shadowOrthoScale
- },
- set: function(e) {
- this._shadowOrthoScale = e,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "orthoLeft", {
- get: function() {
- return this._orthoLeft
- },
- set: function(e) {
- this._orthoLeft = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "orthoRight", {
- get: function() {
- return this._orthoRight
- },
- set: function(e) {
- this._orthoRight = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "orthoTop", {
- get: function() {
- return this._orthoTop
- },
- set: function(e) {
- this._orthoTop = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "orthoBottom", {
- get: function() {
- return this._orthoBottom
- },
- set: function(e) {
- this._orthoBottom = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "DirectionalLight"
- }
- ,
- t.prototype.getTypeID = function() {
- return Cr.LIGHTTYPEID_DIRECTIONALLIGHT
- }
- ,
- t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
- this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(e) : this._setDefaultAutoExtendShadowProjectionMatrix(e, t, i)
- }
- ,
- t.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(e) {
- var t = this.getScene().activeCamera;
- t && P.OrthoLHToRef(this.shadowFrustumSize, this.shadowFrustumSize, void 0 !== this.shadowMinZ ? this.shadowMinZ : t.minZ, void 0 !== this.shadowMaxZ ? this.shadowMaxZ : t.maxZ, e, this.getScene().getEngine().isNDCHalfZRange)
- }
- ,
- t.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(e, t, i) {
- var n = this.getScene().activeCamera;
- if (n) {
- if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
- var r = x.Zero();
- this._orthoLeft = Number.MAX_VALUE,
- this._orthoRight = Number.MIN_VALUE,
- this._orthoTop = Number.MIN_VALUE,
- this._orthoBottom = Number.MAX_VALUE;
- for (var o = Number.MAX_VALUE, a = Number.MIN_VALUE, s = 0; s < i.length; s++) {
- var l = i[s];
- if (l)
- for (var c = l.getBoundingInfo().boundingBox, u = 0; u < c.vectorsWorld.length; u++)
- x.TransformCoordinatesToRef(c.vectorsWorld[u], t, r),
- r.x < this._orthoLeft && (this._orthoLeft = r.x),
- r.y < this._orthoBottom && (this._orthoBottom = r.y),
- r.x > this._orthoRight && (this._orthoRight = r.x),
- r.y > this._orthoTop && (this._orthoTop = r.y),
- this.autoCalcShadowZBounds && (r.z < o && (o = r.z),
- r.z > a && (a = r.z))
- }
- this.autoCalcShadowZBounds && (this._shadowMinZ = o,
- this._shadowMaxZ = a)
- }
- var h = this._orthoRight - this._orthoLeft
- , d = this._orthoTop - this._orthoBottom
- , p = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
- , f = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
- , _ = this.getScene().getEngine().useReverseDepthBuffer;
- P.OrthoOffCenterLHToRef(this._orthoLeft - h * this.shadowOrthoScale, this._orthoRight + h * this.shadowOrthoScale, this._orthoBottom - d * this.shadowOrthoScale, this._orthoTop + d * this.shadowOrthoScale, _ ? f : p, _ ? p : f, e, this.getScene().getEngine().isNDCHalfZRange)
- }
- }
- ,
- t.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()
- }
- ,
- t.prototype.transferToEffect = function(e, t) {
- return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, t),
- this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, t),
- this)
- }
- ,
- t.prototype.transferToNodeMaterialEffect = function(e, t) {
- return this.computeTransformedInformation() ? (e.setFloat3(t, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z),
- this) : (e.setFloat3(t, this.direction.x, this.direction.y, this.direction.z),
- this)
- }
- ,
- t.prototype.getDepthMinZ = function(e) {
- var t = this._scene.getEngine();
- return !t.useReverseDepthBuffer && t.isNDCHalfZRange ? 0 : 1
- }
- ,
- t.prototype.getDepthMaxZ = function(e) {
- var t = this._scene.getEngine();
- return t.useReverseDepthBuffer && t.isNDCHalfZRange ? 0 : 1
- }
- ,
- t.prototype.prepareLightSpecificDefines = function(e, t) {
- e["DIRLIGHT" + t] = !0
- }
- ,
- k([Ce()], t.prototype, "shadowFrustumSize", null),
- k([Ce()], t.prototype, "shadowOrthoScale", null),
- k([Ce()], t.prototype, "autoUpdateExtends", void 0),
- k([Ce()], t.prototype, "autoCalcShadowZBounds", void 0),
- k([Ce("orthoLeft")], t.prototype, "_orthoLeft", void 0),
- k([Ce("orthoRight")], t.prototype, "_orthoRight", void 0),
- k([Ce("orthoTop")], t.prototype, "_orthoTop", void 0),
- k([Ce("orthoBottom")], t.prototype, "_orthoBottom", void 0),
- t
- }(xd);
- function Cd(e) {
- var t = new Array
- , i = new Array
- , n = new Array
- , r = new Array
- , o = e.radius || .5
- , a = e.tessellation || 64
- , s = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1
- , l = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE;
- t.push(0, 0, 0),
- r.push(.5, .5);
- for (var c = 2 * Math.PI * s, u = 1 === s ? c / a : c / (a - 1), h = 0, d = 0; d < a; d++) {
- var p = Math.cos(h)
- , f = Math.sin(h)
- , _ = (p + 1) / 2
- , m = (1 - f) / 2;
- t.push(o * p, o * f, 0),
- r.push(_, pr.UseOpenGLOrientationForUV ? 1 - m : m),
- h += u
- }
- 1 === s && (t.push(t[3], t[4], t[5]),
- r.push(r[2], pr.UseOpenGLOrientationForUV ? 1 - r[3] : r[3]));
- for (var g = t.length / 3, v = 1; v < g - 1; v++)
- i.push(v + 1, 0, v);
- $n.ComputeNormals(t, i, n),
- $n._ComputeSides(l, t, i, n, r, e.frontUVs, e.backUVs);
- var y = new $n;
- return y.indices = i,
- y.positions = t,
- y.normals = n,
- y.uvs = r,
- y
- }
- function Pd(e, t, i) {
- void 0 === t && (t = {}),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- Cd(t).applyToMesh(n, t.updatable),
- n
- }
- var Md = {
- CreateDisc: Pd
- };
- function Id(e, t, i) {
- void 0 === t && (t = {}),
- t.diameter || (t.diameter = 1),
- t.segments || (t.segments = 16);
- var n = Dl("", {
- slice: .5,
- diameter: t.diameter,
- segments: t.segments
- }, i)
- , r = Pd("", {
- radius: t.diameter / 2,
- tessellation: 3 * t.segments + (4 - t.segments)
- }, i);
- r.rotation.x = -Math.PI / 2,
- r.parent = n;
- var o = Vr.MergeMeshes([r, n], !0);
- return o.name = e,
- o
- }
- $n.CreateDisc = Cd,
- Vr.CreateDisc = function(e, t, i, n, r, o) {
- return void 0 === n && (n = null),
- Pd(e, {
- radius: t,
- tessellation: i,
- sideOrientation: o,
- updatable: r
- }, n)
- }
- ;
- var Od = {
- CreateHemisphere: Id
- };
- Vr.CreateHemisphere = function(e, t, i, n) {
- return Id(e, {
- segments: t,
- diameter: i
- }, n)
- }
- ,
- Xe.AddNodeConstructor("Light_Type_2", (function(e, t) {
- return function() {
- return new Dd(e,x.Zero(),x.Zero(),0,0,t)
- }
- }
- ));
- var Dd = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, a) || this;
- return s._innerAngle = 0,
- s._projectionTextureMatrix = P.Zero(),
- s._projectionTextureLightNear = 1e-6,
- s._projectionTextureLightFar = 1e3,
- s._projectionTextureUpDirection = x.Up(),
- s._projectionTextureViewLightDirty = !0,
- s._projectionTextureProjectionLightDirty = !0,
- s._projectionTextureDirty = !0,
- s._projectionTextureViewTargetVector = x.Zero(),
- s._projectionTextureViewLightMatrix = P.Zero(),
- s._projectionTextureProjectionLightMatrix = P.Zero(),
- s._projectionTextureScalingMatrix = P.FromValues(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1),
- s.position = i,
- s.direction = n,
- s.angle = r,
- s.exponent = o,
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "angle", {
- get: function() {
- return this._angle
- },
- set: function(e) {
- this._angle = e,
- this._cosHalfAngle = Math.cos(.5 * e),
- this._projectionTextureProjectionLightDirty = !0,
- this.forceProjectionMatrixCompute(),
- this._computeAngleValues()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "innerAngle", {
- get: function() {
- return this._innerAngle
- },
- set: function(e) {
- this._innerAngle = e,
- this._computeAngleValues()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadowAngleScale", {
- get: function() {
- return this._shadowAngleScale
- },
- set: function(e) {
- this._shadowAngleScale = e,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "projectionTextureMatrix", {
- get: function() {
- return this._projectionTextureMatrix
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "projectionTextureLightNear", {
- get: function() {
- return this._projectionTextureLightNear
- },
- set: function(e) {
- this._projectionTextureLightNear = e,
- this._projectionTextureProjectionLightDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "projectionTextureLightFar", {
- get: function() {
- return this._projectionTextureLightFar
- },
- set: function(e) {
- this._projectionTextureLightFar = e,
- this._projectionTextureProjectionLightDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "projectionTextureUpDirection", {
- get: function() {
- return this._projectionTextureUpDirection
- },
- set: function(e) {
- this._projectionTextureUpDirection = e,
- this._projectionTextureProjectionLightDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "projectionTexture", {
- get: function() {
- return this._projectionTexture
- },
- set: function(e) {
- var i = this;
- this._projectionTexture !== e && (this._projectionTexture = e,
- this._projectionTextureDirty = !0,
- this._projectionTexture && !this._projectionTexture.isReady() && (t._IsProceduralTexture(this._projectionTexture) ? this._projectionTexture.getEffect().executeWhenCompiled((function() {
- i._markMeshesAsLightDirty()
- }
- )) : t._IsTexture(this._projectionTexture) && this._projectionTexture.onLoadObservable.addOnce((function() {
- i._markMeshesAsLightDirty()
- }
- ))))
- },
- enumerable: !1,
- configurable: !0
- }),
- t._IsProceduralTexture = function(e) {
- return void 0 !== e.onGeneratedObservable
- }
- ,
- t._IsTexture = function(e) {
- return void 0 !== e.onLoadObservable
- }
- ,
- Object.defineProperty(t.prototype, "projectionTextureProjectionLightMatrix", {
- get: function() {
- return this._projectionTextureProjectionLightMatrix
- },
- set: function(e) {
- this._projectionTextureProjectionLightMatrix = e,
- this._projectionTextureProjectionLightDirty = !1,
- this._projectionTextureDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "SpotLight"
- }
- ,
- t.prototype.getTypeID = function() {
- return Cr.LIGHTTYPEID_SPOTLIGHT
- }
- ,
- t.prototype._setDirection = function(t) {
- e.prototype._setDirection.call(this, t),
- this._projectionTextureViewLightDirty = !0
- }
- ,
- t.prototype._setPosition = function(t) {
- e.prototype._setPosition.call(this, t),
- this._projectionTextureViewLightDirty = !0
- }
- ,
- t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
- var n = this.getScene().activeCamera;
- if (n) {
- this._shadowAngleScale = this._shadowAngleScale || 1;
- var r = this._shadowAngleScale * this._angle
- , o = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
- , a = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
- , s = this.getScene().getEngine().useReverseDepthBuffer;
- P.PerspectiveFovLHToRef(r, 1, s ? a : o, s ? o : a, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, s)
- }
- }
- ,
- t.prototype._computeProjectionTextureViewLightMatrix = function() {
- this._projectionTextureViewLightDirty = !1,
- this._projectionTextureDirty = !0,
- this.position.addToRef(this.direction, this._projectionTextureViewTargetVector),
- P.LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix)
- }
- ,
- t.prototype._computeProjectionTextureProjectionLightMatrix = function() {
- this._projectionTextureProjectionLightDirty = !1,
- this._projectionTextureDirty = !0;
- var e = this.projectionTextureLightFar
- , t = this.projectionTextureLightNear
- , i = e / (e - t)
- , n = -i * t
- , r = 1 / Math.tan(this._angle / 2);
- P.FromValuesToRef(r / 1, 0, 0, 0, 0, r, 0, 0, 0, 0, i, 1, 0, 0, n, 0, this._projectionTextureProjectionLightMatrix)
- }
- ,
- t.prototype._computeProjectionTextureMatrix = function() {
- if (this._projectionTextureDirty = !1,
- this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix),
- this._projectionTexture instanceof io) {
- var e = this._projectionTexture.uScale / 2
- , t = this._projectionTexture.vScale / 2;
- P.FromValuesToRef(e, 0, 0, 0, 0, t, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1, this._projectionTextureScalingMatrix)
- }
- this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix)
- }
- ,
- t.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()
- }
- ,
- t.prototype._computeAngleValues = function() {
- this._lightAngleScale = 1 / Math.max(.001, Math.cos(.5 * this._innerAngle) - this._cosHalfAngle),
- this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale
- }
- ,
- t.prototype.transferTexturesToEffect = function(e, t) {
- return this.projectionTexture && this.projectionTexture.isReady() && (this._projectionTextureViewLightDirty && this._computeProjectionTextureViewLightMatrix(),
- this._projectionTextureProjectionLightDirty && this._computeProjectionTextureProjectionLightMatrix(),
- this._projectionTextureDirty && this._computeProjectionTextureMatrix(),
- e.setMatrix("textureProjectionMatrix" + t, this._projectionTextureMatrix),
- e.setTexture("projectionLightSampler" + t, this.projectionTexture)),
- this
- }
- ,
- t.prototype.transferToEffect = function(e, t) {
- var i;
- return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, t),
- i = x.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, t),
- i = x.Normalize(this.direction)),
- this._uniformBuffer.updateFloat4("vLightDirection", i.x, i.y, i.z, this._cosHalfAngle, t),
- this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, t),
- this
- }
- ,
- t.prototype.transferToNodeMaterialEffect = function(e, t) {
- var i;
- return i = this.computeTransformedInformation() ? x.Normalize(this.transformedDirection) : x.Normalize(this.direction),
- this.getScene().useRightHandedSystem ? e.setFloat3(t, -i.x, -i.y, -i.z) : e.setFloat3(t, i.x, i.y, i.z),
- this
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._projectionTexture && this._projectionTexture.dispose()
- }
- ,
- t.prototype.getDepthMinZ = function(e) {
- var t = this._scene.getEngine()
- , i = void 0 !== this.shadowMinZ ? this.shadowMinZ : e.minZ;
- return t.useReverseDepthBuffer && t.isNDCHalfZRange ? i : this._scene.getEngine().isNDCHalfZRange ? 0 : i
- }
- ,
- t.prototype.getDepthMaxZ = function(e) {
- var t = this._scene.getEngine()
- , i = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : e.maxZ;
- return t.useReverseDepthBuffer && t.isNDCHalfZRange ? 0 : i
- }
- ,
- t.prototype.prepareLightSpecificDefines = function(e, t) {
- e["SPOTLIGHT" + t] = !0,
- e["PROJECTEDLIGHTTEXTURE" + t] = !(!this.projectionTexture || !this.projectionTexture.isReady())
- }
- ,
- k([Ce()], t.prototype, "angle", null),
- k([Ce()], t.prototype, "innerAngle", null),
- k([Ce()], t.prototype, "shadowAngleScale", null),
- k([Ce()], t.prototype, "exponent", void 0),
- k([Ce()], t.prototype, "projectionTextureLightNear", null),
- k([Ce()], t.prototype, "projectionTextureLightFar", null),
- k([Ce()], t.prototype, "projectionTextureUpDirection", null),
- k([Pe("projectedLightTexture")], t.prototype, "_projectionTexture", void 0),
- t
- }(xd)
- , Nd = function(e) {
- function t(t) {
- void 0 === t && (t = El.DefaultUtilityLayer);
- var i = e.call(this, t) || this;
- return i._cachedPosition = new x,
- i._cachedForward = new x(0,0,1),
- i._pointerObserver = null,
- i.onClickedObservable = new h,
- i._light = null,
- i.attachedMesh = new Sr("",i.gizmoLayer.utilityLayerScene),
- i._attachedMeshParent = new yr("parent",i.gizmoLayer.utilityLayerScene),
- i.attachedMesh.parent = i._attachedMeshParent,
- i._material = new Os("light",i.gizmoLayer.utilityLayerScene),
- i._material.diffuseColor = new D(.5,.5,.5),
- i._material.specularColor = new D(.1,.1,.1),
- i._pointerObserver = t.utilityLayerScene.onPointerObservable.add((function(e) {
- i._light && (i._isHovered = !(!e.pickInfo || -1 == i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),
- i._isHovered && 0 === e.event.button && i.onClickedObservable.notifyObservers(i._light))
- }
- ), Xi.POINTERDOWN),
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "attachedNode", {
- get: function() {
- return this.attachedMesh
- },
- set: function(e) {
- console.warn("Nodes cannot be attached to LightGizmo. Attach to a mesh instead.")
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "light", {
- get: function() {
- return this._light
- },
- set: function(e) {
- var i = this;
- if (this._light = e,
- e) {
- this._lightMesh && this._lightMesh.dispose(),
- this._lightMesh = e instanceof ds ? t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof Rd ? t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene) : e instanceof Dd ? t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene) : t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),
- this._lightMesh.getChildMeshes(!1).forEach((function(e) {
- e.material = i._material
- }
- )),
- this._lightMesh.parent = this._rootMesh;
- var n = this.gizmoLayer._getSharedGizmoLight();
- n.includedOnlyMeshes = n.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),
- this._lightMesh.rotationQuaternion = new C,
- this.attachedMesh.reservedDataStore || (this.attachedMesh.reservedDataStore = {}),
- this.attachedMesh.reservedDataStore.lightGizmo = this,
- e.parent && this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),
- e.position && (this.attachedMesh.position.copyFrom(e.position),
- this.attachedMesh.computeWorldMatrix(!0),
- this._cachedPosition.copyFrom(this.attachedMesh.position)),
- e.direction && (this.attachedMesh.setDirection(e.direction),
- this.attachedMesh.computeWorldMatrix(!0),
- this._cachedForward.copyFrom(this.attachedMesh.forward)),
- this._update()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "material", {
- get: function() {
- return this._material
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._update = function() {
- if (e.prototype._update.call(this),
- this._light) {
- if (this._light.parent && this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),
- this._light.position)
- if (this.attachedMesh.position.equals(this._cachedPosition))
- this.attachedMesh.position.copyFrom(this._light.position),
- this.attachedMesh.computeWorldMatrix(!0),
- this._cachedPosition.copyFrom(this.attachedMesh.position);
- else {
- var t = this.attachedMesh.position;
- this._light.position = new x(t.x,t.y,t.z),
- this._cachedPosition.copyFrom(this.attachedMesh.position)
- }
- if (this._light.direction)
- if (x.DistanceSquared(this.attachedMesh.forward, this._cachedForward) > 1e-4) {
- var i = this.attachedMesh.forward;
- this._light.direction = new x(i.x,i.y,i.z),
- this._cachedForward.copyFrom(this.attachedMesh.forward)
- } else
- x.DistanceSquared(this.attachedMesh.forward, this._light.direction) > 1e-4 && (this.attachedMesh.setDirection(this._light.direction),
- this.attachedMesh.computeWorldMatrix(!0),
- this._cachedForward.copyFrom(this.attachedMesh.forward))
- }
- }
- ,
- t.prototype.dispose = function() {
- this.onClickedObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this._material.dispose(),
- e.prototype.dispose.call(this),
- this._attachedMeshParent.dispose()
- }
- ,
- t._CreateHemisphericLightMesh = function(e) {
- var i = new Vr("hemisphereLight",e)
- , n = Id(i.name, {
- segments: 10,
- diameter: 1
- }, e);
- return n.position.z = -.15,
- n.rotation.x = Math.PI / 2,
- n.parent = i,
- this._CreateLightLines(3, e).parent = i,
- i.scaling.scaleInPlace(t._Scale),
- i.rotation.x = Math.PI / 2,
- i
- }
- ,
- t._CreatePointLightMesh = function(e) {
- var i = new Vr("pointLight",e)
- , n = Dl(i.name, {
- segments: 10,
- diameter: 1
- }, e);
- return n.rotation.x = Math.PI / 2,
- n.parent = i,
- this._CreateLightLines(5, e).parent = i,
- i.scaling.scaleInPlace(t._Scale),
- i.rotation.x = Math.PI / 2,
- i
- }
- ,
- t._CreateSpotLightMesh = function(e) {
- var i = new Vr("spotLight",e);
- Dl(i.name, {
- segments: 10,
- diameter: 1
- }, e).parent = i;
- var n = Id(i.name, {
- segments: 10,
- diameter: 2
- }, e);
- return n.parent = i,
- n.rotation.x = -Math.PI / 2,
- this._CreateLightLines(2, e).parent = i,
- i.scaling.scaleInPlace(t._Scale),
- i.rotation.x = Math.PI / 2,
- i
- }
- ,
- t._CreateDirectionalLightMesh = function(e) {
- var i = new Vr("directionalLight",e)
- , n = new Vr(i.name,e);
- n.parent = i,
- Dl(i.name, {
- diameter: 1.2,
- segments: 10
- }, e).parent = n;
- var r = Ys(i.name, {
- updatable: !1,
- height: 6,
- diameterTop: .3,
- diameterBottom: .3,
- tessellation: 6,
- subdivisions: 1
- }, e);
- r.parent = n;
- var o = r.clone(i.name);
- o.scaling.y = .5,
- o.position.x += 1.25;
- var a = r.clone(i.name);
- a.scaling.y = .5,
- a.position.x += -1.25;
- var s = Ys(i.name, {
- updatable: !1,
- height: 1,
- diameterTop: 0,
- diameterBottom: .6,
- tessellation: 6,
- subdivisions: 1
- }, e);
- return s.position.y += 3,
- s.parent = n,
- (o = s.clone(i.name)).position.y = 1.5,
- o.position.x += 1.25,
- (a = s.clone(i.name)).position.y = 1.5,
- a.position.x += -1.25,
- n.scaling.scaleInPlace(t._Scale),
- n.rotation.z = Math.PI / 2,
- n.rotation.y = Math.PI / 2,
- i
- }
- ,
- t._Scale = .007,
- t._CreateLightLines = function(e, t) {
- var i = new Vr("root",t);
- i.rotation.x = Math.PI / 2;
- var n = new Vr("linePivot",t);
- n.parent = i;
- var r = Ys("line", {
- updatable: !1,
- height: 2,
- diameterTop: .2,
- diameterBottom: .3,
- tessellation: 6,
- subdivisions: 1
- }, t);
- if (r.position.y = r.scaling.y / 2 + 1.2,
- r.parent = n,
- e < 2)
- return n;
- for (var o = 0; o < 4; o++) {
- var a = n.clone("lineParentClone");
- a.rotation.z = Math.PI / 4,
- a.rotation.y = Math.PI / 2 + Math.PI / 2 * o,
- a.getChildMeshes()[0].scaling.y = .5,
- a.getChildMeshes()[0].scaling.x = a.getChildMeshes()[0].scaling.z = .8,
- a.getChildMeshes()[0].position.y = a.getChildMeshes()[0].scaling.y / 2 + 1.2
- }
- if (e < 3)
- return i;
- for (o = 0; o < 4; o++) {
- var s = n.clone("linePivotClone");
- s.rotation.z = Math.PI / 2,
- s.rotation.y = Math.PI / 2 * o
- }
- if (e < 4)
- return i;
- for (o = 0; o < 4; o++) {
- var l = n.clone("linePivotClone");
- l.rotation.z = Math.PI + Math.PI / 4,
- l.rotation.y = Math.PI / 2 + Math.PI / 2 * o,
- l.getChildMeshes()[0].scaling.y = .5,
- l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = .8,
- l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + 1.2
- }
- return e < 5 || (n.clone("linePivotClone").rotation.z = Math.PI),
- i
- }
- ,
- t
- }(Sl)
- , Ld = function(e) {
- function t(t) {
- void 0 === t && (t = El.DefaultUtilityLayer);
- var i = e.call(this, t) || this;
- return i._pointerObserver = null,
- i.onClickedObservable = new h,
- i._camera = null,
- i._invProjection = new P,
- i._material = new Os("cameraGizmoMaterial",i.gizmoLayer.utilityLayerScene),
- i._material.diffuseColor = new D(.5,.5,.5),
- i._material.specularColor = new D(.1,.1,.1),
- i._pointerObserver = t.utilityLayerScene.onPointerObservable.add((function(e) {
- i._camera && (i._isHovered = !(!e.pickInfo || -1 == i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),
- i._isHovered && 0 === e.event.button && i.onClickedObservable.notifyObservers(i._camera))
- }
- ), Xi.POINTERDOWN),
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "displayFrustum", {
- get: function() {
- return this._cameraLinesMesh.isEnabled()
- },
- set: function(e) {
- this._cameraLinesMesh.setEnabled(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "camera", {
- get: function() {
- return this._camera
- },
- set: function(e) {
- var i = this;
- if (this._camera = e,
- this.attachedNode = e,
- e) {
- this._cameraMesh && this._cameraMesh.dispose(),
- this._cameraLinesMesh && this._cameraLinesMesh.dispose(),
- this._cameraMesh = t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),
- this._cameraLinesMesh = t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),
- this._cameraMesh.getChildMeshes(!1).forEach((function(e) {
- e.material = i._material
- }
- )),
- this._cameraMesh.parent = this._rootMesh,
- this._cameraLinesMesh.parent = this._rootMesh,
- this.gizmoLayer.utilityLayerScene.activeCamera && this.gizmoLayer.utilityLayerScene.activeCamera.maxZ < 1.5 * e.maxZ && (this.gizmoLayer.utilityLayerScene.activeCamera.maxZ = 1.5 * e.maxZ),
- this.attachedNode.reservedDataStore || (this.attachedNode.reservedDataStore = {}),
- this.attachedNode.reservedDataStore.cameraGizmo = this;
- var n = this.gizmoLayer._getSharedGizmoLight();
- n.includedOnlyMeshes = n.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),
- this._update()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "material", {
- get: function() {
- return this._material
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._update = function() {
- e.prototype._update.call(this),
- this._camera && (this._camera.getProjectionMatrix().invertToRef(this._invProjection),
- this._cameraLinesMesh.setPivotMatrix(this._invProjection, !1),
- this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x,
- this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y,
- this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z,
- this._cameraMesh.parent = null,
- this._cameraMesh.rotation.y = .5 * Math.PI * (this._camera.getScene().useRightHandedSystem ? 1 : -1),
- this._cameraMesh.parent = this._rootMesh)
- }
- ,
- t.prototype.dispose = function() {
- this.onClickedObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this._cameraMesh && this._cameraMesh.dispose(),
- this._cameraLinesMesh && this._cameraLinesMesh.dispose(),
- this._material.dispose(),
- e.prototype.dispose.call(this)
- }
- ,
- t._CreateCameraMesh = function(e) {
- var i = new Vr("rootCameraGizmo",e)
- , n = new Vr(i.name,e);
- n.parent = i,
- Ml(i.name, {
- width: 1,
- height: .8,
- depth: .5
- }, e).parent = n;
- var r = Ys(i.name, {
- height: .5,
- diameterTop: .8,
- diameterBottom: .8
- }, e);
- r.parent = n,
- r.position.y = .3,
- r.position.x = -.6,
- r.rotation.x = .5 * Math.PI;
- var o = Ys(i.name, {
- height: .5,
- diameterTop: .6,
- diameterBottom: .6
- }, e);
- o.parent = n,
- o.position.y = .5,
- o.position.x = .4,
- o.rotation.x = .5 * Math.PI;
- var a = Ys(i.name, {
- height: .5,
- diameterTop: .5,
- diameterBottom: .5
- }, e);
- return a.parent = n,
- a.position.y = 0,
- a.position.x = .6,
- a.rotation.z = .5 * Math.PI,
- i.scaling.scaleInPlace(t._Scale),
- n.position.x = -.9,
- i
- }
- ,
- t._CreateCameraFrustum = function(e) {
- var t = new Vr("rootCameraGizmo",e)
- , i = new Vr(t.name,e);
- i.parent = t;
- for (var n = 0; n < 4; n += 2)
- for (var r = 0; r < 4; r += 2) {
- var o = Jl("lines", {
- points: [new x(-1 + r,-1 + n,-1), new x(-1 + r,-1 + n,1)]
- }, e);
- o.parent = i,
- o.alwaysSelectAsActiveMesh = !0,
- o.isPickable = !1,
- (o = Jl("lines", {
- points: [new x(-1,-1 + r,-1 + n), new x(1,-1 + r,-1 + n)]
- }, e)).parent = i,
- o.alwaysSelectAsActiveMesh = !0,
- o.isPickable = !1,
- (o = Jl("lines", {
- points: [new x(-1 + r,-1,-1 + n), new x(-1 + r,1,-1 + n)]
- }, e)).parent = i,
- o.alwaysSelectAsActiveMesh = !0,
- o.isPickable = !1
- }
- return t
- }
- ,
- t._Scale = .05,
- t
- }(Sl);
- Pt.IncludesShadersStore.kernelBlurVaryingDeclaration = "varying vec2 sampleCoord{X};";
- Pt.IncludesShadersStore.packingFunctions = "vec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}";
- Pt.IncludesShadersStore.kernelBlurFragment = "#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif\n";
- Pt.IncludesShadersStore.kernelBlurFragment2 = "#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif\n";
- Pt.ShadersStore.kernelBlurPixelShader = "uniform sampler2D textureSampler;\nuniform vec2 delta;\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g; \nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth; \n}\nfloat sampleCoC(in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r; \nreturn coc; \n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include<packingFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT \nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";
- Pt.IncludesShadersStore.kernelBlurVertex = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
- Pt.ShadersStore.kernelBlurVertexShader = "attribute vec2 position;\nuniform vec2 delta;\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var Fd = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h, d) {
- void 0 === s && (s = io.BILINEAR_SAMPLINGMODE),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === h && (h = ""),
- void 0 === d && (d = !1);
- var p = e.call(this, t, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], r, o, s, l, c, null, u, "kernelBlur", {
- varyingCount: 0,
- depCount: 0
- }, !0) || this;
- return p._blockCompilation = d,
- p._packedFloat = !1,
- p._staticDefines = "",
- p._staticDefines = h,
- p.direction = i,
- p.onApplyObservable.add((function(e) {
- p._outputTexture ? e.setFloat2("delta", 1 / p._outputTexture.width * p.direction.x, 1 / p._outputTexture.height * p.direction.y) : e.setFloat2("delta", 1 / p.width * p.direction.x, 1 / p.height * p.direction.y)
- }
- )),
- p.kernel = n,
- p
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "kernel", {
- get: function() {
- return this._idealKernel
- },
- set: function(e) {
- this._idealKernel !== e && (e = Math.max(e, 1),
- this._idealKernel = e,
- this._kernel = this._nearestBestKernel(e),
- this._blockCompilation || this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "packedFloat", {
- get: function() {
- return this._packedFloat
- },
- set: function(e) {
- this._packedFloat !== e && (this._packedFloat = e,
- this._blockCompilation || this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "BlurPostProcess"
- }
- ,
- t.prototype.updateEffect = function(e, t, i, n, r, o) {
- void 0 === e && (e = null),
- void 0 === t && (t = null),
- void 0 === i && (i = null),
- this._updateParameters(r, o)
- }
- ,
- t.prototype._updateParameters = function(t, i) {
- for (var n = this._kernel, r = (n - 1) / 2, o = [], a = [], s = 0, l = 0; l < n; l++) {
- var c = l / (n - 1)
- , u = this._gaussianWeight(2 * c - 1);
- o[l] = l - r,
- a[l] = u,
- s += u
- }
- for (l = 0; l < a.length; l++)
- a[l] /= s;
- var h = []
- , d = []
- , p = [];
- for (l = 0; l <= r; l += 2) {
- var f = Math.min(l + 1, Math.floor(r));
- if (l === f)
- p.push({
- o: o[l],
- w: a[l]
- });
- else {
- var _ = f === r
- , m = a[l] + a[f] * (_ ? .5 : 1)
- , g = o[l] + 1 / (1 + a[l] / a[f]);
- 0 === g ? (p.push({
- o: o[l],
- w: a[l]
- }),
- p.push({
- o: o[l + 1],
- w: a[l + 1]
- })) : (p.push({
- o: g,
- w: m
- }),
- p.push({
- o: -g,
- w: m
- }))
- }
- }
- for (l = 0; l < p.length; l++)
- d[l] = p[l].o,
- h[l] = p[l].w;
- o = d,
- a = h;
- var v = this.getEngine().getCaps().maxVaryingVectors
- , y = Math.max(v, 0) - 1
- , b = Math.min(o.length, y)
- , T = "";
- for (T += this._staticDefines,
- -1 != this._staticDefines.indexOf("DOF") && (T += "#define CENTER_WEIGHT ".concat(this._glslFloat(a[b - 1]), "\r\n"),
- b--),
- l = 0; l < b; l++)
- T += "#define KERNEL_OFFSET".concat(l, " ").concat(this._glslFloat(o[l]), "\r\n"),
- T += "#define KERNEL_WEIGHT".concat(l, " ").concat(this._glslFloat(a[l]), "\r\n");
- var E = 0;
- for (l = y; l < o.length; l++)
- T += "#define KERNEL_DEP_OFFSET".concat(E, " ").concat(this._glslFloat(o[l]), "\r\n"),
- T += "#define KERNEL_DEP_WEIGHT".concat(E, " ").concat(this._glslFloat(a[l]), "\r\n"),
- E++;
- this.packedFloat && (T += "#define PACKEDFLOAT 1"),
- this._blockCompilation = !1,
- e.prototype.updateEffect.call(this, T, null, null, {
- varyingCount: b,
- depCount: E
- }, t, i)
- }
- ,
- t.prototype._nearestBestKernel = function(e) {
- for (var t = Math.round(e), i = 0, n = [t, t - 1, t + 1, t - 2, t + 2]; i < n.length; i++) {
- var r = n[i];
- if (r % 2 != 0 && Math.floor(r / 2) % 2 == 0 && r > 0)
- return Math.max(r, 3)
- }
- return Math.max(t, 3)
- }
- ,
- t.prototype._gaussianWeight = function(e) {
- var t = 1 / 3
- , i = -e * e / (2 * t * t);
- return 1 / (Math.sqrt(2 * Math.PI) * t) * Math.exp(i)
- }
- ,
- t.prototype._glslFloat = function(e, t) {
- return void 0 === t && (t = 8),
- e.toFixed(t).replace(/0+$/, "")
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,void 0,!1)
- }
- ), e, n, r)
- }
- ,
- k([Ce("kernel")], t.prototype, "_kernel", void 0),
- k([Ce("packedFloat")], t.prototype, "_packedFloat", void 0),
- k([Oe()], t.prototype, "direction", void 0),
- t
- }(Ba);
- y("BABYLON.BlurPostProcess", Fd);
- var wd = function(e) {
- function t(t, i, n, r, o, s, l) {
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === s && (s = io.BILINEAR_SAMPLINGMODE),
- void 0 === l && (l = !0);
- var c = e.call(this, t, i, n, r, !0, o, !1, s, l) || this;
- if (c.mirrorPlane = new hn(0,1,0,1),
- c._transformMatrix = P.Zero(),
- c._mirrorMatrix = P.Zero(),
- c._adaptiveBlurKernel = 0,
- c._blurKernelX = 0,
- c._blurKernelY = 0,
- c._blurRatio = 1,
- !(n = c.getScene()))
- return c;
- c.ignoreCameraViewport = !0,
- c._updateGammaSpace(),
- c._imageProcessingConfigChangeObserver = n.imageProcessingConfiguration.onUpdateParameters.add((function() {
- c._updateGammaSpace()
- }
- ));
- var u, h = n.getEngine();
- return h.supportsUniformBuffers && (c._sceneUBO = n.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(t, '")'))),
- c.onBeforeBindObservable.add((function() {
- var e;
- null === (e = h._debugPushGroup) || void 0 === e || e.call(h, "mirror generation for ".concat(t), 1)
- }
- )),
- c.onAfterUnbindObservable.add((function() {
- var e;
- null === (e = h._debugPopGroup) || void 0 === e || e.call(h, 1)
- }
- )),
- c.onBeforeRenderObservable.add((function() {
- c._sceneUBO && (c._currentSceneUBO = n.getSceneUniformBuffer(),
- n.setSceneUniformBuffer(c._sceneUBO),
- n.getSceneUniformBuffer().unbindEffect()),
- P.ReflectionToRef(c.mirrorPlane, c._mirrorMatrix),
- c._mirrorMatrix.multiplyToRef(n.getViewMatrix(), c._transformMatrix),
- n.setTransformMatrix(c._transformMatrix, n.getProjectionMatrix()),
- u = n.clipPlane,
- n.clipPlane = c.mirrorPlane,
- n.getEngine().cullBackFaces = !1,
- n._mirroredCameraPosition = x.TransformCoordinates(n.activeCamera.globalPosition, c._mirrorMatrix)
- }
- )),
- c.onAfterRenderObservable.add((function() {
- c._sceneUBO && n.setSceneUniformBuffer(c._currentSceneUBO),
- n.updateTransformMatrix(),
- n.getEngine().cullBackFaces = null,
- n._mirroredCameraPosition = null,
- n.clipPlane = u
- }
- )),
- c
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "blurRatio", {
- get: function() {
- return this._blurRatio
- },
- set: function(e) {
- this._blurRatio !== e && (this._blurRatio = e,
- this._preparePostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "adaptiveBlurKernel", {
- set: function(e) {
- this._adaptiveBlurKernel = e,
- this._autoComputeBlurKernel()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "blurKernel", {
- set: function(e) {
- this.blurKernelX = e,
- this.blurKernelY = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "blurKernelX", {
- get: function() {
- return this._blurKernelX
- },
- set: function(e) {
- this._blurKernelX !== e && (this._blurKernelX = e,
- this._preparePostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "blurKernelY", {
- get: function() {
- return this._blurKernelY
- },
- set: function(e) {
- this._blurKernelY !== e && (this._blurKernelY = e,
- this._preparePostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._autoComputeBlurKernel = function() {
- var e = this.getScene().getEngine()
- , t = this.getRenderWidth() / e.getRenderWidth()
- , i = this.getRenderHeight() / e.getRenderHeight();
- this.blurKernelX = this._adaptiveBlurKernel * t,
- this.blurKernelY = this._adaptiveBlurKernel * i
- }
- ,
- t.prototype._onRatioRescale = function() {
- this._sizeRatio && (this.resize(this._initialSizeParameter),
- this._adaptiveBlurKernel || this._preparePostProcesses()),
- this._adaptiveBlurKernel && this._autoComputeBlurKernel()
- }
- ,
- t.prototype._updateGammaSpace = function() {
- var e = this.getScene();
- e && (this.gammaSpace = !e.imageProcessingConfiguration.isEnabled || !e.imageProcessingConfiguration.applyByPostProcess)
- }
- ,
- t.prototype._preparePostProcesses = function() {
- if (this.clearPostProcesses(!0),
- this._blurKernelX && this._blurKernelY) {
- var e = this.getScene().getEngine()
- , t = e.getCaps().textureFloatRender && e.getCaps().textureFloatLinearFiltering ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT;
- this._blurX = new Fd("horizontal blur",new A(1,0),this._blurKernelX,this._blurRatio,null,io.BILINEAR_SAMPLINGMODE,e,!1,t),
- this._blurX.autoClear = !1,
- 1 === this._blurRatio && this.samples < 2 && this._texture ? this._blurX.inputTexture = this._renderTarget : this._blurX.alwaysForcePOT = !0,
- this._blurY = new Fd("vertical blur",new A(0,1),this._blurKernelY,this._blurRatio,null,io.BILINEAR_SAMPLINGMODE,e,!1,t),
- this._blurY.autoClear = !1,
- this._blurY.alwaysForcePOT = 1 !== this._blurRatio,
- 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)
- }
- ,
- t.prototype.clone = function() {
- var e = this.getScene();
- if (!e)
- return this;
- var i = this.getSize()
- , n = new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);
- return n.hasAlpha = this.hasAlpha,
- n.level = this.level,
- n.mirrorPlane = this.mirrorPlane.clone(),
- this.renderList && (n.renderList = this.renderList.slice(0)),
- n
- }
- ,
- t.prototype.serialize = function() {
- if (!this.name)
- return null;
- var t = e.prototype.serialize.call(this);
- return t.mirrorPlane = this.mirrorPlane.asArray(),
- t
- }
- ,
- t.prototype.dispose = function() {
- var t;
- e.prototype.dispose.call(this);
- var i = this.getScene();
- i && i.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),
- null === (t = this._sceneUBO) || void 0 === t || t.dispose()
- }
- ,
- t
- }(ns);
- io._CreateMirror = function(e, t, i, n) {
- return new wd(e,t,i,n)
- }
- ;
- var Bd = function(e) {
- function t(t, i, n, r, o, s, l, c, u, d, p, f, _, m, g) {
- void 0 === n && (n = null),
- void 0 === r && (r = !1),
- void 0 === o && (o = null),
- void 0 === s && (s = null),
- void 0 === l && (l = null),
- void 0 === c && (c = a.TEXTUREFORMAT_RGBA),
- void 0 === u && (u = !1),
- void 0 === d && (d = null),
- void 0 === p && (p = !1),
- void 0 === f && (f = .8),
- void 0 === _ && (_ = 0);
- var v, y = this;
- return (y = e.call(this, i) || this)._lodScale = .8,
- y._lodOffset = 0,
- y.onLoadObservable = new h,
- y.boundingBoxPosition = x.Zero(),
- y._rotationY = 0,
- y._files = null,
- y._forcedExtension = null,
- y._extensions = null,
- y.name = t,
- y.url = t,
- y._noMipmap = r,
- y.hasAlpha = !1,
- y._format = c,
- y.isCube = !0,
- y._textureMatrix = P.Identity(),
- y._createPolynomials = p,
- y.coordinatesMode = io.CUBIC_MODE,
- y._extensions = n,
- y._files = o,
- y._forcedExtension = d,
- y._loaderOptions = m,
- y._useSRGBBuffer = g,
- y._lodScale = f,
- y._lodOffset = _,
- t || o ? (y.updateURL(t, d, s, u, l, n, null === (v = y.getScene()) || void 0 === v ? void 0 : v.useDelayedTextureLoading, o),
- y) : y
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "boundingBoxSize", {
- get: function() {
- return this._boundingBoxSize
- },
- set: function(e) {
- if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
- this._boundingBoxSize = e;
- var t = this.getScene();
- t && t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationY", {
- get: function() {
- return this._rotationY
- },
- set: function(e) {
- this._rotationY = e,
- this.setReflectionTextureMatrix(P.RotationY(this._rotationY))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "noMipmap", {
- get: function() {
- return this._noMipmap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "forcedExtension", {
- get: function() {
- return this._forcedExtension
- },
- enumerable: !1,
- configurable: !0
- }),
- t.CreateFromImages = function(e, i, n) {
- var r = "";
- return e.forEach((function(e) {
- return r += e
- }
- )),
- new t(r,i,null,n,e)
- }
- ,
- t.CreateFromPrefilteredData = function(e, i, n, r) {
- void 0 === n && (n = null),
- void 0 === r && (r = !0);
- var o = i.useDelayedTextureLoading;
- i.useDelayedTextureLoading = !1;
- var a = new t(e,i,null,!1,null,null,null,void 0,!0,n,r);
- return i.useDelayedTextureLoading = o,
- a
- }
- ,
- t.prototype.getClassName = function() {
- return "CubeTexture"
- }
- ,
- t.prototype.updateURL = function(e, t, i, n, r, o, s, l) {
- void 0 === i && (i = null),
- void 0 === n && (n = !1),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === s && (s = !1),
- void 0 === l && (l = null),
- this.name && !ae(this.name, "data:") || (this.name = e),
- this.url = e;
- var c = e.lastIndexOf(".")
- , u = t || (c > -1 ? e.substring(c).toLowerCase() : "")
- , h = 0 === u.indexOf(".dds")
- , d = 0 === u.indexOf(".env");
- if (d ? (this.gammaSpace = !1,
- this._prefiltered = !1,
- this.anisotropicFilteringLevel = 1) : (this._prefiltered = n,
- n && (this.gammaSpace = !1,
- this.anisotropicFilteringLevel = 1)),
- l)
- this._files = l;
- else if (d || h || o || (o = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]),
- this._files = this._files || [],
- this._files.length = 0,
- o) {
- for (var p = 0; p < o.length; p++)
- this._files.push(e + o[p]);
- this._extensions = o
- }
- s ? (this.delayLoadState = a.DELAYLOADSTATE_NOTLOADED,
- this._delayedOnLoad = i,
- this._delayedOnError = r) : this._loadTexture(i, r)
- }
- ,
- t.prototype.delayLoad = function(e) {
- this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (e && (this._forcedExtension = e),
- this.delayLoadState = a.DELAYLOADSTATE_LOADED,
- this._loadTexture(this._delayedOnLoad, this._delayedOnError))
- }
- ,
- t.prototype.getReflectionTextureMatrix = function() {
- return this._textureMatrix
- }
- ,
- t.prototype.setReflectionTextureMatrix = function(e) {
- var t, i = this;
- e.updateFlag !== this._textureMatrix.updateFlag && (e.isIdentity() !== this._textureMatrix.isIdentity() && (null === (t = this.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return -1 !== e.getActiveTextures().indexOf(i)
- }
- ))),
- this._textureMatrix = e)
- }
- ,
- t.prototype._loadTexture = function(e, t) {
- var i, n = this;
- void 0 === e && (e = null),
- void 0 === t && (t = null);
- var r = this.getScene()
- , o = this._texture;
- this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer);
- var s = function() {
- var t;
- n.onLoadObservable.notifyObservers(n),
- o && (o.dispose(),
- null === (t = n.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),
- e && e()
- }
- , l = function(e, i) {
- n._loadingError = !0,
- n._errorObject = {
- message: e,
- exception: i
- },
- t && t(e, i),
- io.OnTextureLoadErrorObservable.notifyObservers(n)
- };
- this._texture ? this._texture.isReady ? gi.SetImmediate((function() {
- return s()
- }
- )) : this._texture.onLoadedObservable.add((function() {
- return s()
- }
- )) : (this._prefiltered ? this._texture = this._getEngine().createPrefilteredCubeTexture(this.url, r, this._lodScale, this._lodOffset, e, l, this._format, this._forcedExtension, this._createPolynomials) : this._texture = this._getEngine().createCubeTexture(this.url, r, this._files, this._noMipmap, e, l, this._format, this._forcedExtension, !1, this._lodScale, this._lodOffset, null, this._loaderOptions, !!this._useSRGBBuffer),
- null === (i = this._texture) || void 0 === i || i.onLoadedObservable.add((function() {
- return n.onLoadObservable.notifyObservers(n)
- }
- )))
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- var r = !1;
- return e.prefiltered && (r = e.prefiltered),
- new t(n + e.name,i,e.extensions,!1,e.files || null,null,null,void 0,r,e.forcedExtension)
- }
- ), e, i);
- if (e.boundingBoxPosition && (r.boundingBoxPosition = x.FromArray(e.boundingBoxPosition)),
- e.boundingBoxSize && (r.boundingBoxSize = x.FromArray(e.boundingBoxSize)),
- e.animations)
- for (var o = 0; o < e.animations.length; o++) {
- var a = e.animations[o]
- , s = b("BABYLON.Animation");
- s && r.animations.push(s.Parse(a))
- }
- return r
- }
- ,
- t.prototype.clone = function() {
- var e = this
- , i = 0
- , n = Ge.Clone((function() {
- var n = new t(e.url,e.getScene() || e._getEngine(),e._extensions,e._noMipmap,e._files);
- return i = n.uniqueId,
- n
- }
- ), this);
- return n.uniqueId = i,
- n
- }
- ,
- k([Ce()], t.prototype, "url", void 0),
- k([Ce("rotationY")], t.prototype, "rotationY", null),
- k([Ce("files")], t.prototype, "_files", void 0),
- k([Ce("forcedExtension")], t.prototype, "_forcedExtension", void 0),
- k([Ce("extensions")], t.prototype, "_extensions", void 0),
- k([Ue("textureMatrix")], t.prototype, "_textureMatrix", void 0),
- t
- }(Zr);
- io._CubeTextureParser = Bd.Parse,
- y("BABYLON.CubeTexture", Bd);
- Pt.IncludesShadersStore.backgroundFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n";
- Pt.IncludesShadersStore.backgroundUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\n#include<sceneUboDeclaration>\n";
- Pt.ShadersStore.backgroundPixelShader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#include<helperFunctions>\n#define RECIPROCAL_PI2 0.15915494\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV==1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV==2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n#ifndef BACKMAT_SHADOWONLY\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition.xyz),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\nvec4 color=vec4(finalColor,finalAlpha);\n#else\nvec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);\n#endif\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n#if !defined(SKIPFINALCOLORCLAMP)\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#endif\n#else\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
- Pt.IncludesShadersStore.backgroundVertexDeclaration = "uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";
- Pt.ShadersStore.backgroundVertexShader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV==0\nif (vDiffuseInfos.x==0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
- var Ud = function(e) {
- function t() {
- var t = e.call(this) || this;
- return t.DIFFUSE = !1,
- t.DIFFUSEDIRECTUV = 0,
- t.GAMMADIFFUSE = !1,
- t.DIFFUSEHASALPHA = !1,
- t.OPACITYFRESNEL = !1,
- t.REFLECTIONBLUR = !1,
- t.REFLECTIONFRESNEL = !1,
- t.REFLECTIONFALLOFF = !1,
- t.TEXTURELODSUPPORT = !1,
- t.PREMULTIPLYALPHA = !1,
- t.USERGBCOLOR = !1,
- t.USEHIGHLIGHTANDSHADOWCOLORS = !1,
- t.BACKMAT_SHADOWONLY = !1,
- t.NOISE = !1,
- t.REFLECTIONBGR = !1,
- t.IMAGEPROCESSING = !1,
- t.VIGNETTE = !1,
- t.VIGNETTEBLENDMODEMULTIPLY = !1,
- t.VIGNETTEBLENDMODEOPAQUE = !1,
- t.TONEMAPPING = !1,
- t.TONEMAPPING_ACES = !1,
- t.CONTRAST = !1,
- t.COLORCURVES = !1,
- t.COLORGRADING = !1,
- t.COLORGRADING3D = !1,
- t.SAMPLER3DGREENDEPTH = !1,
- t.SAMPLER3DBGRMAP = !1,
- t.IMAGEPROCESSINGPOSTPROCESS = !1,
- t.SKIPFINALCOLORCLAMP = !1,
- t.EXPOSURE = !1,
- t.MULTIVIEW = !1,
- t.REFLECTION = !1,
- t.REFLECTIONMAP_3D = !1,
- t.REFLECTIONMAP_SPHERICAL = !1,
- t.REFLECTIONMAP_PLANAR = !1,
- t.REFLECTIONMAP_CUBIC = !1,
- t.REFLECTIONMAP_PROJECTION = !1,
- t.REFLECTIONMAP_SKYBOX = !1,
- t.REFLECTIONMAP_EXPLICIT = !1,
- t.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- t.INVERTCUBICMAP = !1,
- t.REFLECTIONMAP_OPPOSITEZ = !1,
- t.LODINREFLECTIONALPHA = !1,
- t.GAMMAREFLECTION = !1,
- t.RGBDREFLECTION = !1,
- t.EQUIRECTANGULAR_RELFECTION_FOV = !1,
- t.MAINUV1 = !1,
- t.MAINUV2 = !1,
- t.UV1 = !1,
- t.UV2 = !1,
- t.CLIPPLANE = !1,
- t.CLIPPLANE2 = !1,
- t.CLIPPLANE3 = !1,
- t.CLIPPLANE4 = !1,
- t.CLIPPLANE5 = !1,
- t.CLIPPLANE6 = !1,
- t.POINTSIZE = !1,
- t.FOG = !1,
- t.NORMAL = !1,
- t.NUM_BONE_INFLUENCERS = 0,
- t.BonesPerMesh = 0,
- t.INSTANCES = !1,
- t.SHADOWFLOAT = !1,
- t.LOGARITHMICDEPTH = !1,
- t.NONUNIFORMSCALING = !1,
- t.ALPHATEST = !1,
- t.rebuild(),
- t
- }
- return U(t, e),
- t
- }(Si)
- , Vd = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n.primaryColor = D.White(),
- n._primaryColorShadowLevel = 0,
- n._primaryColorHighlightLevel = 0,
- n.reflectionTexture = null,
- n.reflectionBlur = 0,
- n.diffuseTexture = null,
- n._shadowLights = null,
- n.shadowLights = null,
- n.shadowLevel = 0,
- n.sceneCenter = x.Zero(),
- n.opacityFresnel = !0,
- n.reflectionFresnel = !1,
- n.reflectionFalloffDistance = 0,
- n.reflectionAmount = 1,
- n.reflectionReflectance0 = .05,
- n.reflectionReflectance90 = .5,
- n.useRGBColor = !0,
- n.enableNoise = !1,
- n._fovMultiplier = 1,
- n.useEquirectangularFOV = !1,
- n._maxSimultaneousLights = 4,
- n.maxSimultaneousLights = 4,
- n._shadowOnly = !1,
- n.shadowOnly = !1,
- n._imageProcessingObserver = null,
- n.switchToBGR = !1,
- n._renderTargets = new bi(16),
- n._reflectionControls = R.Zero(),
- n._white = D.White(),
- n._primaryShadowColor = D.Black(),
- n._primaryHighlightColor = D.Black(),
- n._attachImageProcessingConfiguration(null),
- n.getRenderTargetTextures = function() {
- return n._renderTargets.reset(),
- n._diffuseTexture && n._diffuseTexture.isRenderTarget && n._renderTargets.push(n._diffuseTexture),
- n._reflectionTexture && n._reflectionTexture.isRenderTarget && n._renderTargets.push(n._reflectionTexture),
- n._renderTargets
- }
- ,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "_perceptualColor", {
- get: function() {
- return this.__perceptualColor
- },
- set: function(e) {
- this.__perceptualColor = e,
- this._computePrimaryColorFromPerceptualColor(),
- this._markAllSubMeshesAsLightsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "primaryColorShadowLevel", {
- get: function() {
- return this._primaryColorShadowLevel
- },
- set: function(e) {
- this._primaryColorShadowLevel = e,
- this._computePrimaryColors(),
- this._markAllSubMeshesAsLightsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "primaryColorHighlightLevel", {
- get: function() {
- return this._primaryColorHighlightLevel
- },
- set: function(e) {
- this._primaryColorHighlightLevel = e,
- this._computePrimaryColors(),
- this._markAllSubMeshesAsLightsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "reflectionStandardFresnelWeight", {
- set: function(e) {
- var i = e;
- i < .5 ? (i *= 2,
- this.reflectionReflectance0 = t.StandardReflectance0 * i,
- this.reflectionReflectance90 = t.StandardReflectance90 * i) : (i = 2 * i - 1,
- this.reflectionReflectance0 = t.StandardReflectance0 + (1 - t.StandardReflectance0) * i,
- this.reflectionReflectance90 = t.StandardReflectance90 + (1 - t.StandardReflectance90) * i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fovMultiplier", {
- get: function() {
- return this._fovMultiplier
- },
- set: function(e) {
- isNaN(e) && (e = 1),
- this._fovMultiplier = Math.max(0, Math.min(2, e))
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._attachImageProcessingConfiguration = function(e) {
- var t = this;
- e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
- t._computePrimaryColorFromPerceptualColor(),
- t._markAllSubMeshesAsImageProcessingDirty()
- }
- ))))
- }
- ,
- Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- this._attachImageProcessingConfiguration(e),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorCurvesEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorGradingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraToneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(e) {
- this._imageProcessingConfiguration.toneMappingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraExposure", {
- get: function() {
- return this._imageProcessingConfiguration.exposure
- },
- set: function(e) {
- this._imageProcessingConfiguration.exposure = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraContrast", {
- get: function() {
- return this._imageProcessingConfiguration.contrast
- },
- set: function(e) {
- this._imageProcessingConfiguration.contrast = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorGradingTexture", {
- get: function() {
- return this._imageProcessingConfiguration.colorGradingTexture
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorGradingTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorCurves", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurves
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorCurves = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasRenderTargetTextures", {
- get: function() {
- return !(!this._diffuseTexture || !this._diffuseTexture.isRenderTarget) || !(!this._reflectionTexture || !this._reflectionTexture.isRenderTarget)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.needAlphaTesting = function() {
- return !0
- }
- ,
- t.prototype.needAlphaBlending = function() {
- return this.alpha < 1 || null != this._diffuseTexture && this._diffuseTexture.hasAlpha || this._shadowOnly
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- if (void 0 === i && (i = !1),
- t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
- return !0;
- t.materialDefines || (t.materialDefines = new Ud);
- var n = this.getScene()
- , r = t.materialDefines;
- if (this._isReadyForSubMesh(t))
- return !0;
- var o = n.getEngine();
- if (Mr.PrepareDefinesForLights(n, e, r, !1, this._maxSimultaneousLights),
- r._needNormals = !0,
- Mr.PrepareDefinesForMultiview(n, r),
- r._areTexturesDirty) {
- if (r._needUVs = !1,
- n.texturesEnabled) {
- if (n.getEngine().getCaps().textureLOD && (r.TEXTURELODSUPPORT = !0),
- this._diffuseTexture && vs.DiffuseTextureEnabled) {
- if (!this._diffuseTexture.isReadyOrNotBlocking())
- return !1;
- Mr.PrepareDefinesForMergedUV(this._diffuseTexture, r, "DIFFUSE"),
- r.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha,
- r.GAMMADIFFUSE = this._diffuseTexture.gammaSpace,
- r.OPACITYFRESNEL = this._opacityFresnel
- } else
- r.DIFFUSE = !1,
- r.DIFFUSEHASALPHA = !1,
- r.GAMMADIFFUSE = !1,
- r.OPACITYFRESNEL = !1;
- var s = this._reflectionTexture;
- if (s && vs.ReflectionTextureEnabled) {
- if (!s.isReadyOrNotBlocking())
- return !1;
- switch (r.REFLECTION = !0,
- r.GAMMAREFLECTION = s.gammaSpace,
- r.RGBDREFLECTION = s.isRGBD,
- r.REFLECTIONBLUR = this._reflectionBlur > 0,
- r.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !s.invertZ : s.invertZ,
- r.LODINREFLECTIONALPHA = s.lodLevelInAlpha,
- r.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV,
- r.REFLECTIONBGR = this.switchToBGR,
- s.coordinatesMode === io.INVCUBIC_MODE && (r.INVERTCUBICMAP = !0),
- r.REFLECTIONMAP_3D = s.isCube,
- s.coordinatesMode) {
- case io.EXPLICIT_MODE:
- r.REFLECTIONMAP_EXPLICIT = !0;
- break;
- case io.PLANAR_MODE:
- r.REFLECTIONMAP_PLANAR = !0;
- break;
- case io.PROJECTION_MODE:
- r.REFLECTIONMAP_PROJECTION = !0;
- break;
- case io.SKYBOX_MODE:
- r.REFLECTIONMAP_SKYBOX = !0;
- break;
- case io.SPHERICAL_MODE:
- r.REFLECTIONMAP_SPHERICAL = !0;
- break;
- case io.EQUIRECTANGULAR_MODE:
- r.REFLECTIONMAP_EQUIRECTANGULAR = !0;
- break;
- case io.FIXED_EQUIRECTANGULAR_MODE:
- r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
- break;
- case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
- r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
- break;
- case io.CUBIC_MODE:
- case io.INVCUBIC_MODE:
- default:
- r.REFLECTIONMAP_CUBIC = !0
- }
- this.reflectionFresnel ? (r.REFLECTIONFRESNEL = !0,
- r.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) : (r.REFLECTIONFRESNEL = !1,
- r.REFLECTIONFALLOFF = !1)
- } else
- r.REFLECTION = !1,
- r.REFLECTIONFRESNEL = !1,
- r.REFLECTIONFALLOFF = !1,
- r.REFLECTIONBLUR = !1,
- r.REFLECTIONMAP_3D = !1,
- r.REFLECTIONMAP_SPHERICAL = !1,
- r.REFLECTIONMAP_PLANAR = !1,
- r.REFLECTIONMAP_CUBIC = !1,
- r.REFLECTIONMAP_PROJECTION = !1,
- r.REFLECTIONMAP_SKYBOX = !1,
- r.REFLECTIONMAP_EXPLICIT = !1,
- r.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- r.INVERTCUBICMAP = !1,
- r.REFLECTIONMAP_OPPOSITEZ = !1,
- r.LODINREFLECTIONALPHA = !1,
- r.GAMMAREFLECTION = !1,
- r.RGBDREFLECTION = !1
- }
- r.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
- r.USERGBCOLOR = this._useRGBColor,
- r.NOISE = this._enableNoise
- }
- if (r._areLightsDirty && (r.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (0 !== this._primaryColorShadowLevel || 0 !== this._primaryColorHighlightLevel),
- r.BACKMAT_SHADOWONLY = this._shadowOnly),
- r._areImageProcessingDirty && this._imageProcessingConfiguration) {
- if (!this._imageProcessingConfiguration.isReady())
- return !1;
- this._imageProcessingConfiguration.prepareDefines(r)
- }
- if (Mr.PrepareDefinesForMisc(e, n, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e), r),
- Mr.PrepareDefinesForFrameBoundValues(n, o, r, i, null, t.getRenderingMesh().hasThinInstances),
- Mr.PrepareDefinesForAttributes(e, r, !1, !0, !1) && e && (n.getEngine().getCaps().standardDerivatives || e.isVerticesDataPresent(Bi.NormalKind) || (e.createNormals(!0),
- K.Warn("BackgroundMaterial: Normals have been created for the mesh: " + e.name))),
- r.isDirty) {
- r.markAsProcessed(),
- n.resetCachedMaterial();
- var l = new ys;
- r.FOG && l.addFallback(0, "FOG"),
- r.POINTSIZE && l.addFallback(1, "POINTSIZE"),
- r.MULTIVIEW && l.addFallback(0, "MULTIVIEW"),
- Mr.HandleFallbacksForShadows(r, l, this._maxSimultaneousLights);
- var c = [Bi.PositionKind];
- r.NORMAL && c.push(Bi.NormalKind),
- r.UV1 && c.push(Bi.UVKind),
- r.UV2 && c.push(Bi.UV2Kind),
- Mr.PrepareAttributesForBones(c, e, r, l),
- Mr.PrepareAttributesForInstances(c, r);
- var u = ["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"]
- , h = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"]
- , d = ["Material", "Scene"];
- Ri && (Ri.PrepareUniforms(u, r),
- Ri.PrepareSamplers(h, r)),
- Mr.PrepareUniformsAndSamplersList({
- uniformsNames: u,
- uniformBuffersNames: d,
- samplers: h,
- defines: r,
- maxSimultaneousLights: this._maxSimultaneousLights
- });
- var p = r.toString()
- , f = n.getEngine().createEffect("background", {
- attributes: c,
- uniformsNames: u,
- uniformBuffersNames: d,
- samplers: h,
- defines: p,
- fallbacks: l,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousLights: this._maxSimultaneousLights
- }
- }, o);
- t.setEffect(f, r, this._materialContext),
- this.buildUniformLayout()
- }
- return !(!t.effect || !t.effect.isReady() || (r._renderId = n.getRenderId(),
- t.effect._wasPreviouslyReady = !0,
- 0))
- }
- ,
- t.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())
- }
- ,
- t.prototype._computePrimaryColors = function() {
- 0 === this._primaryColorShadowLevel && 0 === this._primaryColorHighlightLevel || (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))
- }
- ,
- t.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()
- }
- ,
- t.prototype.unbind = function() {
- this._diffuseTexture && this._diffuseTexture.isRenderTarget && this._uniformBuffer.setTexture("diffuseSampler", null),
- this._reflectionTexture && this._reflectionTexture.isRenderTarget && this._uniformBuffer.setTexture("reflectionSampler", null),
- e.prototype.unbind.call(this)
- }
- ,
- t.prototype.bindOnlyWorldMatrix = function(e) {
- this._activeEffect.setMatrix("world", e)
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i) {
- var n = this.getScene()
- , r = i.materialDefines;
- if (r) {
- var o = i.effect;
- if (o) {
- this._activeEffect = o,
- this.bindOnlyWorldMatrix(e),
- Mr.BindBonesParameters(t, this._activeEffect);
- var a = this._mustRebind(n, o, t.visibility);
- if (a) {
- this._uniformBuffer.bindToEffect(o, "Material"),
- this.bindViewProjection(o);
- var s = this._reflectionTexture;
- this._uniformBuffer.useUbo && this.isFrozen && this._uniformBuffer.isSync || (n.texturesEnabled && (this._diffuseTexture && vs.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
- Mr.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")),
- s && vs.ReflectionTextureEnabled && (this._uniformBuffer.updateMatrix("reflectionMatrix", s.getReflectionTextureMatrix()),
- this._uniformBuffer.updateFloat2("vReflectionInfos", s.level, this._reflectionBlur),
- this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", s.getSize().width, s.lodGenerationScale, s.lodGenerationOffset))),
- this.shadowLevel > 0 && this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel),
- this._uniformBuffer.updateFloat("alpha", this.alpha),
- this.pointsCloud && this._uniformBuffer.updateFloat("pointSize", this.pointSize),
- r.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),
- n.texturesEnabled && (this._diffuseTexture && vs.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture),
- s && vs.ReflectionTextureEnabled && (r.REFLECTIONBLUR && r.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", s) : r.REFLECTIONBLUR ? (this._uniformBuffer.setTexture("reflectionSampler", s._lodTextureMid || s),
- this._uniformBuffer.setTexture("reflectionSamplerLow", s._lodTextureLow || s),
- this._uniformBuffer.setTexture("reflectionSamplerHigh", s._lodTextureHigh || s)) : this._uniformBuffer.setTexture("reflectionSampler", s),
- r.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)))),
- Mr.BindClipPlane(this._activeEffect, n),
- n.bindEyePosition(o)
- } else
- n.getEngine()._features.needToAlwaysBindUniformBuffers && (this._uniformBuffer.bindToEffect(o, "Material"),
- this._needToBindSceneUbo = !0);
- !a && this.isFrozen || (n.lightsEnabled && Mr.BindLights(n, t, this._activeEffect, r, this._maxSimultaneousLights),
- this.bindView(o),
- Mr.BindFogParameters(n, t, this._activeEffect, !0),
- this._imageProcessingConfiguration && this._imageProcessingConfiguration.bind(this._activeEffect)),
- this._afterBind(t, this._activeEffect),
- this._uniformBuffer.update()
- }
- }
- }
- ,
- t.prototype.hasTexture = function(t) {
- return !!e.prototype.hasTexture.call(this, t) || this._reflectionTexture === t || this._diffuseTexture === t
- }
- ,
- t.prototype.dispose = function(t, i) {
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- i && (this.diffuseTexture && this.diffuseTexture.dispose(),
- this.reflectionTexture && this.reflectionTexture.dispose()),
- this._renderTargets.dispose(),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- e.prototype.dispose.call(this, t)
- }
- ,
- t.prototype.clone = function(e) {
- var i = this;
- return Ge.Clone((function() {
- return new t(e,i.getScene())
- }
- ), this)
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.customType = "BABYLON.BackgroundMaterial",
- e
- }
- ,
- t.prototype.getClassName = function() {
- return "BackgroundMaterial"
- }
- ,
- t.Parse = function(e, i, n) {
- return Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n)
- }
- ,
- t.StandardReflectance0 = .05,
- t.StandardReflectance90 = .5,
- k([Me()], t.prototype, "_primaryColor", void 0),
- k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColor", void 0),
- k([Me()], t.prototype, "__perceptualColor", void 0),
- k([Ce()], t.prototype, "_primaryColorShadowLevel", void 0),
- k([Ce()], t.prototype, "_primaryColorHighlightLevel", void 0),
- k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "primaryColorHighlightLevel", null),
- k([Pe()], t.prototype, "_reflectionTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
- k([Ce()], t.prototype, "_reflectionBlur", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionBlur", void 0),
- k([Pe()], t.prototype, "_diffuseTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "diffuseTexture", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLights", void 0),
- k([Ce()], t.prototype, "_shadowLevel", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "shadowLevel", void 0),
- k([De()], t.prototype, "_sceneCenter", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "sceneCenter", void 0),
- k([Ce()], t.prototype, "_opacityFresnel", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "opacityFresnel", void 0),
- k([Ce()], t.prototype, "_reflectionFresnel", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFresnel", void 0),
- k([Ce()], t.prototype, "_reflectionFalloffDistance", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionFalloffDistance", void 0),
- k([Ce()], t.prototype, "_reflectionAmount", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionAmount", void 0),
- k([Ce()], t.prototype, "_reflectionReflectance0", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance0", void 0),
- k([Ce()], t.prototype, "_reflectionReflectance90", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionReflectance90", void 0),
- k([Ce()], t.prototype, "_useRGBColor", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRGBColor", void 0),
- k([Ce()], t.prototype, "_enableNoise", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableNoise", void 0),
- k([Ce()], t.prototype, "_maxSimultaneousLights", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "maxSimultaneousLights", void 0),
- k([Ce()], t.prototype, "_shadowOnly", void 0),
- k([Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "shadowOnly", void 0),
- k([we()], t.prototype, "_imageProcessingConfiguration", void 0),
- t
- }(gs);
- y("BABYLON.BackgroundMaterial", Vd);
- var kd = function() {
- function e(t, i) {
- var n = this;
- this._errorHandler = function(e, t) {
- n.onErrorObservable.notifyObservers({
- message: e,
- exception: t
- })
- }
- ,
- this._options = V(V({}, e._GetDefaultOptions()), t),
- this._scene = i,
- this.onErrorObservable = new h,
- this._setupBackground(),
- this._setupImageProcessing()
- }
- return e._GetDefaultOptions = function() {
- return {
- createGround: !0,
- groundSize: 15,
- groundTexture: this._GroundTextureCDNUrl,
- groundColor: new D(.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: a.TEXTURETYPE_UNSIGNED_INT,
- groundYBias: 1e-5,
- createSkybox: !0,
- skyboxSize: 20,
- skyboxTexture: this._SkyboxTextureCDNUrl,
- skyboxColor: new D(.2,.2,.3).toLinearSpace().scale(3),
- backgroundYRotation: 0,
- sizeAuto: !0,
- rootPosition: x.Zero(),
- setupImageProcessing: !0,
- environmentTexture: this._EnvironmentTextureCDNUrl,
- cameraExposure: .8,
- cameraContrast: 1.2,
- toneMappingEnabled: !0
- }
- }
- ,
- Object.defineProperty(e.prototype, "rootMesh", {
- get: function() {
- return this._rootMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skybox", {
- get: function() {
- return this._skybox
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skyboxTexture", {
- get: function() {
- return this._skyboxTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skyboxMaterial", {
- get: function() {
- return this._skyboxMaterial
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ground", {
- get: function() {
- return this._ground
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "groundTexture", {
- get: function() {
- return this._groundTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "groundMirror", {
- get: function() {
- return this._groundMirror
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "groundMirrorRenderList", {
- get: function() {
- return this._groundMirror ? this._groundMirror.renderList : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "groundMaterial", {
- get: function() {
- return this._groundMaterial
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.updateOptions = function(e) {
- var t = V(V({}, this._options), e);
- this._ground && !t.createGround && (this._ground.dispose(),
- this._ground = null),
- this._groundMaterial && !t.createGround && (this._groundMaterial.dispose(),
- this._groundMaterial = null),
- this._groundTexture && this._options.groundTexture != t.groundTexture && (this._groundTexture.dispose(),
- this._groundTexture = null),
- this._skybox && !t.createSkybox && (this._skybox.dispose(),
- this._skybox = null),
- this._skyboxMaterial && !t.createSkybox && (this._skyboxMaterial.dispose(),
- this._skyboxMaterial = null),
- this._skyboxTexture && this._options.skyboxTexture != t.skyboxTexture && (this._skyboxTexture.dispose(),
- this._skyboxTexture = null),
- this._groundMirror && !t.enableGroundMirror && (this._groundMirror.dispose(),
- this._groundMirror = null),
- this._scene.environmentTexture && this._options.environmentTexture != t.environmentTexture && this._scene.environmentTexture.dispose(),
- this._options = t,
- this._setupBackground(),
- this._setupImageProcessing()
- }
- ,
- e.prototype.setMainColor = function(e) {
- this.groundMaterial && (this.groundMaterial.primaryColor = e),
- this.skyboxMaterial && (this.skyboxMaterial.primaryColor = e),
- this.groundMirror && (this.groundMirror.clearColor = new N(e.r,e.g,e.b,1))
- }
- ,
- e.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())
- }
- ,
- e.prototype._setupEnvironmentTexture = function() {
- if (!this._scene.environmentTexture)
- if (this._options.environmentTexture instanceof Zr)
- this._scene.environmentTexture = this._options.environmentTexture;
- else {
- var e = Bd.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
- this._scene.environmentTexture = e
- }
- }
- ,
- e.prototype._setupBackground = function() {
- this._rootMesh || (this._rootMesh = new Vr("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
- }
- ,
- e.prototype._getSceneSize = function() {
- var e = this
- , t = this._options.groundSize
- , i = this._options.skyboxSize
- , n = this._options.rootPosition;
- if (!this._scene.meshes || 1 === this._scene.meshes.length)
- return {
- groundSize: t,
- skyboxSize: i,
- rootPosition: n
- };
- var r = this._scene.getWorldExtends((function(t) {
- return t !== e._ground && t !== e._rootMesh && t !== e._skybox
- }
- ))
- , o = r.max.subtract(r.min);
- if (this._options.sizeAuto) {
- this._scene.activeCamera instanceof _a && this._scene.activeCamera.upperRadiusLimit && (i = t = 2 * this._scene.activeCamera.upperRadiusLimit);
- var a = o.length();
- a > t && (i = t = 2 * a),
- t *= 1.1,
- i *= 1.5,
- (n = r.min.add(o.scale(.5))).y = r.min.y - this._options.groundYBias
- }
- return {
- groundSize: t,
- skyboxSize: i,
- rootPosition: n
- }
- }
- ,
- e.prototype._setupGround = function(e) {
- var t = this;
- this._ground && !this._ground.isDisposed() || (this._ground = vo("BackgroundPlane", {
- size: e.groundSize
- }, this._scene),
- this._ground.rotation.x = Math.PI / 2,
- this._ground.parent = this._rootMesh,
- this._ground.onDisposeObservable.add((function() {
- t._ground = null
- }
- ))),
- this._ground.receiveShadows = this._options.enableGroundShadow
- }
- ,
- e.prototype._setupGroundMaterial = function() {
- this._groundMaterial || (this._groundMaterial = new Vd("BackgroundPlaneMaterial",this._scene)),
- this._groundMaterial.alpha = this._options.groundOpacity,
- this._groundMaterial.alphaMode = a.ALPHA_PREMULTIPLIED_PORTERDUFF,
- 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)
- }
- ,
- e.prototype._setupGroundDiffuseTexture = function() {
- this._groundMaterial && (this._groundTexture || (this._options.groundTexture instanceof Zr ? this._groundMaterial.diffuseTexture = this._options.groundTexture : (this._groundTexture = new io(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)))
- }
- ,
- e.prototype._setupGroundMirrorTexture = function(e) {
- var t = io.CLAMP_ADDRESSMODE;
- if (!this._groundMirror && (this._groundMirror = new wd("BackgroundPlaneMirrorTexture",{
- ratio: this._options.groundMirrorSizeRatio
- },this._scene,!1,this._options.groundMirrorTextureType,io.BILINEAR_SAMPLINGMODE,!0),
- this._groundMirror.mirrorPlane = new hn(0,-1,0,e.rootPosition.y),
- this._groundMirror.anisotropicFilteringLevel = 1,
- this._groundMirror.wrapU = t,
- this._groundMirror.wrapV = t,
- this._groundMirror.renderList))
- for (var i = 0; i < this._scene.meshes.length; i++) {
- var n = this._scene.meshes[i];
- n !== this._ground && n !== this._skybox && n !== this._rootMesh && this._groundMirror.renderList.push(n)
- }
- var r = this._options.groundColor.toGammaSpace();
- this._groundMirror.clearColor = new N(r.r,r.g,r.b,1),
- this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel
- }
- ,
- e.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)
- }
- ,
- e.prototype._setupSkybox = function(e) {
- var t = this;
- this._skybox && !this._skybox.isDisposed() || (this._skybox = Ml("BackgroundSkybox", {
- size: e.skyboxSize,
- sideOrientation: Vr.BACKSIDE
- }, this._scene),
- this._skybox.onDisposeObservable.add((function() {
- t._skybox = null
- }
- ))),
- this._skybox.parent = this._rootMesh
- }
- ,
- e.prototype._setupSkyboxMaterial = function() {
- this._skybox && (this._skyboxMaterial || (this._skyboxMaterial = new Vd("BackgroundSkyboxMaterial",this._scene)),
- this._skyboxMaterial.useRGBColor = !1,
- this._skyboxMaterial.primaryColor = this._options.skyboxColor,
- this._skyboxMaterial.enableNoise = !0,
- this._skybox.material = this._skyboxMaterial)
- }
- ,
- e.prototype._setupSkyboxReflectionTexture = function() {
- this._skyboxMaterial && (this._skyboxTexture || (this._options.skyboxTexture instanceof Zr ? this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture : (this._skyboxTexture = new Bd(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
- this._skyboxTexture.coordinatesMode = io.SKYBOX_MODE,
- this._skyboxTexture.gammaSpace = !1,
- this._skyboxMaterial.reflectionTexture = this._skyboxTexture)))
- }
- ,
- e.prototype.dispose = function() {
- this._groundMaterial && this._groundMaterial.dispose(!0, !0),
- this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0),
- this._rootMesh.dispose(!1)
- }
- ,
- e._GroundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png",
- e._SkyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds",
- e._EnvironmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env",
- e
- }()
- , Gd = function(e) {
- function t(i, n, r, o, a) {
- void 0 === a && (a = null);
- var s = e.call(this, i, o) || this;
- s.onError = a,
- s._halfDome = !1,
- s._crossEye = !1,
- s._useDirectMapping = !1,
- s._textureMode = t.MODE_MONOSCOPIC,
- s._onBeforeCameraRenderObserver = null,
- s.onLoadErrorObservable = new h,
- s.onLoadObservable = new h,
- o = s.getScene(),
- i = i || "textureDome",
- r.resolution = 0 | Math.abs(r.resolution) || 32,
- r.clickToPlay = Boolean(r.clickToPlay),
- r.autoPlay = void 0 === r.autoPlay || Boolean(r.autoPlay),
- r.loop = void 0 === r.loop || Boolean(r.loop),
- r.size = Math.abs(r.size) || (o.activeCamera ? .48 * o.activeCamera.maxZ : 1e3),
- void 0 === r.useDirectMapping ? s._useDirectMapping = !0 : s._useDirectMapping = r.useDirectMapping,
- void 0 === r.faceForward && (r.faceForward = !0),
- s._setReady(!1),
- r.mesh ? s._mesh = r.mesh : s._mesh = Dl(i + "_mesh", {
- segments: r.resolution,
- diameter: r.size,
- updatable: !1,
- sideOrientation: Vr.BACKSIDE
- }, o);
- var l = s._material = new Vd(i + "_material",o);
- l.useEquirectangularFOV = !0,
- l.fovMultiplier = 1,
- l.opacityFresnel = !1;
- var c = s._initTexture(n, o, r);
- if (s.texture = c,
- s._mesh.material = l,
- s._mesh.parent = s,
- s._halfDomeMask = Dl("", {
- slice: .5,
- diameter: .98 * r.size,
- segments: 2 * r.resolution,
- sideOrientation: Vr.BACKSIDE
- }, o),
- s._halfDomeMask.rotate(vn.X, -Math.PI / 2),
- s._halfDomeMask.parent = s._mesh,
- s._halfDome = !!r.halfDomeMode,
- s._halfDomeMask.setEnabled(s._halfDome),
- s._crossEye = !!r.crossEyeMode,
- s._texture.anisotropicFilteringLevel = 1,
- s._texture.onLoadObservable.addOnce((function() {
- s._setReady(!0)
- }
- )),
- r.faceForward && o.activeCamera) {
- var u = o.activeCamera
- , d = x.Forward()
- , p = x.TransformNormal(d, u.getViewMatrix());
- p.normalize(),
- s.rotation.y = Math.acos(x.Dot(d, p))
- }
- return s._changeTextureMode(s._textureMode),
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "texture", {
- get: function() {
- return this._texture
- },
- set: function(e) {
- this._texture !== e && (this._texture = e,
- this._useDirectMapping ? (this._texture.wrapU = io.CLAMP_ADDRESSMODE,
- this._texture.wrapV = io.CLAMP_ADDRESSMODE,
- this._material.diffuseTexture = this._texture) : (this._texture.coordinatesMode = io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,
- this._texture.wrapV = io.CLAMP_ADDRESSMODE,
- this._material.reflectionTexture = this._texture),
- this._changeTextureMode(this._textureMode))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "mesh", {
- get: function() {
- return this._mesh
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fovMultiplier", {
- get: function() {
- return this._material.fovMultiplier
- },
- set: function(e) {
- this._material.fovMultiplier = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "textureMode", {
- get: function() {
- return this._textureMode
- },
- set: function(e) {
- this._textureMode !== e && this._changeTextureMode(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "halfDome", {
- get: function() {
- return this._halfDome
- },
- set: function(e) {
- this._halfDome = e,
- this._halfDomeMask.setEnabled(e),
- this._changeTextureMode(this._textureMode)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "crossEye", {
- get: function() {
- return this._crossEye
- },
- set: function(e) {
- this._crossEye = e,
- this._changeTextureMode(this._textureMode)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "material", {
- get: function() {
- return this._material
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._changeTextureMode = function(e) {
- var i = this;
- switch (this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
- this._textureMode = e,
- this._texture.uScale = 1,
- this._texture.vScale = 1,
- this._texture.uOffset = 0,
- this._texture.vOffset = 0,
- this._texture.vAng = 0,
- e) {
- case t.MODE_MONOSCOPIC:
- this._halfDome && (this._texture.uScale = 2,
- this._texture.uOffset = -1);
- break;
- case t.MODE_SIDEBYSIDE:
- this._texture.uScale = this._halfDome ? .99999 : .5;
- var n = this._halfDome ? 0 : .5
- , r = this._halfDome ? -.5 : 0;
- this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function(e) {
- var t = e.isRightCamera;
- i._crossEye && (t = !t),
- i._texture.uOffset = t ? n : r
- }
- ));
- break;
- case t.MODE_TOPBOTTOM:
- this._texture.vScale = this._halfDome ? .99999 : .5,
- this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add((function(e) {
- var t = e.isRightCamera;
- i._crossEye && (t = !t),
- i._texture.vOffset = t ? .5 : 0
- }
- ))
- }
- }
- ,
- t.prototype.dispose = function(t, i) {
- void 0 === i && (i = !1),
- this._texture.dispose(),
- this._mesh.dispose(),
- this._material.dispose(),
- this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
- this.onLoadErrorObservable.clear(),
- this.onLoadObservable.clear(),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.MODE_MONOSCOPIC = 0,
- t.MODE_TOPBOTTOM = 1,
- t.MODE_SIDEBYSIDE = 2,
- t
- }(yr)
- , zd = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "photoTexture", {
- get: function() {
- return this.texture
- },
- set: function(e) {
- this.texture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "imageMode", {
- get: function() {
- return this.textureMode
- },
- set: function(e) {
- this.textureMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._initTexture = function(e, t, i) {
- var n = this;
- return new io(e,t,!i.generateMipMaps,!this._useDirectMapping,void 0,(function() {
- n.onLoadObservable.notifyObservers()
- }
- ),(function(e, t) {
- n.onLoadErrorObservable.notifyObservers(e || "Unknown error occured"),
- n.onError && n.onError(e, t)
- }
- ))
- }
- ,
- t.MODE_MONOSCOPIC = Gd.MODE_MONOSCOPIC,
- t.MODE_TOPBOTTOM = Gd.MODE_TOPBOTTOM,
- t.MODE_SIDEBYSIDE = Gd.MODE_SIDEBYSIDE,
- t
- }(Gd)
- , Wd = 0
- , Hd = function(e) {
- if (!e.environmentBRDFTexture) {
- var t = e.useDelayedTextureLoading;
- e.useDelayedTextureLoading = !1;
- var i = e._blockEntityCollection;
- e._blockEntityCollection = !1;
- var n = io.CreateFromBase64String("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==", "EnvironmentBRDFTexture" + Wd++, e, !0, !1, io.BILINEAR_SAMPLINGMODE);
- e._blockEntityCollection = i;
- var r = e.getEngine().getLoadedTexturesCache()
- , o = r.indexOf(n.getInternalTexture());
- -1 !== o && r.splice(o, 1),
- n.isRGBD = !0,
- n.wrapU = io.CLAMP_ADDRESSMODE,
- n.wrapV = io.CLAMP_ADDRESSMODE,
- e.environmentBRDFTexture = n,
- e.useDelayedTextureLoading = t,
- Lc.ExpandRGBDTexture(n);
- var a = e.getEngine().onContextRestoredObservable.add((function() {
- n.isRGBD = !0;
- var e = function() {
- n.isReady() ? Lc.ExpandRGBDTexture(n) : gi.SetImmediate(e)
- };
- e()
- }
- ));
- e.onDisposeObservable.add((function() {
- e.getEngine().onContextRestoredObservable.remove(a)
- }
- ))
- }
- return e.environmentBRDFTexture
- }
- , Xd = {
- GetEnvironmentBRDFTexture: Hd
- }
- , jd = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.BRDF_V_HEIGHT_CORRELATED = !1,
- t.MS_BRDF_ENERGY_CONSERVATION = !1,
- t.SPHERICAL_HARMONICS = !1,
- t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1,
- t
- }
- return U(t, e),
- t
- }(Si)
- , Yd = function(e) {
- function t(i, n) {
- void 0 === n && (n = !0);
- var r = e.call(this, i, "PBRBRDF", 90, new jd, n) || this;
- return r._useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION,
- r.useEnergyConservation = t.DEFAULT_USE_ENERGY_CONSERVATION,
- r._useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
- r.useSmithVisibilityHeightCorrelated = t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
- r._useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS,
- r.useSphericalHarmonics = t.DEFAULT_USE_SPHERICAL_HARMONICS,
- r._useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
- r.useSpecularGlossinessInputEnergyConservation = t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
- r._internalMarkAllSubMeshesAsMiscDirty = i._dirtyCallbacks[a.MATERIAL_MiscDirtyFlag],
- r._enable(!0),
- r
- }
- return U(t, e),
- t.prototype._markAllSubMeshesAsMiscDirty = function() {
- this._internalMarkAllSubMeshesAsMiscDirty()
- }
- ,
- t.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
- }
- ,
- t.prototype.getClassName = function() {
- return "PBRBRDFConfiguration"
- }
- ,
- t.DEFAULT_USE_ENERGY_CONSERVATION = !0,
- t.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0,
- t.DEFAULT_USE_SPHERICAL_HARMONICS = !0,
- t.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0,
- k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useEnergyConservation", void 0),
- k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSmithVisibilityHeightCorrelated", void 0),
- k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSphericalHarmonics", void 0),
- k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "useSpecularGlossinessInputEnergyConservation", void 0),
- t
- }(Rs);
- Pt.IncludesShadersStore.pbrFragmentDeclaration = "uniform vec4 vEyePosition;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec4 vMetallicReflectanceFactors;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec3 vAmbientColor;\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize; \n#endif\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_ROUGHNESS\nuniform float vSheenRoughness;\n#endif\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#ifdef REALTIME_FILTERING\nuniform vec2 vRefractionFilteringInfo;\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nuniform vec2 vRefractionIntensityInfos;\nuniform mat4 refractionIntensityMatrix;\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nuniform vec2 vTranslucencyIntensityInfos;\nuniform mat4 translucencyIntensityMatrix;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif\n#ifdef PREPASS\n#ifdef SS_SCATTERING\nuniform float scatteringDiffusionProfile;\n#endif\n#endif\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n#endif\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";
- Pt.IncludesShadersStore.pbrUboDeclaration = "layout(std140,column_major) uniform;\nuniform Material {\nvec2 vAlbedoInfos;\nvec4 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec3 vReflectivityInfos;\nvec2 vMicroSurfaceSamplerInfos;\nvec2 vReflectionInfos;\nvec2 vReflectionFilteringInfo;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec3 vBumpInfos;\nmat4 albedoMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 reflectivityMatrix;\nmat4 microSurfaceSamplerMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 reflectionMatrix;\nvec3 vReflectionColor;\nvec4 vAlbedoColor;\nvec4 vLightingIntensity;\nvec3 vReflectionMicrosurfaceInfos;\nfloat pointSize;\nvec4 vReflectivityColor;\nvec3 vEmissiveColor;\nvec3 vAmbientColor;\nvec2 vDebugMode;\nvec4 vMetallicReflectanceFactors;\nvec2 vMetallicReflectanceInfos;\nmat4 metallicReflectanceMatrix;\nvec2 vReflectanceInfos;\nmat4 reflectanceMatrix;\nvec3 vSphericalL00;\nvec3 vSphericalL1_1;\nvec3 vSphericalL10;\nvec3 vSphericalL11;\nvec3 vSphericalL2_2;\nvec3 vSphericalL2_1;\nvec3 vSphericalL20;\nvec3 vSphericalL21;\nvec3 vSphericalL22;\nvec3 vSphericalX;\nvec3 vSphericalY;\nvec3 vSphericalZ;\nvec3 vSphericalXX_ZZ;\nvec3 vSphericalYY_ZZ;\nvec3 vSphericalZZ;\nvec3 vSphericalXY;\nvec3 vSphericalYZ;\nvec3 vSphericalZX;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n";
- Pt.IncludesShadersStore.pbrFragmentExtraDeclaration = "varying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#include<mainUVVaryingDeclaration>[1..7]\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n";
- Pt.IncludesShadersStore.samplerFragmentAlternateDeclaration = "#ifdef _DEFINENAME_\n#if _DEFINENAME_DIRECTUV==1\n#define v_VARYINGNAME_UV vMainUV1\n#elif _DEFINENAME_DIRECTUV==2\n#define v_VARYINGNAME_UV vMainUV2\n#elif _DEFINENAME_DIRECTUV==3\n#define v_VARYINGNAME_UV vMainUV3\n#elif _DEFINENAME_DIRECTUV==4\n#define v_VARYINGNAME_UV vMainUV4\n#elif _DEFINENAME_DIRECTUV==5\n#define v_VARYINGNAME_UV vMainUV5\n#elif _DEFINENAME_DIRECTUV==6\n#define v_VARYINGNAME_UV vMainUV6\n#else\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrFragmentSamplersDeclaration = "#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)\n#ifdef CLEARCOAT\n#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)\n#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D clearCoatRoughnessSampler;\n#endif\n#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)\n#endif\n#ifdef SHEEN\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)\n#include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D sheenRoughnessSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)\n#endif\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D reflectionSamplerLow;\nuniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform sampler2D refractionSamplerLow;\nuniform sampler2D refractionSamplerHigh;\n#endif\n#endif\n#endif\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)\n#include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)\n#endif\n";
- Pt.IncludesShadersStore.subSurfaceScatteringFunctions = "bool testLightingForSSS(float diffusionProfile)\n{\nreturn diffusionProfile<1.;\n}";
- Pt.IncludesShadersStore.importanceSampling = "vec3 hemisphereCosSample(vec2 u) {\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=1.-u.y;\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { \nfloat phi=2.*PI*u.x;\nfloat sinTheta=pow(u.y,a/(2.*a+1.));\nfloat cosTheta=sqrt(1.-sinTheta*sinTheta);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}";
- Pt.IncludesShadersStore.pbrHelperFunctions = "#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif\n";
- Pt.IncludesShadersStore.harmonicsFunctions = "#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+ vSphericalL1_1*(normal.y)\n+ vSphericalL10*(normal.z)\n+ vSphericalL11*(normal.x)\n+ vSphericalL2_2*(normal.y*normal.x)\n+ vSphericalL2_1*(normal.y*normal.z)\n+ vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+ vSphericalL21*(normal.z*normal.x)\n+ vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz *Nz+C1;\nvec3 t2=a2 *Ny+t1;\nvec3 t3=b3 *Nx+t2;\nreturn t3;\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrDirectLightingSetupFunctions = "struct preLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\nfloat attenuation;\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nresult.lightDistance=sqrt(result.lightDistanceSquared);\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.lightDistance=length(-lightData.xyz);\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
- Pt.IncludesShadersStore.pbrDirectLightingFalloffFunctions = "float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\nattenuation*=attenuation;\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=saturate(cd*lightAngleScale+lightAngleOffset);\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
- Pt.IncludesShadersStore.pbrBRDFFunctions = "#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\nvec2 UV=vec2(NdotV,perceptualRoughness);\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;\n#endif\nreturn reflectance;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n/* NOT USED\n#if defined(SHEEN) && defined(SHEEN_SOFTER)\nfloat getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness)\n{\nfloat c=1.0-NdotV;\nfloat c3=c*c*c;\nreturn 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));\n}\n#endif\n*/\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\n/**\n* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.\n* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table\n*/\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\nreturn 0.25/(VdotH*VdotH); \n}\n#endif\n#ifdef SHEEN\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n/* NOT USED\n#ifdef SHEEN_SOFTER\nfloat l(float x,float alphaG)\n{\nfloat oneMinusAlphaSq=(1.0-alphaG)*(1.0-alphaG);\nfloat a=mix(21.5473,25.3245,oneMinusAlphaSq);\nfloat b=mix(3.82987,3.32435,oneMinusAlphaSq);\nfloat c=mix(0.19823,0.16801,oneMinusAlphaSq);\nfloat d=mix(-1.97760,-1.27393,oneMinusAlphaSq);\nfloat e=mix(-4.32054,-4.85967,oneMinusAlphaSq);\nreturn a/(1.0+b*pow(x,c))+d*x+e;\n}\nfloat lambdaSheen(float cosTheta,float alphaG)\n{\nreturn abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));\n}\nfloat visibility_CharlieSheen(float NdotL,float NdotV,float alphaG)\n{\nfloat G=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));\nreturn G/(4.0*NdotV*NdotL);\n}\n#endif\n*/\n#endif\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";
- Pt.IncludesShadersStore.hdrFilteringFunctions = "#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU)\nfloat radicalInverse_VdC(uint bits) \n{\nbits=(bits<<16u) | (bits>>16u);\nbits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);\nbits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);\nbits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);\nbits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);\nreturn float(bits)*2.3283064365386963e-10; \n}\nvec2 hammersley(uint i,uint N)\n{\nreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\n}\n#else\nfloat vanDerCorpus(int n,int base)\n{\nfloat invBase=1.0/float(base);\nfloat denom =1.0;\nfloat result =0.0;\nfor(int i=0; i<32; ++i)\n{\nif(n>0)\n{\ndenom =mod(float(n),2.0);\nresult+=denom*invBase;\ninvBase=invBase/2.0;\nn =int(float(n)/2.0);\n}\n}\nreturn result;\n}\nvec2 hammersley(int i,int N)\n{\nreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\n}\n#endif\nfloat log4(float x) {\nreturn log2(x)/2.;\n}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\nconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\nconst float K=4.;\n#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nvec3 result=vec3(0.0);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\n#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{\nvec2 Xi=hammersley(i,NUM_SAMPLES);\nvec3 Ls=hemisphereCosSample(Xi);\nLs=normalize(Ls);\nvec3 Ns=vec3(0.,0.,1.);\nfloat NoL=dot(Ns,Ls);\nif (NoL>0.) {\nfloat pdf_inversed=PI/NoL;\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(l,0.0,maxLevel);\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c;\n}\n}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\nreturn result;\n}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nif (alphaG==0.) {\nvec3 c=textureCube(inputTexture,n).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;\n} else {\nvec3 result=vec3(0.);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\nfloat weight=0.;\n#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{\nvec2 Xi=hammersley(i,NUM_SAMPLES);\nvec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);\nfloat NoV=1.;\nfloat NoH=H.z;\nfloat NoH2=H.z*H.z;\nfloat NoL=2.*NoH2-1.;\nvec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);\nL=normalize(L);\nif (NoL>0.) {\nfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(float(l),0.0,maxLevel);\nweight+=NoL;\nvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;\n}\n}\nresult=result/weight;\nreturn result;\n}\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrDirectLightingFunctions = "#define CLEARCOATREFLECTANCE90 1.0\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\nfloat lightRoughness=lightRadius/lightDistance;\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat fresnel=1.;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\n/*#ifdef SHEEN_SOFTER\nfloat visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);\n#else */\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\n/* #endif */\nfloat sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrIBLFunctions = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,geometricNormal));\nreturn square(temp);\n}\n#endif\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockAlbedoOpacity = "struct albedoOpacityOutParams\n{\nvec3 surfaceAlbedo;\nfloat alpha;\n};\n#define pbr_inline\nvoid albedoOpacityBlock(\nin vec4 vAlbedoColor,\n#ifdef ALBEDO\nin vec4 albedoTexture,\nin vec2 albedoInfos,\n#endif\n#ifdef OPACITY\nin vec4 opacityMap,\nin vec2 vOpacityInfos,\n#endif\n#ifdef DETAIL\nin vec4 detailColor,\nin vec4 vDetailInfos,\n#endif\nout albedoOpacityOutParams outParams\n)\n{\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\n#ifdef GAMMAALBEDO\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\n#else\nsurfaceAlbedo*=albedoTexture.rgb;\n#endif\nsurfaceAlbedo*=albedoInfos.y;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#ifdef DETAIL\nfloat detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);\nsurfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; \n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n#ifdef OPACITY\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\nalpha=1.0;\n#endif\n#endif\n#endif\noutParams.surfaceAlbedo=surfaceAlbedo;\noutParams.alpha=alpha;\n}\n";
- Pt.IncludesShadersStore.pbrBlockReflectivity = "struct reflectivityOutParams\n{\nfloat microSurface;\nfloat roughness;\nvec3 surfaceReflectivityColor;\n#ifdef METALLICWORKFLOW\nvec3 surfaceAlbedo;\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\nvec3 ambientOcclusionColor;\n#endif\n#if DEBUGMODE>0\nvec4 surfaceMetallicColorMap;\nvec4 surfaceReflectivityColorMap;\nvec2 metallicRoughness;\nvec3 metallicF0;\n#endif\n};\n#define pbr_inline\nvoid reflectivityBlock(\nin vec4 vReflectivityColor,\n#ifdef METALLICWORKFLOW\nin vec3 surfaceAlbedo,\nin vec4 metallicReflectanceFactors,\n#endif\n#ifdef REFLECTIVITY\nin vec3 reflectivityInfos,\nin vec4 surfaceMetallicOrReflectivityColorMap,\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\nin vec3 ambientOcclusionColorIn,\n#endif\n#ifdef MICROSURFACEMAP\nin vec4 microSurfaceTexel,\n#endif\n#ifdef DETAIL\nin vec4 detailColor,\nin vec4 vDetailInfos,\n#endif\nout reflectivityOutParams outParams\n)\n{\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\n#if DEBUGMODE>0\noutParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;\n#endif\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);\noutParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;\n#endif\n#endif\n#endif\n#ifdef DETAIL\nfloat detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);\nfloat loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);\nfloat hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);\nmetallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));\n#endif\n#ifdef MICROSURFACEMAP\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n#if DEBUGMODE>0\noutParams.metallicRoughness=metallicRoughness;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\nmicroSurface=1.0-metallicRoughness.g;\nvec3 baseColor=surfaceAlbedo;\n#ifdef FROSTBITE_REFLECTANCE\noutParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\nvec3 metallicF0=metallicReflectanceFactors.rgb;\n#if DEBUGMODE>0\noutParams.metallicF0=metallicF0;\n#endif\noutParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);\nsurfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nsurfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;\n#if DEBUGMODE>0\noutParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;\n#endif\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceMetallicOrReflectivityColorMap.a;\nmicroSurface*=reflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\n#endif\n#endif\n#endif\nmicroSurface=saturate(microSurface);\nfloat roughness=1.-microSurface;\noutParams.microSurface=microSurface;\noutParams.roughness=roughness;\noutParams.surfaceReflectivityColor=surfaceReflectivityColor;\n}\n";
- Pt.IncludesShadersStore.pbrBlockAmbientOcclusion = "struct ambientOcclusionOutParams\n{\nvec3 ambientOcclusionColor;\n#if DEBUGMODE>0\nvec3 ambientOcclusionColorMap;\n#endif\n};\n#define pbr_inline\nvoid ambientOcclusionBlock(\n#ifdef AMBIENT\nin vec3 ambientOcclusionColorMap_,\nin vec4 vAmbientInfos,\n#endif\nout ambientOcclusionOutParams outParams\n)\n{\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#if DEBUGMODE>0\noutParams.ambientOcclusionColorMap=ambientOcclusionColorMap;\n#endif\n#endif\noutParams.ambientOcclusionColor=ambientOcclusionColor;\n}\n";
- Pt.IncludesShadersStore.pbrBlockAlphaFresnel = "#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\nstruct alphaFresnelOutParams\n{\nfloat alpha;\n};\n#define pbr_inline\nvoid alphaFresnelBlock(\nin vec3 normalW,\nin vec3 viewDirectionW,\nin float alpha,\nin float microSurface,\nout alphaFresnelOutParams outParams\n)\n{\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\noutParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (outParams.alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\noutParams.alpha=1.0;\n#endif\n#endif\n}\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockAnisotropic = "#ifdef ANISOTROPIC\nstruct anisotropicOutParams\n{\nfloat anisotropy;\nvec3 anisotropicTangent;\nvec3 anisotropicBitangent;\nvec3 anisotropicNormal;\n#if DEBUGMODE>0\nvec3 anisotropyMapData;\n#endif\n};\n#define pbr_inline\nvoid anisotropicBlock(\nin vec3 vAnisotropy,\n#ifdef ANISOTROPIC_TEXTURE\nin vec3 anisotropyMapData,\n#endif\nin mat3 TBN,\nin vec3 normalW,\nin vec3 viewDirectionW,\nout anisotropicOutParams outParams\n)\n{\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#if DEBUGMODE>0\noutParams.anisotropyMapData=anisotropyMapData;\n#endif\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\noutParams.anisotropy=anisotropy;\noutParams.anisotropicTangent=anisotropicTangent;\noutParams.anisotropicBitangent=anisotropicBitangent;\noutParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockReflection = "#ifdef REFLECTION\nstruct reflectionOutParams\n{\nvec4 environmentRadiance;\nvec3 environmentIrradiance;\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords;\n#else\nvec2 reflectionCoords;\n#endif\n#ifdef SS_TRANSLUCENCY\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nvec3 irradianceVector;\n#endif\n#endif\n#endif\n};\n#define pbr_inline\nvoid createReflectionCoords(\nin vec3 vPositionW,\nin vec3 normalW,\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REFLECTIONMAP_3D\nout vec3 reflectionCoords\n#else\nout vec2 reflectionCoords\n#endif\n)\n{\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionCoords=reflectionVector;\n#else\nreflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n}\n#define pbr_inline\n#define inline\nvoid sampleReflectionTexture(\nin float alphaG,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nin float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nin float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\nconst vec3 reflectionCoords,\n#else\nin sampler2D reflectionSampler,\nconst vec2 reflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\nout vec4 environmentRadiance\n)\n{\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\n#else\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#endif\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);\nif (lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nenvironmentRadiance=mix(\nenvironmentMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\n}\n#define pbr_inline\n#define inline\nvoid reflectionBlock(\nin vec3 vPositionW,\nin vec3 normalW,\nin float alphaG,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nin float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nin float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\n#else\nin sampler2D reflectionSampler,\n#endif\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nin vec3 vEnvironmentIrradiance,\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nin mat4 reflectionMatrix,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\nin samplerCube irradianceSampler,\n#else\nin sampler2D irradianceSampler,\n#endif\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\nout reflectionOutParams outParams\n)\n{\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.);\n#else\nvec2 reflectionCoords=vec2(0.);\n#endif\ncreateReflectionCoords(\nvPositionW,\nnormalW,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\nreflectionCoords\n);\nsampleReflectionTexture(\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionSampler,\nreflectionCoords,\n#else\nreflectionSampler,\nreflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentRadiance\n);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#ifdef SS_TRANSLUCENCY\noutParams.irradianceVector=irradianceVector;\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\nvec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);\nenvironmentIrradiance=environmentIrradiance4.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradiance4);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\nenvironmentIrradiance*=vReflectionColor.rgb;\noutParams.environmentRadiance=environmentRadiance;\noutParams.environmentIrradiance=environmentIrradiance;\noutParams.reflectionCoords=reflectionCoords;\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockSheen = "#ifdef SHEEN\nstruct sheenOutParams\n{\nfloat sheenIntensity;\nvec3 sheenColor;\nfloat sheenRoughness;\n#ifdef SHEEN_LINKWITHALBEDO\nvec3 surfaceAlbedo;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfloat sheenAlbedoScaling;\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nvec3 finalSheenRadianceScaled;\n#endif\n#if DEBUGMODE>0\nvec4 sheenMapData;\nvec3 sheenEnvironmentReflectance;\n#endif\n};\n#define pbr_inline\n#define inline\nvoid sheenBlock(\nin vec4 vSheenColor,\n#ifdef SHEEN_ROUGHNESS\nin float vSheenRoughness,\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nin vec4 sheenMapRoughnessData,\n#endif\n#endif\nin float roughness,\n#ifdef SHEEN_TEXTURE\nin vec4 sheenMapData,\nin float sheenMapLevel,\n#endif\nin float reflectance,\n#ifdef SHEEN_LINKWITHALBEDO\nin vec3 baseColor,\nin vec3 surfaceAlbedo,\n#endif\n#ifdef ENVIRONMENTBRDF\nin float NdotV,\nin vec3 environmentBrdf,\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nin vec2 AARoughnessFactors,\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\nin vec4 vLightingIntensity,\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\nin vec3 reflectionCoords,\n#else\nin sampler2D reflectionSampler,\nin vec2 reflectionCoords,\n#endif\nin float NdotVUnclamped,\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nin float seo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\nin float eho,\n#endif\n#endif\nout sheenOutParams outParams\n)\n{\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\n#if DEBUGMODE>0\noutParams.sheenMapData=sheenMapData;\n#endif\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\noutParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;\n#ifdef SHEEN_TEXTURE\nsheenIntensity*=sheenMapData.a;\n#endif\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\n#ifdef SHEEN_GAMMATEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#else\nsheenColor.rgb*=sheenMapData.rgb;\n#endif\nsheenColor.rgb*=sheenMapLevel;\n#endif\n#ifdef SHEEN_ROUGHNESS\nfloat sheenRoughness=vSheenRoughness;\n#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE\n#if defined(SHEEN_TEXTURE)\nsheenRoughness*=sheenMapData.a;\n#endif\n#elif defined(SHEEN_TEXTURE_ROUGHNESS)\n#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL\nsheenRoughness*=sheenMapData.a;\n#else\nsheenRoughness*=sheenMapRoughnessData.a;\n#endif\n#endif\n#else\nfloat sheenRoughness=roughness;\n#ifdef SHEEN_TEXTURE\nsheenIntensity*=sheenMapData.a;\n#endif\n#endif\n#if !defined(SHEEN_ALBEDOSCALING)\nsheenIntensity*=(1.-reflectance);\n#endif\nsheenColor*=sheenIntensity;\n#endif\n#ifdef ENVIRONMENTBRDF\n/*#ifdef SHEEN_SOFTER\nvec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));\n#else*/\n#ifdef SHEEN_ROUGHNESS\nvec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);\n#else\nvec3 environmentSheenBrdf=environmentBrdf;\n#endif\n/*#endif*/\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\nsampleReflectionTexture(\nsheenAlphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nsheenRoughness,\n#endif\nreflectionSampler,\nreflectionCoords,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentSheenRadiance\n);\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nsheenEnvironmentReflectance*=seo;\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\nsheenEnvironmentReflectance*=eho;\n#endif\n#if DEBUGMODE>0\noutParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;\n#endif\noutParams.finalSheenRadianceScaled=\nenvironmentSheenRadiance.rgb *\nsheenEnvironmentReflectance *\nvLightingIntensity.z;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\noutParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;\n#endif\noutParams.sheenIntensity=sheenIntensity;\noutParams.sheenColor=sheenColor;\noutParams.sheenRoughness=sheenRoughness;\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockClearcoat = "struct clearcoatOutParams\n{\nvec3 specularEnvironmentR0;\nfloat conservationFactor;\nvec3 clearCoatNormalW;\nvec2 clearCoatAARoughnessFactors;\nfloat clearCoatIntensity;\nfloat clearCoatRoughness;\n#ifdef REFLECTION\nvec3 finalClearCoatRadianceScaled;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 absorption;\nfloat clearCoatNdotVRefract;\nvec3 clearCoatColor;\nfloat clearCoatThickness;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nvec3 energyConservationFactorClearCoat;\n#endif\n#if DEBUGMODE>0\nmat3 TBNClearCoat;\nvec2 clearCoatMapData;\nvec4 clearCoatTintMapData;\nvec4 environmentClearCoatRadiance;\nfloat clearCoatNdotV;\nvec3 clearCoatEnvironmentReflectance;\n#endif\n};\n#ifdef CLEARCOAT\n#define pbr_inline\n#define inline\nvoid clearcoatBlock(\nin vec3 vPositionW,\nin vec3 geometricNormalW,\nin vec3 viewDirectionW,\nin vec2 vClearCoatParams,\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nin vec4 clearCoatMapRoughnessData,\n#endif\nin vec3 specularEnvironmentR0,\n#ifdef CLEARCOAT_TEXTURE\nin vec2 clearCoatMapData,\n#endif\n#ifdef CLEARCOAT_TINT\nin vec4 vClearCoatTintParams,\nin float clearCoatColorAtDistance,\nin vec4 vClearCoatRefractionParams,\n#ifdef CLEARCOAT_TINT_TEXTURE\nin vec4 clearCoatTintMapData,\n#endif\n#endif\n#ifdef CLEARCOAT_BUMP\nin vec2 vClearCoatBumpInfos,\nin vec4 clearCoatBumpMapData,\nin vec2 vClearCoatBumpUV,\n#if defined(TANGENT) && defined(NORMAL)\nin mat3 vTBN,\n#else\nin vec2 vClearCoatTangentSpaceParams,\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nin mat4 normalMatrix,\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nin vec3 faceNormal,\n#endif\n#ifdef REFLECTION\nin vec3 vReflectionMicrosurfaceInfos,\nin vec2 vReflectionInfos,\nin vec3 vReflectionColor,\nin vec4 vLightingIntensity,\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSampler,\n#else\nin sampler2D reflectionSampler,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nin samplerCube reflectionSamplerLow,\nin samplerCube reflectionSamplerHigh,\n#else\nin sampler2D reflectionSamplerLow,\nin sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vReflectionFilteringInfo,\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\nin float ambientMonochrome,\n#endif\n#endif\n#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\nin float frontFacingMultiplier,\n#endif\nout clearcoatOutParams outParams\n)\n{\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nclearCoatIntensity*=clearCoatMapData.x;\n#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#if DEBUGMODE>0\noutParams.clearCoatMapData=clearCoatMapData;\n#endif\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL\nclearCoatRoughness*=clearCoatMapData.y;\n#else\nclearCoatRoughness*=clearCoatMapRoughnessData.y;\n#endif\n#endif\noutParams.clearCoatIntensity=clearCoatIntensity;\noutParams.clearCoatRoughness=clearCoatRoughness;\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\n#ifdef CLEARCOAT_TINT_GAMMATEXTURE\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\n#else\nclearCoatColor*=clearCoatTintMapData.rgb;\n#endif\nclearCoatThickness*=clearCoatTintMapData.a;\n#if DEBUGMODE>0\noutParams.clearCoatTintMapData=clearCoatTintMapData;\n#endif\n#endif\noutParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\noutParams.clearCoatThickness=clearCoatThickness;\n#endif\n#ifdef CLEARCOAT_REMAP_F0\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\n#else\nvec3 specularEnvironmentR0Updated=specularEnvironmentR0;\n#endif\noutParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\nvec3 clearCoatNormalW=geometricNormalW;\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nvec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);\n#endif\n#if DEBUGMODE>0\noutParams.TBNClearCoat=TBNClearCoat;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;\n#endif\noutParams.clearCoatNormalW=clearCoatNormalW;\noutParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n#if DEBUGMODE>0\noutParams.clearCoatNdotV=clearCoatNdotV;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\noutParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\n#endif\n#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);\n#endif\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\nclearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\nsampleReflectionTexture(\nclearCoatAlphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nclearCoatNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nclearCoatRoughness,\n#endif\nreflectionSampler,\nclearCoatReflectionCoords,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentClearCoatRadiance\n);\n#if DEBUGMODE>0\noutParams.environmentClearCoatRadiance=environmentClearCoatRadiance;\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#if DEBUGMODE>0\noutParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;\n#endif\noutParams.finalClearCoatRadianceScaled=\nenvironmentClearCoatRadiance.rgb *\nclearCoatEnvironmentReflectance *\nvLightingIntensity.z;\n#endif\n#if defined(CLEARCOAT_TINT)\noutParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#endif\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\noutParams.conservationFactor=(1.-fresnelIBLClearCoat);\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\noutParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);\n#endif\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockSubSurface = "struct subSurfaceOutParams\n{\nvec3 specularEnvironmentReflectance;\n#ifdef SS_REFRACTION\nvec3 finalRefraction;\nvec3 surfaceAlbedo;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nfloat alpha;\n#endif\n#ifdef REFLECTION\nfloat refractionFactorForIrradiance;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nvec3 transmittance;\nfloat translucencyIntensity;\n#ifdef REFLECTION\nvec3 refractionIrradiance;\n#endif\n#endif\n#if DEBUGMODE>0\nvec4 thicknessMap;\nvec4 environmentRefraction;\nvec3 refractionTransmittance;\n#endif\n};\n#ifdef SUBSURFACE\n#define pbr_inline\n#define inline\nvoid subSurfaceBlock(\nin vec3 vSubSurfaceIntensity,\nin vec2 vThicknessParam,\nin vec4 vTintColor,\nin vec3 normalW,\nin vec3 specularEnvironmentReflectance,\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nin vec4 thicknessMap,\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nin vec4 refractionIntensityMap,\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nin vec4 translucencyIntensityMap,\n#endif\n#ifdef REFLECTION\n#ifdef SS_TRANSLUCENCY\nin mat4 reflectionMatrix,\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nin vec3 irradianceVector_,\n#endif\n#if defined(REALTIME_FILTERING)\nin samplerCube reflectionSampler,\nin vec2 vReflectionFilteringInfo,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\nin samplerCube irradianceSampler,\n#else\nin sampler2D irradianceSampler,\n#endif\n#endif\n#endif\n#endif\n#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\nin vec3 surfaceAlbedo,\n#endif\n#ifdef SS_REFRACTION\nin vec3 vPositionW,\nin vec3 viewDirectionW,\nin mat4 view,\nin vec4 vRefractionInfos,\nin mat4 refractionMatrix,\nin vec4 vRefractionMicrosurfaceInfos,\nin vec4 vLightingIntensity,\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nin float alpha,\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nin float NdotVUnclamped,\n#endif\n#ifdef SS_LINEARSPECULARREFRACTION\nin float roughness,\n#endif\nin float alphaG,\n#ifdef SS_REFRACTIONMAP_3D\nin samplerCube refractionSampler,\n#ifndef LODBASEDMICROSFURACE\nin samplerCube refractionSamplerLow,\nin samplerCube refractionSamplerHigh,\n#endif\n#else\nin sampler2D refractionSampler,\n#ifndef LODBASEDMICROSFURACE\nin sampler2D refractionSamplerLow,\nin sampler2D refractionSamplerHigh,\n#endif\n#endif\n#ifdef ANISOTROPIC\nin anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REALTIME_FILTERING\nin vec2 vRefractionFilteringInfo,\n#endif\n#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\nin vec3 refractionPosition,\nin vec3 refractionSize,\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nin vec3 vDiffusionDistance,\n#endif\nout subSurfaceOutParams outParams\n)\n{\noutParams.specularEnvironmentReflectance=specularEnvironmentReflectance;\n#ifdef SS_REFRACTION\nfloat refractionIntensity=vSubSurfaceIntensity.x;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nrefractionIntensity*=(1.0-alpha);\noutParams.alpha=1.0;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if defined(SS_USE_GLTF_TEXTURES)\nfloat thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;\n#else\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\n#endif\n#if DEBUGMODE>0\noutParams.thicknessMap=thicknessMap;\n#endif\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\n#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE)\n#if defined(SS_USE_GLTF_TEXTURES)\nrefractionIntensity*=thicknessMap.r;\n#else\nrefractionIntensity*=thicknessMap.g;\n#endif\n#endif\n#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE)\ntranslucencyIntensity*=thicknessMap.b;\n#endif\n#endif\n#else\nfloat thickness=vThicknessParam.y;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\n#ifdef SS_USE_GLTF_TEXTURES\nrefractionIntensity*=refractionIntensityMap.r;\n#else\nrefractionIntensity*=refractionIntensityMap.g;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\ntranslucencyIntensity*=translucencyIntensityMap.b;\n#endif\n#ifdef SS_TRANSLUCENCY\nthickness=maxEps(thickness);\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\ntransmittance*=translucencyIntensity;\noutParams.transmittance=transmittance;\noutParams.translucencyIntensity=translucencyIntensity;\n#endif\n#ifdef SS_REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef SS_REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n#ifdef SS_REFRACTIONMAP_3D\n#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);\n#endif\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\n#ifdef SS_USE_THICKNESS_AS_DEPTH\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\n#endif\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef SS_HAS_THICKNESS\nfloat ior=vRefractionInfos.y;\n#else\nfloat ior=vRefractionMicrosurfaceInfos.w;\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nfloat refractionAlphaG=alphaG;\nrefractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);\n#elif defined(SS_LINEARSPECULARREFRACTION)\nfloat refractionRoughness=alphaG;\nrefractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));\nfloat refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);\n#else\nfloat refractionAlphaG=alphaG;\nrefractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef SS_LODINREFRACTIONALPHA\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\n#ifdef REALTIME_FILTERING\nenvironmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);\n#else\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#endif\n#else\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif (lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n} else {\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef SS_RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef SS_GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n#ifdef SS_REFRACTION\nvec3 refractionTransmittance=vec3(refractionIntensity);\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\nenvironmentRefraction.rgb*=volumeAlbedo;\n#else\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);\n#endif\n#ifdef SS_ALBEDOFORREFRACTIONTINT\nenvironmentRefraction.rgb*=surfaceAlbedo.rgb;\n#endif\noutParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);\n#ifdef REFLECTION\noutParams.refractionFactorForIrradiance=(1.-refractionIntensity);\n#endif\n#ifdef UNUSED_MULTIPLEBOUNCES\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\noutParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\n#endif\nrefractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;\n#if DEBUGMODE>0\noutParams.refractionTransmittance=refractionTransmittance;\n#endif\noutParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;\n#if DEBUGMODE>0\noutParams.environmentRefraction=environmentRefraction;\n#endif\n#endif\n#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#else\nvec3 irradianceVector=irradianceVector_;\n#endif\n#if defined(USESPHERICALFROMREFLECTIONMAP)\n#if defined(REALTIME_FILTERING)\nvec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);\n#else\nvec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);\n#endif\n#elif defined(USEIRRADIANCEMAP)\n#ifdef REFLECTIONMAP_3D\nvec3 irradianceCoords=irradianceVector;\n#else\nvec2 irradianceCoords=irradianceVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nirradianceCoords/=irradianceVector.z;\n#endif\nirradianceCoords.y=1.0-irradianceCoords.y;\n#endif\nvec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);\n#ifdef RGBDREFLECTION\nrefractionIrradiance.rgb=fromRGBD(refractionIrradiance);\n#endif\n#ifdef GAMMAREFLECTION\nrefractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);\n#endif\n#else\nvec4 refractionIrradiance=vec4(0.);\n#endif\nrefractionIrradiance.rgb*=transmittance;\n#ifdef SS_ALBEDOFORTRANSLUCENCYTINT\nrefractionIrradiance.rgb*=surfaceAlbedo.rgb;\n#endif\noutParams.refractionIrradiance=refractionIrradiance.rgb;\n#endif\n}\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockNormalGeometric = "vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\nvec3 geometricNormalW=normalW;\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\ngeometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockNormalFinal = "#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockLightmapInit = "#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\n#ifdef GAMMALIGHTMAP\nlightmapColor.rgb=toLinearSpace(lightmapColor.rgb);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockGeometryInfo = "float NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\nalphaG+=AARoughnessFactors.y;\n#endif\n#if defined(ENVIRONMENTBRDF)\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness);\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=aoOut.ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);\n#endif\n#endif\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockReflectance0 = "float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);\nvec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);\n#else \nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);\n#endif\n#ifdef ALPHAFRESNEL\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nspecularEnvironmentR90=specularEnvironmentR90*reflectance90;\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockReflectance = "#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n#ifdef CLEARCOAT\nspecularEnvironmentReflectance*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nspecularEnvironmentReflectance*=clearcoatOut.absorption;\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockDirectLighting = "vec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.; \n#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\nvec3 absorption=vec3(0.);\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockFinalLitComponents = "#if defined(ENVIRONMENTBRDF)\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n#ifndef METALLICWORKFLOW\n#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n#endif\n#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)\nsurfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;\n#endif\n#ifdef REFLECTION\nvec3 finalIrradiance=reflectionOut.environmentIrradiance;\n#if defined(CLEARCOAT)\nfinalIrradiance*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nfinalIrradiance*=clearcoatOut.absorption;\n#endif\n#endif\n#if defined(SS_REFRACTION)\nfinalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;\n#endif\n#if defined(SS_TRANSLUCENCY)\nfinalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);\nfinalIrradiance+=subSurfaceOut.refractionIrradiance;\n#endif\nfinalIrradiance*=surfaceAlbedo.rgb;\nfinalIrradiance*=vLightingIntensity.z;\nfinalIrradiance*=aoOut.ambientOcclusionColor;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfinalSpecularScaled*=sheenOut.sheenAlbedoScaling;\n#endif\n#endif\n#ifdef REFLECTION\nvec3 finalRadiance=reflectionOut.environmentRadiance.rgb;\nfinalRadiance*=subSurfaceOut.specularEnvironmentReflectance;\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfinalRadianceScaled*=sheenOut.sheenAlbedoScaling;\n#endif\n#endif\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenOut.sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;\n#endif\n#endif\n#endif\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;\n#endif\n#ifdef SS_REFRACTION\nsubSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;\n#ifdef CLEARCOAT_TINT\nsubSurfaceOut.finalRefraction*=clearcoatOut.absorption;\n#endif\n#endif\n#endif\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n";
- Pt.IncludesShadersStore.pbrBlockFinalUnlitComponents = "vec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\nfinalDiffuse*=vLightingIntensity.x;\nvec3 finalAmbient=vAmbientColor;\nfinalAmbient*=surfaceAlbedo.rgb;\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\n#ifdef GAMMAEMISSIVE\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\n#else\nfinalEmissive*=emissiveColorTex.rgb;\n#endif\nfinalEmissive*= vEmissiveInfos.y;\n#endif\nfinalEmissive*=vLightingIntensity.y;\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;\n#endif\nfinalAmbient*=aoOut.ambientOcclusionColor;\nfinalDiffuse*=ambientOcclusionForDirectDiffuse;\n";
- Pt.IncludesShadersStore.pbrBlockFinalColorComposition = "vec4 finalColor=vec4(\nfinalAmbient +\nfinalDiffuse +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance +\n#endif\n#ifdef SPECULARTERM\nfinalSpecularScaled +\n#endif\n#ifdef SHEEN\nfinalSheenScaled +\n#endif\n#ifdef CLEARCOAT\nfinalClearCoatScaled +\n#endif\n#ifdef REFLECTION\nfinalRadianceScaled +\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\nsheenOut.finalSheenRadianceScaled +\n#endif\n#ifdef CLEARCOAT\nclearcoatOut.finalClearCoatRadianceScaled +\n#endif\n#endif\n#ifdef SS_REFRACTION\nsubSurfaceOut.finalRefraction +\n#endif\n#endif\nfinalEmissive,\nalpha);\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor.rgb;\n#else\nfinalColor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\nfinalColor=max(finalColor,0.0);\n";
- Pt.IncludesShadersStore.pbrBlockImageProcessing = "#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)\n#if !defined(SKIPFINALCOLORCLAMP)\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#endif\n#else\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\nfinalColor.rgb*=finalColor.a;\n#endif\n";
- Pt.IncludesShadersStore.pbrDebug = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {\n#if DEBUGMODE==1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==5\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE==7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==10 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearcoatOut.clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE==20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE==21 && defined(AMBIENT)\ngl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE==22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE==23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);\n#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;\n#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenOut.sheenMapData.rgb;\n#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;\n#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\ngl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;\n#elif DEBUGMODE==40 && defined(SS_REFRACTION)\ngl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==41 && defined(REFLECTION)\ngl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==54 && defined(REFLECTION)\ngl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==61\ngl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==62 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);\n#elif DEBUGMODE==71 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.metallicF0;\n#elif DEBUGMODE==63\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE==64\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE==65\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);\n#elif DEBUGMODE==68 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);\n#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=subSurfaceOut.transmittance;\n#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=subSurfaceOut.refractionTransmittance;\n#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE==86 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE==87\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#ifdef PREPASS\ngl_FragData[0]=toLinearSpace(gl_FragColor); \ngl_FragData[1]=vec4(0.,0.,0.,0.); \n#endif\nreturn;\n}\n#endif\n";
- Pt.ShadersStore.pbrPixelShader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\nprecision highp float;\n#include<oitDeclaration>\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE\n#endif\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<importanceSampling>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#include<pbrBlockAlbedoOpacity>\n#include<pbrBlockReflectivity>\n#include<pbrBlockAmbientOcclusion>\n#include<pbrBlockAlphaFresnel>\n#include<pbrBlockAnisotropic>\n#include<pbrBlockReflection>\n#include<pbrBlockSheen>\n#include<pbrBlockClearcoat>\n#include<pbrBlockSubSurface>\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<oitFragment>\n#include<clipPlaneFragment>\n#include<pbrBlockNormalGeometric>\n#include<bumpFragment>\n#include<pbrBlockNormalFinal>\nalbedoOpacityOutParams albedoOpacityOut;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#endif\nalbedoOpacityBlock(\nvAlbedoColor,\n#ifdef ALBEDO\nalbedoTexture,\nvAlbedoInfos,\n#endif\n#ifdef OPACITY\nopacityMap,\nvOpacityInfos,\n#endif\n#ifdef DETAIL\ndetailColor,\nvDetailInfos,\n#endif\nalbedoOpacityOut\n);\nvec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;\nfloat alpha=albedoOpacityOut.alpha;\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\nambientOcclusionOutParams aoOut;\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;\n#endif\nambientOcclusionBlock(\n#ifdef AMBIENT\nambientOcclusionColorMap,\nvAmbientInfos,\n#endif\naoOut\n);\n#include<pbrBlockLightmapInit>\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\nvec3 baseColor=surfaceAlbedo;\nreflectivityOutParams reflectivityOut;\n#if defined(REFLECTIVITY)\nvec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nvec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;\n#ifndef METALLICWORKFLOW\n#ifdef REFLECTIVITY_GAMMA\nsurfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);\n#endif\nsurfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;\n#endif\n#endif\n#if defined(MICROSURFACEMAP)\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\n#endif\n#ifdef METALLICWORKFLOW\nvec4 metallicReflectanceFactors=vMetallicReflectanceFactors;\n#ifdef REFLECTANCE\nvec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);\n#ifdef REFLECTANCE_GAMMA\nreflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);\n#endif\nmetallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;\n#endif\n#ifdef METALLIC_REFLECTANCE\nvec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);\n#ifdef METALLIC_REFLECTANCE_GAMMA\nmetallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);\n#endif\n#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY\nmetallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;\n#endif\nmetallicReflectanceFactors*=metallicReflectanceFactorsMap.a;\n#endif\n#endif\nreflectivityBlock(\nvReflectivityColor,\n#ifdef METALLICWORKFLOW\nsurfaceAlbedo,\nmetallicReflectanceFactors,\n#endif\n#ifdef REFLECTIVITY\nvReflectivityInfos,\nsurfaceMetallicOrReflectivityColorMap,\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\naoOut.ambientOcclusionColor,\n#endif\n#ifdef MICROSURFACEMAP\nmicroSurfaceTexel,\n#endif\n#ifdef DETAIL\ndetailColor,\nvDetailInfos,\n#endif\nreflectivityOut\n);\nfloat microSurface=reflectivityOut.microSurface;\nfloat roughness=reflectivityOut.roughness;\n#ifdef METALLICWORKFLOW\nsurfaceAlbedo=reflectivityOut.surfaceAlbedo;\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\naoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;\n#endif\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\nalphaFresnelOutParams alphaFresnelOut;\nalphaFresnelBlock(\nnormalW,\nviewDirectionW,\nalpha,\nmicroSurface,\nalphaFresnelOut\n);\nalpha=alphaFresnelOut.alpha;\n#endif\n#endif\n#include<pbrBlockGeometryInfo>\n#ifdef ANISOTROPIC\nanisotropicOutParams anisotropicOut;\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\n#endif\nanisotropicBlock(\nvAnisotropy,\n#ifdef ANISOTROPIC_TEXTURE\nanisotropyMapData,\n#endif\nTBN,\nnormalW,\nviewDirectionW,\nanisotropicOut\n);\n#endif\n#ifdef REFLECTION\nreflectionOutParams reflectionOut;\n#ifndef USE_CUSTOM_REFLECTION\nreflectionBlock(\nvPositionW,\nnormalW,\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\nreflectionSampler,\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nvEnvironmentIrradiance,\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nreflectionMatrix,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\nirradianceSampler,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nreflectionOut\n);\n#else\n#define CUSTOM_REFLECTION\n#endif\n#endif\n#include<pbrBlockReflectance0>\n#ifdef SHEEN\nsheenOutParams sheenOut;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);\n#endif\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nvec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;\n#endif\nsheenBlock(\nvSheenColor,\n#ifdef SHEEN_ROUGHNESS\nvSheenRoughness,\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nsheenMapRoughnessData,\n#endif\n#endif\nroughness,\n#ifdef SHEEN_TEXTURE\nsheenMapData,\nvSheenInfos.y,\n#endif\nreflectance,\n#ifdef SHEEN_LINKWITHALBEDO\nbaseColor,\nsurfaceAlbedo,\n#endif\n#ifdef ENVIRONMENTBRDF\nNdotV,\nenvironmentBrdf,\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nAARoughnessFactors,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\nvLightingIntensity,\nreflectionSampler,\nreflectionOut.reflectionCoords,\nNdotVUnclamped,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nseo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\neho,\n#endif\n#endif\nsheenOut\n);\n#ifdef SHEEN_LINKWITHALBEDO\nsurfaceAlbedo=sheenOut.surfaceAlbedo;\n#endif\n#endif\nclearcoatOutParams clearcoatOut;\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nvec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;\n#endif\n#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\n#endif\n#ifdef CLEARCOAT_BUMP\nvec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);\n#endif\nclearcoatBlock(\nvPositionW,\ngeometricNormalW,\nviewDirectionW,\nvClearCoatParams,\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nclearCoatMapRoughnessData,\n#endif\nspecularEnvironmentR0,\n#ifdef CLEARCOAT_TEXTURE\nclearCoatMapData,\n#endif\n#ifdef CLEARCOAT_TINT\nvClearCoatTintParams,\nclearCoatColorAtDistance,\nvClearCoatRefractionParams,\n#ifdef CLEARCOAT_TINT_TEXTURE\nclearCoatTintMapData,\n#endif\n#endif\n#ifdef CLEARCOAT_BUMP\nvClearCoatBumpInfos,\nclearCoatBumpMapData,\nvClearCoatBumpUV,\n#if defined(TANGENT) && defined(NORMAL)\nvTBN,\n#else\nvClearCoatTangentSpaceParams,\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nnormalMatrix,\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nfaceNormal,\n#endif\n#ifdef REFLECTION\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\nvLightingIntensity,\nreflectionSampler,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\nambientMonochrome,\n#endif\n#endif\n#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\n(gl_FrontFacing ? 1. : -1.),\n#endif\nclearcoatOut\n);\n#else\nclearcoatOut.specularEnvironmentR0=specularEnvironmentR0;\n#endif\n#include<pbrBlockReflectance>\nsubSurfaceOutParams subSurfaceOut;\n#ifdef SUBSURFACE\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nvec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nvec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);\n#endif\nsubSurfaceBlock(\nvSubSurfaceIntensity,\nvThicknessParam,\nvTintColor,\nnormalW,\nspecularEnvironmentReflectance,\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nthicknessMap,\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nrefractionIntensityMap,\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\ntranslucencyIntensityMap,\n#endif\n#ifdef REFLECTION\n#ifdef SS_TRANSLUCENCY\nreflectionMatrix,\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nreflectionOut.irradianceVector,\n#endif\n#if defined(REALTIME_FILTERING)\nreflectionSampler,\nvReflectionFilteringInfo,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\nirradianceSampler,\n#endif\n#endif\n#endif\n#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\nsurfaceAlbedo,\n#endif\n#ifdef SS_REFRACTION\nvPositionW,\nviewDirectionW,\nview,\nvRefractionInfos,\nrefractionMatrix,\nvRefractionMicrosurfaceInfos,\nvLightingIntensity,\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nalpha,\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nNdotVUnclamped,\n#endif\n#ifdef SS_LINEARSPECULARREFRACTION\nroughness,\n#endif\nalphaG,\nrefractionSampler,\n#ifndef LODBASEDMICROSFURACE\nrefractionSamplerLow,\nrefractionSamplerHigh,\n#endif\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\n#ifdef REALTIME_FILTERING\nvRefractionFilteringInfo,\n#endif\n#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\nvRefractionPosition,\nvRefractionSize,\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nvDiffusionDistance,\n#endif\nsubSurfaceOut\n);\n#ifdef SS_REFRACTION\nsurfaceAlbedo=subSurfaceOut.surfaceAlbedo;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nalpha=subSurfaceOut.alpha;\n#endif\n#endif\n#else\nsubSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;\n#endif\n#include<pbrBlockDirectLighting>\n#include<lightFragment>[0..maxSimultaneousLights]\n#include<pbrBlockFinalLitComponents>\n#endif \n#include<pbrBlockFinalUnlitComponents>\n#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION\n#include<pbrBlockFinalColorComposition>\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#include<pbrBlockImageProcessing>\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\nfloat writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_ALBEDO_SQRT\nvec3 sqAlbedo=sqrt(surfaceAlbedo); \n#endif\n#ifdef PREPASS_IRRADIANCE\nvec3 irradiance=finalDiffuse;\n#ifndef UNLIT\n#ifdef REFLECTION\nirradiance+=finalIrradiance;\n#endif\n#endif\n#ifdef SS_SCATTERING\ngl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a); \nirradiance/=sqAlbedo;\n#else\ngl_FragData[0]=finalColor; \nfloat scatteringDiffusionProfile=255.;\n#endif\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.); \n#else\ngl_FragData[0]=vec4(finalColor.rgb,finalColor.a);\n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); \n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo); \n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo); \n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(REFLECTIVITY)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,baseReflectivity.a*writeGeometryInfo);\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=finalColor;\n#endif\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth==nearestDepth) {\nfrontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;\nfrontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);\n} else {\nbackColor+=finalColor;\n}\n#endif\n#include<pbrDebug>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
- Pt.IncludesShadersStore.pbrVertexDeclaration = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef METALLIC_REFLECTANCE\nuniform vec2 vMetallicReflectanceInfos;\nuniform mat4 metallicReflectanceMatrix;\n#endif\n#ifdef REFLECTANCE\nuniform vec2 vReflectanceInfos;\nuniform mat4 reflectanceMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\n#ifdef SS_REFRACTIONINTENSITY_TEXTURE\nuniform vec2 vRefractionIntensityInfos;\nuniform mat4 refractionIntensityMatrix;\n#endif\n#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE\nuniform vec2 vTranslucencyIntensityInfos;\nuniform mat4 translucencyIntensityMatrix;\n#endif\n#endif\n#ifdef NORMAL\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n#endif\n#endif\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n#endif\n#define ADDITIONAL_VERTEX_DECLARATION\n";
- Pt.ShadersStore.pbrVertexShader = "precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#include<uvAttributeDeclaration>[2..7]\n#include<mainUVVaryingDeclaration>[1..7]\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\n#include<prePassVertexDeclaration>\n#include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)\n#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)\n#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)\n#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)\n#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)\n#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)\n#include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)\n#include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)\n#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)\n#ifdef CLEARCOAT\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)\n#include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)\n#endif\n#ifdef SHEEN\n#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)\n#endif\n#ifdef ANISOTROPIC\n#include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)\n#endif\n#ifdef SUBSURFACE\n#include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)\n#include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)\n#endif\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n#ifndef UV1\nvec2 uvUpdated=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#include<uvVariableDeclaration>[2..7]\n#include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)\n#ifdef CLEARCOAT\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)\n#endif\n#ifdef SHEEN\n#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.z)\n#endif\n#ifdef ANISOTROPIC\n#include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)\n#endif\n#ifdef SUBSURFACE\n#include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)\n#include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var Kd = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.CLEARCOAT = !1,
- t.CLEARCOAT_DEFAULTIOR = !1,
- t.CLEARCOAT_TEXTURE = !1,
- t.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
- t.CLEARCOAT_TEXTUREDIRECTUV = 0,
- t.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0,
- t.CLEARCOAT_BUMP = !1,
- t.CLEARCOAT_BUMPDIRECTUV = 0,
- t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
- t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1,
- t.CLEARCOAT_REMAP_F0 = !1,
- t.CLEARCOAT_TINT = !1,
- t.CLEARCOAT_TINT_TEXTURE = !1,
- t.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0,
- t.CLEARCOAT_TINT_GAMMATEXTURE = !1,
- t
- }
- return U(t, e),
- t
- }(Si)
- , Qd = function(e) {
- function t(i, n) {
- void 0 === n && (n = !0);
- var r = e.call(this, i, "PBRClearCoat", 100, new Kd, n) || this;
- return r._isEnabled = !1,
- r.isEnabled = !1,
- r.intensity = 1,
- r.roughness = 0,
- r._indexOfRefraction = t._DefaultIndexOfRefraction,
- r.indexOfRefraction = t._DefaultIndexOfRefraction,
- r._texture = null,
- r.texture = null,
- r._useRoughnessFromMainTexture = !0,
- r.useRoughnessFromMainTexture = !0,
- r._textureRoughness = null,
- r.textureRoughness = null,
- r._remapF0OnInterfaceChange = !0,
- r.remapF0OnInterfaceChange = !0,
- r._bumpTexture = null,
- r.bumpTexture = null,
- r._isTintEnabled = !1,
- r.isTintEnabled = !1,
- r.tintColor = D.White(),
- r.tintColorAtDistance = 1,
- r.tintThickness = 1,
- r._tintTexture = null,
- r.tintTexture = null,
- r._internalMarkAllSubMeshesAsTexturesDirty = i._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
- r
- }
- return U(t, e),
- t.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._enable(this._isEnabled),
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- if (!this._isEnabled)
- return !0;
- var n = this._material._disableBumpMap;
- if (e._areTexturesDirty && t.texturesEnabled) {
- if (this._texture && vs.ClearCoatTextureEnabled && !this._texture.isReadyOrNotBlocking())
- return !1;
- if (this._textureRoughness && vs.ClearCoatTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())
- return !1;
- if (i.getCaps().standardDerivatives && this._bumpTexture && vs.ClearCoatBumpTextureEnabled && !n && !this._bumpTexture.isReady())
- return !1;
- if (this._isTintEnabled && this._tintTexture && vs.ClearCoatTintTextureEnabled && !this._tintTexture.isReadyOrNotBlocking())
- return !1
- }
- return !0
- }
- ,
- t.prototype.prepareDefines = function(e, i) {
- var n;
- this._isEnabled ? (e.CLEARCOAT = !0,
- e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
- e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = null !== this._texture && this._texture._texture === (null === (n = this._textureRoughness) || void 0 === n ? void 0 : n._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
- e.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange,
- e._areTexturesDirty && i.texturesEnabled && (this._texture && vs.ClearCoatTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._texture, e, "CLEARCOAT_TEXTURE") : e.CLEARCOAT_TEXTURE = !1,
- this._textureRoughness && vs.ClearCoatTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._textureRoughness, e, "CLEARCOAT_TEXTURE_ROUGHNESS") : e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
- this._bumpTexture && vs.ClearCoatBumpTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._bumpTexture, e, "CLEARCOAT_BUMP") : e.CLEARCOAT_BUMP = !1,
- e.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === t._DefaultIndexOfRefraction,
- this._isTintEnabled ? (e.CLEARCOAT_TINT = !0,
- this._tintTexture && vs.ClearCoatTintTextureEnabled ? (Mr.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)
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i, n) {
- var r, o, a, s, l, c, u, h;
- if (this._isEnabled) {
- var d = n.materialDefines
- , p = this._material.isFrozen
- , f = this._material._disableBumpMap
- , _ = this._material._invertNormalMapX
- , m = this._material._invertNormalMapY
- , g = d.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
- if (!e.useUbo || !p || !e.isSync) {
- g && vs.ClearCoatTextureEnabled ? (e.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
- Mr.BindTextureMatrix(this._texture, e, "clearCoat")) : (this._texture || this._textureRoughness) && vs.ClearCoatTextureEnabled && (e.updateFloat4("vClearCoatInfos", null !== (o = null === (r = this._texture) || void 0 === r ? void 0 : r.coordinatesIndex) && void 0 !== o ? o : 0, null !== (s = null === (a = this._texture) || void 0 === a ? void 0 : a.level) && void 0 !== s ? s : 0, null !== (c = null === (l = this._textureRoughness) || void 0 === l ? void 0 : l.coordinatesIndex) && void 0 !== c ? c : 0, null !== (h = null === (u = this._textureRoughness) || void 0 === u ? void 0 : u.level) && void 0 !== h ? h : 0),
- this._texture && Mr.BindTextureMatrix(this._texture, e, "clearCoat"),
- !this._textureRoughness || g || d.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE || Mr.BindTextureMatrix(this._textureRoughness, e, "clearCoatRoughness")),
- this._bumpTexture && i.getCaps().standardDerivatives && vs.ClearCoatTextureEnabled && !f && (e.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level),
- Mr.BindTextureMatrix(this._bumpTexture, e, "clearCoatBump"),
- t._mirroredCameraPosition ? e.updateFloat2("vClearCoatTangentSpaceParams", _ ? 1 : -1, m ? 1 : -1) : e.updateFloat2("vClearCoatTangentSpaceParams", _ ? -1 : 1, m ? -1 : 1)),
- this._tintTexture && vs.ClearCoatTintTextureEnabled && (e.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level),
- Mr.BindTextureMatrix(this._tintTexture, e, "clearCoatTint")),
- e.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
- var v = 1 - this._indexOfRefraction
- , y = 1 + this._indexOfRefraction
- , b = Math.pow(-v / y, 2)
- , T = 1 / this._indexOfRefraction;
- e.updateFloat4("vClearCoatRefractionParams", b, T, v, y),
- 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)))
- }
- t.texturesEnabled && (this._texture && vs.ClearCoatTextureEnabled && e.setTexture("clearCoatSampler", this._texture),
- this._textureRoughness && !g && !d.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && vs.ClearCoatTextureEnabled && e.setTexture("clearCoatRoughnessSampler", this._textureRoughness),
- this._bumpTexture && i.getCaps().standardDerivatives && vs.ClearCoatBumpTextureEnabled && !f && e.setTexture("clearCoatBumpSampler", this._bumpTexture),
- this._isTintEnabled && this._tintTexture && vs.ClearCoatTintTextureEnabled && e.setTexture("clearCoatTintSampler", this._tintTexture))
- }
- }
- ,
- t.prototype.hasTexture = function(e) {
- return this._texture === e || this._textureRoughness === e || this._bumpTexture === e || this._tintTexture === e
- }
- ,
- t.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)
- }
- ,
- t.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)
- }
- ,
- t.prototype.dispose = function(e) {
- var t, i, n, r;
- e && (null === (t = this._texture) || void 0 === t || t.dispose(),
- null === (i = this._textureRoughness) || void 0 === i || i.dispose(),
- null === (n = this._bumpTexture) || void 0 === n || n.dispose(),
- null === (r = this._tintTexture) || void 0 === r || r.dispose())
- }
- ,
- t.prototype.getClassName = function() {
- return "PBRClearCoatConfiguration"
- }
- ,
- t.prototype.addFallbacks = function(e, t, i) {
- return e.CLEARCOAT_BUMP && t.addFallback(i++, "CLEARCOAT_BUMP"),
- e.CLEARCOAT_TINT && t.addFallback(i++, "CLEARCOAT_TINT"),
- e.CLEARCOAT && t.addFallback(i++, "CLEARCOAT"),
- i
- }
- ,
- t.prototype.getSamplers = function(e) {
- e.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler")
- }
- ,
- t.prototype.getUniforms = function() {
- return {
- ubo: [{
- name: "vClearCoatParams",
- size: 2,
- type: "vec2"
- }, {
- name: "vClearCoatRefractionParams",
- size: 4,
- type: "vec4"
- }, {
- name: "vClearCoatInfos",
- size: 4,
- type: "vec4"
- }, {
- name: "clearCoatMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "clearCoatRoughnessMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "vClearCoatBumpInfos",
- size: 2,
- type: "vec2"
- }, {
- name: "vClearCoatTangentSpaceParams",
- size: 2,
- type: "vec2"
- }, {
- name: "clearCoatBumpMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "vClearCoatTintParams",
- size: 4,
- type: "vec4"
- }, {
- name: "clearCoatColorAtDistance",
- size: 1,
- type: "float"
- }, {
- name: "vClearCoatTintInfos",
- size: 2,
- type: "vec2"
- }, {
- name: "clearCoatTintMatrix",
- size: 16,
- type: "mat4"
- }]
- }
- }
- ,
- t._DefaultIndexOfRefraction = 1.5,
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
- k([Ce()], t.prototype, "intensity", void 0),
- k([Ce()], t.prototype, "roughness", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "remapF0OnInterfaceChange", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTintEnabled", void 0),
- k([Me()], t.prototype, "tintColor", void 0),
- k([Ce()], t.prototype, "tintColorAtDistance", void 0),
- k([Ce()], t.prototype, "tintThickness", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "tintTexture", void 0),
- t
- }(Rs)
- , qd = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.ANISOTROPIC = !1,
- t.ANISOTROPIC_TEXTURE = !1,
- t.ANISOTROPIC_TEXTUREDIRECTUV = 0,
- t.MAINUV1 = !1,
- t
- }
- return U(t, e),
- t
- }(Si)
- , Zd = function(e) {
- function t(t, i) {
- void 0 === i && (i = !0);
- var n = e.call(this, t, "PBRAnisotropic", 110, new qd, i) || this;
- return n._isEnabled = !1,
- n.isEnabled = !1,
- n.intensity = 1,
- n.direction = new A(1,0),
- n._texture = null,
- n.texture = null,
- n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
- n
- }
- return U(t, e),
- t.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._enable(this._isEnabled),
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t) {
- return !this._isEnabled || !(e._areTexturesDirty && t.texturesEnabled && this._texture && vs.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking())
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- this._isEnabled ? (e.ANISOTROPIC = this._isEnabled,
- this._isEnabled && !i.isVerticesDataPresent(Bi.TangentKind) && (e._needUVs = !0,
- e.MAINUV1 = !0),
- e._areTexturesDirty && t.texturesEnabled && (this._texture && vs.AnisotropicTextureEnabled ? Mr.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1)) : (e.ANISOTROPIC = !1,
- e.ANISOTROPIC_TEXTURE = !1)
- }
- ,
- t.prototype.bindForSubMesh = function(e, t) {
- if (this._isEnabled) {
- var i = this._material.isFrozen;
- e.useUbo && i && e.isSync || (this._texture && vs.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level),
- Mr.BindTextureMatrix(this._texture, e, "anisotropy")),
- e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)),
- t.texturesEnabled && this._texture && vs.AnisotropicTextureEnabled && e.setTexture("anisotropySampler", this._texture)
- }
- }
- ,
- t.prototype.hasTexture = function(e) {
- return this._texture === e
- }
- ,
- t.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture)
- }
- ,
- t.prototype.getAnimatables = function(e) {
- this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
- }
- ,
- t.prototype.dispose = function(e) {
- e && this._texture && this._texture.dispose()
- }
- ,
- t.prototype.getClassName = function() {
- return "PBRAnisotropicConfiguration"
- }
- ,
- t.prototype.addFallbacks = function(e, t, i) {
- return e.ANISOTROPIC && t.addFallback(i++, "ANISOTROPIC"),
- i
- }
- ,
- t.prototype.getSamplers = function(e) {
- e.push("anisotropySampler")
- }
- ,
- t.prototype.getUniforms = function() {
- return {
- ubo: [{
- name: "vAnisotropy",
- size: 3,
- type: "vec3"
- }, {
- name: "vAnisotropyInfos",
- size: 2,
- type: "vec2"
- }, {
- name: "anisotropyMatrix",
- size: 16,
- type: "mat4"
- }]
- }
- }
- ,
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
- k([Ce()], t.prototype, "intensity", void 0),
- k([Oe()], t.prototype, "direction", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
- t
- }(Rs)
- , Jd = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.SHEEN = !1,
- t.SHEEN_TEXTURE = !1,
- t.SHEEN_GAMMATEXTURE = !1,
- t.SHEEN_TEXTURE_ROUGHNESS = !1,
- t.SHEEN_TEXTUREDIRECTUV = 0,
- t.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0,
- t.SHEEN_LINKWITHALBEDO = !1,
- t.SHEEN_ROUGHNESS = !1,
- t.SHEEN_ALBEDOSCALING = !1,
- t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
- t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1,
- t
- }
- return U(t, e),
- t
- }(Si)
- , $d = function(e) {
- function t(t, i) {
- void 0 === i && (i = !0);
- var n = e.call(this, t, "Sheen", 120, new Jd, i) || this;
- return n._isEnabled = !1,
- n.isEnabled = !1,
- n._linkSheenWithAlbedo = !1,
- n.linkSheenWithAlbedo = !1,
- n.intensity = 1,
- n.color = D.White(),
- n._texture = null,
- n.texture = null,
- n._useRoughnessFromMainTexture = !0,
- n.useRoughnessFromMainTexture = !0,
- n._roughness = null,
- n.roughness = null,
- n._textureRoughness = null,
- n.textureRoughness = null,
- n._albedoScaling = !1,
- n.albedoScaling = !1,
- n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
- n
- }
- return U(t, e),
- t.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._enable(this._isEnabled),
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t) {
- if (!this._isEnabled)
- return !0;
- if (e._areTexturesDirty && t.texturesEnabled) {
- if (this._texture && vs.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking())
- return !1;
- if (this._textureRoughness && vs.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())
- return !1
- }
- return !0
- }
- ,
- t.prototype.prepareDefines = function(e, t) {
- var i;
- this._isEnabled ? (e.SHEEN = !0,
- e.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo,
- e.SHEEN_ROUGHNESS = null !== this._roughness,
- e.SHEEN_ALBEDOSCALING = this._albedoScaling,
- e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
- e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = null !== this._texture && this._texture._texture === (null === (i = this._textureRoughness) || void 0 === i ? void 0 : i._texture) && this._texture.checkTransformsAreIdentical(this._textureRoughness),
- e._areTexturesDirty && t.texturesEnabled && (this._texture && vs.SheenTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"),
- e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1,
- this._textureRoughness && vs.SheenTextureEnabled ? Mr.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)
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i, n) {
- var r, o, a, s, l, c, u, h;
- if (this._isEnabled) {
- var d = n.materialDefines
- , p = this._material.isFrozen
- , f = d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
- e.useUbo && p && e.isSync || (f && vs.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
- Mr.BindTextureMatrix(this._texture, e, "sheen")) : (this._texture || this._textureRoughness) && vs.SheenTextureEnabled && (e.updateFloat4("vSheenInfos", null !== (o = null === (r = this._texture) || void 0 === r ? void 0 : r.coordinatesIndex) && void 0 !== o ? o : 0, null !== (s = null === (a = this._texture) || void 0 === a ? void 0 : a.level) && void 0 !== s ? s : 0, null !== (c = null === (l = this._textureRoughness) || void 0 === l ? void 0 : l.coordinatesIndex) && void 0 !== c ? c : 0, null !== (h = null === (u = this._textureRoughness) || void 0 === u ? void 0 : u.level) && void 0 !== h ? h : 0),
- this._texture && Mr.BindTextureMatrix(this._texture, e, "sheen"),
- !this._textureRoughness || f || d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE || Mr.BindTextureMatrix(this._textureRoughness, e, "sheenRoughness")),
- e.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity),
- null !== this._roughness && e.updateFloat("vSheenRoughness", this._roughness)),
- t.texturesEnabled && (this._texture && vs.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture),
- this._textureRoughness && !f && !d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && vs.SheenTextureEnabled && e.setTexture("sheenRoughnessSampler", this._textureRoughness))
- }
- }
- ,
- t.prototype.hasTexture = function(e) {
- return this._texture === e || this._textureRoughness === e
- }
- ,
- t.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture),
- this._textureRoughness && e.push(this._textureRoughness)
- }
- ,
- t.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)
- }
- ,
- t.prototype.dispose = function(e) {
- var t, i;
- e && (null === (t = this._texture) || void 0 === t || t.dispose(),
- null === (i = this._textureRoughness) || void 0 === i || i.dispose())
- }
- ,
- t.prototype.getClassName = function() {
- return "PBRSheenConfiguration"
- }
- ,
- t.prototype.addFallbacks = function(e, t, i) {
- return e.SHEEN && t.addFallback(i++, "SHEEN"),
- i
- }
- ,
- t.prototype.getSamplers = function(e) {
- e.push("sheenSampler", "sheenRoughnessSampler")
- }
- ,
- t.prototype.getUniforms = function() {
- return {
- ubo: [{
- name: "vSheenColor",
- size: 4,
- type: "vec4"
- }, {
- name: "vSheenRoughness",
- size: 1,
- type: "float"
- }, {
- name: "vSheenInfos",
- size: 4,
- type: "vec4"
- }, {
- name: "sheenMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "sheenRoughnessMatrix",
- size: 16,
- type: "mat4"
- }]
- }
- }
- ,
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isEnabled", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkSheenWithAlbedo", void 0),
- k([Ce()], t.prototype, "intensity", void 0),
- k([Me()], t.prototype, "color", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "texture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMainTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "textureRoughness", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoScaling", void 0),
- t
- }(Rs)
- , ep = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.SUBSURFACE = !1,
- t.SS_REFRACTION = !1,
- t.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
- t.SS_TRANSLUCENCY = !1,
- t.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
- t.SS_SCATTERING = !1,
- t.SS_THICKNESSANDMASK_TEXTURE = !1,
- t.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0,
- t.SS_HAS_THICKNESS = !1,
- t.SS_REFRACTIONINTENSITY_TEXTURE = !1,
- t.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV = 0,
- t.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
- t.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV = 0,
- t.SS_REFRACTIONMAP_3D = !1,
- t.SS_REFRACTIONMAP_OPPOSITEZ = !1,
- t.SS_LODINREFRACTIONALPHA = !1,
- t.SS_GAMMAREFRACTION = !1,
- t.SS_RGBDREFRACTION = !1,
- t.SS_LINEARSPECULARREFRACTION = !1,
- t.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
- t.SS_ALBEDOFORREFRACTIONTINT = !1,
- t.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
- t.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
- t.SS_USE_THICKNESS_AS_DEPTH = !1,
- t.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
- t.SS_USE_GLTF_TEXTURES = !1,
- t
- }
- return U(t, e),
- t
- }(Si)
- , tp = function(e) {
- function t(t, i) {
- void 0 === i && (i = !0);
- var n = e.call(this, t, "PBRSubSurface", 130, new ep, i) || this;
- return n._isRefractionEnabled = !1,
- n.isRefractionEnabled = !1,
- n._isTranslucencyEnabled = !1,
- n.isTranslucencyEnabled = !1,
- n._isScatteringEnabled = !1,
- n.isScatteringEnabled = !1,
- n._scatteringDiffusionProfileIndex = 0,
- n.refractionIntensity = 1,
- n.translucencyIntensity = 1,
- n.useAlbedoToTintRefraction = !1,
- n.useAlbedoToTintTranslucency = !1,
- n._thicknessTexture = null,
- n.thicknessTexture = null,
- n._refractionTexture = null,
- n.refractionTexture = null,
- n._indexOfRefraction = 1.5,
- n.indexOfRefraction = 1.5,
- n._volumeIndexOfRefraction = -1,
- n._invertRefractionY = !1,
- n.invertRefractionY = !1,
- n._linkRefractionWithTransparency = !1,
- n.linkRefractionWithTransparency = !1,
- n.minimumThickness = 0,
- n.maximumThickness = 1,
- n.useThicknessAsDepth = !1,
- n.tintColor = D.White(),
- n.tintColorAtDistance = 1,
- n.diffusionDistance = D.White(),
- n._useMaskFromThicknessTexture = !1,
- n.useMaskFromThicknessTexture = !1,
- n._refractionIntensityTexture = null,
- n.refractionIntensityTexture = null,
- n._translucencyIntensityTexture = null,
- n.translucencyIntensityTexture = null,
- n._useGltfStyleTextures = !1,
- n.useGltfStyleTextures = !1,
- n._scene = t.getScene(),
- n.registerForExtraEvents = !0,
- n._internalMarkAllSubMeshesAsTexturesDirty = t._dirtyCallbacks[a.MATERIAL_TextureDirtyFlag],
- n._internalMarkScenePrePassDirty = t._dirtyCallbacks[a.MATERIAL_PrePassDirtyFlag],
- n
- }
- return U(t, e),
- Object.defineProperty(t.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(t.prototype, "volumeIndexOfRefraction", {
- get: function() {
- return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction
- },
- set: function(e) {
- this._volumeIndexOfRefraction = e >= 1 ? e : -1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._enable(this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled),
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- t.prototype._markScenePrePassDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty(),
- this._internalMarkScenePrePassDirty()
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t) {
- if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
- return !0;
- if (e._areTexturesDirty && t.texturesEnabled) {
- if (this._thicknessTexture && vs.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
- return !1;
- var i = this._getRefractionTexture(t);
- if (i && vs.RefractionTextureEnabled && !i.isReadyOrNotBlocking())
- return !1
- }
- return !0
- }
- ,
- t.prototype.prepareDefines = function(e, t) {
- if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
- return e.SUBSURFACE = !1,
- e.SS_TRANSLUCENCY = !1,
- e.SS_SCATTERING = !1,
- void (e.SS_REFRACTION = !1);
- if (e._areTexturesDirty) {
- e.SUBSURFACE = !0,
- 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;
- var i = !!this._thicknessTexture && !!this._refractionIntensityTexture && this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._refractionIntensityTexture._texture === this._thicknessTexture._texture
- , n = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture
- , r = (i || !this._refractionIntensityTexture) && (n || !this._translucencyIntensityTexture);
- if (e._areTexturesDirty && t.texturesEnabled && (this._thicknessTexture && vs.ThicknessTextureEnabled && Mr.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"),
- this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && !r && Mr.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"),
- this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && !r && Mr.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) && r,
- e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures,
- e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && r,
- e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && r,
- this._isRefractionEnabled && t.texturesEnabled) {
- var o = this._getRefractionTexture(t);
- o && vs.RefractionTextureEnabled && (e.SS_REFRACTION = !0,
- e.SS_REFRACTIONMAP_3D = o.isCube,
- e.SS_GAMMAREFRACTION = o.gammaSpace,
- e.SS_RGBDREFRACTION = o.isRGBD,
- e.SS_LINEARSPECULARREFRACTION = o.linearSpecularLOD,
- e.SS_REFRACTIONMAP_OPPOSITEZ = o.invertZ,
- e.SS_LODINREFRACTIONALPHA = o.lodLevelInAlpha,
- e.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency,
- e.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction,
- e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = o.isCube && o.boundingBoxSize,
- e.SS_USE_THICKNESS_AS_DEPTH = this.useThicknessAsDepth)
- }
- this._isTranslucencyEnabled && (e.SS_ALBEDOFORTRANSLUCENCYTINT = this.useAlbedoToTintTranslucency)
- }
- }
- ,
- t.prototype.hardBindForSubMesh = function(e, t, i, n) {
- if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
- n.getRenderingMesh().getWorldMatrix().decompose(I.Vector3[0]);
- var r = Math.max(Math.abs(I.Vector3[0].x), Math.abs(I.Vector3[0].y), Math.abs(I.Vector3[0].z));
- e.updateFloat2("vThicknessParam", this.minimumThickness * r, (this.maximumThickness - this.minimumThickness) * r)
- }
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i, n) {
- if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
- var r = n.materialDefines
- , o = this._material.isFrozen
- , a = this._material.realTimeFiltering
- , s = r.LODBASEDMICROSFURACE
- , l = this._getRefractionTexture(t);
- if (!e.useUbo || !o || !e.isSync) {
- if (this._thicknessTexture && vs.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level),
- Mr.BindTextureMatrix(this._thicknessTexture, e, "thickness")),
- this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && r.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level),
- Mr.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")),
- this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && r.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level),
- Mr.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")),
- l && vs.RefractionTextureEnabled) {
- e.updateMatrix("refractionMatrix", l.getReflectionTextureMatrix());
- var c = 1;
- l.isCube || l.depth && (c = l.depth);
- var u = l.getSize().width
- , h = this.volumeIndexOfRefraction;
- if (e.updateFloat4("vRefractionInfos", l.level, 1 / h, c, this._invertRefractionY ? -1 : 1),
- e.updateFloat4("vRefractionMicrosurfaceInfos", u, l.lodGenerationScale, l.lodGenerationOffset, 1 / this.indexOfRefraction),
- a && e.updateFloat2("vRefractionFilteringInfo", u, d.Log2(u)),
- l.boundingBoxSize) {
- var p = l;
- e.updateVector3("vRefractionPosition", p.boundingBoxPosition),
- e.updateVector3("vRefractionSize", p.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)
- }
- t.texturesEnabled && (this._thicknessTexture && vs.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture),
- this._refractionIntensityTexture && vs.RefractionIntensityTextureEnabled && r.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture),
- this._translucencyIntensityTexture && vs.TranslucencyIntensityTextureEnabled && r.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture),
- l && vs.RefractionTextureEnabled && (s ? e.setTexture("refractionSampler", l) : (e.setTexture("refractionSampler", l._lodTextureMid || l),
- e.setTexture("refractionSamplerLow", l._lodTextureLow || l),
- e.setTexture("refractionSamplerHigh", l._lodTextureHigh || l))))
- }
- }
- ,
- t.prototype._getRefractionTexture = function(e) {
- return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? e.environmentTexture : null
- }
- ,
- Object.defineProperty(t.prototype, "disableAlphaBlending", {
- get: function() {
- return this._isRefractionEnabled && this._linkRefractionWithTransparency
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.fillRenderTargetTextures = function(e) {
- vs.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && e.push(this._refractionTexture)
- }
- ,
- t.prototype.hasTexture = function(e) {
- return this._thicknessTexture === e || this._refractionTexture === e
- }
- ,
- t.prototype.hasRenderTargetTextures = function() {
- return !!(vs.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
- }
- ,
- t.prototype.getActiveTextures = function(e) {
- this._thicknessTexture && e.push(this._thicknessTexture),
- this._refractionTexture && e.push(this._refractionTexture)
- }
- ,
- t.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)
- }
- ,
- t.prototype.dispose = function(e) {
- e && (this._thicknessTexture && this._thicknessTexture.dispose(),
- this._refractionTexture && this._refractionTexture.dispose())
- }
- ,
- t.prototype.getClassName = function() {
- return "PBRSubSurfaceConfiguration"
- }
- ,
- t.prototype.addFallbacks = function(e, t, i) {
- return e.SS_SCATTERING && t.addFallback(i++, "SS_SCATTERING"),
- e.SS_TRANSLUCENCY && t.addFallback(i++, "SS_TRANSLUCENCY"),
- i
- }
- ,
- t.prototype.getSamplers = function(e) {
- e.push("thicknessSampler", "refractionIntensitySampler", "translucencyIntensitySampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh")
- }
- ,
- t.prototype.getUniforms = function() {
- return {
- ubo: [{
- name: "vRefractionMicrosurfaceInfos",
- size: 4,
- type: "vec4"
- }, {
- name: "vRefractionFilteringInfo",
- size: 2,
- type: "vec2"
- }, {
- name: "vTranslucencyIntensityInfos",
- size: 2,
- type: "vec2"
- }, {
- name: "vRefractionInfos",
- size: 4,
- type: "vec4"
- }, {
- name: "refractionMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "vThicknessInfos",
- size: 2,
- type: "vec2"
- }, {
- name: "vRefractionIntensityInfos",
- size: 2,
- type: "vec2"
- }, {
- name: "thicknessMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "refractionIntensityMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "translucencyIntensityMatrix",
- size: 16,
- type: "mat4"
- }, {
- name: "vThicknessParam",
- size: 2,
- type: "vec2"
- }, {
- name: "vDiffusionDistance",
- size: 3,
- type: "vec3"
- }, {
- name: "vTintColor",
- size: 4,
- type: "vec4"
- }, {
- name: "vSubSurfaceIntensity",
- size: 3,
- type: "vec3"
- }, {
- name: "vRefractionPosition",
- size: 3,
- type: "vec3"
- }, {
- name: "vRefractionSize",
- size: 3,
- type: "vec3"
- }, {
- name: "scatteringDiffusionProfile",
- size: 1,
- type: "float"
- }]
- }
- }
- ,
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isRefractionEnabled", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "isTranslucencyEnabled", void 0),
- k([Ce(), Re("_markScenePrePassDirty")], t.prototype, "isScatteringEnabled", void 0),
- k([Ce()], t.prototype, "_scatteringDiffusionProfileIndex", void 0),
- k([Ce()], t.prototype, "refractionIntensity", void 0),
- k([Ce()], t.prototype, "translucencyIntensity", void 0),
- k([Ce()], t.prototype, "useAlbedoToTintRefraction", void 0),
- k([Ce()], t.prototype, "useAlbedoToTintTranslucency", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "thicknessTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "indexOfRefraction", void 0),
- k([Ce()], t.prototype, "_volumeIndexOfRefraction", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "volumeIndexOfRefraction", null),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertRefractionY", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "linkRefractionWithTransparency", void 0),
- k([Ce()], t.prototype, "minimumThickness", void 0),
- k([Ce()], t.prototype, "maximumThickness", void 0),
- k([Ce()], t.prototype, "useThicknessAsDepth", void 0),
- k([Me()], t.prototype, "tintColor", void 0),
- k([Ce()], t.prototype, "tintColorAtDistance", void 0),
- k([Me()], t.prototype, "diffusionDistance", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMaskFromThicknessTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "refractionIntensityTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "translucencyIntensityTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useGltfStyleTextures", void 0),
- t
- }(Rs)
- , ip = {
- effect: null,
- subMesh: null
- }
- , np = function(e) {
- function t(t) {
- var i = e.call(this, t) || 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.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.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.INSTANCESCOLOR = !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.UNLIT = !1,
- i.DEBUGMODE = 0,
- i.rebuild(),
- i
- }
- return U(t, e),
- t.prototype.reset = function() {
- e.prototype.reset.call(this),
- this.ALPHATESTVALUE = "0.5",
- this.PBR = !0,
- this.NORMALXYSCALE = !0
- }
- ,
- t
- }(Si)
- , rp = function(e) {
- function t(i, n) {
- var r = e.call(this, i, n) || this;
- return r._directIntensity = 1,
- r._emissiveIntensity = 1,
- r._environmentIntensity = 1,
- r._specularIntensity = 1,
- r._lightingInfos = new R(r._directIntensity,r._emissiveIntensity,r._environmentIntensity,r._specularIntensity),
- r._disableBumpMap = !1,
- r._albedoTexture = null,
- r._ambientTexture = null,
- r._ambientTextureStrength = 1,
- r._ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
- r._opacityTexture = null,
- r._reflectionTexture = null,
- r._emissiveTexture = null,
- r._reflectivityTexture = null,
- r._metallicTexture = null,
- r._metallic = null,
- r._roughness = null,
- r._metallicF0Factor = 1,
- r._metallicReflectanceColor = D.White(),
- r._useOnlyMetallicFromMetallicReflectanceTexture = !1,
- r._metallicReflectanceTexture = null,
- r._reflectanceTexture = null,
- r._microSurfaceTexture = null,
- r._bumpTexture = null,
- r._lightmapTexture = null,
- r._ambientColor = new D(0,0,0),
- r._albedoColor = new D(1,1,1),
- r._reflectivityColor = new D(1,1,1),
- r._reflectionColor = new D(1,1,1),
- r._emissiveColor = new D(0,0,0),
- r._microSurface = .9,
- r._useLightmapAsShadowmap = !1,
- r._useHorizonOcclusion = !0,
- r._useRadianceOcclusion = !0,
- r._useAlphaFromAlbedoTexture = !1,
- r._useSpecularOverAlpha = !0,
- r._useMicroSurfaceFromReflectivityMapAlpha = !1,
- r._useRoughnessFromMetallicTextureAlpha = !0,
- r._useRoughnessFromMetallicTextureGreen = !1,
- r._useMetallnessFromMetallicTextureBlue = !1,
- r._useAmbientOcclusionFromMetallicTextureRed = !1,
- r._useAmbientInGrayScale = !1,
- r._useAutoMicroSurfaceFromReflectivityMap = !1,
- r._lightFalloff = t.LIGHTFALLOFF_PHYSICAL,
- r._useRadianceOverAlpha = !0,
- r._useObjectSpaceNormalMap = !1,
- r._useParallax = !1,
- r._useParallaxOcclusion = !1,
- r._parallaxScaleBias = .05,
- r._disableLighting = !1,
- r._maxSimultaneousLights = 4,
- r._invertNormalMapX = !1,
- r._invertNormalMapY = !1,
- r._twoSidedLighting = !1,
- r._alphaCutOff = .4,
- r._forceAlphaTest = !1,
- r._useAlphaFresnel = !1,
- r._useLinearAlphaFresnel = !1,
- r._environmentBRDFTexture = null,
- r._forceIrradianceInFragment = !1,
- r._realTimeFiltering = !1,
- r._realTimeFilteringQuality = a.TEXTURE_FILTERING_QUALITY_LOW,
- r._forceNormalForward = !1,
- r._enableSpecularAntiAliasing = !1,
- r._imageProcessingObserver = null,
- r._renderTargets = new bi(16),
- r._globalAmbientColor = new D(0,0,0),
- r._useLogarithmicDepth = !1,
- r._unlit = !1,
- r._debugMode = 0,
- r.debugMode = 0,
- r._debugLimit = -1,
- r._debugFactor = 1,
- r._cacheHasRenderTargetTextures = !1,
- r.brdf = new Yd(r),
- r.clearCoat = new Qd(r),
- r.anisotropy = new Zd(r),
- r.sheen = new $d(r),
- r.subSurface = new tp(r),
- r.detailMap = new Ps(r),
- r._attachImageProcessingConfiguration(null),
- r.getRenderTargetTextures = function() {
- return r._renderTargets.reset(),
- vs.ReflectionTextureEnabled && r._reflectionTexture && r._reflectionTexture.isRenderTarget && r._renderTargets.push(r._reflectionTexture),
- r._eventInfo.renderTargets = r._renderTargets,
- r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),
- r._renderTargets
- }
- ,
- r._environmentBRDFTexture = Hd(r.getScene()),
- r.prePassConfiguration = new ms,
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "realTimeFiltering", {
- get: function() {
- return this._realTimeFiltering
- },
- set: function(e) {
- this._realTimeFiltering = e,
- this.markAsDirty(a.MATERIAL_TextureDirtyFlag)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "realTimeFilteringQuality", {
- get: function() {
- return this._realTimeFilteringQuality
- },
- set: function(e) {
- this._realTimeFilteringQuality = e,
- this.markAsDirty(a.MATERIAL_TextureDirtyFlag)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "canRenderToMRT", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._attachImageProcessingConfiguration = function(e) {
- var t = this;
- e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
- t._markAllSubMeshesAsImageProcessingDirty()
- }
- ))))
- }
- ,
- Object.defineProperty(t.prototype, "hasRenderTargetTextures", {
- get: function() {
- return !!(vs.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) || this._cacheHasRenderTargetTextures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isPrePassCapable", {
- get: function() {
- return !this.disableDepthWrite
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "PBRBaseMaterial"
- }
- ,
- Object.defineProperty(t.prototype, "useLogarithmicDepth", {
- get: function() {
- return this._useLogarithmicDepth
- },
- set: function(e) {
- this._useLogarithmicDepth = e && this.getScene().getEngine().getCaps().fragmentDepthSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_disableAlphaBlending", {
- get: function() {
- var e;
- return this._transparencyMode === t.PBRMATERIAL_OPAQUE || this._transparencyMode === t.PBRMATERIAL_ALPHATEST || (null === (e = this.subSurface) || void 0 === e ? void 0 : e.disableAlphaBlending)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.needAlphaBlending = function() {
- return !this._disableAlphaBlending && (this.alpha < 1 || null != this._opacityTexture || this._shouldUseAlphaFromAlbedoTexture())
- }
- ,
- t.prototype.needAlphaTesting = function() {
- var e;
- return !!this._forceAlphaTest || !(null === (e = this.subSurface) || void 0 === e ? void 0 : e.disableAlphaBlending) && this._hasAlphaChannel() && (null == this._transparencyMode || this._transparencyMode === t.PBRMATERIAL_ALPHATEST)
- }
- ,
- t.prototype._shouldUseAlphaFromAlbedoTexture = function() {
- return null != this._albedoTexture && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== t.PBRMATERIAL_OPAQUE
- }
- ,
- t.prototype._hasAlphaChannel = function() {
- return null != this._albedoTexture && this._albedoTexture.hasAlpha || null != this._opacityTexture
- }
- ,
- t.prototype.getAlphaTestTexture = function() {
- return this._albedoTexture
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- if (this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
- t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
- return !0;
- t.materialDefines || (this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo),
- t.materialDefines = new np(this._eventInfo.defineNames));
- var n = t.materialDefines;
- if (this._isReadyForSubMesh(t))
- return !0;
- var r = this.getScene()
- , o = r.getEngine();
- if (n._areTexturesDirty && (this._eventInfo.hasRenderTargetTextures = !1,
- this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),
- this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures,
- r.texturesEnabled)) {
- if (this._albedoTexture && vs.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking())
- return !1;
- if (this._ambientTexture && vs.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking())
- return !1;
- if (this._opacityTexture && vs.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
- return !1;
- var a = this._getReflectionTexture();
- if (a && vs.ReflectionTextureEnabled) {
- if (!a.isReadyOrNotBlocking())
- return !1;
- if (a.irradianceTexture && !a.irradianceTexture.isReadyOrNotBlocking())
- return !1
- }
- if (this._lightmapTexture && vs.LightmapTextureEnabled && !this._lightmapTexture.isReadyOrNotBlocking())
- return !1;
- if (this._emissiveTexture && vs.EmissiveTextureEnabled && !this._emissiveTexture.isReadyOrNotBlocking())
- return !1;
- if (vs.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())
- return !1;
- if (this._reflectanceTexture && !this._reflectanceTexture.isReadyOrNotBlocking())
- return !1;
- if (this._microSurfaceTexture && !this._microSurfaceTexture.isReadyOrNotBlocking())
- return !1
- }
- if (o.getCaps().standardDerivatives && this._bumpTexture && vs.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady())
- return !1;
- if (this._environmentBRDFTexture && vs.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
- return !1
- }
- if (this._eventInfo.isReadyForSubMesh = !0,
- this._eventInfo.defines = n,
- this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),
- !this._eventInfo.isReadyForSubMesh)
- return !1;
- if (n._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
- return !1;
- o.getCaps().standardDerivatives || e.isVerticesDataPresent(Bi.NormalKind) || (e.createNormals(!0),
- K.Warn("PBRMaterial: Normals have been created for the mesh: " + e.name));
- var s = t.effect
- , l = n._areLightsDisposed
- , c = this._prepareEffect(e, n, this.onCompiled, this.onError, i, null, t.getRenderingMesh().hasThinInstances);
- if (c)
- if (this._onEffectCreatedObservable && (ip.effect = c,
- ip.subMesh = t,
- this._onEffectCreatedObservable.notifyObservers(ip)),
- this.allowShaderHotSwapping && s && !c.isReady()) {
- if (c = s,
- n.markAsUnprocessed(),
- l)
- return n._areLightsDisposed = !0,
- !1
- } else
- r.resetCachedMaterial(),
- t.setEffect(c, n, this._materialContext);
- return !(!t.effect || !t.effect.isReady() || (n._renderId = r.getRenderId(),
- t.effect._wasPreviouslyReady = !0,
- 0))
- }
- ,
- t.prototype.isMetallicWorkflow = function() {
- return !(null == this._metallic && null == this._roughness && !this._metallicTexture)
- }
- ,
- t.prototype._prepareEffect = function(e, t, i, n, r, o, s) {
- if (void 0 === i && (i = null),
- void 0 === n && (n = null),
- void 0 === r && (r = null),
- void 0 === o && (o = null),
- this._prepareDefines(e, t, r, o, s),
- !t.isDirty)
- return null;
- t.markAsProcessed();
- var l = this.getScene().getEngine()
- , c = new ys
- , u = 0;
- t.USESPHERICALINVERTEX && c.addFallback(u++, "USESPHERICALINVERTEX"),
- t.FOG && c.addFallback(u, "FOG"),
- t.SPECULARAA && c.addFallback(u, "SPECULARAA"),
- t.POINTSIZE && c.addFallback(u, "POINTSIZE"),
- t.LOGARITHMICDEPTH && c.addFallback(u, "LOGARITHMICDEPTH"),
- t.PARALLAX && c.addFallback(u, "PARALLAX"),
- t.PARALLAXOCCLUSION && c.addFallback(u++, "PARALLAXOCCLUSION"),
- t.ENVIRONMENTBRDF && c.addFallback(u++, "ENVIRONMENTBRDF"),
- t.TANGENT && c.addFallback(u++, "TANGENT"),
- t.BUMP && c.addFallback(u++, "BUMP"),
- u = Mr.HandleFallbacksForShadows(t, c, this._maxSimultaneousLights, u++),
- t.SPECULARTERM && c.addFallback(u++, "SPECULARTERM"),
- t.USESPHERICALFROMREFLECTIONMAP && c.addFallback(u++, "USESPHERICALFROMREFLECTIONMAP"),
- t.USEIRRADIANCEMAP && c.addFallback(u++, "USEIRRADIANCEMAP"),
- t.LIGHTMAP && c.addFallback(u++, "LIGHTMAP"),
- t.NORMAL && c.addFallback(u++, "NORMAL"),
- t.AMBIENT && c.addFallback(u++, "AMBIENT"),
- t.EMISSIVE && c.addFallback(u++, "EMISSIVE"),
- t.VERTEXCOLOR && c.addFallback(u++, "VERTEXCOLOR"),
- t.MORPHTARGETS && c.addFallback(u++, "MORPHTARGETS"),
- t.MULTIVIEW && c.addFallback(0, "MULTIVIEW");
- var h = [Bi.PositionKind];
- t.NORMAL && h.push(Bi.NormalKind),
- t.TANGENT && h.push(Bi.TangentKind);
- for (var d = 1; d <= a.MAX_SUPPORTED_UV_SETS; ++d)
- t["UV" + d] && h.push("uv".concat(1 === d ? "" : d));
- t.VERTEXCOLOR && h.push(Bi.ColorKind),
- Mr.PrepareAttributesForBones(h, e, t, c),
- Mr.PrepareAttributesForInstances(h, t),
- Mr.PrepareAttributesForMorphTargets(h, e, t),
- Mr.PrepareAttributesForBakedVertexAnimation(h, e, t);
- var p = "pbr"
- , f = ["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"]
- , _ = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler", "bumpSampler", "lightmapSampler", "opacitySampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "microSurfaceSampler", "environmentBrdfSampler", "boneSampler", "metallicReflectanceSampler", "reflectanceSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
- , m = ["Material", "Scene", "Mesh"];
- this._eventInfo.fallbacks = c,
- this._eventInfo.fallbackRank = u,
- this._eventInfo.defines = t,
- this._eventInfo.uniforms = f,
- this._eventInfo.samplers = _,
- this._eventInfo.uniformBuffersNames = m,
- this._eventInfo.customCode = void 0,
- this._callbackPluginEventGeneric(Ar.PrepareEffect, this._eventInfo),
- ms.AddUniforms(f),
- ms.AddSamplers(_),
- Ri && (Ri.PrepareUniforms(f, t),
- Ri.PrepareSamplers(_, t)),
- Mr.PrepareUniformsAndSamplersList({
- uniformsNames: f,
- uniformBuffersNames: m,
- samplers: _,
- defines: t,
- maxSimultaneousLights: this._maxSimultaneousLights
- });
- var g = {};
- this.customShaderNameResolve && (p = this.customShaderNameResolve(p, f, m, _, t, h, g));
- var v = t.toString();
- return l.createEffect(p, {
- attributes: h,
- uniformsNames: f,
- uniformBuffersNames: m,
- samplers: _,
- defines: v,
- fallbacks: c,
- onCompiled: i,
- onError: n,
- indexParameters: {
- maxSimultaneousLights: this._maxSimultaneousLights,
- maxSimultaneousMorphTargets: t.NUM_MORPH_INFLUENCERS
- },
- processFinalCode: g.processFinalCode,
- processCodeAfterIncludes: this._eventInfo.customCode,
- multiTarget: t.PREPASS
- }, l)
- }
- ,
- t.prototype._prepareDefines = function(e, i, n, r, o) {
- var s;
- void 0 === n && (n = null),
- void 0 === r && (r = null),
- void 0 === o && (o = !1);
- var l = this.getScene()
- , c = l.getEngine();
- Mr.PrepareDefinesForLights(l, e, i, !0, this._maxSimultaneousLights, this._disableLighting),
- i._needNormals = !0,
- Mr.PrepareDefinesForMultiview(l, i);
- var u = this.needAlphaBlendingForMesh(e) && this.getScene().useOrderIndependentTransparency;
- if (Mr.PrepareDefinesForPrePass(l, i, this.canRenderToMRT && !u),
- Mr.PrepareDefinesForOIT(l, i, u),
- i.METALLICWORKFLOW = this.isMetallicWorkflow(),
- i._areTexturesDirty) {
- if (i._needUVs = !1,
- l.texturesEnabled) {
- l.getEngine().getCaps().textureLOD && (i.LODBASEDMICROSFURACE = !0),
- this._albedoTexture && vs.DiffuseTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._albedoTexture, i, "ALBEDO"),
- i.GAMMAALBEDO = this._albedoTexture.gammaSpace) : i.ALBEDO = !1,
- this._ambientTexture && vs.AmbientTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._ambientTexture, i, "AMBIENT"),
- i.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : i.AMBIENT = !1,
- this._opacityTexture && vs.OpacityTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._opacityTexture, i, "OPACITY"),
- i.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : i.OPACITY = !1;
- var h = this._getReflectionTexture();
- if (h && vs.ReflectionTextureEnabled) {
- switch (i.REFLECTION = !0,
- i.GAMMAREFLECTION = h.gammaSpace,
- i.RGBDREFLECTION = h.isRGBD,
- i.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !h.invertZ : h.invertZ,
- i.LODINREFLECTIONALPHA = h.lodLevelInAlpha,
- i.LINEARSPECULARREFLECTION = h.linearSpecularLOD,
- this.realTimeFiltering && this.realTimeFilteringQuality > 0 ? (i.NUM_SAMPLES = "" + this.realTimeFilteringQuality,
- c._features.needTypeSuffixInShaderConstants && (i.NUM_SAMPLES = i.NUM_SAMPLES + "u"),
- i.REALTIME_FILTERING = !0) : i.REALTIME_FILTERING = !1,
- h.coordinatesMode === io.INVCUBIC_MODE && (i.INVERTCUBICMAP = !0),
- i.REFLECTIONMAP_3D = h.isCube,
- i.REFLECTIONMAP_CUBIC = !1,
- i.REFLECTIONMAP_EXPLICIT = !1,
- i.REFLECTIONMAP_PLANAR = !1,
- i.REFLECTIONMAP_PROJECTION = !1,
- i.REFLECTIONMAP_SKYBOX = !1,
- i.REFLECTIONMAP_SPHERICAL = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- h.coordinatesMode) {
- case io.EXPLICIT_MODE:
- i.REFLECTIONMAP_EXPLICIT = !0;
- break;
- case io.PLANAR_MODE:
- i.REFLECTIONMAP_PLANAR = !0;
- break;
- case io.PROJECTION_MODE:
- i.REFLECTIONMAP_PROJECTION = !0;
- break;
- case io.SKYBOX_MODE:
- i.REFLECTIONMAP_SKYBOX = !0;
- break;
- case io.SPHERICAL_MODE:
- i.REFLECTIONMAP_SPHERICAL = !0;
- break;
- case io.EQUIRECTANGULAR_MODE:
- i.REFLECTIONMAP_EQUIRECTANGULAR = !0;
- break;
- case io.FIXED_EQUIRECTANGULAR_MODE:
- i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
- break;
- case io.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
- i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
- break;
- case io.CUBIC_MODE:
- case io.INVCUBIC_MODE:
- default:
- i.REFLECTIONMAP_CUBIC = !0,
- i.USE_LOCAL_REFLECTIONMAP_CUBIC = !!h.boundingBoxSize
- }
- h.coordinatesMode !== io.SKYBOX_MODE && (h.irradianceTexture ? (i.USEIRRADIANCEMAP = !0,
- i.USESPHERICALFROMREFLECTIONMAP = !1) : h.isCube && (i.USESPHERICALFROMREFLECTIONMAP = !0,
- i.USEIRRADIANCEMAP = !1,
- this._forceIrradianceInFragment || this.realTimeFiltering || l.getEngine().getCaps().maxVaryingVectors <= 8 ? i.USESPHERICALINVERTEX = !1 : i.USESPHERICALINVERTEX = !0))
- } else
- 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.USESPHERICALINVERTEX = !1,
- i.REFLECTIONMAP_OPPOSITEZ = !1,
- i.LODINREFLECTIONALPHA = !1,
- i.GAMMAREFLECTION = !1,
- i.RGBDREFLECTION = !1,
- i.LINEARSPECULARREFLECTION = !1;
- if (this._lightmapTexture && vs.LightmapTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._lightmapTexture, i, "LIGHTMAP"),
- i.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
- i.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace,
- i.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : i.LIGHTMAP = !1,
- this._emissiveTexture && vs.EmissiveTextureEnabled ? (Mr.PrepareDefinesForMergedUV(this._emissiveTexture, i, "EMISSIVE"),
- i.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : i.EMISSIVE = !1,
- vs.SpecularTextureEnabled) {
- if (this._metallicTexture ? (Mr.PrepareDefinesForMergedUV(this._metallicTexture, i, "REFLECTIVITY"),
- i.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha,
- i.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen,
- i.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue,
- i.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed,
- i.REFLECTIVITY_GAMMA = !1) : this._reflectivityTexture ? (Mr.PrepareDefinesForMergedUV(this._reflectivityTexture, i, "REFLECTIVITY"),
- i.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha,
- i.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap,
- i.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace) : i.REFLECTIVITY = !1,
- this._metallicReflectanceTexture || this._reflectanceTexture) {
- var d = null !== this._metallicReflectanceTexture && this._metallicReflectanceTexture._texture === (null === (s = this._reflectanceTexture) || void 0 === s ? void 0 : s._texture) && this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);
- i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture && !d,
- this._metallicReflectanceTexture ? (Mr.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, i, "METALLIC_REFLECTANCE"),
- i.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace) : i.METALLIC_REFLECTANCE = !1,
- this._reflectanceTexture && !d && (!this._metallicReflectanceTexture || this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture) ? (Mr.PrepareDefinesForMergedUV(this._reflectanceTexture, i, "REFLECTANCE"),
- i.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : i.REFLECTANCE = !1
- } else
- i.METALLIC_REFLECTANCE = !1,
- i.REFLECTANCE = !1;
- this._microSurfaceTexture ? Mr.PrepareDefinesForMergedUV(this._microSurfaceTexture, i, "MICROSURFACEMAP") : i.MICROSURFACEMAP = !1
- } else
- i.REFLECTIVITY = !1,
- i.MICROSURFACEMAP = !1;
- l.getEngine().getCaps().standardDerivatives && this._bumpTexture && vs.BumpTextureEnabled && !this._disableBumpMap ? (Mr.PrepareDefinesForMergedUV(this._bumpTexture, i, "BUMP"),
- this._useParallax && this._albedoTexture && vs.DiffuseTextureEnabled ? (i.PARALLAX = !0,
- i.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : i.PARALLAX = !1,
- i.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : i.BUMP = !1,
- this._environmentBRDFTexture && vs.ReflectionTextureEnabled ? (i.ENVIRONMENTBRDF = !0,
- i.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (i.ENVIRONMENTBRDF = !1,
- i.ENVIRONMENTBRDF_RGBD = !1),
- this._shouldUseAlphaFromAlbedoTexture() ? i.ALPHAFROMALBEDO = !0 : i.ALPHAFROMALBEDO = !1
- }
- i.SPECULAROVERALPHA = this._useSpecularOverAlpha,
- this._lightFalloff === t.LIGHTFALLOFF_STANDARD ? (i.USEPHYSICALLIGHTFALLOFF = !1,
- i.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === t.LIGHTFALLOFF_GLTF ? (i.USEPHYSICALLIGHTFALLOFF = !1,
- i.USEGLTFLIGHTFALLOFF = !0) : (i.USEPHYSICALLIGHTFALLOFF = !0,
- i.USEGLTFLIGHTFALLOFF = !1),
- i.RADIANCEOVERALPHA = this._useRadianceOverAlpha,
- !this.backFaceCulling && this._twoSidedLighting ? i.TWOSIDEDLIGHTING = !0 : i.TWOSIDEDLIGHTING = !1,
- i.SPECULARAA = l.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing
- }
- (i._areTexturesDirty || i._areMiscDirty) && (i.ALPHATESTVALUE = "".concat(this._alphaCutOff).concat(this._alphaCutOff % 1 == 0 ? "." : ""),
- i.PREMULTIPLYALPHA = this.alphaMode === a.ALPHA_PREMULTIPLIED || this.alphaMode === a.ALPHA_PREMULTIPLIED_PORTERDUFF,
- i.ALPHABLEND = this.needAlphaBlendingForMesh(e),
- i.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel,
- i.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel),
- i._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(i),
- i.FORCENORMALFORWARD = this._forceNormalForward,
- i.RADIANCEOCCLUSION = this._useRadianceOcclusion,
- i.HORIZONOCCLUSION = this._useHorizonOcclusion,
- i._areMiscDirty && (Mr.PrepareDefinesForMisc(e, l, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(e) || this._forceAlphaTest, i),
- i.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !e.isVerticesDataPresent(Bi.NormalKind),
- i.DEBUGMODE = this._debugMode),
- this._eventInfo.defines = i,
- this._eventInfo.mesh = e,
- this._callbackPluginEventPrepareDefines(this._eventInfo),
- Mr.PrepareDefinesForFrameBoundValues(l, c, i, !!n, r, o),
- Mr.PrepareDefinesForAttributes(e, i, !0, !0, !0, this._transparencyMode !== t.PBRMATERIAL_OPAQUE)
- }
- ,
- t.prototype.forceCompilation = function(e, t, i) {
- var n = this
- , r = V({
- clipPlane: !1,
- useInstances: !1
- }, i);
- this._uniformBufferLayoutBuilt || this.buildUniformLayout(),
- this._callbackPluginEventGeneric(Ar.GetDefineNames, this._eventInfo);
- var o = new np(this._eventInfo.defineNames)
- , a = this._prepareEffect(e, o, void 0, void 0, r.useInstances, r.clipPlane, e.hasThinInstances);
- this._onEffectCreatedObservable && (ip.effect = a,
- ip.subMesh = null,
- this._onEffectCreatedObservable.notifyObservers(ip)),
- a.isReady() ? t && t(this) : a.onCompileObservable.add((function() {
- t && t(n)
- }
- ))
- }
- ,
- t.prototype.buildUniformLayout = function() {
- var t = this._uniformBuffer;
- t.addUniform("vAlbedoInfos", 2),
- t.addUniform("vAmbientInfos", 4),
- t.addUniform("vOpacityInfos", 2),
- t.addUniform("vEmissiveInfos", 2),
- t.addUniform("vLightmapInfos", 2),
- t.addUniform("vReflectivityInfos", 3),
- t.addUniform("vMicroSurfaceSamplerInfos", 2),
- t.addUniform("vReflectionInfos", 2),
- t.addUniform("vReflectionFilteringInfo", 2),
- t.addUniform("vReflectionPosition", 3),
- t.addUniform("vReflectionSize", 3),
- t.addUniform("vBumpInfos", 3),
- t.addUniform("albedoMatrix", 16),
- t.addUniform("ambientMatrix", 16),
- t.addUniform("opacityMatrix", 16),
- t.addUniform("emissiveMatrix", 16),
- t.addUniform("lightmapMatrix", 16),
- t.addUniform("reflectivityMatrix", 16),
- t.addUniform("microSurfaceSamplerMatrix", 16),
- t.addUniform("bumpMatrix", 16),
- t.addUniform("vTangentSpaceParams", 2),
- t.addUniform("reflectionMatrix", 16),
- t.addUniform("vReflectionColor", 3),
- t.addUniform("vAlbedoColor", 4),
- t.addUniform("vLightingIntensity", 4),
- t.addUniform("vReflectionMicrosurfaceInfos", 3),
- t.addUniform("pointSize", 1),
- t.addUniform("vReflectivityColor", 4),
- t.addUniform("vEmissiveColor", 3),
- t.addUniform("vAmbientColor", 3),
- t.addUniform("vDebugMode", 2),
- t.addUniform("vMetallicReflectanceFactors", 4),
- t.addUniform("vMetallicReflectanceInfos", 2),
- t.addUniform("metallicReflectanceMatrix", 16),
- t.addUniform("vReflectanceInfos", 2),
- t.addUniform("reflectanceMatrix", 16),
- t.addUniform("vSphericalL00", 3),
- t.addUniform("vSphericalL1_1", 3),
- t.addUniform("vSphericalL10", 3),
- t.addUniform("vSphericalL11", 3),
- t.addUniform("vSphericalL2_2", 3),
- t.addUniform("vSphericalL2_1", 3),
- t.addUniform("vSphericalL20", 3),
- t.addUniform("vSphericalL21", 3),
- t.addUniform("vSphericalL22", 3),
- t.addUniform("vSphericalX", 3),
- t.addUniform("vSphericalY", 3),
- t.addUniform("vSphericalZ", 3),
- t.addUniform("vSphericalXX_ZZ", 3),
- t.addUniform("vSphericalYY_ZZ", 3),
- t.addUniform("vSphericalZZ", 3),
- t.addUniform("vSphericalXY", 3),
- t.addUniform("vSphericalYZ", 3),
- t.addUniform("vSphericalZX", 3),
- e.prototype.buildUniformLayout.call(this)
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i) {
- var n, r, o, a, s = this.getScene(), l = i.materialDefines;
- if (l) {
- var c = i.effect;
- if (c) {
- this._activeEffect = c,
- t.getMeshUniformBuffer().bindToEffect(c, "Mesh"),
- t.transferToEffect(e);
- var u = s.getEngine();
- this._uniformBuffer.bindToEffect(c, "Material"),
- this.prePassConfiguration.bindForSubMesh(this._activeEffect, s, t, e, this.isFrozen),
- this._eventInfo.subMesh = i,
- this._callbackPluginEventHardBindForSubMesh(this._eventInfo),
- l.OBJECTSPACE_NORMALMAP && (e.toNormalMatrix(this._normalMatrix),
- this.bindOnlyNormalMatrix(this._normalMatrix));
- var h = this._mustRebind(s, c, t.visibility);
- Mr.BindBonesParameters(t, this._activeEffect, this.prePassConfiguration);
- var p = null
- , f = this._uniformBuffer;
- if (h) {
- if (this.bindViewProjection(c),
- p = this._getReflectionTexture(),
- !f.useUbo || !this.isFrozen || !f.isSync) {
- if (s.texturesEnabled) {
- if (this._albedoTexture && vs.DiffuseTextureEnabled && (f.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level),
- Mr.BindTextureMatrix(this._albedoTexture, f, "albedo")),
- this._ambientTexture && vs.AmbientTextureEnabled && (f.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights),
- Mr.BindTextureMatrix(this._ambientTexture, f, "ambient")),
- this._opacityTexture && vs.OpacityTextureEnabled && (f.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
- Mr.BindTextureMatrix(this._opacityTexture, f, "opacity")),
- p && vs.ReflectionTextureEnabled) {
- if (f.updateMatrix("reflectionMatrix", p.getReflectionTextureMatrix()),
- f.updateFloat2("vReflectionInfos", p.level, 0),
- p.boundingBoxSize) {
- var _ = p;
- f.updateVector3("vReflectionPosition", _.boundingBoxPosition),
- f.updateVector3("vReflectionSize", _.boundingBoxSize)
- }
- if (this.realTimeFiltering) {
- var m = p.getSize().width;
- f.updateFloat2("vReflectionFilteringInfo", m, d.Log2(m))
- }
- if (!l.USEIRRADIANCEMAP) {
- var g = p.sphericalPolynomial;
- if (l.USESPHERICALFROMREFLECTIONMAP && g)
- if (l.SPHERICAL_HARMONICS) {
- var v = g.preScaledHarmonics;
- f.updateVector3("vSphericalL00", v.l00),
- f.updateVector3("vSphericalL1_1", v.l1_1),
- f.updateVector3("vSphericalL10", v.l10),
- f.updateVector3("vSphericalL11", v.l11),
- f.updateVector3("vSphericalL2_2", v.l2_2),
- f.updateVector3("vSphericalL2_1", v.l2_1),
- f.updateVector3("vSphericalL20", v.l20),
- f.updateVector3("vSphericalL21", v.l21),
- f.updateVector3("vSphericalL22", v.l22)
- } else
- f.updateFloat3("vSphericalX", g.x.x, g.x.y, g.x.z),
- f.updateFloat3("vSphericalY", g.y.x, g.y.y, g.y.z),
- f.updateFloat3("vSphericalZ", g.z.x, g.z.y, g.z.z),
- f.updateFloat3("vSphericalXX_ZZ", g.xx.x - g.zz.x, g.xx.y - g.zz.y, g.xx.z - g.zz.z),
- f.updateFloat3("vSphericalYY_ZZ", g.yy.x - g.zz.x, g.yy.y - g.zz.y, g.yy.z - g.zz.z),
- f.updateFloat3("vSphericalZZ", g.zz.x, g.zz.y, g.zz.z),
- f.updateFloat3("vSphericalXY", g.xy.x, g.xy.y, g.xy.z),
- f.updateFloat3("vSphericalYZ", g.yz.x, g.yz.y, g.yz.z),
- f.updateFloat3("vSphericalZX", g.zx.x, g.zx.y, g.zx.z)
- }
- f.updateFloat3("vReflectionMicrosurfaceInfos", p.getSize().width, p.lodGenerationScale, p.lodGenerationOffset)
- }
- this._emissiveTexture && vs.EmissiveTextureEnabled && (f.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
- Mr.BindTextureMatrix(this._emissiveTexture, f, "emissive")),
- this._lightmapTexture && vs.LightmapTextureEnabled && (f.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
- Mr.BindTextureMatrix(this._lightmapTexture, f, "lightmap")),
- vs.SpecularTextureEnabled && (this._metallicTexture ? (f.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength),
- Mr.BindTextureMatrix(this._metallicTexture, f, "reflectivity")) : this._reflectivityTexture && (f.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1),
- Mr.BindTextureMatrix(this._reflectivityTexture, f, "reflectivity")),
- this._metallicReflectanceTexture && (f.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level),
- Mr.BindTextureMatrix(this._metallicReflectanceTexture, f, "metallicReflectance")),
- this._reflectanceTexture && l.REFLECTANCE && (f.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level),
- Mr.BindTextureMatrix(this._reflectanceTexture, f, "reflectance")),
- this._microSurfaceTexture && (f.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level),
- Mr.BindTextureMatrix(this._microSurfaceTexture, f, "microSurfaceSampler"))),
- this._bumpTexture && u.getCaps().standardDerivatives && vs.BumpTextureEnabled && !this._disableBumpMap && (f.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias),
- Mr.BindTextureMatrix(this._bumpTexture, f, "bump"),
- s._mirroredCameraPosition ? f.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : f.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1))
- }
- if (this.pointsCloud && f.updateFloat("pointSize", this.pointSize),
- l.METALLICWORKFLOW) {
- L.Color3[0].r = void 0 === this._metallic || null === this._metallic ? 1 : this._metallic,
- L.Color3[0].g = void 0 === this._roughness || null === this._roughness ? 1 : this._roughness,
- f.updateColor4("vReflectivityColor", L.Color3[0], 1);
- var y = null !== (r = null === (n = this.subSurface) || void 0 === n ? void 0 : n._indexOfRefraction) && void 0 !== r ? r : 1.5
- , b = Math.pow((y - 1) / (y + 1), 2);
- this._metallicReflectanceColor.scaleToRef(b * this._metallicF0Factor, L.Color3[0]);
- var T = this._metallicF0Factor;
- f.updateColor4("vMetallicReflectanceFactors", L.Color3[0], T)
- } else
- f.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
- f.updateColor3("vEmissiveColor", vs.EmissiveTextureEnabled ? this._emissiveColor : D.BlackReadOnly),
- f.updateColor3("vReflectionColor", this._reflectionColor),
- !l.SS_REFRACTION && (null === (o = this.subSurface) || void 0 === o ? void 0 : o._linkRefractionWithTransparency) ? f.updateColor4("vAlbedoColor", this._albedoColor, 1) : f.updateColor4("vAlbedoColor", this._albedoColor, this.alpha),
- this._lightingInfos.x = this._directIntensity,
- this._lightingInfos.y = this._emissiveIntensity,
- this._lightingInfos.z = this._environmentIntensity * s.environmentIntensity,
- this._lightingInfos.w = this._specularIntensity,
- f.updateVector4("vLightingIntensity", this._lightingInfos),
- s.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor),
- f.updateColor3("vAmbientColor", this._globalAmbientColor),
- f.updateFloat2("vDebugMode", this._debugLimit, this._debugFactor)
- }
- s.texturesEnabled && (this._albedoTexture && vs.DiffuseTextureEnabled && f.setTexture("albedoSampler", this._albedoTexture),
- this._ambientTexture && vs.AmbientTextureEnabled && f.setTexture("ambientSampler", this._ambientTexture),
- this._opacityTexture && vs.OpacityTextureEnabled && f.setTexture("opacitySampler", this._opacityTexture),
- p && vs.ReflectionTextureEnabled && (l.LODBASEDMICROSFURACE ? f.setTexture("reflectionSampler", p) : (f.setTexture("reflectionSampler", p._lodTextureMid || p),
- f.setTexture("reflectionSamplerLow", p._lodTextureLow || p),
- f.setTexture("reflectionSamplerHigh", p._lodTextureHigh || p)),
- l.USEIRRADIANCEMAP && f.setTexture("irradianceSampler", p.irradianceTexture)),
- l.ENVIRONMENTBRDF && f.setTexture("environmentBrdfSampler", this._environmentBRDFTexture),
- this._emissiveTexture && vs.EmissiveTextureEnabled && f.setTexture("emissiveSampler", this._emissiveTexture),
- this._lightmapTexture && vs.LightmapTextureEnabled && f.setTexture("lightmapSampler", this._lightmapTexture),
- vs.SpecularTextureEnabled && (this._metallicTexture ? f.setTexture("reflectivitySampler", this._metallicTexture) : this._reflectivityTexture && f.setTexture("reflectivitySampler", this._reflectivityTexture),
- this._metallicReflectanceTexture && f.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture),
- this._reflectanceTexture && l.REFLECTANCE && f.setTexture("reflectanceSampler", this._reflectanceTexture),
- this._microSurfaceTexture && f.setTexture("microSurfaceSampler", this._microSurfaceTexture)),
- this._bumpTexture && u.getCaps().standardDerivatives && vs.BumpTextureEnabled && !this._disableBumpMap && f.setTexture("bumpSampler", this._bumpTexture)),
- this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(t) && this.getScene().depthPeelingRenderer.bind(c),
- this._eventInfo.subMesh = i,
- this._callbackPluginEventBindForSubMesh(this._eventInfo),
- Mr.BindClipPlane(this._activeEffect, s),
- this.bindEyePosition(c)
- } else
- s.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
- !h && this.isFrozen || (s.lightsEnabled && !this._disableLighting && Mr.BindLights(s, t, this._activeEffect, l, this._maxSimultaneousLights),
- (s.fogEnabled && t.applyFog && s.fogMode !== mn.FOGMODE_NONE || p || t.receiveShadows) && this.bindView(c),
- Mr.BindFogParameters(s, t, this._activeEffect, !0),
- l.NUM_MORPH_INFLUENCERS && Mr.BindMorphTargetParameters(t, this._activeEffect),
- l.BAKED_VERTEX_ANIMATION_TEXTURE && (null === (a = t.bakedVertexAnimationManager) || void 0 === a || a.bind(c, l.INSTANCES)),
- this._imageProcessingConfiguration.bind(this._activeEffect),
- Mr.BindLogDepth(l, this._activeEffect, s)),
- this._afterBind(t, this._activeEffect),
- f.update()
- }
- }
- }
- ,
- t.prototype.getAnimatables = function() {
- var t = e.prototype.getAnimatables.call(this);
- return this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0 && t.push(this._albedoTexture),
- this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && t.push(this._ambientTexture),
- this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && t.push(this._opacityTexture),
- this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && t.push(this._reflectionTexture),
- this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && t.push(this._emissiveTexture),
- this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0 ? t.push(this._metallicTexture) : this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0 && t.push(this._reflectivityTexture),
- this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && t.push(this._bumpTexture),
- this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && t.push(this._lightmapTexture),
- t
- }
- ,
- t.prototype._getReflectionTexture = function() {
- return this._reflectionTexture ? this._reflectionTexture : this.getScene().environmentTexture
- }
- ,
- t.prototype.getActiveTextures = function() {
- var t = e.prototype.getActiveTextures.call(this);
- return this._albedoTexture && t.push(this._albedoTexture),
- this._ambientTexture && t.push(this._ambientTexture),
- this._opacityTexture && t.push(this._opacityTexture),
- this._reflectionTexture && t.push(this._reflectionTexture),
- this._emissiveTexture && t.push(this._emissiveTexture),
- this._reflectivityTexture && t.push(this._reflectivityTexture),
- this._metallicTexture && t.push(this._metallicTexture),
- this._metallicReflectanceTexture && t.push(this._metallicReflectanceTexture),
- this._reflectanceTexture && t.push(this._reflectanceTexture),
- this._microSurfaceTexture && t.push(this._microSurfaceTexture),
- this._bumpTexture && t.push(this._bumpTexture),
- this._lightmapTexture && t.push(this._lightmapTexture),
- t
- }
- ,
- t.prototype.hasTexture = function(t) {
- return !!e.prototype.hasTexture.call(this, t) || this._albedoTexture === t || this._ambientTexture === t || this._opacityTexture === t || this._reflectionTexture === t || this._reflectivityTexture === t || this._metallicTexture === t || this._metallicReflectanceTexture === t || this._reflectanceTexture === t || this._microSurfaceTexture === t || this._bumpTexture === t || this._lightmapTexture === t
- }
- ,
- t.prototype.setPrePassRenderer = function() {
- var e;
- if (null === (e = this.subSurface) || void 0 === e ? void 0 : e.isScatteringEnabled) {
- var t = this.getScene().enableSubSurfaceForPrePass();
- return t && (t.enabled = !0),
- !0
- }
- return !1
- }
- ,
- t.prototype.dispose = function(t, i) {
- var n, r, o, a, s, l, c, u, h, d, p, f;
- i && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(),
- null === (n = this._albedoTexture) || void 0 === n || n.dispose(),
- null === (r = this._ambientTexture) || void 0 === r || r.dispose(),
- null === (o = this._opacityTexture) || void 0 === o || o.dispose(),
- null === (a = this._reflectionTexture) || void 0 === a || a.dispose(),
- null === (s = this._emissiveTexture) || void 0 === s || s.dispose(),
- null === (l = this._metallicTexture) || void 0 === l || l.dispose(),
- null === (c = this._reflectivityTexture) || void 0 === c || c.dispose(),
- null === (u = this._bumpTexture) || void 0 === u || u.dispose(),
- null === (h = this._lightmapTexture) || void 0 === h || h.dispose(),
- null === (d = this._metallicReflectanceTexture) || void 0 === d || d.dispose(),
- null === (p = this._reflectanceTexture) || void 0 === p || p.dispose(),
- null === (f = this._microSurfaceTexture) || void 0 === f || f.dispose()),
- this._renderTargets.dispose(),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.PBRMATERIAL_OPAQUE = Or.MATERIAL_OPAQUE,
- t.PBRMATERIAL_ALPHATEST = Or.MATERIAL_ALPHATEST,
- t.PBRMATERIAL_ALPHABLEND = Or.MATERIAL_ALPHABLEND,
- t.PBRMATERIAL_ALPHATESTANDBLEND = Or.MATERIAL_ALPHATESTANDBLEND,
- t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0,
- t.LIGHTFALLOFF_PHYSICAL = 0,
- t.LIGHTFALLOFF_GLTF = 1,
- t.LIGHTFALLOFF_STANDARD = 2,
- k([we()], t.prototype, "_imageProcessingConfiguration", void 0),
- k([Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "debugMode", void 0),
- k([Ce()], t.prototype, "useLogarithmicDepth", null),
- t
- }(gs)
- , op = function(e) {
- function t(i, n) {
- var r = e.call(this, i, n) || this;
- return r.directIntensity = 1,
- r.emissiveIntensity = 1,
- r.environmentIntensity = 1,
- r.specularIntensity = 1,
- r.disableBumpMap = !1,
- r.ambientTextureStrength = 1,
- r.ambientTextureImpactOnAnalyticalLights = t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
- r.metallicF0Factor = 1,
- r.metallicReflectanceColor = D.White(),
- r.useOnlyMetallicFromMetallicReflectanceTexture = !1,
- r.ambientColor = new D(0,0,0),
- r.albedoColor = new D(1,1,1),
- r.reflectivityColor = new D(1,1,1),
- r.reflectionColor = new D(1,1,1),
- r.emissiveColor = new D(0,0,0),
- r.microSurface = 1,
- r.useLightmapAsShadowmap = !1,
- r.useAlphaFromAlbedoTexture = !1,
- r.forceAlphaTest = !1,
- r.alphaCutOff = .4,
- r.useSpecularOverAlpha = !0,
- r.useMicroSurfaceFromReflectivityMapAlpha = !1,
- r.useRoughnessFromMetallicTextureAlpha = !0,
- r.useRoughnessFromMetallicTextureGreen = !1,
- r.useMetallnessFromMetallicTextureBlue = !1,
- r.useAmbientOcclusionFromMetallicTextureRed = !1,
- r.useAmbientInGrayScale = !1,
- r.useAutoMicroSurfaceFromReflectivityMap = !1,
- r.useRadianceOverAlpha = !0,
- r.useObjectSpaceNormalMap = !1,
- r.useParallax = !1,
- r.useParallaxOcclusion = !1,
- r.parallaxScaleBias = .05,
- r.disableLighting = !1,
- r.forceIrradianceInFragment = !1,
- r.maxSimultaneousLights = 4,
- r.invertNormalMapX = !1,
- r.invertNormalMapY = !1,
- r.twoSidedLighting = !1,
- r.useAlphaFresnel = !1,
- r.useLinearAlphaFresnel = !1,
- r.environmentBRDFTexture = null,
- r.forceNormalForward = !1,
- r.enableSpecularAntiAliasing = !1,
- r.useHorizonOcclusion = !0,
- r.useRadianceOcclusion = !0,
- r.unlit = !1,
- r._environmentBRDFTexture = Hd(r.getScene()),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "refractionTexture", {
- get: function() {
- return this.subSurface.refractionTexture
- },
- set: function(e) {
- this.subSurface.refractionTexture = e,
- e ? this.subSurface.isRefractionEnabled = !0 : this.subSurface.linkRefractionWithTransparency || (this.subSurface.isRefractionEnabled = !1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "indexOfRefraction", {
- get: function() {
- return this.subSurface.indexOfRefraction
- },
- set: function(e) {
- this.subSurface.indexOfRefraction = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "invertRefractionY", {
- get: function() {
- return this.subSurface.invertRefractionY
- },
- set: function(e) {
- this.subSurface.invertRefractionY = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "linkRefractionWithTransparency", {
- get: function() {
- return this.subSurface.linkRefractionWithTransparency
- },
- set: function(e) {
- this.subSurface.linkRefractionWithTransparency = e,
- e && (this.subSurface.isRefractionEnabled = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "usePhysicalLightFalloff", {
- get: function() {
- return this._lightFalloff === rp.LIGHTFALLOFF_PHYSICAL
- },
- set: function(e) {
- e !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
- this._lightFalloff = e ? rp.LIGHTFALLOFF_PHYSICAL : rp.LIGHTFALLOFF_STANDARD)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useGLTFLightFalloff", {
- get: function() {
- return this._lightFalloff === rp.LIGHTFALLOFF_GLTF
- },
- set: function(e) {
- e !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
- this._lightFalloff = e ? rp.LIGHTFALLOFF_GLTF : rp.LIGHTFALLOFF_STANDARD)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- this._attachImageProcessingConfiguration(e),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorCurvesEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(e) {
- this.imageProcessingConfiguration.colorGradingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraToneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(e) {
- this._imageProcessingConfiguration.toneMappingEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraExposure", {
- get: function() {
- return this._imageProcessingConfiguration.exposure
- },
- set: function(e) {
- this._imageProcessingConfiguration.exposure = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraContrast", {
- get: function() {
- return this._imageProcessingConfiguration.contrast
- },
- set: function(e) {
- this._imageProcessingConfiguration.contrast = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorGradingTexture", {
- get: function() {
- return this._imageProcessingConfiguration.colorGradingTexture
- },
- set: function(e) {
- this._imageProcessingConfiguration.colorGradingTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraColorCurves", {
- get: function() {
- return this._imageProcessingConfiguration.colorCurves
- },
- set: function(e) {
- this._imageProcessingConfiguration.colorCurves = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "PBRMaterial"
- }
- ,
- t.prototype.clone = function(e) {
- var i = this
- , n = Ge.Clone((function() {
- return new t(e,i.getScene())
- }
- ), this);
- return n.id = e,
- n.name = e,
- this.stencil.copyTo(n.stencil),
- this.clearCoat.copyTo(n.clearCoat),
- this.anisotropy.copyTo(n.anisotropy),
- this.brdf.copyTo(n.brdf),
- this.sheen.copyTo(n.sheen),
- this.subSurface.copyTo(n.subSurface),
- n
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.customType = "BABYLON.PBRMaterial",
- t.clearCoat = this.clearCoat.serialize(),
- t.anisotropy = this.anisotropy.serialize(),
- t.brdf = this.brdf.serialize(),
- t.sheen = this.sheen.serialize(),
- t.subSurface = this.subSurface.serialize(),
- t
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n);
- return e.stencil && r.stencil.parse(e.stencil, i, n),
- e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
- e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
- e.brdf && r.brdf.parse(e.brdf, i, n),
- e.sheen && r.sheen.parse(e.sheen, i, n),
- e.subSurface && r.subSurface.parse(e.subSurface, i, n),
- r
- }
- ,
- t.PBRMATERIAL_OPAQUE = rp.PBRMATERIAL_OPAQUE,
- t.PBRMATERIAL_ALPHATEST = rp.PBRMATERIAL_ALPHATEST,
- t.PBRMATERIAL_ALPHABLEND = rp.PBRMATERIAL_ALPHABLEND,
- t.PBRMATERIAL_ALPHATESTANDBLEND = rp.PBRMATERIAL_ALPHATESTANDBLEND,
- t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = rp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "directIntensity", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveIntensity", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentIntensity", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "specularIntensity", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "disableBumpMap", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureStrength", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientTextureImpactOnAnalyticalLights", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "opacityTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicF0Factor", void 0),
- k([Me(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceColor", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallicReflectanceTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectanceTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurfaceTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "bumpTexture", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0),
- k([Me("ambient"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "ambientColor", void 0),
- k([Me("albedo"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "albedoColor", void 0),
- k([Me("reflectivity"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectivityColor", void 0),
- k([Me("reflection"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "reflectionColor", void 0),
- k([Me("emissive"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "microSurface", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "useAlphaFromAlbedoTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "forceAlphaTest", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesAndMiscDirty")], t.prototype, "alphaCutOff", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useSpecularOverAlpha", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureAlpha", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRoughnessFromMetallicTextureGreen", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useMetallnessFromMetallicTextureBlue", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAmbientInGrayScale", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0),
- k([Ce()], t.prototype, "usePhysicalLightFalloff", null),
- k([Ce()], t.prototype, "useGLTFLightFalloff", null),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOverAlpha", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useObjectSpaceNormalMap", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallax", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useParallaxOcclusion", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "parallaxScaleBias", void 0),
- k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceIrradianceInFragment", void 0),
- k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "twoSidedLighting", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useAlphaFresnel", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLinearAlphaFresnel", void 0),
- k([Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "environmentBRDFTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "forceNormalForward", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "enableSpecularAntiAliasing", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useHorizonOcclusion", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useRadianceOcclusion", void 0),
- k([Ce(), Re("_markAllSubMeshesAsMiscDirty")], t.prototype, "unlit", void 0),
- t
- }(rp);
- y("BABYLON.PBRMaterial", op);
- var ap = 131072
- , sp = 131072;
- function lp(e) {
- return e.charCodeAt(0) + (e.charCodeAt(1) << 8) + (e.charCodeAt(2) << 16) + (e.charCodeAt(3) << 24)
- }
- var cp = lp("DXT1")
- , up = lp("DXT3")
- , hp = lp("DXT5")
- , dp = lp("DX10")
- , pp = function() {
- function e() {}
- return e.GetDDSInfo = function(e) {
- var t = new Int32Array(e.buffer,e.byteOffset,31)
- , i = new Int32Array(e.buffer,e.byteOffset,35)
- , n = 1;
- t[2] & ap && (n = Math.max(1, t[7]));
- var r = t[21]
- , o = r === dp ? i[32] : 0
- , s = a.TEXTURETYPE_UNSIGNED_INT;
- switch (r) {
- case 113:
- s = a.TEXTURETYPE_HALF_FLOAT;
- break;
- case 116:
- s = a.TEXTURETYPE_FLOAT;
- break;
- case dp:
- if (10 === o) {
- s = a.TEXTURETYPE_HALF_FLOAT;
- break
- }
- if (2 === o) {
- s = a.TEXTURETYPE_FLOAT;
- break
- }
- }
- return {
- width: t[4],
- height: t[3],
- mipmapCount: n,
- isFourCC: 4 == (4 & t[20]),
- isRGB: 64 == (64 & t[20]),
- isLuminance: (t[20] & sp) === sp,
- isCube: 512 == (512 & t[28]),
- isCompressed: r === cp || r === up || r === hp,
- dxgiFormat: o,
- textureType: s
- }
- }
- ,
- e._GetHalfFloatAsFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
- for (var s = new Float32Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
- for (var h = 0; h < t; h++) {
- var d = 4 * (h + u * t);
- s[c] = Dc(l[d]),
- s[c + 1] = Dc(l[d + 1]),
- s[c + 2] = Dc(l[d + 2]),
- e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = Dc(l[d + 3]),
- c += 4
- }
- return s
- }
- ,
- e._GetHalfFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
- if (e.StoreLODInAlphaChannel) {
- for (var s = new Uint16Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
- for (var h = 0; h < t; h++) {
- var d = 4 * (h + u * t);
- s[c] = l[d],
- s[c + 1] = l[d + 1],
- s[c + 2] = l[d + 2],
- s[c + 3] = Oc(a),
- c += 4
- }
- return s
- }
- return new Uint16Array(o,n,r)
- }
- ,
- e._GetFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
- if (e.StoreLODInAlphaChannel) {
- for (var s = new Float32Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
- for (var h = 0; h < t; h++) {
- var d = 4 * (h + u * t);
- s[c] = l[d],
- s[c + 1] = l[d + 1],
- s[c + 2] = l[d + 2],
- s[c + 3] = a,
- c += 4
- }
- return s
- }
- return new Float32Array(o,n,r)
- }
- ,
- e._GetFloatAsHalfFloatRGBAArrayBuffer = function(t, i, n, r, o, a) {
- for (var s = new Uint16Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
- for (var h = 0; h < t; h++)
- s[c] = Oc(l[c]),
- s[c + 1] = Oc(l[c + 1]),
- s[c + 2] = Oc(l[c + 2]),
- e.StoreLODInAlphaChannel ? s[c + 3] = Oc(a) : s[c + 3] = Oc(l[c + 3]),
- c += 4;
- return s
- }
- ,
- e._GetFloatAsUIntRGBAArrayBuffer = function(t, i, n, r, o, a) {
- for (var s = new Uint8Array(r), l = new Float32Array(o,n), c = 0, u = 0; u < i; u++)
- for (var h = 0; h < t; h++) {
- var p = 4 * (h + u * t);
- s[c] = 255 * d.Clamp(l[p]),
- s[c + 1] = 255 * d.Clamp(l[p + 1]),
- s[c + 2] = 255 * d.Clamp(l[p + 2]),
- e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * d.Clamp(l[p + 3]),
- c += 4
- }
- return s
- }
- ,
- e._GetHalfFloatAsUIntRGBAArrayBuffer = function(t, i, n, r, o, a) {
- for (var s = new Uint8Array(r), l = new Uint16Array(o,n), c = 0, u = 0; u < i; u++)
- for (var h = 0; h < t; h++) {
- var p = 4 * (h + u * t);
- s[c] = 255 * d.Clamp(Dc(l[p])),
- s[c + 1] = 255 * d.Clamp(Dc(l[p + 1])),
- s[c + 2] = 255 * d.Clamp(Dc(l[p + 2])),
- e.StoreLODInAlphaChannel ? s[c + 3] = a : s[c + 3] = 255 * d.Clamp(Dc(l[p + 3])),
- c += 4
- }
- return s
- }
- ,
- e._GetRGBAArrayBuffer = function(e, t, i, n, r, o, a, s, l) {
- for (var c = new Uint8Array(n), u = new Uint8Array(r,i), h = 0, d = 0; d < t; d++)
- for (var p = 0; p < e; p++) {
- var f = 4 * (p + d * e);
- c[h] = u[f + o],
- c[h + 1] = u[f + a],
- c[h + 2] = u[f + s],
- c[h + 3] = u[f + l],
- h += 4
- }
- return c
- }
- ,
- e._ExtractLongWordOrder = function(t) {
- return 0 === t || 255 === t || -16777216 === t ? 0 : 1 + e._ExtractLongWordOrder(t >> 8)
- }
- ,
- e._GetRGBArrayBuffer = function(e, t, i, n, r, o, a, s) {
- for (var l = new Uint8Array(n), c = new Uint8Array(r,i), u = 0, h = 0; h < t; h++)
- for (var d = 0; d < e; d++) {
- var p = 3 * (d + h * e);
- l[u] = c[p + o],
- l[u + 1] = c[p + a],
- l[u + 2] = c[p + s],
- u += 3
- }
- return l
- }
- ,
- e._GetLuminanceArrayBuffer = function(e, t, i, n, r) {
- for (var o = new Uint8Array(n), a = new Uint8Array(r,i), s = 0, l = 0; l < t; l++)
- for (var c = 0; c < e; c++) {
- var u = c + l * e;
- o[s] = a[u],
- s++
- }
- return o
- }
- ,
- e.UploadDDSLevels = function(t, i, n, r, o, s, l, c, u) {
- void 0 === l && (l = -1),
- void 0 === u && (u = !0);
- var h = null;
- r.sphericalPolynomial && (h = new Array);
- var d = !!t.getCaps().s3tc;
- i.generateMipMaps = o;
- var p, f, _, m, g, v, y, b = new Int32Array(n.buffer,n.byteOffset,31), T = 0, E = 0, S = 1;
- if (542327876 === b[0])
- if (r.isFourCC || r.isRGB || r.isLuminance)
- if (!r.isCompressed || d) {
- var A = b[22];
- m = b[1] + 4;
- var x, R = !1;
- if (r.isFourCC)
- switch (p = b[21]) {
- case cp:
- S = 8,
- E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1;
- break;
- case up:
- S = 16,
- E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3;
- break;
- case hp:
- S = 16,
- E = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5;
- break;
- case 113:
- R = !0,
- A = 64;
- break;
- case 116:
- R = !0,
- A = 128;
- break;
- case dp:
- m += 20;
- var C = !1;
- switch (r.dxgiFormat) {
- case 10:
- R = !0,
- A = 64,
- C = !0;
- break;
- case 2:
- R = !0,
- A = 128,
- C = !0;
- break;
- case 88:
- r.isRGB = !0,
- r.isFourCC = !1,
- A = 32,
- C = !0
- }
- if (C)
- break;
- default:
- return void console.error("Unsupported FourCC code:", (x = p,
- String.fromCharCode(255 & x, x >> 8 & 255, x >> 16 & 255, x >> 24 & 255)))
- }
- var P = e._ExtractLongWordOrder(b[23])
- , M = e._ExtractLongWordOrder(b[24])
- , I = e._ExtractLongWordOrder(b[25])
- , O = e._ExtractLongWordOrder(b[26]);
- R && (E = t._getRGBABufferInternalSizedFormat(r.textureType)),
- v = 1,
- b[2] & ap && !1 !== o && (v = Math.max(1, b[7]));
- for (var D = c || 0, N = t.getCaps(), L = D; L < s; L++) {
- for (f = b[4],
- _ = b[3],
- y = 0; y < v; ++y) {
- if (-1 === l || l === y) {
- var F = -1 === l ? y : 0;
- if (!r.isCompressed && r.isFourCC) {
- i.format = a.TEXTUREFORMAT_RGBA,
- T = f * _ * 4;
- var w = null;
- if (t._badOS || t._badDesktopOS || !N.textureHalfFloat && !N.textureFloat)
- 128 === A ? (w = e._GetFloatAsUIntRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F),
- h && 0 == F && h.push(e._GetFloatRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F))) : 64 === A && (w = e._GetHalfFloatAsUIntRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F),
- h && 0 == F && h.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, F))),
- i.type = a.TEXTURETYPE_UNSIGNED_INT;
- else {
- var B = N.textureFloat && (u && N.textureFloatLinearFiltering || !u)
- , U = N.textureHalfFloat && (u && N.textureHalfFloatLinearFiltering || !u)
- , V = (128 === A || 64 === A && !U) && B ? a.TEXTURETYPE_FLOAT : (64 === A || 128 === A && !B) && U ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE
- , k = void 0
- , G = null;
- if (128 === A)
- switch (V) {
- case a.TEXTURETYPE_FLOAT:
- k = e._GetFloatRGBAArrayBuffer,
- G = null;
- break;
- case a.TEXTURETYPE_HALF_FLOAT:
- k = e._GetFloatAsHalfFloatRGBAArrayBuffer,
- G = e._GetFloatRGBAArrayBuffer;
- break;
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- k = e._GetFloatAsUIntRGBAArrayBuffer,
- G = e._GetFloatRGBAArrayBuffer
- }
- else
- switch (V) {
- case a.TEXTURETYPE_FLOAT:
- k = e._GetHalfFloatAsFloatRGBAArrayBuffer,
- G = null;
- break;
- case a.TEXTURETYPE_HALF_FLOAT:
- k = e._GetHalfFloatRGBAArrayBuffer,
- G = e._GetHalfFloatAsFloatRGBAArrayBuffer;
- break;
- case a.TEXTURETYPE_UNSIGNED_BYTE:
- k = e._GetHalfFloatAsUIntRGBAArrayBuffer,
- G = e._GetHalfFloatAsFloatRGBAArrayBuffer
- }
- i.type = V,
- w = k(f, _, n.byteOffset + m, T, n.buffer, F),
- h && 0 == F && h.push(G ? G(f, _, n.byteOffset + m, T, n.buffer, F) : w)
- }
- w && t._uploadDataToTextureDirectly(i, w, L, F)
- } else if (r.isRGB)
- i.type = a.TEXTURETYPE_UNSIGNED_INT,
- 24 === A ? (i.format = a.TEXTUREFORMAT_RGB,
- T = f * _ * 3,
- g = e._GetRGBArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, P, M, I),
- t._uploadDataToTextureDirectly(i, g, L, F)) : (i.format = a.TEXTUREFORMAT_RGBA,
- T = f * _ * 4,
- g = e._GetRGBAArrayBuffer(f, _, n.byteOffset + m, T, n.buffer, P, M, I, O),
- t._uploadDataToTextureDirectly(i, g, L, F));
- else if (r.isLuminance) {
- var z = t._getUnpackAlignement()
- , W = f;
- T = Math.floor((f + z - 1) / z) * z * (_ - 1) + W,
- g = e._GetLuminanceArrayBuffer(f, _, n.byteOffset + m, T, n.buffer),
- i.format = a.TEXTUREFORMAT_LUMINANCE,
- i.type = a.TEXTURETYPE_UNSIGNED_INT,
- t._uploadDataToTextureDirectly(i, g, L, F)
- } else
- T = Math.max(4, f) / 4 * Math.max(4, _) / 4 * S,
- g = new Uint8Array(n.buffer,n.byteOffset + m,T),
- i.type = a.TEXTURETYPE_UNSIGNED_INT,
- t._uploadCompressedDataToTextureDirectly(i, E, f, _, g, L, F)
- }
- m += A ? f * _ * (A / 8) : T,
- f *= .5,
- _ *= .5,
- f = Math.max(1, f),
- _ = Math.max(1, _)
- }
- if (void 0 !== c)
- break
- }
- h && h.length > 0 ? r.sphericalPolynomial = wc.ConvertCubeMapToSphericalPolynomial({
- size: b[4],
- right: h[0],
- left: h[1],
- up: h[2],
- down: h[3],
- front: h[4],
- back: h[5],
- format: a.TEXTUREFORMAT_RGBA,
- type: a.TEXTURETYPE_FLOAT,
- gammaSpace: !1
- }) : r.sphericalPolynomial = void 0
- } else
- K.Error("Compressed textures are not supported on this platform.");
- else
- K.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
- else
- K.Error("Invalid magic number in DDS header")
- }
- ,
- e.StoreLODInAlphaChannel = !1,
- e
- }();
- Ht.prototype.createPrefilteredCubeTexture = function(e, t, i, n, r, o, s, l, c) {
- var u = this;
- return void 0 === r && (r = null),
- void 0 === o && (o = null),
- void 0 === l && (l = null),
- void 0 === c && (c = !0),
- this.createCubeTexture(e, t, null, !1, (function(e) {
- if (e) {
- var o = e.texture;
- if (c ? e.info.sphericalPolynomial && (o._sphericalPolynomial = e.info.sphericalPolynomial) : o._sphericalPolynomial = new Pc,
- o._source = At.CubePrefiltered,
- u.getCaps().textureLOD)
- r && r(o);
- else {
- var s = u._gl
- , l = e.width;
- if (l) {
- for (var h = [], p = 0; p < 3; p++) {
- var f = 1 - p / 2
- , _ = n
- , m = d.Log2(l) * i + n
- , g = _ + (m - _) * f
- , v = Math.round(Math.min(Math.max(g, 0), m))
- , y = new Lt(u,At.Temp);
- if (y.type = o.type,
- y.format = o.format,
- y.width = Math.pow(2, Math.max(d.Log2(l) - v, 0)),
- y.height = y.width,
- y.isCube = !0,
- y._cachedWrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- y._cachedWrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
- u._bindTextureDirectly(s.TEXTURE_CUBE_MAP, y, !0),
- y.samplingMode = a.TEXTURE_LINEAR_LINEAR,
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MAG_FILTER, s.LINEAR),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MIN_FILTER, s.LINEAR),
- 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),
- e.isDDS) {
- var b = e.info
- , T = e.data;
- u._unpackFlipY(b.isCompressed),
- pp.UploadDDSLevels(u, y, T, b, !0, 6, v)
- } else
- K.Warn("DDS is the only prefiltered cube map supported so far.");
- u._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null);
- var E = new Zr(t);
- E.isCube = !0,
- E._texture = y,
- y.isReady = !0,
- h.push(E)
- }
- o._lodTextureHigh = h[2],
- o._lodTextureMid = h[1],
- o._lodTextureLow = h[0],
- r && r(o)
- }
- }
- } else
- r && r(null)
- }
- ), o, s, l, c, i, n)
- }
- ;
- var fp = function() {
- function e() {
- this.supportCascades = !0
- }
- return e.prototype.canLoad = function(e) {
- return oe(e, ".dds")
- }
- ,
- e.prototype.loadCubeData = function(e, t, i, n) {
- var r, o = t.getEngine(), a = !1, s = 1e3;
- if (Array.isArray(e))
- for (var l = 0; l < e.length; l++) {
- var c = e[l];
- r = pp.GetDDSInfo(c),
- t.width = r.width,
- t.height = r.height,
- a = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && t.generateMipMaps,
- o._unpackFlipY(r.isCompressed),
- pp.UploadDDSLevels(o, t, c, r, a, 6, -1, l),
- r.isFourCC || 1 !== r.mipmapCount ? s = r.mipmapCount - 1 : o.generateMipMapsForCubemap(t)
- }
- else
- c = e,
- r = pp.GetDDSInfo(c),
- t.width = r.width,
- t.height = r.height,
- i && (r.sphericalPolynomial = new Pc),
- a = (r.isRGB || r.isLuminance || r.mipmapCount > 1) && t.generateMipMaps,
- o._unpackFlipY(r.isCompressed),
- pp.UploadDDSLevels(o, t, c, r, a, 6),
- r.isFourCC || 1 !== r.mipmapCount ? s = r.mipmapCount - 1 : o.generateMipMapsForCubemap(t, !1);
- o._setCubeMapTextureParams(t, a, s),
- t.isReady = !0,
- t.onLoadedObservable.notifyObservers(t),
- t.onLoadedObservable.clear(),
- n && n({
- isDDS: !0,
- width: t.width,
- info: r,
- data: e,
- texture: t
- })
- }
- ,
- e.prototype.loadData = function(e, t, i) {
- var n = pp.GetDDSInfo(e)
- , r = (n.isRGB || n.isLuminance || n.mipmapCount > 1) && t.generateMipMaps && n.width >> n.mipmapCount - 1 == 1;
- i(n.width, n.height, r, n.isFourCC, (function() {
- pp.UploadDDSLevels(t.getEngine(), t, e, n, r, 1)
- }
- ))
- }
- ,
- e
- }();
- vr._TextureLoaders.push(new fp);
- var _p = function() {
- function e() {
- this.supportCascades = !1
- }
- return e.prototype.canLoad = function(e) {
- return oe(e, ".env")
- }
- ,
- e.prototype.loadCubeData = function(e, t, i, n, r) {
- if (!Array.isArray(e)) {
- var o = Vc(e);
- if (o) {
- t.width = o.width,
- t.height = o.width;
- try {
- Yc(t, o),
- Hc(t, e, o).then((function() {
- t.isReady = !0,
- t.onLoadedObservable.notifyObservers(t),
- t.onLoadedObservable.clear(),
- n && n()
- }
- ), (function(e) {
- null == r || r("Can not upload environment levels", e)
- }
- ))
- } catch (e) {
- null == r || r("Can not upload environment file", e)
- }
- } else
- r && r("Can not parse the environment file", null)
- }
- }
- ,
- e.prototype.loadData = function() {
- throw ".env not supported in 2d."
- }
- ,
- e
- }();
- vr._TextureLoaders.push(new _p);
- var mp = function() {
- function e(t, i) {
- if (this.data = t,
- this.isInvalid = !1,
- !e.IsValid(t))
- return this.isInvalid = !0,
- void K.Error("texture missing KTX identifier");
- var n = Uint32Array.BYTES_PER_ELEMENT
- , r = new DataView(this.data.buffer,this.data.byteOffset + 12,13 * n)
- , o = 67305985 === r.getUint32(0, !0);
- this.glType = r.getUint32(1 * n, o),
- this.glTypeSize = r.getUint32(2 * n, o),
- this.glFormat = r.getUint32(3 * n, o),
- this.glInternalFormat = r.getUint32(4 * n, o),
- this.glBaseInternalFormat = r.getUint32(5 * n, o),
- this.pixelWidth = r.getUint32(6 * n, o),
- this.pixelHeight = r.getUint32(7 * n, o),
- this.pixelDepth = r.getUint32(8 * n, o),
- this.numberOfArrayElements = r.getUint32(9 * n, o),
- this.numberOfFaces = r.getUint32(10 * n, o),
- this.numberOfMipmapLevels = r.getUint32(11 * n, o),
- this.bytesOfKeyValueData = r.getUint32(12 * n, o),
- 0 === this.glType ? (this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels),
- 0 !== this.pixelHeight && 0 === this.pixelDepth ? 0 === this.numberOfArrayElements ? this.numberOfFaces === i ? this.loadType = e.COMPRESSED_2D : K.Error("number of faces expected" + i + ", but found " + this.numberOfFaces) : K.Error("texture arrays not currently supported") : K.Error("only 2D textures currently supported")) : K.Error("only compressed formats currently supported")
- }
- return e.prototype.uploadLevels = function(t, i) {
- switch (this.loadType) {
- case e.COMPRESSED_2D:
- this._upload2DCompressedLevels(t, i);
- case e.TEX_2D:
- case e.COMPRESSED_3D:
- case e.TEX_3D:
- }
- }
- ,
- e.prototype._upload2DCompressedLevels = function(t, i) {
- for (var n = e.HEADER_LEN + this.bytesOfKeyValueData, r = this.pixelWidth, o = this.pixelHeight, a = i ? this.numberOfMipmapLevels : 1, s = 0; s < a; s++) {
- var l = new Int32Array(this.data.buffer,this.data.byteOffset + n,1)[0];
- n += 4;
- for (var c = 0; c < this.numberOfFaces; c++) {
- var u = new Uint8Array(this.data.buffer,this.data.byteOffset + n,l);
- t.getEngine()._uploadCompressedDataToTextureDirectly(t, this.glInternalFormat, r, o, u, c, s),
- n += l,
- n += 3 - (l + 3) % 4
- }
- r = Math.max(1, .5 * r),
- o = Math.max(1, .5 * o)
- }
- }
- ,
- e.IsValid = function(e) {
- if (e.byteLength >= 12) {
- var t = new Uint8Array(e.buffer,e.byteOffset,12);
- if (171 === t[0] && 75 === t[1] && 84 === t[2] && 88 === t[3] && 32 === t[4] && 49 === t[5] && 49 === t[6] && 187 === t[7] && 13 === t[8] && 10 === t[9] && 26 === t[10] && 10 === t[11])
- return !0
- }
- return !1
- }
- ,
- e.HEADER_LEN = 64,
- e.COMPRESSED_2D = 0,
- e.COMPRESSED_3D = 1,
- e.TEX_2D = 2,
- e.TEX_3D = 3,
- e
- }()
- , gp = function() {
- function e(e) {
- this._pendingActions = new Array,
- this._workerInfos = e.map((function(e) {
- return {
- workerPromise: Promise.resolve(e),
- idle: !0
- }
- }
- ))
- }
- return e.prototype.dispose = function() {
- for (var e = 0, t = this._workerInfos; e < t.length; e++)
- t[e].workerPromise.then((function(e) {
- e.terminate()
- }
- ));
- this._workerInfos.length = 0,
- this._pendingActions.length = 0
- }
- ,
- e.prototype.push = function(e) {
- this._executeOnIdleWorker(e) || this._pendingActions.push(e)
- }
- ,
- e.prototype._executeOnIdleWorker = function(e) {
- for (var t = 0, i = this._workerInfos; t < i.length; t++) {
- var n = i[t];
- if (n.idle)
- return this._execute(n, e),
- !0
- }
- return !1
- }
- ,
- e.prototype._execute = function(e, t) {
- var i = this;
- e.idle = !1,
- e.workerPromise.then((function(n) {
- t(n, (function() {
- var t = i._pendingActions.shift();
- t ? i._execute(e, t) : e.idle = !0
- }
- ))
- }
- ))
- }
- ,
- e
- }()
- , vp = function(e) {
- function t(i, n, r) {
- void 0 === r && (r = t.DefaultOptions);
- var o = e.call(this, []) || this;
- return o._maxWorkers = i,
- o._createWorkerAsync = n,
- o._options = r,
- o
- }
- return U(t, e),
- t.prototype.push = function(e) {
- if (!this._executeOnIdleWorker(e))
- if (this._workerInfos.length < this._maxWorkers) {
- var t = {
- workerPromise: this._createWorkerAsync(),
- idle: !1
- };
- this._workerInfos.push(t),
- this._execute(t, e)
- } else
- this._pendingActions.push(e)
- }
- ,
- t.prototype._execute = function(t, i) {
- var n = this;
- t.timeoutId && (clearTimeout(t.timeoutId),
- delete t.timeoutId),
- e.prototype._execute.call(this, t, (function(e, r) {
- i(e, (function() {
- r(),
- t.idle && (t.timeoutId = setTimeout((function() {
- t.workerPromise.then((function(e) {
- e.terminate()
- }
- ));
- var e = n._workerInfos.indexOf(t);
- -1 !== e && n._workerInfos.splice(e, 1)
- }
- ), n._options.idleTimeElapsedBeforeRelease))
- }
- ))
- }
- ))
- }
- ,
- t.DefaultOptions = {
- idleTimeElapsedBeforeRelease: 1e3
- },
- t
- }(gp)
- , yp = function() {
- function e(t, i) {
- void 0 === i && (i = e.DefaultNumWorkers),
- this._engine = t,
- e._Initialize(i)
- }
- return e.GetDefaultNumWorkers = function() {
- return "object" == typeof navigator && navigator.hardwareConcurrency ? Math.min(Math.floor(.5 * navigator.hardwareConcurrency), 4) : 1
- }
- ,
- e._Initialize = function(t) {
- e._WorkerPoolPromise || e._DecoderModulePromise || (t && "function" == typeof Worker ? e._WorkerPoolPromise = new Promise((function(i) {
- var n = "(".concat(bp, ")()")
- , r = URL.createObjectURL(new Blob([n],{
- type: "application/javascript"
- }));
- i(new vp(t,(function() {
- return new Promise((function(t, i) {
- var n = new Worker(r)
- , o = function(e) {
- n.removeEventListener("error", o),
- n.removeEventListener("message", a),
- i(e)
- }
- , a = function(e) {
- "init" === e.data.action && (n.removeEventListener("error", o),
- n.removeEventListener("message", a),
- t(n))
- };
- n.addEventListener("error", o),
- n.addEventListener("message", a),
- n.postMessage({
- action: "init",
- urls: e.URLConfig
- })
- }
- ))
- }
- )))
- }
- )) : "undefined" == typeof KTX2DECODER ? e._DecoderModulePromise = gi.LoadScriptAsync(e.URLConfig.jsDecoderModule).then((function() {
- KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
- KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0;
- var t = e.URLConfig;
- return null !== t.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = t.wasmUASTCToASTC),
- null !== t.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = t.wasmUASTCToBC7),
- null !== t.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = t.wasmUASTCToRGBA_UNORM),
- null !== t.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = t.wasmUASTCToRGBA_SRGB),
- null !== t.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = t.jsMSCTranscoder),
- null !== t.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = t.wasmMSCTranscoder),
- null !== t.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = t.wasmZSTDDecoder),
- new KTX2DECODER.KTX2Decoder
- }
- )) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
- KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0,
- e._DecoderModulePromise = Promise.resolve(new KTX2DECODER.KTX2Decoder)))
- }
- ,
- e.prototype.uploadAsync = function(t, i, n) {
- var r = this
- , o = this._engine.getCaps()
- , a = {
- astc: !!o.astc,
- bptc: !!o.bptc,
- s3tc: !!o.s3tc,
- pvrtc: !!o.pvrtc,
- etc2: !!o.etc2,
- etc1: !!o.etc1
- };
- if (e._WorkerPoolPromise)
- return e._WorkerPoolPromise.then((function(e) {
- return new Promise((function(o, s) {
- e.push((function(e, l) {
- var c = function(t) {
- e.removeEventListener("error", c),
- e.removeEventListener("message", u),
- s(t),
- l()
- }
- , u = function(t) {
- if ("decoded" === t.data.action) {
- if (e.removeEventListener("error", c),
- e.removeEventListener("message", u),
- t.data.success)
- try {
- r._createTexture(t.data.decodedData, i, n),
- o()
- } catch (e) {
- s({
- message: e
- })
- }
- else
- s({
- message: t.data.msg
- });
- l()
- }
- };
- e.addEventListener("error", c),
- e.addEventListener("message", u);
- var h = new Uint8Array(t.byteLength);
- h.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),
- e.postMessage({
- action: "decode",
- data: h,
- caps: a,
- options: n
- }, [h.buffer])
- }
- ))
- }
- ))
- }
- ));
- if (e._DecoderModulePromise)
- return e._DecoderModulePromise.then((function(e) {
- return new Promise((function(n, a) {
- e.decode(t, o).then((function(e) {
- r._createTexture(e, i),
- n()
- }
- )).catch((function(e) {
- a({
- message: e
- })
- }
- ))
- }
- ))
- }
- ));
- throw new Error("KTX2 decoder module is not available")
- }
- ,
- e.prototype._createTexture = function(e, t, i) {
- if (this._engine._bindTextureDirectly(3553, t),
- i && (i.transcodedFormat = e.transcodedFormat,
- i.isInGammaSpace = e.isInGammaSpace,
- i.hasAlpha = e.hasAlpha,
- i.transcoderName = e.transcoderName),
- 32856 === e.transcodedFormat ? (t.type = a.TEXTURETYPE_UNSIGNED_BYTE,
- t.format = a.TEXTUREFORMAT_RGBA) : t.format = e.transcodedFormat,
- t._gammaSpace = e.isInGammaSpace,
- t.generateMipMaps = e.mipmaps.length > 1,
- e.errors)
- throw new Error("KTX2 container - could not transcode the data. " + e.errors);
- for (var n = 0; n < e.mipmaps.length; ++n) {
- var r = e.mipmaps[n];
- if (!r || !r.data)
- throw new Error("KTX2 container - could not transcode one of the image");
- 32856 === e.transcodedFormat ? (t.width = r.width,
- t.height = r.height,
- this._engine._uploadDataToTextureDirectly(t, r.data, 0, n, void 0, !0)) : this._engine._uploadCompressedDataToTextureDirectly(t, e.transcodedFormat, r.width, r.height, r.data, 0, n)
- }
- t._extension = ".ktx2",
- t.width = e.mipmaps[0].width,
- t.height = e.mipmaps[0].height,
- t.isReady = !0,
- this._engine._bindTextureDirectly(3553, null)
- }
- ,
- e.IsValid = function(e) {
- if (e.byteLength >= 12) {
- var t = new Uint8Array(e.buffer,e.byteOffset,12);
- if (171 === t[0] && 75 === t[1] && 84 === t[2] && 88 === t[3] && 32 === t[4] && 50 === t[5] && 48 === t[6] && 187 === t[7] && 13 === t[8] && 10 === t[9] && 26 === t[10] && 10 === t[11])
- return !0
- }
- return !1
- }
- ,
- e.URLConfig = {
- jsDecoderModule: "https://preview.babylonjs.com/babylon.ktx2Decoder.js",
- wasmUASTCToASTC: null,
- wasmUASTCToBC7: null,
- wasmUASTCToRGBA_UNORM: null,
- wasmUASTCToRGBA_SRGB: null,
- jsMSCTranscoder: null,
- wasmMSCTranscoder: null,
- wasmZSTDDecoder: null
- },
- e.DefaultNumWorkers = e.GetDefaultNumWorkers(),
- e
- }();
- function bp() {
- var e;
- onmessage = function(t) {
- if (t.data)
- switch (t.data.action) {
- case "init":
- var i = t.data.urls;
- importScripts(i.jsDecoderModule),
- null !== i.wasmUASTCToASTC && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
- null !== i.wasmUASTCToBC7 && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
- null !== i.wasmUASTCToRGBA_UNORM && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
- null !== i.wasmUASTCToRGBA_SRGB && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
- null !== i.jsMSCTranscoder && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
- null !== i.wasmMSCTranscoder && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
- null !== i.wasmZSTDDecoder && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder),
- e = new KTX2DECODER.KTX2Decoder,
- postMessage({
- action: "init"
- });
- break;
- case "decode":
- e.decode(t.data.data, t.data.caps, t.data.options).then((function(e) {
- for (var t = [], i = 0; i < e.mipmaps.length; ++i) {
- var n = e.mipmaps[i];
- n && n.data && t.push(n.data.buffer)
- }
- postMessage({
- action: "decoded",
- success: !0,
- decodedData: e
- }, t)
- }
- )).catch((function(e) {
- postMessage({
- action: "decoded",
- success: !1,
- msg: e
- })
- }
- ))
- }
- }
- }
- var Tp = function() {
- function e() {
- this.supportCascades = !1
- }
- return e.prototype.canLoad = function(e, t) {
- return oe(e, ".ktx") || oe(e, ".ktx2") || "image/ktx" === t || "image/ktx2" === t
- }
- ,
- e.prototype.loadCubeData = function(e, t, i, n) {
- if (!Array.isArray(e)) {
- t._invertVScale = !t.invertY;
- var r = t.getEngine()
- , o = new mp(e,6)
- , a = o.numberOfMipmapLevels > 1 && t.generateMipMaps;
- r._unpackFlipY(!0),
- o.uploadLevels(t, t.generateMipMaps),
- t.width = o.pixelWidth,
- t.height = o.pixelHeight,
- r._setCubeMapTextureParams(t, a, o.numberOfMipmapLevels - 1),
- t.isReady = !0,
- t.onLoadedObservable.notifyObservers(t),
- t.onLoadedObservable.clear(),
- n && n()
- }
- }
- ,
- e.prototype.loadData = function(e, t, i, n) {
- if (mp.IsValid(e)) {
- t._invertVScale = !t.invertY;
- var r = new mp(e,1);
- i(r.pixelWidth, r.pixelHeight, t.generateMipMaps, !0, (function() {
- r.uploadLevels(t, t.generateMipMaps)
- }
- ), r.isInvalid)
- } else
- yp.IsValid(e) ? new yp(t.getEngine()).uploadAsync(e, t, n).then((function() {
- i(t.width, t.height, t.generateMipMaps, !0, (function() {}
- ), !1)
- }
- ), (function(e) {
- K.Warn("Failed to load KTX2 texture data: ".concat(e.message)),
- i(0, 0, !1, !1, (function() {}
- ), !0)
- }
- )) : (K.Error("texture missing KTX identifier"),
- i(0, 0, !1, !1, (function() {}
- ), !0))
- }
- ,
- e
- }();
- vr._TextureLoaders.unshift(new Tp);
- var Ep = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, x.Zero(), i) || this;
- return r._xrSessionManager = n,
- r._firstFrame = !1,
- r._referenceQuaternion = C.Identity(),
- r._referencedPosition = new x,
- r._trackingState = Ls.NOT_TRACKING,
- r.onBeforeCameraTeleport = new h,
- r.onAfterCameraTeleport = new h,
- r.onTrackingStateChanged = new h,
- r.compensateOnFirstFrame = !0,
- r._rotate180 = new C(0,1,0,0),
- r.minZ = .1,
- r.rotationQuaternion = new C,
- r.cameraRigMode = Rr.RIG_MODE_CUSTOM,
- r.updateUpVectorFromRotation = !0,
- r._updateNumberOfRigCameras(1),
- r.freezeProjectionMatrix(),
- r._xrSessionManager.onXRSessionInit.add((function() {
- r._referencedPosition.copyFromFloats(0, 0, 0),
- r._referenceQuaternion.copyFromFloats(0, 0, 0, 1),
- r._firstFrame = r.compensateOnFirstFrame
- }
- )),
- r._xrSessionManager.onXRFrameObservable.add((function() {
- r._firstFrame && r._updateFromXRSession(),
- r._updateReferenceSpace(),
- r._updateFromXRSession()
- }
- ), void 0, !0),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "trackingState", {
- get: function() {
- return this._trackingState
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._setTrackingState = function(e) {
- this._trackingState !== e && (this._trackingState = e,
- this.onTrackingStateChanged.notifyObservers(e))
- }
- ,
- Object.defineProperty(t.prototype, "realWorldHeight", {
- get: function() {
- var e = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);
- return e && e.transform ? e.transform.position.y : 0
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._updateForDualEyeDebugging = function() {
- this._updateNumberOfRigCameras(2),
- this.rigCameras[0].viewport = new xr(0,0,.5,1),
- this.rigCameras[0].outputRenderTarget = null,
- this.rigCameras[1].viewport = new xr(.5,0,.5,1),
- this.rigCameras[1].outputRenderTarget = null
- }
- ,
- t.prototype.setTransformationFromNonVRCamera = function(e, t) {
- void 0 === e && (e = this.getScene().activeCamera),
- void 0 === t && (t = !0),
- e && e !== this && (e.computeWorldMatrix().decompose(void 0, this.rotationQuaternion, this.position),
- this.position.y = 0,
- C.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion),
- this._firstFrame = !0,
- t && this._xrSessionManager.resetReferenceSpace())
- }
- ,
- t.prototype.getClassName = function() {
- return "WebXRCamera"
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._lastXRViewerPose = void 0
- }
- ,
- t.prototype._updateFromXRSession = function() {
- var e = this
- , t = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
- if (this._lastXRViewerPose = t || void 0,
- t) {
- var i = t.emulatedPosition ? Ls.TRACKING_LOST : Ls.TRACKING;
- if (this._setTrackingState(i),
- t.transform) {
- var n = t.transform.orientation;
- if (void 0 === t.transform.orientation.x)
- return;
- var r = t.transform.position;
- this._referencedPosition.set(r.x, r.y, r.z),
- this._referenceQuaternion.set(n.x, n.y, n.z, n.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 !== t.views.length && this._updateNumberOfRigCameras(t.views.length),
- t.views.forEach((function(t, i) {
- var n, r = e.rigCameras[i];
- r.isLeftCamera || r.isRightCamera || ("right" === t.eye ? r._isRightCamera = !0 : "left" === t.eye && (r._isLeftCamera = !0));
- var o = t.transform.position
- , a = t.transform.orientation;
- r.parent = e.parent,
- r.position.set(o.x, o.y, o.z),
- r.rotationQuaternion.set(a.x, a.y, a.z, a.w),
- e._scene.useRightHandedSystem ? r.rotationQuaternion.multiplyInPlace(e._rotate180) : (r.position.z *= -1,
- r.rotationQuaternion.z *= -1,
- r.rotationQuaternion.w *= -1),
- P.FromFloat32ArrayToRefScaled(t.projectionMatrix, 0, 1, r._projectionMatrix),
- e._scene.useRightHandedSystem || r._projectionMatrix.toggleProjectionMatrixHandInPlace(),
- 0 === i && e._projectionMatrix.copyFrom(r._projectionMatrix);
- var s = e._xrSessionManager.getRenderTargetTextureForView(t);
- e._renderingMultiview = (null === (n = null == s ? void 0 : s._texture) || void 0 === n ? void 0 : n.isMultiview) || !1,
- e._renderingMultiview ? 0 == i && (e._xrSessionManager.trySetViewportForView(e.viewport, t),
- e.outputRenderTarget = s) : (e._xrSessionManager.trySetViewportForView(r.viewport, t),
- r.outputRenderTarget = s || e._xrSessionManager.getRenderTargetTextureForView(t))
- }
- ))
- } else
- this._setTrackingState(Ls.NOT_TRACKING)
- }
- ,
- t.prototype._updateNumberOfRigCameras = function(e) {
- for (void 0 === e && (e = 1); this.rigCameras.length < e; ) {
- var t = new da("XR-RigCamera: " + this.rigCameras.length,x.Zero(),this.getScene());
- t.minZ = .1,
- t.rotationQuaternion = new C,
- t.updateUpVectorFromRotation = !0,
- t.isRigCamera = !0,
- t.rigParent = this,
- t.freezeProjectionMatrix(),
- this.rigCameras.push(t)
- }
- for (; this.rigCameras.length > e; ) {
- var i = this.rigCameras.pop();
- i && i.dispose()
- }
- }
- ,
- t.prototype._updateReferenceSpace = function() {
- if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {
- var e = I.Matrix[0]
- , i = I.Matrix[1]
- , n = I.Matrix[2];
- P.ComposeToRef(t._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, e),
- P.ComposeToRef(t._ScaleReadOnly, this.rotationQuaternion, this.position, i),
- e.invert().multiplyToRef(i, n),
- n.invert(),
- this._scene.useRightHandedSystem || n.toggleModelMatrixHandInPlace(),
- n.decompose(void 0, this._referenceQuaternion, this._referencedPosition);
- var r = 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(r)
- }
- }
- ,
- t._ScaleReadOnly = x.One(),
- t
- }(pa)
- , Sp = function() {
- function e(e) {
- var t = 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 h,
- this.onStateChangedObservable = new h,
- this.state = Ns.NOT_IN_XR,
- this.sessionManager = new Xs(e),
- this.camera = new Ep("webxr",e,this.sessionManager),
- this.featuresManager = new Oo(this.sessionManager),
- e.onDisposeObservable.addOnce((function() {
- t.dispose()
- }
- ))
- }
- return e.CreateAsync = function(t) {
- var i = new e(t);
- return i.sessionManager.initializeAsync().then((function() {
- return i._supported = !0,
- i
- }
- )).catch((function(e) {
- throw i._setState(Ns.NOT_IN_XR),
- i.dispose(),
- e
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- var e;
- this.exitXRAsync(),
- this.camera.dispose(),
- this.onStateChangedObservable.clear(),
- this.onInitialXRPoseSetObservable.clear(),
- this.sessionManager.dispose(),
- null === (e = this._spectatorCamera) || void 0 === e || e.dispose(),
- this._nonVRCamera && (this._scene.activeCamera = this._nonVRCamera)
- }
- ,
- e.prototype.enterXRAsync = function(e, t, i, n) {
- var r, o;
- return void 0 === i && (i = this.sessionManager.getWebXRRenderTarget()),
- void 0 === n && (n = {}),
- G(this, void 0, void 0, (function() {
- var a, s, l, c = this;
- return z(this, (function(u) {
- switch (u.label) {
- case 0:
- if (!this._supported)
- throw "WebXR not supported in this browser or environment";
- return this._setState(Ns.ENTERING_XR),
- "viewer" !== t && "local" !== t && (n.optionalFeatures = n.optionalFeatures || [],
- n.optionalFeatures.push(t)),
- [4, this.featuresManager._extendXRSessionInitObject(n)];
- case 1:
- n = u.sent(),
- "immersive-ar" === e && "unbounded" !== t && K.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),
- u.label = 2;
- case 2:
- return u.trys.push([2, 6, , 7]),
- [4, this.sessionManager.initializeSessionAsync(e, n)];
- case 3:
- return u.sent(),
- [4, this.sessionManager.setReferenceSpaceTypeAsync(t)];
- case 4:
- return u.sent(),
- [4, i.initializeXRLayerAsync(this.sessionManager.session)];
- case 5:
- return a = u.sent(),
- s = {
- depthFar: this.camera.maxZ,
- depthNear: this.camera.minZ
- },
- this.featuresManager.getEnabledFeature(Io.LAYERS) || (s.baseLayer = a),
- this.sessionManager.updateRenderState(s),
- this.sessionManager.runXRRenderLoop(),
- this._originalSceneAutoClear = this._scene.autoClear,
- this._nonVRCamera = this._scene.activeCamera,
- this._attachedToElement = !!(null === (r = this._nonVRCamera) || void 0 === r ? void 0 : r.inputs.attachedToElement),
- null === (o = this._nonVRCamera) || void 0 === o || o.detachControl(),
- this._scene.activeCamera = this.camera,
- "immersive-ar" !== e ? this._nonXRToXRCamera() : (this._scene.autoClear = !1,
- this.camera.compensateOnFirstFrame = !1,
- this.camera.position.set(0, 0, 0),
- this.camera.rotationQuaternion.set(0, 0, 0, 1)),
- this.sessionManager.onXRSessionEnded.addOnce((function() {
- c.state !== Ns.EXITING_XR && c._setState(Ns.EXITING_XR),
- c.camera.rigCameras.forEach((function(e) {
- e.outputRenderTarget = null
- }
- )),
- c._scene.autoClear = c._originalSceneAutoClear,
- c._scene.activeCamera = c._nonVRCamera,
- c._attachedToElement && c._nonVRCamera && c._nonVRCamera.attachControl(!!c._nonVRCamera.inputs.noPreventDefault),
- "immersive-ar" !== e && c.camera.compensateOnFirstFrame && (c._nonVRCamera.setPosition ? c._nonVRCamera.setPosition(c.camera.position) : c._nonVRCamera.position.copyFrom(c.camera.position)),
- c._setState(Ns.NOT_IN_XR)
- }
- )),
- this.sessionManager.onXRFrameObservable.addOnce((function() {
- c._setState(Ns.IN_XR)
- }
- )),
- [2, this.sessionManager];
- case 6:
- throw l = u.sent(),
- console.log(l),
- console.log(l.message),
- this._setState(Ns.NOT_IN_XR),
- l;
- case 7:
- return [2]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype.exitXRAsync = function() {
- return this.state !== Ns.IN_XR ? Promise.resolve() : (this._setState(Ns.EXITING_XR),
- this.sessionManager.exitXRAsync())
- }
- ,
- e.prototype.enableSpectatorMode = function() {
- var e = this;
- if (!this._spectatorMode) {
- var t = function() {
- e._spectatorCamera && (e._spectatorCamera.position.copyFrom(e.camera.rigCameras[0].globalPosition),
- e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[0].absoluteRotation))
- }
- , i = function() {
- e.state === Ns.IN_XR ? (e._spectatorCamera = new Na("webxr-spectator",x.Zero(),e._scene),
- e._spectatorCamera.rotationQuaternion = new C,
- e._scene.activeCameras = [e.camera, e._spectatorCamera],
- e.sessionManager.onXRFrameObservable.add(t),
- e._scene.onAfterRenderCameraObservable.add((function(t) {
- t === e.camera && (e._scene.getEngine().framebufferDimensionsObject = null)
- }
- ))) : e.state === Ns.EXITING_XR && (e.sessionManager.onXRFrameObservable.removeCallback(t),
- e._scene.activeCameras = null)
- };
- this._spectatorMode = !0,
- this.onStateChangedObservable.add(i),
- i()
- }
- }
- ,
- e.prototype._nonXRToXRCamera = function() {
- this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),
- this.onInitialXRPoseSetObservable.notifyObservers(this.camera)
- }
- ,
- e.prototype._setState = function(e) {
- this.state !== e && (this.state = e,
- this.onStateChangedObservable.notifyObservers(this.state))
- }
- ,
- e
- }()
- , Ap = function() {
- function e(e, t, i, n) {
- void 0 === i && (i = -1),
- void 0 === n && (n = []),
- this.id = e,
- this.type = t,
- this._buttonIndex = i,
- this._axesIndices = n,
- this._axes = {
- x: 0,
- y: 0
- },
- this._changes = {},
- this._currentValue = 0,
- this._hasChanges = !1,
- this._pressed = !1,
- this._touched = !1,
- this.onAxisValueChangedObservable = new h,
- this.onButtonStateChangedObservable = new h
- }
- return Object.defineProperty(e.prototype, "axes", {
- get: function() {
- return this._axes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "changes", {
- get: function() {
- return this._changes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasChanges", {
- get: function() {
- return this._hasChanges
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pressed", {
- get: function() {
- return this._pressed
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "touched", {
- get: function() {
- return this._touched
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._currentValue
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this.onAxisValueChangedObservable.clear(),
- this.onButtonStateChangedObservable.clear()
- }
- ,
- e.prototype.isAxes = function() {
- return 0 !== this._axesIndices.length
- }
- ,
- e.prototype.isButton = function() {
- return -1 !== this._buttonIndex
- }
- ,
- e.prototype.update = function(e) {
- var t = !1
- , i = !1;
- if (this._hasChanges = !1,
- this._changes = {},
- this.isButton()) {
- var n = e.buttons[this._buttonIndex];
- if (!n)
- return;
- this._currentValue !== n.value && (this.changes.value = {
- current: n.value,
- previous: this._currentValue
- },
- t = !0,
- this._currentValue = n.value),
- this._touched !== n.touched && (this.changes.touched = {
- current: n.touched,
- previous: this._touched
- },
- t = !0,
- this._touched = n.touched),
- this._pressed !== n.pressed && (this.changes.pressed = {
- current: n.pressed,
- previous: this._pressed
- },
- t = !0,
- this._pressed = n.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]],
- i = !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]],
- i = !0)),
- t && (this._hasChanges = !0,
- this.onButtonStateChangedObservable.notifyObservers(this)),
- i && (this._hasChanges = !0,
- this.onAxisValueChangedObservable.notifyObservers(this._axes))
- }
- ,
- e.BUTTON_TYPE = "button",
- e.SQUEEZE_TYPE = "squeeze",
- e.THUMBSTICK_TYPE = "thumbstick",
- e.TOUCHPAD_TYPE = "touchpad",
- e.TRIGGER_TYPE = "trigger",
- e
- }()
- , xp = function() {
- function e(e, t, i, n, r, o) {
- void 0 === r && (r = !1);
- var a = this;
- this.scene = e,
- this.layout = t,
- this.gamepadObject = i,
- this.handedness = n,
- this._doNotLoadControllerMesh = r,
- this._controllerCache = o,
- this._initComponent = function(e) {
- if (e) {
- var t = a.layout.components[e]
- , i = t.type
- , n = t.gamepadIndices.button
- , r = [];
- void 0 !== t.gamepadIndices.xAxis && void 0 !== t.gamepadIndices.yAxis && r.push(t.gamepadIndices.xAxis, t.gamepadIndices.yAxis),
- a.components[e] = new Ap(e,i,n,r)
- }
- }
- ,
- this._modelReady = !1,
- this.components = {},
- this.disableAnimation = !1,
- this.onModelLoadedObservable = new h,
- t.components && Object.keys(t.components).forEach(this._initComponent)
- }
- return e.prototype.dispose = function() {
- var e = this;
- this.getComponentIds().forEach((function(t) {
- return e.getComponent(t).dispose()
- }
- )),
- this.rootMesh && (this.rootMesh.getChildren(void 0, !0).forEach((function(e) {
- e.setEnabled(!1)
- }
- )),
- this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache))
- }
- ,
- e.prototype.getAllComponentsOfType = function(e) {
- var t = this;
- return this.getComponentIds().map((function(e) {
- return t.components[e]
- }
- )).filter((function(t) {
- return t.type === e
- }
- ))
- }
- ,
- e.prototype.getComponent = function(e) {
- return this.components[e]
- }
- ,
- e.prototype.getComponentIds = function() {
- return Object.keys(this.components)
- }
- ,
- e.prototype.getComponentOfType = function(e) {
- return this.getAllComponentsOfType(e)[0] || null
- }
- ,
- e.prototype.getMainComponent = function() {
- return this.getComponent(this.layout.selectComponentId)
- }
- ,
- e.prototype.loadModel = function() {
- return G(this, void 0, void 0, (function() {
- var e, t, i = this;
- return z(this, (function(n) {
- return e = !this._getModelLoadingConstraints(),
- t = this._getGenericFilenameAndPath(),
- e ? K.Warn("Falling back to generic models") : t = this._getFilenameAndPath(),
- [2, new Promise((function(n, r) {
- var o = function(t) {
- e ? i._getGenericParentMesh(t) : i._setRootMesh(t),
- i._processLoadedModel(t),
- i._modelReady = !0,
- i.onModelLoadedObservable.notifyObservers(i),
- n(!0)
- };
- if (i._controllerCache) {
- var a = i._controllerCache.filter((function(e) {
- return e.filename === t.filename && e.path === t.path
- }
- ));
- if (a[0])
- return a[0].meshes.forEach((function(e) {
- return e.setEnabled(!0)
- }
- )),
- void o(a[0].meshes)
- }
- od.ImportMesh("", t.path, t.filename, i.scene, (function(e) {
- i._controllerCache && i._controllerCache.push(V(V({}, t), {
- meshes: e
- })),
- o(e)
- }
- ), null, (function(e, n) {
- K.Log(n),
- K.Warn("Failed to retrieve controller model of type ".concat(i.profileId, " from the remote server: ").concat(t.path).concat(t.filename)),
- r(n)
- }
- ))
- }
- ))]
- }
- ))
- }
- ))
- }
- ,
- e.prototype.updateFromXRFrame = function(e) {
- var t = this;
- this.getComponentIds().forEach((function(e) {
- return t.getComponent(e).update(t.gamepadObject)
- }
- )),
- this.updateModel(e)
- }
- ,
- Object.defineProperty(e.prototype, "handness", {
- get: function() {
- return this.handedness
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.pulse = function(e, t, i) {
- return void 0 === i && (i = 0),
- this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[i] ? this.gamepadObject.hapticActuators[i].pulse(e, t) : Promise.resolve(!1)
- }
- ,
- e.prototype._getChildByName = function(e, t) {
- return e.getChildren((function(e) {
- return e.name === t
- }
- ), !1)[0]
- }
- ,
- e.prototype._getImmediateChildByName = function(e, t) {
- return e.getChildren((function(e) {
- return e.name == t
- }
- ), !0)[0]
- }
- ,
- e.prototype._lerpTransform = function(e, t, i) {
- if (e.minMesh && e.maxMesh && e.valueMesh && e.minMesh.rotationQuaternion && e.maxMesh.rotationQuaternion && e.valueMesh.rotationQuaternion) {
- var n = i ? .5 * t + .5 : t;
- C.SlerpToRef(e.minMesh.rotationQuaternion, e.maxMesh.rotationQuaternion, n, e.valueMesh.rotationQuaternion),
- x.LerpToRef(e.minMesh.position, e.maxMesh.position, n, e.valueMesh.position)
- }
- }
- ,
- e.prototype.updateModel = function(e) {
- this._modelReady && this._updateModel(e)
- }
- ,
- e.prototype._getGenericFilenameAndPath = function() {
- return {
- filename: "generic.babylon",
- path: "https://controllers.babylonjs.com/generic/"
- }
- }
- ,
- e.prototype._getGenericParentMesh = function(e) {
- var t = this;
- this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
- e.forEach((function(e) {
- e.parent || (e.isPickable = !1,
- e.setParent(t.rootMesh))
- }
- )),
- this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)
- }
- ,
- e
- }()
- , Rp = function(e) {
- function t(i, n, r) {
- var o = e.call(this, i, Cp[r], n, r) || this;
- return o.profileId = t.ProfileId,
- o
- }
- return U(t, e),
- t.prototype._getFilenameAndPath = function() {
- return {
- filename: "generic.babylon",
- path: "https://controllers.babylonjs.com/generic/"
- }
- }
- ,
- t.prototype._getModelLoadingConstraints = function() {
- return !0
- }
- ,
- t.prototype._processLoadedModel = function(e) {}
- ,
- t.prototype._setRootMesh = function(e) {
- var t = this;
- this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
- e.forEach((function(e) {
- e.isPickable = !1,
- e.parent || e.setParent(t.rootMesh)
- }
- )),
- this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)
- }
- ,
- t.prototype._updateModel = function() {}
- ,
- t.ProfileId = "generic-trigger",
- t
- }(xp)
- , Cp = {
- 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"
- }
- }
- , Pp = function(e) {
- function t(t, i, n, r, o) {
- var a = e.call(this, t, n.layouts[i.handedness || "none"], i.gamepad, i.handedness, void 0, o) || this;
- return a._repositoryUrl = r,
- a.controllerCache = o,
- a._buttonMeshMapping = {},
- a._touchDots = {},
- a.profileId = n.profileId,
- a
- }
- return U(t, e),
- t.prototype.dispose = function() {
- var t = this;
- e.prototype.dispose.call(this),
- this.controllerCache || Object.keys(this._touchDots).forEach((function(e) {
- t._touchDots[e].dispose()
- }
- ))
- }
- ,
- t.prototype._getFilenameAndPath = function() {
- return {
- filename: this.layout.assetPath,
- path: "".concat(this._repositoryUrl, "/profiles/").concat(this.profileId, "/")
- }
- }
- ,
- t.prototype._getModelLoadingConstraints = function() {
- var e = od.IsPluginForExtensionAvailable(".glb");
- return e || K.Warn("glTF / glb loader was not registered, using generic controller instead"),
- e
- }
- ,
- t.prototype._processLoadedModel = function(e) {
- var t = this;
- this.getComponentIds().forEach((function(e) {
- var i = t.layout.components[e];
- t._buttonMeshMapping[e] = {
- mainMesh: t._getChildByName(t.rootMesh, i.rootNodeName),
- states: {}
- },
- Object.keys(i.visualResponses).forEach((function(n) {
- var r = i.visualResponses[n];
- if ("transform" === r.valueNodeProperty)
- t._buttonMeshMapping[e].states[n] = {
- valueMesh: t._getChildByName(t.rootMesh, r.valueNodeName),
- minMesh: t._getChildByName(t.rootMesh, r.minNodeName),
- maxMesh: t._getChildByName(t.rootMesh, r.maxNodeName)
- };
- else {
- var o = i.type === Ap.TOUCHPAD_TYPE && i.touchPointNodeName ? i.touchPointNodeName : r.valueNodeName;
- if (t._buttonMeshMapping[e].states[n] = {
- valueMesh: t._getChildByName(t.rootMesh, o)
- },
- i.type === Ap.TOUCHPAD_TYPE && !t._touchDots[n]) {
- var a = Dl(n + "dot", {
- diameter: .0015,
- segments: 8
- }, t.scene);
- a.material = new Os(n + "mat",t.scene),
- a.material.diffuseColor = D.Red(),
- a.parent = t._buttonMeshMapping[e].states[n].valueMesh || null,
- a.isVisible = !1,
- t._touchDots[n] = a
- }
- }
- }
- ))
- }
- ))
- }
- ,
- t.prototype._setRootMesh = function(e) {
- var t;
- this.rootMesh = new Vr(this.profileId + "-" + this.handedness,this.scene),
- this.rootMesh.isPickable = !1;
- for (var i = 0; i < e.length; i++) {
- var n = e[i];
- n.isPickable = !1,
- n.parent || (t = n)
- }
- t && t.setParent(this.rootMesh),
- this.scene.useRightHandedSystem || this.rootMesh.rotate(vn.Y, Math.PI, Ji.WORLD)
- }
- ,
- t.prototype._updateModel = function(e) {
- var t = this;
- this.disableAnimation || this.getComponentIds().forEach((function(e) {
- var i = t.getComponent(e);
- if (i.hasChanges) {
- var n = t._buttonMeshMapping[e]
- , r = t.layout.components[e];
- Object.keys(r.visualResponses).forEach((function(e) {
- var o = r.visualResponses[e]
- , a = i.value;
- if ("xAxis" === o.componentProperty ? a = i.axes.x : "yAxis" === o.componentProperty && (a = i.axes.y),
- "transform" === o.valueNodeProperty)
- t._lerpTransform(n.states[e], a, "button" !== o.componentProperty);
- else {
- var s = n.states[e].valueMesh;
- s && (s.isVisible = i.touched || i.pressed),
- t._touchDots[e] && (t._touchDots[e].isVisible = i.touched || i.pressed)
- }
- }
- ))
- }
- }
- ))
- }
- ,
- t
- }(xp)
- , Mp = []
- , Ip = function() {
- function e() {}
- return e.ClearProfilesCache = function() {
- this._ProfilesList = null,
- this._ProfileLoadingPromises = {}
- }
- ,
- e.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"])
- }
- ,
- e.FindFallbackWithProfileId = function(e) {
- var t = this._Fallbacks[e] || [];
- return t.unshift(e),
- t
- }
- ,
- e.GetMotionControllerWithXRInput = function(e, t, i) {
- var n = this
- , r = [];
- i && r.push(i),
- r.push.apply(r, e.profiles || []),
- r.length && !r[0] && r.pop(),
- e.gamepad && e.gamepad.id && e.gamepad.id === (e.gamepad.id.match(/oculus touch/gi) ? e.gamepad.id : void 0) && r.push("oculus-touch-v2");
- var o = r.indexOf("windows-mixed-reality");
- if (-1 !== o && r.splice(o, 0, "microsoft-mixed-reality"),
- r.length || r.push("generic-trigger"),
- this.UseOnlineRepository) {
- var a = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers
- , s = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
- return a.call(this, r, e, t).catch((function() {
- return s.call(n, r, e, t)
- }
- ))
- }
- return this._LoadProfilesFromAvailableControllers(r, e, t)
- }
- ,
- e.RegisterController = function(e, t) {
- this._AvailableControllers[e] = t
- }
- ,
- e.RegisterFallbacksForProfileId = function(e, t) {
- var i;
- this._Fallbacks[e] ? (i = this._Fallbacks[e]).push.apply(i, t) : this._Fallbacks[e] = t
- }
- ,
- e.UpdateProfilesList = function() {
- return this._ProfilesList = gi.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then((function(e) {
- return JSON.parse(e.toString())
- }
- )),
- this._ProfilesList
- }
- ,
- e.ClearControllerCache = function() {
- Mp.forEach((function(e) {
- e.meshes.forEach((function(e) {
- e.dispose(!1, !0)
- }
- ))
- }
- )),
- Mp.length = 0
- }
- ,
- e._LoadProfileFromRepository = function(e, t, i) {
- var n = this;
- return Promise.resolve().then((function() {
- return n._ProfilesList ? n._ProfilesList : n.UpdateProfilesList()
- }
- )).then((function(t) {
- for (var i = 0; i < e.length; ++i)
- if (e[i] && t[e[i]])
- return e[i];
- throw new Error("neither controller ".concat(e[0], " nor all fallbacks were found in the repository,"))
- }
- )).then((function(e) {
- return n._ProfileLoadingPromises[e] || (n._ProfileLoadingPromises[e] = gi.LoadFileAsync("".concat(n.BaseRepositoryUrl, "/profiles/").concat(e, "/profile.json"), !1).then((function(e) {
- return JSON.parse(e)
- }
- ))),
- n._ProfileLoadingPromises[e]
- }
- )).then((function(e) {
- return new Pp(i,t,e,n.BaseRepositoryUrl,n.DisableControllerCache ? void 0 : Mp)
- }
- ))
- }
- ,
- e._LoadProfilesFromAvailableControllers = function(e, t, i) {
- for (var n = 0; n < e.length; ++n)
- if (e[n])
- for (var r = this.FindFallbackWithProfileId(e[n]), o = 0; o < r.length; ++o) {
- var a = this._AvailableControllers[r[o]];
- if (a)
- return Promise.resolve(a(t, i))
- }
- throw new Error("no controller requested was found in the available controllers list")
- }
- ,
- e._AvailableControllers = {},
- e._Fallbacks = {},
- e._ProfileLoadingPromises = {},
- e.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",
- e.PrioritizeOnlineRepository = !0,
- e.UseOnlineRepository = !0,
- e.DisableControllerCache = !0,
- e
- }();
- Ip.RegisterController(Rp.ProfileId, (function(e, t) {
- return new Rp(t,e.gamepad,e.handedness)
- }
- )),
- Ip.DefaultFallbacks();
- var Op, Dp, Np = 0, Lp = function() {
- function e(e, t, i) {
- void 0 === i && (i = {});
- var n = this;
- this._scene = e,
- this.inputSource = t,
- this._options = i,
- this._tmpVector = new x,
- this._disposed = !1,
- this.onDisposeObservable = new h,
- this.onMeshLoadedObservable = new h,
- this.onMotionControllerInitObservable = new h,
- this._uniqueId = "controller-".concat(Np++, "-").concat(t.targetRayMode, "-").concat(t.handedness),
- this.pointer = new Sr("".concat(this._uniqueId, "-pointer"),e),
- this.pointer.rotationQuaternion = new C,
- this.inputSource.gripSpace && (this.grip = new Sr("".concat(this._uniqueId, "-grip"),this._scene),
- this.grip.rotationQuaternion = new C),
- this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- this.inputSource.gamepad && "tracked-pointer" === this.inputSource.targetRayMode && Ip.GetMotionControllerWithXRInput(t, e, this._options.forceControllerProfile).then((function(e) {
- n.motionController = e,
- n.onMotionControllerInitObservable.notifyObservers(e),
- n._options.doNotLoadControllerMesh || n.motionController._doNotLoadControllerMesh || n.motionController.loadModel().then((function(e) {
- var t;
- e && n.motionController && n.motionController.rootMesh && (n._options.renderingGroupId && (n.motionController.rootMesh.renderingGroupId = n._options.renderingGroupId,
- n.motionController.rootMesh.getChildMeshes(!1).forEach((function(e) {
- return e.renderingGroupId = n._options.renderingGroupId
- }
- ))),
- n.onMeshLoadedObservable.notifyObservers(n.motionController.rootMesh),
- n.motionController.rootMesh.parent = n.grip || n.pointer,
- n.motionController.disableAnimation = !!n._options.disableMotionControllerAnimation),
- n._disposed && (null === (t = n.motionController) || void 0 === t || t.dispose())
- }
- ))
- }
- ), (function() {
- gi.Warn("Could not find a matching motion controller for the registered input source")
- }
- ))
- }
- return Object.defineProperty(e.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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
- }
- ,
- e.prototype.getWorldPointerRayToRef = function(e, t) {
- void 0 === t && (t = !1);
- var i = t && this.grip ? this.grip : this.pointer;
- x.TransformNormalToRef(this._tmpVector, i.getWorldMatrix(), e.direction),
- e.direction.normalize(),
- e.origin.copyFrom(i.absolutePosition),
- e.length = 1e3
- }
- ,
- e.prototype.updateFromXRFrame = function(e, t, i) {
- var n = e.getPose(this.inputSource.targetRaySpace, t);
- if (this._lastXRPose = n,
- n) {
- var r = n.transform.position;
- this.pointer.position.set(r.x, r.y, r.z);
- var o = n.transform.orientation;
- this.pointer.rotationQuaternion.set(o.x, o.y, o.z, o.w),
- this._scene.useRightHandedSystem || (this.pointer.position.z *= -1,
- this.pointer.rotationQuaternion.z *= -1,
- this.pointer.rotationQuaternion.w *= -1),
- this.pointer.parent = i.parent
- }
- if (this.inputSource.gripSpace && this.grip) {
- var a = e.getPose(this.inputSource.gripSpace, t);
- if (a) {
- r = a.transform.position;
- var s = a.transform.orientation;
- this.grip.position.set(r.x, r.y, r.z),
- this.grip.rotationQuaternion.set(s.x, s.y, s.z, s.w),
- this._scene.useRightHandedSystem || (this.grip.position.z *= -1,
- this.grip.rotationQuaternion.z *= -1,
- this.grip.rotationQuaternion.w *= -1)
- }
- this.grip.parent = i.parent
- }
- this.motionController && this.motionController.updateFromXRFrame(e)
- }
- ,
- e
- }(), Fp = function() {
- function e(e, t, i) {
- void 0 === i && (i = {});
- var n = this;
- if (this.xrSessionManager = e,
- this.xrCamera = t,
- this._options = i,
- this.controllers = [],
- this.onControllerAddedObservable = new h,
- this.onControllerRemovedObservable = new h,
- this._onInputSourcesChange = function(e) {
- n._addAndRemoveControllers(e.added, e.removed)
- }
- ,
- this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add((function() {
- n._addAndRemoveControllers([], n.controllers.map((function(e) {
- return e.inputSource
- }
- )))
- }
- )),
- this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add((function(e) {
- e.addEventListener("inputsourceschange", n._onInputSourcesChange)
- }
- )),
- this._frameObserver = this.xrSessionManager.onXRFrameObservable.add((function(e) {
- n.controllers.forEach((function(t) {
- t.updateFromXRFrame(e, n.xrSessionManager.referenceSpace, n.xrCamera)
- }
- ))
- }
- )),
- this._options.customControllersRepositoryURL && (Ip.BaseRepositoryUrl = this._options.customControllersRepositoryURL),
- Ip.UseOnlineRepository = !this._options.disableOnlineControllerRepository,
- Ip.UseOnlineRepository)
- try {
- Ip.UpdateProfilesList().catch((function() {
- Ip.UseOnlineRepository = !1
- }
- ))
- } catch (e) {
- Ip.UseOnlineRepository = !1
- }
- }
- return e.prototype._addAndRemoveControllers = function(e, t) {
- for (var i = this, n = this.controllers.map((function(e) {
- return e.inputSource
- }
- )), r = 0, o = e; r < o.length; r++) {
- var a = o[r];
- if (-1 === n.indexOf(a)) {
- var s = new Lp(this.xrSessionManager.scene,a,V(V({}, this._options.controllerOptions || {}), {
- forceControllerProfile: this._options.forceInputProfile,
- doNotLoadControllerMesh: this._options.doNotLoadControllerMeshes,
- disableMotionControllerAnimation: this._options.disableControllerAnimation
- }));
- this.controllers.push(s),
- this.onControllerAddedObservable.notifyObservers(s)
- }
- }
- var l = []
- , c = [];
- this.controllers.forEach((function(e) {
- -1 === t.indexOf(e.inputSource) ? l.push(e) : c.push(e)
- }
- )),
- this.controllers = l,
- c.forEach((function(e) {
- i.onControllerRemovedObservable.notifyObservers(e),
- e.dispose()
- }
- ))
- }
- ,
- e.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(),
- Ip.ClearControllerCache()
- }
- ,
- e
- }(), wp = function() {
- function e(e) {
- this._xrSessionManager = e,
- this._attached = !1,
- this._removeOnDetach = [],
- this.isDisposed = !1,
- this.disableAutoAttach = !1,
- this.xrNativeFeatureName = ""
- }
- return Object.defineProperty(e.prototype, "attached", {
- get: function() {
- return this._attached
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attach = function(e) {
- var t = 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(e) {
- return t._onXRFrame(e)
- }
- )),
- !0
- }
- ,
- e.prototype.detach = function() {
- return this._attached ? (this._attached = !1,
- this._removeOnDetach.forEach((function(e) {
- e.observable.remove(e.observer)
- }
- )),
- !0) : (this.disableAutoAttach = !0,
- !1)
- }
- ,
- e.prototype.dispose = function() {
- this.detach(),
- this.isDisposed = !0
- }
- ,
- e.prototype.isCompatible = function() {
- return !0
- }
- ,
- e.prototype._addNewAttachObserver = function(e, t) {
- this._removeOnDetach.push({
- observable: e,
- observer: e.add(t)
- })
- }
- ,
- e
- }(), Bp = function(e) {
- function t(i, n) {
- var r = e.call(this, i) || this;
- return r._options = n,
- r._attachController = function(e) {
- if (!r._controllers[e.uniqueId]) {
- var i = r._generateNewMeshPair(e.pointer)
- , n = i.laserPointer
- , o = i.selectionMesh;
- switch (r._controllers[e.uniqueId] = {
- xrController: e,
- laserPointer: n,
- selectionMesh: o,
- meshUnderPointer: null,
- pick: null,
- tmpRay: new _o(new x,new x),
- disabledByNearInteraction: !1,
- id: t._IdCounter++
- },
- r._attachedController ? !r._options.enablePointerSelectionOnAllControllers && r._options.preferredHandedness && e.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = e.uniqueId) : r._options.enablePointerSelectionOnAllControllers || (r._attachedController = e.uniqueId),
- e.inputSource.targetRayMode) {
- case "tracked-pointer":
- return r._attachTrackedPointerRayMode(e);
- case "gaze":
- return r._attachGazeMode(e);
- case "screen":
- return r._attachScreenRayMode(e)
- }
- }
- }
- ,
- r._controllers = {},
- r._tmpVectorForPickCompare = new x,
- r.disablePointerLighting = !0,
- r.disableSelectionMeshLighting = !0,
- r.displayLaserPointer = !0,
- r.displaySelectionMesh = !0,
- r.laserPointerPickedColor = new D(.9,.9,.9),
- r.laserPointerDefaultColor = new D(.7,.7,.7),
- r.selectionMeshDefaultColor = new D(.8,.8,.8),
- r.selectionMeshPickedColor = new D(.3,.3,1),
- r._identityMatrix = P.Identity(),
- r._screenCoordinatesRef = x.Zero(),
- r._viewportRef = new xr(0,0,0,0),
- r._scene = r._xrSessionManager.scene,
- r
- }
- return U(t, e),
- t.prototype.attach = function() {
- var i = this;
- if (!e.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(e) {
- i._detachController(e.uniqueId)
- }
- )),
- this._scene.constantlyUpdateMeshUnderPointer = !0,
- this._options.gazeCamera) {
- var n = this._options.gazeCamera
- , r = this._generateNewMeshPair(n)
- , o = r.laserPointer
- , a = r.selectionMesh;
- this._controllers.camera = {
- webXRCamera: n,
- laserPointer: o,
- selectionMesh: a,
- meshUnderPointer: null,
- pick: null,
- tmpRay: new _o(new x,new x),
- disabledByNearInteraction: !1,
- id: t._IdCounter++
- },
- this._attachGazeMode()
- }
- return !0
- }
- ,
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
- t._detachController(e)
- }
- )),
- !0)
- }
- ,
- t.prototype.getMeshUnderPointer = function(e) {
- return this._controllers[e] ? this._controllers[e].meshUnderPointer : null
- }
- ,
- t.prototype.getXRControllerByPointerId = function(e) {
- for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)
- if (this._controllers[t[i]].id === e)
- return this._controllers[t[i]].xrController || null;
- return null
- }
- ,
- t.prototype._getPointerSelectionDisabledByPointerId = function(e) {
- for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)
- if (this._controllers[t[i]].id === e)
- return this._controllers[t[i]].disabledByNearInteraction;
- return !0
- }
- ,
- t.prototype._setPointerSelectionDisabledByPointerId = function(e, t) {
- for (var i = Object.keys(this._controllers), n = 0; n < i.length; ++n)
- if (this._controllers[i[n]].id === e)
- return void (this._controllers[i[n]].disabledByNearInteraction = t)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t = this;
- Object.keys(this._controllers).forEach((function(e) {
- var i, n = t._controllers[e];
- if (!t._options.enablePointerSelectionOnAllControllers && e !== t._attachedController || n.disabledByNearInteraction)
- return n.selectionMesh.isVisible = !1,
- n.laserPointer.isVisible = !1,
- void (n.pick = null);
- if (n.laserPointer.isVisible = t.displayLaserPointer,
- n.xrController)
- i = n.xrController.pointer.position,
- n.xrController.getWorldPointerRayToRef(n.tmpRay);
- else {
- if (!n.webXRCamera)
- return;
- i = n.webXRCamera.position,
- n.webXRCamera.getForwardRayToRef(n.tmpRay)
- }
- if (t._options.maxPointerDistance && (n.tmpRay.length = t._options.maxPointerDistance),
- !t._options.disableScenePointerVectorUpdate && i) {
- var r = t._xrSessionManager.scene
- , o = t._options.xrInput.xrCamera;
- o && (o.viewport.toGlobalToRef(r.getEngine().getRenderWidth(), r.getEngine().getRenderHeight(), t._viewportRef),
- x.ProjectToRef(i, t._identityMatrix, r.getTransformMatrix(), t._viewportRef, t._screenCoordinatesRef),
- "number" != typeof t._screenCoordinatesRef.x || "number" != typeof t._screenCoordinatesRef.y || isNaN(t._screenCoordinatesRef.x) || isNaN(t._screenCoordinatesRef.y) || (r.pointerX = t._screenCoordinatesRef.x,
- r.pointerY = t._screenCoordinatesRef.y,
- n.screenCoordinates = {
- x: t._screenCoordinatesRef.x,
- y: t._screenCoordinatesRef.y
- }))
- }
- var a = null;
- t._utilityLayerScene && (a = t._utilityLayerScene.pickWithRay(n.tmpRay, t._utilityLayerScene.pointerMovePredicate || t.raySelectionPredicate));
- var s = t._scene.pickWithRay(n.tmpRay, t._scene.pointerMovePredicate || t.raySelectionPredicate);
- a && a.hit ? s && s.hit ? a.distance < s.distance ? n.pick = a : n.pick = s : n.pick = a : n.pick = s,
- n.pick && n.xrController && (n.pick.aimTransform = n.xrController.pointer,
- n.pick.gripTransform = n.xrController.grip || null);
- var l = n.pick;
- if (l && l.pickedPoint && l.hit) {
- t._updatePointerDistance(n.laserPointer, l.distance),
- n.selectionMesh.position.copyFrom(l.pickedPoint),
- n.selectionMesh.scaling.x = Math.sqrt(l.distance),
- n.selectionMesh.scaling.y = Math.sqrt(l.distance),
- n.selectionMesh.scaling.z = Math.sqrt(l.distance);
- var c = t._convertNormalToDirectionOfRay(l.getNormal(!0), n.tmpRay);
- if (n.selectionMesh.position.copyFrom(l.pickedPoint),
- c) {
- var u = x.Cross(vn.Y, c)
- , h = x.Cross(c, u);
- x.RotationFromAxisToRef(h, c, u, n.selectionMesh.rotation),
- n.selectionMesh.position.addInPlace(c.scale(.001))
- }
- n.selectionMesh.isVisible = t.displaySelectionMesh,
- n.meshUnderPointer = l.pickedMesh
- } else
- n.selectionMesh.isVisible = !1,
- t._updatePointerDistance(n.laserPointer, 1),
- n.meshUnderPointer = null
- }
- ))
- }
- ,
- Object.defineProperty(t.prototype, "_utilityLayerScene", {
- get: function() {
- return this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._attachGazeMode = function(e) {
- var t = this
- , i = this._controllers[e && e.uniqueId || "camera"]
- , n = this._options.timeToSelect || 3e3
- , r = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene
- , o = new Ui
- , a = qs("selection", {
- diameter: .0525,
- thickness: .015,
- tessellation: 20
- }, r);
- a.isVisible = !1,
- a.isPickable = !1,
- a.parent = i.selectionMesh;
- var s = 0
- , l = !1
- , c = {
- pointerId: i.id,
- pointerType: "xr"
- };
- i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
- if (i.pick) {
- if (t._augmentPointerInit(c, i.id, i.screenCoordinates),
- i.laserPointer.material.alpha = 0,
- a.isVisible = !1,
- i.pick.hit)
- if (t._pickingMoved(o, i.pick))
- l && (t._options.disablePointerUpOnTouchOut || t._scene.simulatePointerUp(i.pick, c)),
- l = !1,
- s = 0;
- else if (s > n / 10 && (a.isVisible = !0),
- (s += t._scene.getEngine().getDeltaTime()) >= n)
- t._scene.simulatePointerDown(i.pick, c),
- l = !0,
- t._options.disablePointerUpOnTouchOut && t._scene.simulatePointerUp(i.pick, c),
- a.isVisible = !1;
- else {
- var e = 1 - s / n;
- a.scaling.set(e, e, e)
- }
- else
- l = !1,
- s = 0;
- t._scene.simulatePointerMove(i.pick, c),
- o = i.pick
- }
- }
- )),
- void 0 !== this._options.renderingGroupId && (a.renderingGroupId = this._options.renderingGroupId),
- e && e.onDisposeObservable.addOnce((function() {
- i.pick && !t._options.disablePointerUpOnTouchOut && l && (t._scene.simulatePointerUp(i.pick, c),
- i.finalPointerUpTriggered = !0),
- a.dispose()
- }
- ))
- }
- ,
- t.prototype._attachScreenRayMode = function(e) {
- var t = this
- , i = this._controllers[e.uniqueId]
- , n = !1
- , r = {
- pointerId: i.id,
- pointerType: "xr"
- };
- i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
- t._augmentPointerInit(r, i.id, i.screenCoordinates),
- !i.pick || t._options.disablePointerUpOnTouchOut && n || (n ? t._scene.simulatePointerMove(i.pick, r) : (t._scene.simulatePointerDown(i.pick, r),
- i.pointerDownTriggered = !0,
- n = !0,
- t._options.disablePointerUpOnTouchOut && t._scene.simulatePointerUp(i.pick, r)))
- }
- )),
- e.onDisposeObservable.addOnce((function() {
- t._augmentPointerInit(r, i.id, i.screenCoordinates),
- t._xrSessionManager.runInXRFrame((function() {
- i.pick && !i.finalPointerUpTriggered && n && !t._options.disablePointerUpOnTouchOut && (t._scene.simulatePointerUp(i.pick, r),
- i.finalPointerUpTriggered = !0)
- }
- ))
- }
- ))
- }
- ,
- t.prototype._attachTrackedPointerRayMode = function(e) {
- var t = this
- , i = this._controllers[e.uniqueId];
- if (this._options.forceGazeMode)
- return this._attachGazeMode(e);
- var n = {
- pointerId: i.id,
- pointerType: "xr"
- };
- if (i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
- i.laserPointer.material.disableLighting = t.disablePointerLighting,
- i.selectionMesh.material.disableLighting = t.disableSelectionMeshLighting,
- i.pick && (t._augmentPointerInit(n, i.id, i.screenCoordinates),
- t._scene.simulatePointerMove(i.pick, n))
- }
- )),
- e.inputSource.gamepad) {
- var r = function(r) {
- t._options.overrideButtonId && (i.selectionComponent = r.getComponent(t._options.overrideButtonId)),
- i.selectionComponent || (i.selectionComponent = r.getMainComponent()),
- i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function(r) {
- if (r.changes.pressed) {
- var o = r.changes.pressed.current;
- i.pick ? (t._options.enablePointerSelectionOnAllControllers || e.uniqueId === t._attachedController) && (t._augmentPointerInit(n, i.id, i.screenCoordinates),
- o ? (t._scene.simulatePointerDown(i.pick, n),
- i.pointerDownTriggered = !0,
- i.selectionMesh.material.emissiveColor = t.selectionMeshPickedColor,
- i.laserPointer.material.emissiveColor = t.laserPointerPickedColor) : (t._scene.simulatePointerUp(i.pick, n),
- i.selectionMesh.material.emissiveColor = t.selectionMeshDefaultColor,
- i.laserPointer.material.emissiveColor = t.laserPointerDefaultColor)) : !o || t._options.enablePointerSelectionOnAllControllers || t._options.disableSwitchOnClick || (t._attachedController = e.uniqueId)
- }
- }
- ))
- };
- e.motionController ? r(e.motionController) : e.onMotionControllerInitObservable.add(r)
- } else {
- var o = function(e) {
- t._augmentPointerInit(n, i.id, i.screenCoordinates),
- i.xrController && e.inputSource === i.xrController.inputSource && i.pick && (t._scene.simulatePointerDown(i.pick, n),
- i.pointerDownTriggered = !0,
- i.selectionMesh.material.emissiveColor = t.selectionMeshPickedColor,
- i.laserPointer.material.emissiveColor = t.laserPointerPickedColor)
- }
- , a = function(e) {
- t._augmentPointerInit(n, i.id, i.screenCoordinates),
- i.xrController && e.inputSource === i.xrController.inputSource && i.pick && (t._scene.simulatePointerUp(i.pick, n),
- i.selectionMesh.material.emissiveColor = t.selectionMeshDefaultColor,
- i.laserPointer.material.emissiveColor = t.laserPointerDefaultColor)
- };
- i.eventListeners = {
- selectend: a,
- selectstart: o
- },
- this._xrSessionManager.session.addEventListener("selectstart", o),
- this._xrSessionManager.session.addEventListener("selectend", a)
- }
- }
- ,
- t.prototype._convertNormalToDirectionOfRay = function(e, t) {
- return e && Math.acos(x.Dot(e, t.direction)) < Math.PI / 2 && e.scaleInPlace(-1),
- e
- }
- ,
- t.prototype._detachController = function(e) {
- var t = this
- , i = this._controllers[e];
- if (i) {
- if (i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),
- i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),
- i.eventListeners && Object.keys(i.eventListeners).forEach((function(e) {
- var n = i.eventListeners && i.eventListeners[e];
- n && t._xrSessionManager.session.removeEventListener(e, n)
- }
- )),
- !i.finalPointerUpTriggered && i.pointerDownTriggered) {
- var n = {
- pointerId: i.id,
- pointerType: "xr"
- };
- this._xrSessionManager.runInXRFrame((function() {
- t._augmentPointerInit(n, i.id, i.screenCoordinates),
- t._scene.simulatePointerUp(new Ui, n)
- }
- ))
- }
- this._xrSessionManager.scene.onBeforeRenderObservable.addOnce((function() {
- try {
- if (i.selectionMesh.dispose(),
- i.laserPointer.dispose(),
- delete t._controllers[e],
- t._attachedController === e) {
- var n = Object.keys(t._controllers);
- n.length ? t._attachedController = n[0] : t._attachedController = ""
- }
- } catch (e) {
- gi.Warn("controller already detached.")
- }
- }
- ))
- }
- }
- ,
- t.prototype._generateNewMeshPair = function(e) {
- var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
- , i = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : Ys("laserPointer", {
- height: 1,
- diameterTop: 2e-4,
- diameterBottom: .004,
- tessellation: 20,
- subdivisions: 1
- }, t);
- i.parent = e;
- var n = new Os("laserPointerMat",t);
- n.emissiveColor = this.laserPointerDefaultColor,
- n.alpha = .7,
- i.material = n,
- i.rotation.x = Math.PI / 2,
- this._updatePointerDistance(i, 1),
- i.isPickable = !1,
- i.isVisible = !1;
- var r = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : qs("gazeTracker", {
- diameter: .0105,
- thickness: .0075,
- tessellation: 20
- }, t);
- r.bakeCurrentTransformIntoVertices(),
- r.isPickable = !1,
- r.isVisible = !1;
- var o = new Os("targetMat",t);
- return o.specularColor = D.Black(),
- o.emissiveColor = this.selectionMeshDefaultColor,
- o.backFaceCulling = !1,
- r.material = o,
- void 0 !== this._options.renderingGroupId && (i.renderingGroupId = this._options.renderingGroupId,
- r.renderingGroupId = this._options.renderingGroupId),
- {
- laserPointer: i,
- selectionMesh: r
- }
- }
- ,
- t.prototype._pickingMoved = function(e, t) {
- var i;
- if (!e.hit || !t.hit)
- return !0;
- if (!(e.pickedMesh && e.pickedPoint && t.pickedMesh && t.pickedPoint))
- return !0;
- if (e.pickedMesh !== t.pickedMesh)
- return !0;
- null === (i = e.pickedPoint) || void 0 === i || i.subtractToRef(t.pickedPoint, this._tmpVectorForPickCompare),
- this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
- var n = .01 * (this._options.gazeModePointerMovedFactor || 1) * t.distance;
- return this._tmpVectorForPickCompare.length() > n
- }
- ,
- t.prototype._updatePointerDistance = function(e, t) {
- void 0 === t && (t = 100),
- e.scaling.y = t,
- this._scene.useRightHandedSystem && (t *= -1),
- e.position.z = t / 2 + .05
- }
- ,
- t.prototype._augmentPointerInit = function(e, t, i) {
- e.pointerId = t,
- e.pointerType = "xr",
- i && (e.screenX = i.x,
- e.screenY = i.y)
- }
- ,
- Object.defineProperty(t.prototype, "lasterPointerDefaultColor", {
- get: function() {
- return this.laserPointerDefaultColor
- },
- enumerable: !1,
- configurable: !0
- }),
- t._IdCounter = 200,
- t.Name = Io.POINTER_SELECTION,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(Bp.Name, (function(e, t) {
- return function() {
- return new Bp(e,t)
- }
- }
- ), Bp.Version, !0),
- function(e) {
- e[e.Float = 1] = "Float",
- e[e.Int = 2] = "Int",
- e[e.Vector2 = 4] = "Vector2",
- e[e.Vector3 = 8] = "Vector3",
- e[e.Vector4 = 16] = "Vector4",
- e[e.Color3 = 32] = "Color3",
- e[e.Color4 = 64] = "Color4",
- e[e.Matrix = 128] = "Matrix",
- e[e.Object = 256] = "Object",
- e[e.AutoDetect = 1024] = "AutoDetect",
- e[e.BasedOnInput = 2048] = "BasedOnInput"
- }(Op || (Op = {})),
- function(e) {
- e[e.Vertex = 1] = "Vertex",
- e[e.Fragment = 2] = "Fragment",
- e[e.Neutral = 4] = "Neutral",
- e[e.VertexAndFragment = 3] = "VertexAndFragment"
- }(Dp || (Dp = {}));
- var Up, Vp, kp = function() {
- function e() {
- 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 e.prototype.finalize = function(e) {
- var t = e.sharedData.emitComments
- , i = this.target === Dp.Fragment;
- this.compilationString = "\r\n".concat(t ? "//Entry point\r\n" : "", "void main(void) {\r\n").concat(this.compilationString),
- this._constantDeclaration && (this.compilationString = "\r\n".concat(t ? "//Constants\r\n" : "").concat(this._constantDeclaration, "\r\n").concat(this.compilationString));
- var n = "";
- for (var r in this.functions)
- n += this.functions[r] + "\r\n";
- for (var o in this.compilationString = "\r\n".concat(n, "\r\n").concat(this.compilationString),
- !i && this._varyingTransfer && (this.compilationString = "".concat(this.compilationString, "\r\n").concat(this._varyingTransfer)),
- this._injectAtEnd && (this.compilationString = "".concat(this.compilationString, "\r\n").concat(this._injectAtEnd)),
- this.compilationString = "".concat(this.compilationString, "\r\n}"),
- this.sharedData.varyingDeclaration && (this.compilationString = "\r\n".concat(t ? "//Varyings\r\n" : "").concat(this.sharedData.varyingDeclaration, "\r\n").concat(this.compilationString)),
- this._samplerDeclaration && (this.compilationString = "\r\n".concat(t ? "//Samplers\r\n" : "").concat(this._samplerDeclaration, "\r\n").concat(this.compilationString)),
- this._uniformDeclaration && (this.compilationString = "\r\n".concat(t ? "//Uniforms\r\n" : "").concat(this._uniformDeclaration, "\r\n").concat(this.compilationString)),
- this._attributeDeclaration && !i && (this.compilationString = "\r\n".concat(t ? "//Attributes\r\n" : "").concat(this._attributeDeclaration, "\r\n").concat(this.compilationString)),
- this.compilationString = "precision highp float;\r\n" + this.compilationString,
- this.extensions) {
- var a = this.extensions[o];
- this.compilationString = "\r\n".concat(a, "\r\n").concat(this.compilationString)
- }
- this._builtCompilationString = this.compilationString
- }
- ,
- Object.defineProperty(e.prototype, "_repeatableContentAnchor", {
- get: function() {
- return "###___ANCHOR".concat(this._repeatableContentAnchorIndex++, "___###")
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getFreeVariableName = function(e) {
- return e = e.replace(/[^a-zA-Z_]+/g, ""),
- void 0 === this.sharedData.variableNames[e] ? (this.sharedData.variableNames[e] = 0,
- "output" === e || "texture" === e ? e + this.sharedData.variableNames[e] : e) : (this.sharedData.variableNames[e]++,
- e + this.sharedData.variableNames[e])
- }
- ,
- e.prototype._getFreeDefineName = function(e) {
- return void 0 === this.sharedData.defineNames[e] ? this.sharedData.defineNames[e] = 0 : this.sharedData.defineNames[e]++,
- e + this.sharedData.defineNames[e]
- }
- ,
- e.prototype._excludeVariableName = function(e) {
- this.sharedData.variableNames[e] = 0
- }
- ,
- e.prototype._emit2DSampler = function(e) {
- this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2D ".concat(e, ";\r\n"),
- this.samplers.push(e))
- }
- ,
- e.prototype._getGLType = function(e) {
- switch (e) {
- case Op.Float:
- return "float";
- case Op.Int:
- return "int";
- case Op.Vector2:
- return "vec2";
- case Op.Color3:
- case Op.Vector3:
- return "vec3";
- case Op.Color4:
- case Op.Vector4:
- return "vec4";
- case Op.Matrix:
- return "mat4"
- }
- return ""
- }
- ,
- e.prototype._emitExtension = function(e, t, i) {
- void 0 === i && (i = ""),
- this.extensions[e] || (i && (t = "#if ".concat(i, "\r\n").concat(t, "\r\n#endif")),
- this.extensions[e] = t)
- }
- ,
- e.prototype._emitFunction = function(e, t, i) {
- this.functions[e] || (this.sharedData.emitComments && (t = i + "\r\n" + t),
- this.functions[e] = t)
- }
- ,
- e.prototype._emitCodeFromInclude = function(e, t, i) {
- if (i && i.repeatKey)
- return "#include<".concat(e, ">[0..").concat(i.repeatKey, "]\r\n");
- var n = Mt.IncludesShadersStore[e] + "\r\n";
- if (this.sharedData.emitComments && (n = t + "\r\n" + n),
- !i)
- return n;
- if (i.replaceStrings)
- for (var r = 0; r < i.replaceStrings.length; r++) {
- var o = i.replaceStrings[r];
- n = n.replace(o.search, o.replace)
- }
- return n
- }
- ,
- e.prototype._emitFunctionFromInclude = function(e, t, i, n) {
- void 0 === n && (n = "");
- var r = e + n;
- if (!this.functions[r]) {
- if (!i || !(i.removeAttributes || i.removeUniforms || i.removeVaryings || i.removeIfDef || i.replaceStrings))
- return i && i.repeatKey ? this.functions[r] = "#include<".concat(e, ">[0..").concat(i.repeatKey, "]\r\n") : this.functions[r] = "#include<".concat(e, ">\r\n"),
- void (this.sharedData.emitComments && (this.functions[r] = t + "\r\n" + this.functions[r]));
- if (this.functions[r] = Mt.IncludesShadersStore[e],
- this.sharedData.emitComments && (this.functions[r] = t + "\r\n" + this.functions[r]),
- i.removeIfDef && (this.functions[r] = this.functions[r].replace(/^\s*?#ifdef.+$/gm, ""),
- this.functions[r] = this.functions[r].replace(/^\s*?#endif.*$/gm, ""),
- this.functions[r] = this.functions[r].replace(/^\s*?#else.*$/gm, ""),
- this.functions[r] = this.functions[r].replace(/^\s*?#elif.*$/gm, "")),
- i.removeAttributes && (this.functions[r] = this.functions[r].replace(/^\s*?attribute.+$/gm, "")),
- i.removeUniforms && (this.functions[r] = this.functions[r].replace(/^\s*?uniform.+$/gm, "")),
- i.removeVaryings && (this.functions[r] = this.functions[r].replace(/^\s*?varying.+$/gm, "")),
- i.replaceStrings)
- for (var o = 0; o < i.replaceStrings.length; o++) {
- var a = i.replaceStrings[o];
- this.functions[r] = this.functions[r].replace(a.search, a.replace)
- }
- }
- }
- ,
- e.prototype._registerTempVariable = function(e) {
- return -1 === this.sharedData.temps.indexOf(e) && (this.sharedData.temps.push(e),
- !0)
- }
- ,
- e.prototype._emitVaryingFromString = function(e, t, i, n) {
- return void 0 === i && (i = ""),
- void 0 === n && (n = !1),
- -1 === this.sharedData.varyings.indexOf(e) && (this.sharedData.varyings.push(e),
- i && (ae(i, "defined(") ? this.sharedData.varyingDeclaration += "#if ".concat(i, "\r\n") : this.sharedData.varyingDeclaration += "".concat(n ? "#ifndef" : "#ifdef", " ").concat(i, "\r\n")),
- this.sharedData.varyingDeclaration += "varying ".concat(t, " ").concat(e, ";\r\n"),
- i && (this.sharedData.varyingDeclaration += "#endif\r\n"),
- !0)
- }
- ,
- e.prototype._emitUniformFromString = function(e, t, i, n) {
- void 0 === i && (i = ""),
- void 0 === n && (n = !1),
- -1 === this.uniforms.indexOf(e) && (this.uniforms.push(e),
- i && (ae(i, "defined(") ? this._uniformDeclaration += "#if ".concat(i, "\r\n") : this._uniformDeclaration += "".concat(n ? "#ifndef" : "#ifdef", " ").concat(i, "\r\n")),
- this._uniformDeclaration += "uniform ".concat(t, " ").concat(e, ";\r\n"),
- i && (this._uniformDeclaration += "#endif\r\n"))
- }
- ,
- e.prototype._emitFloat = function(e) {
- return e.toString() === e.toFixed(0) ? "".concat(e, ".0") : e.toString()
- }
- ,
- e
- }(), Gp = function() {
- function e() {
- 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 e.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\n"),
- 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\n");
- for (var t = 0, i = this.checks.notConnectedNonOptionalInputs; t < i.length; t++) {
- var n = i[t];
- e += "input ".concat(n.name, " from block ").concat(n.ownerBlock.name, "[").concat(n.ownerBlock.getClassName(), "] is not connected and is not optional.\r\n")
- }
- if (e)
- throw "Build of NodeMaterial failed:\r\n" + e
- }
- ,
- e
- }();
- !function(e) {
- e[e.Compatible = 0] = "Compatible",
- e[e.TypeIncompatible = 1] = "TypeIncompatible",
- e[e.TargetIncompatible = 2] = "TargetIncompatible",
- e[e.HierarchyIssue = 3] = "HierarchyIssue"
- }(Up || (Up = {})),
- function(e) {
- e[e.Input = 0] = "Input",
- e[e.Output = 1] = "Output"
- }(Vp || (Vp = {}));
- var zp = function() {
- function e(e, t, i) {
- this._connectedPoint = null,
- this._endpoints = new Array,
- this._typeConnectionSource = null,
- this._defaultConnectionPointType = null,
- this._linkedConnectionSource = null,
- this._acceptedConnectionPointType = null,
- this._type = Op.Float,
- this._enforceAssociatedVariableName = !1,
- this.needDualDirectionValidation = !1,
- this.acceptedConnectionPointTypes = new Array,
- this.excludedConnectionPointTypes = new Array,
- this.onConnectionObservable = new h,
- this.isExposedOnFrame = !1,
- this.exposedPortPosition = -1,
- this._prioritizeVertex = !1,
- this._target = Dp.VertexAndFragment,
- this._ownerBlock = t,
- this.name = e,
- this._direction = i
- }
- return e.AreEquivalentTypes = function(e, t) {
- switch (e) {
- case Op.Vector3:
- if (t === Op.Color3)
- return !0;
- break;
- case Op.Vector4:
- if (t === Op.Color4)
- return !0;
- break;
- case Op.Color3:
- if (t === Op.Vector3)
- return !0;
- break;
- case Op.Color4:
- if (t === Op.Vector4)
- return !0
- }
- return !1
- }
- ,
- Object.defineProperty(e.prototype, "direction", {
- get: function() {
- return this._direction
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "associatedVariableName", {
- get: function() {
- return this._ownerBlock.isInput ? this._ownerBlock.associatedVariableName : this._enforceAssociatedVariableName && this._associatedVariableName || !this._connectedPoint ? this._associatedVariableName : this._connectedPoint.associatedVariableName
- },
- set: function(e) {
- this._associatedVariableName = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "innerType", {
- get: function() {
- return this._linkedConnectionSource && this._linkedConnectionSource.isConnected ? this.type : this._type
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "type", {
- get: function() {
- if (this._type === Op.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 === Op.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(e.prototype, "target", {
- get: function() {
- return this._prioritizeVertex && this._ownerBlock ? this._target !== Dp.VertexAndFragment ? this._target : this._ownerBlock.target === Dp.Fragment ? Dp.Fragment : Dp.Vertex : this._target
- },
- set: function(e) {
- this._target = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isConnected", {
- get: function() {
- return null !== this.connectedPoint || this.hasEndpoints
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isConnectedToInputBlock", {
- get: function() {
- return null !== this.connectedPoint && this.connectedPoint.ownerBlock.isInput
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "connectInputBlock", {
- get: function() {
- return this.isConnectedToInputBlock ? this.connectedPoint.ownerBlock : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "connectedPoint", {
- get: function() {
- return this._connectedPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ownerBlock", {
- get: function() {
- return this._ownerBlock
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sourceBlock", {
- get: function() {
- return this._connectedPoint ? this._connectedPoint.ownerBlock : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "connectedBlocks", {
- get: function() {
- return 0 === this._endpoints.length ? [] : this._endpoints.map((function(e) {
- return e.ownerBlock
- }
- ))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "endpoints", {
- get: function() {
- return this._endpoints
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasEndpoints", {
- get: function() {
- return this._endpoints && this._endpoints.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isDirectlyConnectedToVertexOutput", {
- get: function() {
- if (!this.hasEndpoints)
- return !1;
- for (var e = 0, t = this._endpoints; e < t.length; e++) {
- var i = t[e];
- if (i.ownerBlock.target === Dp.Vertex)
- return !0;
- if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
- return e.isDirectlyConnectedToVertexOutput
- }
- )))
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isConnectedInVertexShader", {
- get: function() {
- if (this.target === Dp.Vertex)
- return !0;
- if (!this.hasEndpoints)
- return !1;
- for (var e = 0, t = this._endpoints; e < t.length; e++) {
- var i = t[e];
- if (i.ownerBlock.target === Dp.Vertex)
- return !0;
- if (i.target === Dp.Vertex)
- return !0;
- if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
- return e.isConnectedInVertexShader
- }
- )))
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isConnectedInFragmentShader", {
- get: function() {
- if (this.target === Dp.Fragment)
- return !0;
- if (!this.hasEndpoints)
- return !1;
- for (var e = 0, t = this._endpoints; e < t.length; e++) {
- var i = t[e];
- if (i.ownerBlock.target === Dp.Fragment)
- return !0;
- if ((i.ownerBlock.target === Dp.Neutral || i.ownerBlock.target === Dp.VertexAndFragment) && i.ownerBlock.outputs.some((function(e) {
- return e.isConnectedInFragmentShader
- }
- )))
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.createCustomInputBlock = function() {
- return null
- }
- ,
- e.prototype.getClassName = function() {
- return "NodeMaterialConnectionPoint"
- }
- ,
- e.prototype.canConnectTo = function(e) {
- return this.checkCompatibilityState(e) === Up.Compatible
- }
- ,
- e.prototype.checkCompatibilityState = function(t) {
- var i = this._ownerBlock
- , n = t.ownerBlock;
- if (i.target === Dp.Fragment) {
- if (n.target === Dp.Vertex)
- return Up.TargetIncompatible;
- for (var r = 0, o = n.outputs; r < o.length; r++) {
- var a = o[r];
- if (a.ownerBlock.target != Dp.Neutral && a.isConnectedInVertexShader)
- return Up.TargetIncompatible
- }
- }
- if (this.type !== t.type && t.innerType !== Op.AutoDetect)
- return e.AreEquivalentTypes(this.type, t.type) || t.acceptedConnectionPointTypes && -1 !== t.acceptedConnectionPointTypes.indexOf(this.type) || t._acceptedConnectionPointType && e.AreEquivalentTypes(t._acceptedConnectionPointType.type, this.type) ? Up.Compatible : Up.TypeIncompatible;
- if (t.excludedConnectionPointTypes && -1 !== t.excludedConnectionPointTypes.indexOf(this.type))
- return Up.TypeIncompatible;
- var s = n
- , l = i;
- return this.direction === Vp.Input && (s = i,
- l = n),
- s.isAnAncestorOf(l) ? Up.HierarchyIssue : Up.Compatible
- }
- ,
- e.prototype.connectTo = function(e, t) {
- if (void 0 === t && (t = !1),
- !t && !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
- }
- ,
- e.prototype.disconnectFrom = function(e) {
- var t = this._endpoints.indexOf(e);
- return -1 === t || (this._endpoints.splice(t, 1),
- e._connectedPoint = null,
- this._enforceAssociatedVariableName = !1,
- e._enforceAssociatedVariableName = !1),
- this
- }
- ,
- e.prototype.serialize = function(e) {
- void 0 === e && (e = !0);
- var t = {};
- return t.name = this.name,
- t.displayName = this.displayName,
- e && this.connectedPoint && (t.inputName = this.name,
- t.targetBlockId = this.connectedPoint.ownerBlock.uniqueId,
- t.targetConnectionName = this.connectedPoint.name,
- t.isExposedOnFrame = !0,
- t.exposedPortPosition = this.exposedPortPosition),
- (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (t.isExposedOnFrame = !0,
- t.exposedPortPosition = this.exposedPortPosition),
- t
- }
- ,
- e.prototype.dispose = function() {
- this.onConnectionObservable.clear()
- }
- ,
- e
- }()
- , Wp = function() {
- function e(e, t, i, n) {
- void 0 === t && (t = Dp.Vertex),
- void 0 === i && (i = !1),
- void 0 === n && (n = !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 = t,
- this._originalTargetIsNeutral = t === Dp.Neutral,
- this._isFinalMerger = i,
- this._isInput = n,
- this._name = e,
- this.uniqueId = pn.UniqueId
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return this._name
- },
- set: function(e) {
- this.validateBlockName(e) && (this._name = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isUnique", {
- get: function() {
- return this._isUnique
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isFinalMerger", {
- get: function() {
- return this._isFinalMerger
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isInput", {
- get: function() {
- return this._isInput
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buildId", {
- get: function() {
- return this._buildId
- },
- set: function(e) {
- this._buildId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "target", {
- get: function() {
- return this._target
- },
- set: function(e) {
- 0 == (this._target & e) && (this._target = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "inputs", {
- get: function() {
- return this._inputs
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "outputs", {
- get: function() {
- return this._outputs
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getInputByName = function(e) {
- var t = this._inputs.filter((function(t) {
- return t.name === e
- }
- ));
- return t.length ? t[0] : null
- }
- ,
- e.prototype.getOutputByName = function(e) {
- var t = this._outputs.filter((function(t) {
- return t.name === e
- }
- ));
- return t.length ? t[0] : null
- }
- ,
- e.prototype.initialize = function(e) {}
- ,
- e.prototype.bind = function(e, t, i, n) {}
- ,
- e.prototype._declareOutput = function(e, t) {
- return "".concat(t._getGLType(e.type), " ").concat(e.associatedVariableName)
- }
- ,
- e.prototype._writeVariable = function(e) {
- return e.connectedPoint ? "".concat(e.associatedVariableName) : "0."
- }
- ,
- e.prototype._writeFloat = function(e) {
- var t = e.toString();
- return -1 === t.indexOf(".") && (t += ".0"),
- "".concat(t)
- }
- ,
- e.prototype.getClassName = function() {
- return "NodeMaterialBlock"
- }
- ,
- e.prototype.registerInput = function(e, t, i, n, r) {
- return void 0 === i && (i = !1),
- (r = null != r ? r : new zp(e,this,Vp.Input)).type = t,
- r.isOptional = i,
- n && (r.target = n),
- this._inputs.push(r),
- this
- }
- ,
- e.prototype.registerOutput = function(e, t, i, n) {
- return (n = null != n ? n : new zp(e,this,Vp.Output)).type = t,
- i && (n.target = i),
- this._outputs.push(n),
- this
- }
- ,
- e.prototype.getFirstAvailableInput = function(e) {
- void 0 === e && (e = null);
- for (var t = 0, i = this._inputs; t < i.length; t++) {
- var n = i[t];
- if (!(n.connectedPoint || e && e.type !== n.type && n.type !== Op.AutoDetect))
- return n
- }
- return null
- }
- ,
- e.prototype.getFirstAvailableOutput = function(e) {
- void 0 === e && (e = null);
- for (var t = 0, i = this._outputs; t < i.length; t++) {
- var n = i[t];
- if (!e || !e.target || e.target === Dp.Neutral || 0 != (e.target & n.target))
- return n
- }
- return null
- }
- ,
- e.prototype.getSiblingOutput = function(e) {
- var t = this._outputs.indexOf(e);
- return -1 === t || t >= this._outputs.length ? null : this._outputs[t + 1]
- }
- ,
- e.prototype.isAnAncestorOf = function(e) {
- for (var t = 0, i = this._outputs; t < i.length; t++) {
- var n = i[t];
- if (n.hasEndpoints)
- for (var r = 0, o = n.endpoints; r < o.length; r++) {
- var a = o[r];
- if (a.ownerBlock === e)
- return !0;
- if (a.ownerBlock.isAnAncestorOf(e))
- return !0
- }
- }
- return !1
- }
- ,
- e.prototype.connectTo = function(e, t) {
- if (0 !== this._outputs.length) {
- for (var i = t && t.output ? this.getOutputByName(t.output) : this.getFirstAvailableOutput(e), n = !0; n; ) {
- var r = t && t.input ? e.getInputByName(t.input) : e.getFirstAvailableInput(i);
- if (i && r && i.canConnectTo(r))
- i.connectTo(r),
- n = !1;
- else {
- if (!i)
- throw "Unable to find a compatible match";
- i = this.getSiblingOutput(i)
- }
- }
- return this
- }
- }
- ,
- e.prototype._buildBlock = function(e) {}
- ,
- e.prototype.updateUniformsAndSamples = function(e, t, i, n) {}
- ,
- e.prototype.provideFallbacks = function(e, t) {}
- ,
- e.prototype.initializeDefines = function(e, t, i, n) {
- void 0 === n && (n = !1)
- }
- ,
- e.prototype.prepareDefines = function(e, t, i, n, r) {
- void 0 === n && (n = !1)
- }
- ,
- e.prototype.autoConfigure = function(e) {}
- ,
- e.prototype.replaceRepeatableContent = function(e, t, i, n) {}
- ,
- Object.defineProperty(e.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", {
- get: function() {
- return !(this.isInput || this.isFinalMerger || this._outputs.some((function(e) {
- return e.isDirectlyConnectedToVertexOutput
- }
- )) || this.target === Dp.Vertex || this.target !== Dp.VertexAndFragment && this.target !== Dp.Neutral || !this._outputs.some((function(e) {
- return e.isConnectedInVertexShader
- }
- )))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function(e, t, i, n) {
- return void 0 === n && (n = !1),
- !0
- }
- ,
- e.prototype._linkConnectionTypes = function(e, t, i) {
- void 0 === i && (i = !1),
- i ? this._inputs[t]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[t],
- this._inputs[t]._linkedConnectionSource = this._inputs[e]
- }
- ,
- e.prototype._processBuild = function(e, t, i, n) {
- e.build(t, n);
- var r = null != t._vertexState
- , o = e._buildTarget === Dp.Vertex && e.target !== Dp.VertexAndFragment;
- if (r && (0 == (e.target & e._buildTarget) || 0 == (e.target & i.target) || this.target !== Dp.VertexAndFragment && o) && (!e.isInput && t.target !== e._buildTarget || e.isInput && e.isAttribute && !e._noContextSwitch)) {
- var a = i.connectedPoint;
- t._vertexState._emitVaryingFromString("v_" + a.associatedVariableName, t._getGLType(a.type)) && (t._vertexState.compilationString += "".concat("v_" + a.associatedVariableName, " = ").concat(a.associatedVariableName, ";\r\n")),
- i.associatedVariableName = "v_" + a.associatedVariableName,
- i._enforceAssociatedVariableName = !0
- }
- }
- ,
- e.prototype.validateBlockName = function(e) {
- for (var t = 0, 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"]; t < i.length; t++)
- if (e === i[t])
- return !1;
- return !0
- }
- ,
- e.prototype.build = function(e, t) {
- if (this._buildId === e.sharedData.buildId)
- return !0;
- if (!this.isInput)
- for (var i = 0, n = this._outputs; i < n.length; i++)
- (c = n[i]).associatedVariableName || (c.associatedVariableName = e._getFreeVariableName(c.name));
- for (var r = 0, o = this._inputs; r < o.length; r++) {
- var a = o[r];
- if (a.connectedPoint) {
- if (this.target !== Dp.Neutral) {
- if (0 == (a.target & this.target))
- continue;
- if (0 == (a.target & e.target))
- continue
- }
- (d = a.connectedPoint.ownerBlock) && d !== this && this._processBuild(d, e, a, t)
- } else
- a.isOptional || e.sharedData.checks.notConnectedNonOptionalInputs.push(a)
- }
- if (this._buildId === e.sharedData.buildId)
- return !0;
- if (e.sharedData.verbose && console.log("".concat(e.target === Dp.Vertex ? "Vertex shader" : "Fragment shader", ": Building ").concat(this.name, " [").concat(this.getClassName(), "]")),
- this.isFinalMerger)
- switch (e.target) {
- case Dp.Vertex:
- e.sharedData.checks.emitVertex = !0;
- break;
- case Dp.Fragment:
- e.sharedData.checks.emitFragment = !0
- }
- !this.isInput && e.sharedData.emitComments && (e.compilationString += "\r\n//".concat(this.name, "\r\n")),
- this._buildBlock(e),
- this._buildId = e.sharedData.buildId,
- this._buildTarget = e.target;
- for (var s = 0, l = this._outputs; s < l.length; s++) {
- var c;
- if (0 != ((c = l[s]).target & e.target))
- for (var u = 0, h = c.endpoints; u < h.length; u++) {
- var d, p = h[u];
- (d = p.ownerBlock) && 0 != (d.target & e.target) && -1 !== t.indexOf(d) && this._processBuild(d, e, p, t)
- }
- }
- return !1
- }
- ,
- e.prototype._inputRename = function(e) {
- return e
- }
- ,
- e.prototype._outputRename = function(e) {
- return e
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var e = this._codeVariableName;
- return "".concat(e, ".visibleInInspector = ").concat(this.visibleInInspector, ";\r\n").concat(e, ".visibleOnFrame = ").concat(this.visibleOnFrame, ";\r\n").concat(e, ".target = ").concat(this.target, ";\r\n")
- }
- ,
- e.prototype._dumpCode = function(e, t) {
- var i;
- t.push(this);
- var n = this.name.replace(/[^A-Za-z_]+/g, "");
- if (this._codeVariableName = n || "".concat(this.getClassName(), "_").concat(this.uniqueId),
- -1 !== e.indexOf(this._codeVariableName)) {
- var r = 0;
- do {
- r++,
- this._codeVariableName = n + r
- } while (-1 !== e.indexOf(this._codeVariableName))
- }
- e.push(this._codeVariableName),
- i = "\r\n// ".concat(this.getClassName(), "\r\n"),
- this.comments && (i += "// ".concat(this.comments, "\r\n")),
- i += "var ".concat(this._codeVariableName, " = new BABYLON.").concat(this.getClassName(), '("').concat(this.name, '");\r\n'),
- i += this._dumpPropertiesCode();
- for (var o = 0, a = this.inputs; o < a.length; o++) {
- var s = a[o];
- if (s.isConnected) {
- var l = s.connectedPoint.ownerBlock;
- -1 === t.indexOf(l) && (i += l._dumpCode(e, t))
- }
- }
- for (var c = 0, u = this.outputs; c < u.length; c++) {
- var h = u[c];
- if (h.hasEndpoints)
- for (var d = 0, p = h.endpoints; d < p.length; d++)
- (l = p[d].ownerBlock) && -1 === t.indexOf(l) && (i += l._dumpCode(e, t))
- }
- return i
- }
- ,
- e.prototype._dumpCodeForOutputConnections = function(e) {
- var t = "";
- if (-1 !== e.indexOf(this))
- return t;
- e.push(this);
- for (var i = 0, n = this.inputs; i < n.length; i++) {
- var r = n[i];
- if (r.isConnected) {
- var o = r.connectedPoint
- , a = o.ownerBlock;
- t += a._dumpCodeForOutputConnections(e),
- t += "".concat(a._codeVariableName, ".").concat(a._outputRename(o.name), ".connectTo(").concat(this._codeVariableName, ".").concat(this._inputRename(r.name), ");\r\n")
- }
- }
- return t
- }
- ,
- e.prototype.clone = function(e, t) {
- void 0 === t && (t = "");
- var i = this.serialize()
- , n = b(i.customType);
- if (n) {
- var r = new n;
- return r._deserialize(i, e, t),
- r
- }
- return null
- }
- ,
- e.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 t = 0, i = this.inputs; t < i.length; t++) {
- var n = i[t];
- e.inputs.push(n.serialize())
- }
- for (var r = 0, o = this.outputs; r < o.length; r++) {
- var a = o[r];
- e.outputs.push(a.serialize(!1))
- }
- return e
- }
- ,
- e.prototype._deserialize = function(e, t, i) {
- var n;
- this.name = e.name,
- this.comments = e.comments,
- this.visibleInInspector = !!e.visibleInInspector,
- this.visibleOnFrame = !!e.visibleOnFrame,
- this._target = null !== (n = e.target) && void 0 !== n ? n : this.target,
- this._deserializePortDisplayNamesAndExposedOnFrame(e)
- }
- ,
- e.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(e) {
- var t = this
- , i = e.inputs
- , n = e.outputs;
- i && i.forEach((function(e, i) {
- e.displayName && (t.inputs[i].displayName = e.displayName),
- e.isExposedOnFrame && (t.inputs[i].isExposedOnFrame = e.isExposedOnFrame,
- t.inputs[i].exposedPortPosition = e.exposedPortPosition)
- }
- )),
- n && n.forEach((function(e, i) {
- e.displayName && (t.outputs[i].displayName = e.displayName),
- e.isExposedOnFrame && (t.outputs[i].isExposedOnFrame = e.isExposedOnFrame,
- t.outputs[i].exposedPortPosition = e.exposedPortPosition)
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- for (var e = 0, t = this.inputs; e < t.length; e++)
- t[e].dispose();
- for (var i = 0, n = this.outputs; i < n.length; i++)
- n[i].dispose()
- }
- ,
- e
- }()
- , Hp = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.complementW = 1,
- i.complementZ = 0,
- i.target = Dp.Vertex,
- i.registerInput("vector", Op.AutoDetect),
- i.registerInput("transform", Op.Matrix),
- i.registerOutput("output", Op.Vector4),
- i.registerOutput("xyz", Op.Vector3),
- i._inputs[0].onConnectionObservable.add((function(e) {
- if (e.ownerBlock.isInput) {
- var t = e.ownerBlock;
- "normal" !== t.name && "tangent" !== t.name || (i.complementW = 0)
- }
- }
- )),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "TransformBlock"
- }
- ,
- Object.defineProperty(t.prototype, "vector", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyz", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "transform", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.vector
- , n = this.transform;
- if (i.connectedPoint) {
- if (0 === this.complementW) {
- var r = "//".concat(this.name);
- t._emitFunctionFromInclude("helperFunctions", r),
- t.sharedData.blocksWithDefines.push(this);
- var o = t._getFreeVariableName("".concat(n.associatedVariableName, "_NUS"));
- switch (t.compilationString += "mat3 ".concat(o, " = mat3(").concat(n.associatedVariableName, ");\r\n"),
- t.compilationString += "#ifdef NONUNIFORMSCALING\r\n",
- t.compilationString += "".concat(o, " = transposeMat3(inverseMat3(").concat(o, "));\r\n"),
- t.compilationString += "#endif\r\n",
- i.connectedPoint.type) {
- case Op.Vector2:
- t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * vec3(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), "), ").concat(this._writeFloat(this.complementW), ");\r\n");
- break;
- case Op.Vector3:
- case Op.Color3:
- t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\r\n");
- break;
- default:
- t.compilationString += this._declareOutput(this.output, t) + " = vec4(".concat(o, " * ").concat(i.associatedVariableName, ".xyz, ").concat(this._writeFloat(this.complementW), ");\r\n")
- }
- } else
- switch (o = n.associatedVariableName,
- i.connectedPoint.type) {
- case Op.Vector2:
- t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementZ), ", ").concat(this._writeFloat(this.complementW), ");\r\n");
- break;
- case Op.Vector3:
- case Op.Color3:
- t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * vec4(").concat(i.associatedVariableName, ", ").concat(this._writeFloat(this.complementW), ");\r\n");
- break;
- default:
- t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, " * ").concat(i.associatedVariableName, ";\r\n")
- }
- this.xyz.hasEndpoints && (t.compilationString += this._declareOutput(this.xyz, t) + " = ".concat(this.output.associatedVariableName, ".xyz;\r\n"))
- }
- return this
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- e.nonUniformScaling && i.setValue("NONUNIFORMSCALING", !0)
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.complementZ = this.complementZ,
- t.complementW = this.complementW,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.complementZ = void 0 !== t.complementZ ? t.complementZ : 0,
- this.complementW = void 0 !== t.complementW ? t.complementW : 1
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".complementZ = ").concat(this.complementZ, ";\r\n") + "".concat(this._codeVariableName, ".complementW = ").concat(this.complementW, ";\r\n")
- }
- ,
- t
- }(Wp);
- y("BABYLON.TransformBlock", Hp);
- var Xp, jp = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Vertex, !0) || this;
- return i.registerInput("vector", Op.Vector4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VertexOutputBlock"
- }
- ,
- Object.defineProperty(t.prototype, "vector", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._isLogarithmicDepthEnabled = function(e) {
- for (var t = 0, i = e; t < i.length; t++)
- if (i[t].useLogarithmicDepth)
- return !0;
- return !1
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.vector;
- return t.compilationString += "gl_Position = ".concat(i.associatedVariableName, ";\r\n"),
- this._isLogarithmicDepthEnabled(t.sharedData.fragmentOutputNodes) && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
- t._emitVaryingFromString("vFragmentDepth", "float"),
- t.compilationString += "vFragmentDepth = 1.0 + gl_Position.w;\r\n",
- t.compilationString += "gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\r\n"),
- this
- }
- ,
- t
- }(Wp);
- function Yp(e, t, i, n) {
- return void 0 === t && (t = Xp.Boolean),
- void 0 === i && (i = "PROPERTIES"),
- function(r, o) {
- var a = r._propStore;
- a || (a = [],
- r._propStore = a),
- a.push({
- propertyName: o,
- displayName: e,
- type: t,
- groupName: i,
- options: null != n ? n : {}
- })
- }
- }
- y("BABYLON.VertexOutputBlock", jp),
- function(e) {
- e[e.Boolean = 0] = "Boolean",
- e[e.Float = 1] = "Float",
- e[e.Int = 2] = "Int",
- e[e.Vector2 = 3] = "Vector2",
- e[e.List = 4] = "List"
- }(Xp || (Xp = {}));
- var Kp, Qp, qp, Zp = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment, !0) || this;
- return i.convertToGammaSpace = !1,
- i.convertToLinearSpace = !1,
- i.useLogarithmicDepth = !1,
- i.registerInput("rgba", Op.Color4, !0),
- i.registerInput("rgb", Op.Color3, !0),
- i.registerInput("a", Op.Float, !0),
- i.rgb.acceptedConnectionPointTypes.push(Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FragmentOutputBlock"
- }
- ,
- t.prototype.initialize = function(e) {
- e._excludeVariableName("logarithmicDepthConstant"),
- e._excludeVariableName("vFragmentDepth")
- }
- ,
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgb", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.prepareDefines = function(e, t, i) {
- i.setValue(this._linearDefineName, this.convertToLinearSpace, !0),
- i.setValue(this._gammaDefineName, this.convertToGammaSpace, !0)
- }
- ,
- t.prototype.bind = function(e, t, i) {
- this.useLogarithmicDepth && i && Mr.BindLogDepth(void 0, e, i.getScene())
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.rgba
- , n = this.rgb
- , r = this.a;
- t.sharedData.hints.needAlphaBlending = i.isConnected || r.isConnected,
- t.sharedData.blocksWithDefines.push(this),
- this.useLogarithmicDepth && (t._emitUniformFromString("logarithmicDepthConstant", "float"),
- t._emitVaryingFromString("vFragmentDepth", "float"),
- t.sharedData.bindableBlocks.push(this)),
- this._linearDefineName = t._getFreeDefineName("CONVERTTOLINEAR"),
- this._gammaDefineName = t._getFreeDefineName("CONVERTTOGAMMA");
- var o = "//".concat(this.name);
- if (t._emitFunctionFromInclude("helperFunctions", o),
- i.connectedPoint)
- r.isConnected ? t.compilationString += "gl_FragColor = vec4(".concat(i.associatedVariableName, ".rgb, ").concat(r.associatedVariableName, ");\r\n") : t.compilationString += "gl_FragColor = ".concat(i.associatedVariableName, ";\r\n");
- else if (n.connectedPoint) {
- var a = "1.0";
- r.connectedPoint && (a = r.associatedVariableName),
- n.connectedPoint.type === Op.Float ? t.compilationString += "gl_FragColor = vec4(".concat(n.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(n.associatedVariableName, ", ").concat(a, ");\r\n") : t.compilationString += "gl_FragColor = vec4(".concat(n.associatedVariableName, ", ").concat(a, ");\r\n")
- } else
- t.sharedData.checks.notConnectedNonOptionalInputs.push(i);
- return t.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
- t.compilationString += "gl_FragColor = toLinearSpace(gl_FragColor);\r\n",
- t.compilationString += "#endif\r\n",
- t.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
- t.compilationString += "gl_FragColor = toGammaSpace(gl_FragColor);\r\n",
- t.compilationString += "#endif\r\n",
- this.useLogarithmicDepth && (t.compilationString += "gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\r\n"),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\r\n"),
- (t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\r\n")) + "".concat(this._codeVariableName, ".useLogarithmicDepth = ").concat(this.useLogarithmicDepth, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.convertToGammaSpace = this.convertToGammaSpace,
- t.convertToLinearSpace = this.convertToLinearSpace,
- t.useLogarithmicDepth = this.useLogarithmicDepth,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- var r;
- e.prototype._deserialize.call(this, t, i, n),
- this.convertToGammaSpace = t.convertToGammaSpace,
- this.convertToLinearSpace = t.convertToLinearSpace,
- this.useLogarithmicDepth = null !== (r = t.useLogarithmicDepth) && void 0 !== r && r
- }
- ,
- k([Yp("Convert to gamma space", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "convertToGammaSpace", void 0),
- k([Yp("Convert to linear space", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "convertToLinearSpace", void 0),
- k([Yp("Use logarithmic depth", Xp.Boolean, "PROPERTIES")], t.prototype, "useLogarithmicDepth", void 0),
- t
- }(Wp);
- y("BABYLON.FragmentOutputBlock", Zp),
- function(e) {
- e[e.Uniform = 0] = "Uniform",
- e[e.Attribute = 1] = "Attribute",
- e[e.Varying = 2] = "Varying",
- e[e.Undefined = 3] = "Undefined"
- }(Kp || (Kp = {})),
- function(e) {
- e[e.World = 1] = "World",
- e[e.View = 2] = "View",
- e[e.Projection = 3] = "Projection",
- e[e.ViewProjection = 4] = "ViewProjection",
- e[e.WorldView = 5] = "WorldView",
- e[e.WorldViewProjection = 6] = "WorldViewProjection",
- e[e.CameraPosition = 7] = "CameraPosition",
- e[e.FogColor = 8] = "FogColor",
- e[e.DeltaTime = 9] = "DeltaTime",
- e[e.CameraParameters = 10] = "CameraParameters",
- e[e.MaterialAlpha = 11] = "MaterialAlpha"
- }(Qp || (Qp = {})),
- function(e) {
- e[e.None = 0] = "None",
- e[e.Time = 1] = "Time"
- }(qp || (qp = {}));
- var Jp = {
- position2d: "position",
- particle_uv: "vUV",
- particle_color: "vColor",
- particle_texturemask: "textureMask",
- particle_positionw: "vPositionW"
- }
- , $p = {
- particle_uv: !0,
- particle_color: !0,
- particle_texturemask: !0,
- particle_positionw: !0
- }
- , ef = {
- particle_texturemask: !0
- }
- , tf = function(e) {
- function t(t, i, n) {
- void 0 === i && (i = Dp.Vertex),
- void 0 === n && (n = Op.AutoDetect);
- var r = e.call(this, t, i, !1, !0) || this;
- return r._mode = Kp.Undefined,
- r._animationType = qp.None,
- r.min = 0,
- r.max = 0,
- r.isBoolean = !1,
- r.matrixMode = 0,
- r._systemValue = null,
- r.isConstant = !1,
- r.groupInInspector = "",
- r.onValueChangedObservable = new h,
- r.convertToGammaSpace = !1,
- r.convertToLinearSpace = !1,
- r._type = n,
- r.setDefaultValue(),
- r.registerOutput("output", n),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "type", {
- get: function() {
- if (this._type === Op.AutoDetect) {
- if (this.isUniform && null != this.value) {
- if (!isNaN(this.value))
- return this._type = Op.Float,
- this._type;
- switch (this.value.getClassName()) {
- case "Vector2":
- return this._type = Op.Vector2,
- this._type;
- case "Vector3":
- return this._type = Op.Vector3,
- this._type;
- case "Vector4":
- return this._type = Op.Vector4,
- this._type;
- case "Color3":
- return this._type = Op.Color3,
- this._type;
- case "Color4":
- return this._type = Op.Color4,
- this._type;
- case "Matrix":
- return this._type = Op.Matrix,
- this._type
- }
- }
- if (this.isAttribute)
- switch (this.name) {
- case "position":
- case "normal":
- case "tangent":
- case "particle_positionw":
- return this._type = Op.Vector3,
- this._type;
- case "uv":
- case "uv2":
- case "uv3":
- case "uv4":
- case "uv5":
- case "uv6":
- case "position2d":
- case "particle_uv":
- return this._type = Op.Vector2,
- this._type;
- case "matricesIndices":
- case "matricesWeights":
- case "world0":
- case "world1":
- case "world2":
- case "world3":
- return this._type = Op.Vector4,
- this._type;
- case "color":
- case "particle_color":
- case "particle_texturemask":
- return this._type = Op.Color4,
- this._type
- }
- if (this.isSystemValue)
- switch (this._systemValue) {
- case Qp.World:
- case Qp.WorldView:
- case Qp.WorldViewProjection:
- case Qp.View:
- case Qp.ViewProjection:
- case Qp.Projection:
- return this._type = Op.Matrix,
- this._type;
- case Qp.CameraPosition:
- return this._type = Op.Vector3,
- this._type;
- case Qp.FogColor:
- return this._type = Op.Color3,
- this._type;
- case Qp.DeltaTime:
- case Qp.MaterialAlpha:
- return this._type = Op.Float,
- this._type;
- case Qp.CameraParameters:
- return this._type = Op.Vector4,
- this._type
- }
- }
- return this._type
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.validateBlockName = function(t) {
- return !!this.isAttribute || e.prototype.validateBlockName.call(this, t)
- }
- ,
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setAsAttribute = function(e) {
- return this._mode = Kp.Attribute,
- e && (this.name = e),
- this
- }
- ,
- t.prototype.setAsSystemValue = function(e) {
- return this.systemValue = e,
- this
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._storedValue
- },
- set: function(e) {
- this.type === Op.Float && (this.isBoolean ? e = e ? 1 : 0 : this.min !== this.max && (e = Math.max(this.min, e),
- e = Math.min(this.max, e))),
- this._storedValue = e,
- this._mode = Kp.Uniform,
- this.onValueChangedObservable.notifyObservers(this)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "valueCallback", {
- get: function() {
- return this._valueCallback
- },
- set: function(e) {
- this._valueCallback = e,
- this._mode = Kp.Uniform
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "associatedVariableName", {
- get: function() {
- return this._associatedVariableName
- },
- set: function(e) {
- this._associatedVariableName = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "animationType", {
- get: function() {
- return this._animationType
- },
- set: function(e) {
- this._animationType = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isUndefined", {
- get: function() {
- return this._mode === Kp.Undefined
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isUniform", {
- get: function() {
- return this._mode === Kp.Uniform
- },
- set: function(e) {
- this._mode = e ? Kp.Uniform : Kp.Undefined,
- this.associatedVariableName = ""
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isAttribute", {
- get: function() {
- return this._mode === Kp.Attribute
- },
- set: function(e) {
- this._mode = e ? Kp.Attribute : Kp.Undefined,
- this.associatedVariableName = ""
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isVarying", {
- get: function() {
- return this._mode === Kp.Varying
- },
- set: function(e) {
- this._mode = e ? Kp.Varying : Kp.Undefined,
- this.associatedVariableName = ""
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isSystemValue", {
- get: function() {
- return null != this._systemValue
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "systemValue", {
- get: function() {
- return this._systemValue
- },
- set: function(e) {
- this._mode = Kp.Uniform,
- this.associatedVariableName = "",
- this._systemValue = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "InputBlock"
- }
- ,
- t.prototype.animate = function(e) {
- this._animationType === qp.Time && this.type === Op.Float && (this.value += .01 * e.getAnimationRatio())
- }
- ,
- t.prototype._emitDefine = function(e) {
- return "!" === e[0] ? "#ifndef ".concat(e.substring(1), "\r\n") : "#ifdef ".concat(e, "\r\n")
- }
- ,
- t.prototype.initialize = function() {
- this.associatedVariableName = ""
- }
- ,
- t.prototype.setDefaultValue = function() {
- switch (this.type) {
- case Op.Float:
- this.value = 0;
- break;
- case Op.Vector2:
- this.value = A.Zero();
- break;
- case Op.Vector3:
- this.value = x.Zero();
- break;
- case Op.Vector4:
- this.value = R.Zero();
- break;
- case Op.Color3:
- this.value = D.White();
- break;
- case Op.Color4:
- this.value = new N(1,1,1,1);
- break;
- case Op.Matrix:
- this.value = P.Identity()
- }
- }
- ,
- t.prototype._emitConstant = function(e) {
- switch (this.type) {
- case Op.Float:
- return "".concat(e._emitFloat(this.value));
- case Op.Vector2:
- return "vec2(".concat(this.value.x, ", ").concat(this.value.y, ")");
- case Op.Vector3:
- return "vec3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
- case Op.Vector4:
- return "vec4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
- case Op.Color3:
- return L.Color3[0].set(this.value.r, this.value.g, this.value.b),
- this.convertToGammaSpace && L.Color3[0].toGammaSpaceToRef(L.Color3[0]),
- this.convertToLinearSpace && L.Color3[0].toLinearSpaceToRef(L.Color3[0]),
- "vec3(".concat(L.Color3[0].r, ", ").concat(L.Color3[0].g, ", ").concat(L.Color3[0].b, ")");
- case Op.Color4:
- return L.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
- this.convertToGammaSpace && L.Color4[0].toGammaSpaceToRef(L.Color4[0]),
- this.convertToLinearSpace && L.Color4[0].toLinearSpaceToRef(L.Color4[0]),
- "vec4(".concat(L.Color4[0].r, ", ").concat(L.Color4[0].g, ", ").concat(L.Color4[0].b, ", ").concat(L.Color4[0].a, ")")
- }
- return ""
- }
- ,
- Object.defineProperty(t.prototype, "_noContextSwitch", {
- get: function() {
- return $p[this.name]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._emit = function(e, t) {
- var i;
- if (this.isUniform) {
- if (this.associatedVariableName || (this.associatedVariableName = e._getFreeVariableName("u_" + this.name)),
- this.isConstant) {
- if (-1 !== e.constants.indexOf(this.associatedVariableName))
- return;
- return e.constants.push(this.associatedVariableName),
- void (e._constantDeclaration += this._declareOutput(this.output, e) + " = ".concat(this._emitConstant(e), ";\r\n"))
- }
- if (-1 !== e.uniforms.indexOf(this.associatedVariableName))
- return;
- e.uniforms.push(this.associatedVariableName),
- t && (e._uniformDeclaration += this._emitDefine(t)),
- e._uniformDeclaration += "uniform ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, ";\r\n"),
- t && (e._uniformDeclaration += "#endif\r\n");
- var n = e.sharedData.hints;
- if (null !== this._systemValue && void 0 !== this._systemValue)
- switch (this._systemValue) {
- case Qp.WorldView:
- n.needWorldViewMatrix = !0;
- break;
- case Qp.WorldViewProjection:
- n.needWorldViewProjectionMatrix = !0
- }
- else
- this._animationType !== qp.None && e.sharedData.animatedInputs.push(this)
- } else if (this.isAttribute) {
- if (this.associatedVariableName = null !== (i = Jp[this.name]) && void 0 !== i ? i : this.name,
- this.target === Dp.Vertex && e._vertexState)
- return void ($p[this.name] ? ef[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), t) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), t) : this._emit(e._vertexState, t));
- if (-1 !== e.attributes.indexOf(this.associatedVariableName))
- return;
- e.attributes.push(this.associatedVariableName),
- $p[this.name] ? ef[this.name] ? e._emitUniformFromString(this.associatedVariableName, e._getGLType(this.type), t) : e._emitVaryingFromString(this.associatedVariableName, e._getGLType(this.type), t) : (t && (e._attributeDeclaration += this._emitDefine(t)),
- e._attributeDeclaration += "attribute ".concat(e._getGLType(this.type), " ").concat(this.associatedVariableName, ";\r\n"),
- t && (e._attributeDeclaration += "#endif\r\n"))
- }
- }
- ,
- t.prototype._transmitWorld = function(e, t, i, n) {
- if (this._systemValue) {
- var r = this.associatedVariableName;
- switch (this._systemValue) {
- case Qp.World:
- e.setMatrix(r, t);
- break;
- case Qp.WorldView:
- e.setMatrix(r, i);
- break;
- case Qp.WorldViewProjection:
- e.setMatrix(r, n)
- }
- }
- }
- ,
- t.prototype._transmit = function(e, t, i) {
- if (!this.isAttribute) {
- var n = this.associatedVariableName;
- if (this._systemValue)
- switch (this._systemValue) {
- case Qp.World:
- case Qp.WorldView:
- case Qp.WorldViewProjection:
- return;
- case Qp.View:
- e.setMatrix(n, t.getViewMatrix());
- break;
- case Qp.Projection:
- e.setMatrix(n, t.getProjectionMatrix());
- break;
- case Qp.ViewProjection:
- e.setMatrix(n, t.getTransformMatrix());
- break;
- case Qp.CameraPosition:
- t.bindEyePosition(e, n, !0);
- break;
- case Qp.FogColor:
- e.setColor3(n, t.fogColor);
- break;
- case Qp.DeltaTime:
- e.setFloat(n, t.deltaTime / 1e3);
- break;
- case Qp.CameraParameters:
- t.activeCamera && e.setFloat4(n, t.getEngine().hasOriginBottomLeft ? -1 : 1, t.activeCamera.minZ, t.activeCamera.maxZ, 1 / t.activeCamera.maxZ);
- break;
- case Qp.MaterialAlpha:
- e.setFloat(n, i.alpha)
- }
- else {
- var r = this._valueCallback ? this._valueCallback() : this._storedValue;
- if (null !== r)
- switch (this.type) {
- case Op.Float:
- e.setFloat(n, r);
- break;
- case Op.Int:
- e.setInt(n, r);
- break;
- case Op.Color3:
- L.Color3[0].set(this.value.r, this.value.g, this.value.b),
- this.convertToGammaSpace && L.Color3[0].toGammaSpaceToRef(L.Color3[0]),
- this.convertToLinearSpace && L.Color3[0].toLinearSpaceToRef(L.Color3[0]),
- e.setColor3(n, L.Color3[0]);
- break;
- case Op.Color4:
- L.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
- this.convertToGammaSpace && L.Color4[0].toGammaSpaceToRef(L.Color4[0]),
- this.convertToLinearSpace && L.Color4[0].toLinearSpaceToRef(L.Color4[0]),
- e.setDirectColor4(n, L.Color4[0]);
- break;
- case Op.Vector2:
- e.setVector2(n, r);
- break;
- case Op.Vector3:
- e.setVector3(n, r);
- break;
- case Op.Vector4:
- e.setVector4(n, r);
- break;
- case Op.Matrix:
- e.setMatrix(n, r)
- }
- }
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t),
- (this.isUniform || this.isSystemValue) && t.sharedData.inputBlocks.push(this),
- this._emit(t)
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = this._codeVariableName;
- if (this.isAttribute)
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, '.setAsAttribute("').concat(this.name, '");\r\n');
- if (this.isSystemValue)
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(t, ".setAsSystemValue(BABYLON.NodeMaterialSystemValues.").concat(Qp[this._systemValue], ");\r\n");
- if (this.isUniform) {
- var i = []
- , n = "";
- switch (this.type) {
- case Op.Float:
- n = "".concat(this.value);
- break;
- case Op.Vector2:
- n = "new BABYLON.Vector2(".concat(this.value.x, ", ").concat(this.value.y, ")");
- break;
- case Op.Vector3:
- n = "new BABYLON.Vector3(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ")");
- break;
- case Op.Vector4:
- n = "new BABYLON.Vector4(".concat(this.value.x, ", ").concat(this.value.y, ", ").concat(this.value.z, ", ").concat(this.value.w, ")");
- break;
- case Op.Color3:
- n = "new BABYLON.Color3(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ")"),
- this.convertToGammaSpace && (n += ".toGammaSpace()"),
- this.convertToLinearSpace && (n += ".toLinearSpace()");
- break;
- case Op.Color4:
- n = "new BABYLON.Color4(".concat(this.value.r, ", ").concat(this.value.g, ", ").concat(this.value.b, ", ").concat(this.value.a, ")"),
- this.convertToGammaSpace && (n += ".toGammaSpace()"),
- this.convertToLinearSpace && (n += ".toLinearSpace()");
- break;
- case Op.Matrix:
- n = "BABYLON.Matrix.FromArray([".concat(this.value.m, "])")
- }
- return i.push("".concat(t, ".value = ").concat(n)),
- this.type === Op.Float && i.push("".concat(t, ".min = ").concat(this.min), "".concat(t, ".max = ").concat(this.max), "".concat(t, ".isBoolean = ").concat(this.isBoolean), "".concat(t, ".matrixMode = ").concat(this.matrixMode), "".concat(t, ".animationType = BABYLON.AnimatedInputBlockTypes.").concat(qp[this.animationType])),
- i.push("".concat(t, ".isConstant = ").concat(this.isConstant)),
- i.push(""),
- e.prototype._dumpPropertiesCode.call(this) + i.join(";\r\n")
- }
- return e.prototype._dumpPropertiesCode.call(this)
- }
- ,
- t.prototype.dispose = function() {
- this.onValueChangedObservable.clear(),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.type = this.type,
- t.mode = this._mode,
- t.systemValue = this._systemValue,
- t.animationType = this._animationType,
- t.min = this.min,
- t.max = this.max,
- t.isBoolean = this.isBoolean,
- t.matrixMode = this.matrixMode,
- t.isConstant = this.isConstant,
- t.groupInInspector = this.groupInInspector,
- t.convertToGammaSpace = this.convertToGammaSpace,
- t.convertToLinearSpace = this.convertToLinearSpace,
- null != this._storedValue && this._mode === Kp.Uniform && (this._storedValue.asArray ? (t.valueType = "BABYLON." + this._storedValue.getClassName(),
- t.value = this._storedValue.asArray()) : (t.valueType = "number",
- t.value = this._storedValue)),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- if (this._mode = t.mode,
- e.prototype._deserialize.call(this, t, i, n),
- this._type = t.type,
- this._systemValue = t.systemValue || t.wellKnownValue,
- this._animationType = t.animationType,
- this.min = t.min || 0,
- this.max = t.max || 0,
- this.isBoolean = !!t.isBoolean,
- this.matrixMode = t.matrixMode || 0,
- this.isConstant = !!t.isConstant,
- this.groupInInspector = t.groupInInspector || "",
- this.convertToGammaSpace = !!t.convertToGammaSpace,
- this.convertToLinearSpace = !!t.convertToLinearSpace,
- t.valueType)
- if ("number" === t.valueType)
- this._storedValue = t.value;
- else {
- var r = b(t.valueType);
- r && (this._storedValue = r.FromArray(t.value))
- }
- }
- ,
- t
- }(Wp);
- y("BABYLON.InputBlock", tf);
- var nf = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.VertexAndFragment) || this;
- return i._samplerName = "textureSampler",
- i.convertToGammaSpace = !1,
- i.convertToLinearSpace = !1,
- i._isUnique = !1,
- i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
- i.registerOutput("rgba", Op.Color4, Dp.Neutral),
- i.registerOutput("rgb", Op.Color3, Dp.Neutral),
- i.registerOutput("r", Op.Float, Dp.Neutral),
- i.registerOutput("g", Op.Float, Dp.Neutral),
- i.registerOutput("b", Op.Float, Dp.Neutral),
- i.registerOutput("a", Op.Float, Dp.Neutral),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[0]._prioritizeVertex = !1,
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "CurrentScreenBlock"
- }
- ,
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgb", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("textureSampler")
- }
- ,
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- return this.uv.isConnected ? this.uv.sourceBlock.isInput ? Dp.VertexAndFragment : Dp.Fragment : Dp.VertexAndFragment
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.prepareDefines = function(e, t, i) {
- i.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
- i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
- }
- ,
- t.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- t.prototype._injectVertexCode = function(e) {
- var t = this.uv;
- if (t.connectedPoint.ownerBlock.isInput && (t.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(t.associatedVariableName, "vec2")),
- this._mainUVName = "vMain" + t.associatedVariableName,
- e._emitVaryingFromString(this._mainUVName, "vec2"),
- e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
- this._outputs.some((function(e) {
- return e.isConnectedInVertexShader
- }
- ))) {
- this._writeTextureRead(e, !0);
- for (var i = 0, n = this._outputs; i < n.length; i++) {
- var r = n[i];
- r.hasEndpoints && this._writeOutput(e, r, r.name, !0)
- }
- }
- }
- ,
- t.prototype._writeTextureRead = function(e, t) {
- void 0 === t && (t = !1);
- var i = this.uv;
- if (t) {
- if (e.target === Dp.Fragment)
- return;
- e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
- } else
- this.uv.ownerBlock.target !== Dp.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\r\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
- }
- ,
- t.prototype._writeOutput = function(e, t, i, n) {
- if (void 0 === n && (n = !1),
- n) {
- if (e.target === Dp.Fragment)
- return;
- e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
- } else
- this.uv.ownerBlock.target !== Dp.Fragment ? (e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
- e.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
- e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\r\n"),
- e.compilationString += "#endif\r\n",
- e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
- e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\r\n"),
- e.compilationString += "#endif\r\n") : e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
- t.sharedData.blockingBlocks.indexOf(this) < 0 && t.sharedData.blockingBlocks.push(this),
- t.sharedData.textureBlocks.indexOf(this) < 0 && t.sharedData.textureBlocks.push(this),
- t.sharedData.blocksWithDefines.indexOf(this) < 0 && t.sharedData.blocksWithDefines.push(this),
- t.target !== Dp.Fragment)
- return t._emit2DSampler(this._samplerName),
- void this._injectVertexCode(t);
- if (this._outputs.some((function(e) {
- return e.isConnectedInFragmentShader
- }
- ))) {
- t._emit2DSampler(this._samplerName),
- this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
- this._gammaDefineName = t._getFreeDefineName("ISGAMMA");
- var i = "//".concat(this.name);
- t._emitFunctionFromInclude("helperFunctions", i),
- this._writeTextureRead(t);
- for (var n = 0, r = this._outputs; n < r.length; n++) {
- var o = r[n];
- o.hasEndpoints && this._writeOutput(t, o, o.name)
- }
- return this
- }
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.convertToGammaSpace = this.convertToGammaSpace,
- t.convertToLinearSpace = this.convertToLinearSpace,
- this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.convertToGammaSpace = t.convertToGammaSpace,
- this.convertToLinearSpace = !!t.convertToLinearSpace,
- t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
- this.texture = io.Parse(t.texture, i, n))
- }
- ,
- t
- }(Wp);
- y("BABYLON.CurrentScreenBlock", nf);
- var rf = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i._samplerName = "diffuseSampler",
- i.convertToGammaSpace = !1,
- i.convertToLinearSpace = !1,
- i._isUnique = !1,
- i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
- i.registerOutput("rgba", Op.Color4, Dp.Neutral),
- i.registerOutput("rgb", Op.Color3, Dp.Neutral),
- i.registerOutput("r", Op.Float, Dp.Neutral),
- i.registerOutput("g", Op.Float, Dp.Neutral),
- i.registerOutput("b", Op.Float, Dp.Neutral),
- i.registerOutput("a", Op.Float, Dp.Neutral),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ParticleTextureBlock"
- }
- ,
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgb", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("diffuseSampler")
- }
- ,
- t.prototype.autoConfigure = function(e) {
- if (!this.uv.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "particle_uv" === e.name
- }
- ));
- t || (t = new tf("uv")).setAsAttribute("particle_uv"),
- t.output.connectTo(this.uv)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- i.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
- i.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
- }
- ,
- t.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- t.prototype._writeOutput = function(e, t, i) {
- e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
- e.compilationString += "#ifdef ".concat(this._linearDefineName, "\r\n"),
- e.compilationString += "".concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\r\n"),
- e.compilationString += "#endif\r\n",
- e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\r\n"),
- e.compilationString += "".concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\r\n"),
- e.compilationString += "#endif\r\n"
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target !== Dp.Vertex) {
- this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
- t._emit2DSampler(this._samplerName),
- t.sharedData.blockingBlocks.push(this),
- t.sharedData.textureBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this),
- this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
- this._gammaDefineName = t._getFreeDefineName("ISGAMMA");
- var i = "//".concat(this.name);
- t._emitFunctionFromInclude("helperFunctions", i),
- t.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this.uv.associatedVariableName, ");\r\n");
- for (var n = 0, r = this._outputs; n < r.length; n++) {
- var o = r[n];
- o.hasEndpoints && this._writeOutput(t, o, o.name)
- }
- return this
- }
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.convertToGammaSpace = this.convertToGammaSpace,
- t.convertToLinearSpace = this.convertToLinearSpace,
- this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.convertToGammaSpace = t.convertToGammaSpace,
- this.convertToLinearSpace = !!t.convertToLinearSpace,
- t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
- this.texture = io.Parse(t.texture, i, n))
- }
- ,
- t
- }(Wp);
- y("BABYLON.ParticleTextureBlock", rf);
- var of = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i._isUnique = !0,
- i.registerInput("color", Op.Color4, !1, Dp.Fragment),
- i.registerOutput("rampColor", Op.Color4, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ParticleRampGradientBlock"
- }
- ,
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rampColor", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("remapRanges"),
- e._excludeVariableName("rampSampler"),
- e._excludeVariableName("baseColor"),
- e._excludeVariableName("alpha"),
- e._excludeVariableName("remappedColorIndex"),
- e._excludeVariableName("rampColor"),
- e._excludeVariableName("finalAlpha")
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target !== Dp.Vertex)
- return t._emit2DSampler("rampSampler"),
- t._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"),
- t.compilationString += "\n #ifdef RAMPGRADIENT\n vec4 baseColor = ".concat(this.color.associatedVariableName, ";\n float alpha = ").concat(this.color.associatedVariableName, ".a;\n\n float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);\n\n vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));\n baseColor.rgb *= rampColor.rgb;\n\n // Remapped alpha\n float finalAlpha = baseColor.a;\n baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);\n\n ").concat(this._declareOutput(this.rampColor, t), " = baseColor;\n #else\n ").concat(this._declareOutput(this.rampColor, t), " = ").concat(this.color.associatedVariableName, ";\n #endif\n "),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ParticleRampGradientBlock", of);
- var af = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i._isUnique = !0,
- i.registerInput("color", Op.Color4, !1, Dp.Fragment),
- i.registerInput("alphaTexture", Op.Float, !1, Dp.Fragment),
- i.registerInput("alphaColor", Op.Float, !1, Dp.Fragment),
- i.registerOutput("blendColor", Op.Color4, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ParticleBlendMultiplyBlock"
- }
- ,
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "alphaTexture", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "alphaColor", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "blendColor", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("sourceAlpha")
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target !== Dp.Vertex)
- return t.compilationString += "\n #ifdef BLENDMULTIPLYMODE\n ".concat(this._declareOutput(this.blendColor, t), ";\n float sourceAlpha = ").concat(this.alphaColor.associatedVariableName, " * ").concat(this.alphaTexture.associatedVariableName, ";\n ").concat(this.blendColor.associatedVariableName, ".rgb = ").concat(this.color.associatedVariableName, ".rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);\n ").concat(this.blendColor.associatedVariableName, ".a = ").concat(this.color.associatedVariableName, ".a;\n #else\n ").concat(this._declareOutput(this.blendColor, t), " = ").concat(this.color.associatedVariableName, ";\n #endif\n "),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ParticleBlendMultiplyBlock", af);
- var sf = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.xSwizzle = "x",
- i.ySwizzle = "y",
- i.zSwizzle = "z",
- i.wSwizzle = "w",
- i.registerInput("xyzw ", Op.Vector4, !0),
- i.registerInput("xyz ", Op.Vector3, !0),
- i.registerInput("xy ", Op.Vector2, !0),
- i.registerInput("zw ", Op.Vector2, !0),
- i.registerInput("x", Op.Float, !0),
- i.registerInput("y", Op.Float, !0),
- i.registerInput("z", Op.Float, !0),
- i.registerInput("w", Op.Float, !0),
- i.registerOutput("xyzw", Op.Vector4),
- i.registerOutput("xyz", Op.Vector3),
- i.registerOutput("xy", Op.Vector2),
- i.registerOutput("zw", Op.Vector2),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VectorMergerBlock"
- }
- ,
- Object.defineProperty(t.prototype, "xyzwIn", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyzIn", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyIn", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "zwIn", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "z", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "w", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyzw", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyzOut", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyOut", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "zwOut", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xy", {
- get: function() {
- return this.xyOut
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyz", {
- get: function() {
- return this.xyzOut
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._inputRename = function(e) {
- return "xyzw " === e ? "xyzwIn" : "xyz " === e ? "xyzIn" : "xy " === e ? "xyIn" : "zw " === e ? "zwIn" : e
- }
- ,
- t.prototype._buildSwizzle = function(e) {
- return "." + (this.xSwizzle + this.ySwizzle + this.zSwizzle + this.wSwizzle).substr(0, e)
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.x
- , n = this.y
- , r = this.z
- , o = this.w
- , a = this.xyIn
- , s = this.zwIn
- , l = this.xyzIn
- , c = this.xyzwIn
- , u = this._outputs[0]
- , h = this._outputs[1]
- , d = this._outputs[2]
- , p = this._outputs[3];
- return c.isConnected ? (u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(4), ";\r\n")),
- h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n")),
- d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(c.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n"))) : l.isConnected ? (u.hasEndpoints && (t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(l.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
- h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n")),
- d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(l.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n"))) : a.isConnected ? (u.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ")").concat(this._buildSwizzle(4), ";\r\n") : t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
- h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = vec3(".concat(a.associatedVariableName, ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n")),
- d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n")),
- p.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(p, t) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n") : t.compilationString += this._declareOutput(p, t) + " = vec2(".concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n"))) : (u.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(s.associatedVariableName, ")").concat(this._buildSwizzle(4), ";\r\n") : t.compilationString += this._declareOutput(u, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
- h.hasEndpoints && (t.compilationString += this._declareOutput(h, t) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n")),
- d.hasEndpoints && (t.compilationString += this._declareOutput(d, t) + " = vec2(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n")),
- p.hasEndpoints && (s.isConnected ? t.compilationString += this._declareOutput(p, t) + " = ".concat(s.associatedVariableName).concat(this._buildSwizzle(2), ";\r\n") : t.compilationString += this._declareOutput(p, t) + " = vec2(".concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(2), ";\r\n"))),
- this
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.xSwizzle = this.xSwizzle,
- t.ySwizzle = this.ySwizzle,
- t.zSwizzle = this.zSwizzle,
- t.wSwizzle = this.wSwizzle,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- var r, o, a, s;
- e.prototype._deserialize.call(this, t, i, n),
- this.xSwizzle = null !== (r = t.xSwizzle) && void 0 !== r ? r : "x",
- this.ySwizzle = null !== (o = t.ySwizzle) && void 0 !== o ? o : "y",
- this.zSwizzle = null !== (a = t.zSwizzle) && void 0 !== a ? a : "z",
- this.wSwizzle = null !== (s = t.wSwizzle) && void 0 !== s ? s : "w"
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return t += "".concat(this._codeVariableName, '.xSwizzle = "').concat(this.xSwizzle, '";\r\n'),
- t += "".concat(this._codeVariableName, '.ySwizzle = "').concat(this.ySwizzle, '";\r\n'),
- (t += "".concat(this._codeVariableName, '.zSwizzle = "').concat(this.zSwizzle, '";\r\n')) + "".concat(this._codeVariableName, '.wSwizzle = "').concat(this.wSwizzle, '";\r\n')
- }
- ,
- t
- }(Wp);
- y("BABYLON.VectorMergerBlock", sf);
- var lf = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.sourceRange = new A(-1,1),
- i.targetRange = new A(0,1),
- i.registerInput("input", Op.AutoDetect),
- i.registerInput("sourceMin", Op.Float, !0),
- i.registerInput("sourceMax", Op.Float, !0),
- i.registerInput("targetMin", Op.Float, !0),
- i.registerInput("targetMax", Op.Float, !0),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "RemapBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sourceMin", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sourceMax", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "targetMin", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "targetMax", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x)
- , r = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y)
- , o = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x)
- , a = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(o, " + (").concat(this._inputs[0].associatedVariableName, " - ").concat(n, ") * (").concat(a, " - ").concat(o, ") / (").concat(r, " - ").concat(n, ");\r\n"),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".sourceRange = new BABYLON.Vector2(").concat(this.sourceRange.x, ", ").concat(this.sourceRange.y, ");\r\n") + "".concat(this._codeVariableName, ".targetRange = new BABYLON.Vector2(").concat(this.targetRange.x, ", ").concat(this.targetRange.y, ");\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.sourceRange = this.sourceRange.asArray(),
- t.targetRange = this.targetRange.asArray(),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.sourceRange = A.FromArray(t.sourceRange),
- this.targetRange = A.FromArray(t.targetRange)
- }
- ,
- k([Yp("From", Xp.Vector2)], t.prototype, "sourceRange", void 0),
- k([Yp("To", Xp.Vector2)], t.prototype, "targetRange", void 0),
- t
- }(Wp);
- y("BABYLON.RemapBlock", lf);
- var cf, uf = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "MultiplyBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " * ").concat(this.right.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.MultiplyBlock", uf),
- function(e) {
- e[e.Material = 0] = "Material",
- e[e.PostProcess = 1] = "PostProcess",
- e[e.Particle = 2] = "Particle",
- e[e.ProceduralTexture = 3] = "ProceduralTexture"
- }(cf || (cf = {}));
- var hf = function() {
- function e() {
- this.direction1 = new x(0,1,0),
- this.direction2 = new x(0,1,0),
- this.minEmitBox = new x(-.5,-.5,-.5),
- this.maxEmitBox = new x(.5,.5,.5)
- }
- return e.prototype.startDirectionFunction = function(e, t, i, n) {
- var r = d.RandomRange(this.direction1.x, this.direction2.x)
- , o = d.RandomRange(this.direction1.y, this.direction2.y)
- , a = d.RandomRange(this.direction1.z, this.direction2.z);
- if (n)
- return t.x = r,
- t.y = o,
- void (t.z = a);
- x.TransformNormalFromFloatsToRef(r, o, a, e, t)
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- var r = d.RandomRange(this.minEmitBox.x, this.maxEmitBox.x)
- , o = d.RandomRange(this.minEmitBox.y, this.maxEmitBox.y)
- , a = d.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
- if (n)
- return t.x = r,
- t.y = o,
- void (t.z = a);
- x.TransformCoordinatesFromFloatsToRef(r, o, a, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2),
- e.setVector3("minEmitBox", this.minEmitBox),
- e.setVector3("maxEmitBox", this.maxEmitBox)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3),
- e.addUniform("minEmitBox", 3),
- e.addUniform("maxEmitBox", 3)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return "#define BOXEMITTER"
- }
- ,
- e.prototype.getClassName = function() {
- return "BoxParticleEmitter"
- }
- ,
- e.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
- }
- ,
- e.prototype.parse = function(e) {
- x.FromArrayToRef(e.direction1, 0, this.direction1),
- x.FromArrayToRef(e.direction2, 0, this.direction2),
- x.FromArrayToRef(e.minEmitBox, 0, this.minEmitBox),
- x.FromArrayToRef(e.maxEmitBox, 0, this.maxEmitBox)
- }
- ,
- e
- }()
- , df = function() {
- function e(e, t, i) {
- void 0 === e && (e = 1),
- void 0 === t && (t = Math.PI),
- void 0 === i && (i = 0),
- this.directionRandomizer = i,
- this.radiusRange = 1,
- this.heightRange = 1,
- this.emitFromSpawnPointOnly = !1,
- this.angle = t,
- this.radius = e
- }
- return Object.defineProperty(e.prototype, "radius", {
- get: function() {
- return this._radius
- },
- set: function(e) {
- this._radius = e,
- this._buildHeight()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "angle", {
- get: function() {
- return this._angle
- },
- set: function(e) {
- this._angle = e,
- this._buildHeight()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildHeight = function() {
- 0 !== this._angle ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1
- }
- ,
- e.prototype.startDirectionFunction = function(e, t, i, n) {
- n ? I.Vector3[0].copyFrom(i._localPosition).normalize() : i.position.subtractToRef(e.getTranslation(), I.Vector3[0]).normalize();
- var r = d.RandomRange(0, this.directionRandomizer)
- , o = d.RandomRange(0, this.directionRandomizer)
- , a = d.RandomRange(0, this.directionRandomizer);
- t.x = I.Vector3[0].x + r,
- t.y = I.Vector3[0].y + o,
- t.z = I.Vector3[0].z + a,
- t.normalize()
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- var r, o = d.RandomRange(0, 2 * Math.PI);
- r = this.emitFromSpawnPointOnly ? 1e-4 : 1 - (r = d.RandomRange(0, this.heightRange)) * r;
- var a = this._radius - d.RandomRange(0, this._radius * this.radiusRange)
- , s = (a *= r) * Math.sin(o)
- , l = a * Math.cos(o)
- , c = r * this._height;
- if (n)
- return t.x = s,
- t.y = c,
- void (t.z = l);
- x.TransformCoordinatesFromFloatsToRef(s, c, l, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this._radius,this._angle,this.directionRandomizer);
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.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)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 2),
- e.addUniform("coneAngle", 1),
- e.addUniform("height", 2),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- e.prototype.getEffectDefines = function() {
- var e = "#define CONEEMITTER";
- return this.emitFromSpawnPointOnly && (e += "\n#define CONEEMITTERSPAWNPOINT"),
- e
- }
- ,
- e.prototype.getClassName = function() {
- return "ConeParticleEmitter"
- }
- ,
- e.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
- }
- ,
- e.prototype.parse = function(e) {
- this.radius = e.radius,
- this.angle = e.angle,
- this.directionRandomizer = e.directionRandomizer,
- this.radiusRange = void 0 !== e.radiusRange ? e.radiusRange : 1,
- this.heightRange = void 0 !== e.radiusRange ? e.heightRange : 1,
- this.emitFromSpawnPointOnly = void 0 !== e.emitFromSpawnPointOnly && e.emitFromSpawnPointOnly
- }
- ,
- e
- }()
- , pf = function() {
- function e(e, t, i, n) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1),
- void 0 === i && (i = 1),
- void 0 === n && (n = 0),
- this.radius = e,
- this.height = t,
- this.radiusRange = i,
- this.directionRandomizer = n,
- this._tempVector = x.Zero()
- }
- return e.prototype.startDirectionFunction = function(e, t, i, n, r) {
- i.position.subtractToRef(e.getTranslation(), this._tempVector),
- this._tempVector.normalize(),
- x.TransformNormalToRef(this._tempVector, r, this._tempVector);
- var o = d.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2)
- , a = Math.atan2(this._tempVector.x, this._tempVector.z);
- a += d.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer,
- this._tempVector.y = o,
- this._tempVector.x = Math.sin(a),
- this._tempVector.z = Math.cos(a),
- this._tempVector.normalize(),
- n ? t.copyFrom(this._tempVector) : x.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, e, t)
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- var r = d.RandomRange(-this.height / 2, this.height / 2)
- , o = d.RandomRange(0, 2 * Math.PI)
- , a = d.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1)
- , s = Math.sqrt(a) * this.radius
- , l = s * Math.cos(o)
- , c = s * Math.sin(o);
- n ? t.copyFromFloats(l, r, c) : x.TransformCoordinatesFromFloatsToRef(l, r, c, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this.radius,this.directionRandomizer);
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("height", this.height),
- e.setFloat("radiusRange", this.radiusRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("height", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return "#define CYLINDEREMITTER"
- }
- ,
- e.prototype.getClassName = function() {
- return "CylinderParticleEmitter"
- }
- ,
- e.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
- }
- ,
- e.prototype.parse = function(e) {
- this.radius = e.radius,
- this.height = e.height,
- this.radiusRange = e.radiusRange,
- this.directionRandomizer = e.directionRandomizer
- }
- ,
- e
- }()
- , ff = function(e) {
- function t(t, i, n, r, o) {
- void 0 === t && (t = 1),
- void 0 === i && (i = 1),
- void 0 === n && (n = 1),
- void 0 === r && (r = new x(0,1,0)),
- void 0 === o && (o = new x(0,1,0));
- var a = e.call(this, t, i, n) || this;
- return a.direction1 = r,
- a.direction2 = o,
- a
- }
- return U(t, e),
- t.prototype.startDirectionFunction = function(e, t) {
- var i = d.RandomRange(this.direction1.x, this.direction2.x)
- , n = d.RandomRange(this.direction1.y, this.direction2.y)
- , r = d.RandomRange(this.direction1.z, this.direction2.z);
- x.TransformNormalFromFloatsToRef(i, n, r, e, t)
- }
- ,
- t.prototype.clone = function() {
- var e = new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);
- return fe.DeepCopy(this, e),
- e
- }
- ,
- t.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("height", this.height),
- e.setFloat("radiusRange", this.radiusRange),
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2)
- }
- ,
- t.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("height", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3)
- }
- ,
- t.prototype.getEffectDefines = function() {
- return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER"
- }
- ,
- t.prototype.getClassName = function() {
- return "CylinderDirectedParticleEmitter"
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.direction1 = this.direction1.asArray(),
- t.direction2 = this.direction2.asArray(),
- t
- }
- ,
- t.prototype.parse = function(t) {
- e.prototype.parse.call(this, t),
- this.direction1.copyFrom(t.direction1),
- this.direction2.copyFrom(t.direction2)
- }
- ,
- t
- }(pf)
- , _f = function() {
- function e(e, t, i) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1),
- void 0 === i && (i = 0),
- this.radius = e,
- this.radiusRange = t,
- this.directionRandomizer = i
- }
- return e.prototype.startDirectionFunction = function(e, t, i, n) {
- var r = i.position.subtract(e.getTranslation()).normalize()
- , o = d.RandomRange(0, this.directionRandomizer)
- , a = d.RandomRange(0, this.directionRandomizer)
- , s = d.RandomRange(0, this.directionRandomizer);
- r.x += o,
- r.y += a,
- r.z += s,
- r.normalize(),
- n ? t.copyFrom(r) : x.TransformNormalFromFloatsToRef(r.x, r.y, r.z, e, t)
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- var r = this.radius - d.RandomRange(0, this.radius * this.radiusRange)
- , o = d.RandomRange(0, 1)
- , a = d.RandomRange(0, 2 * Math.PI)
- , s = Math.acos(2 * o - 1)
- , l = r * Math.cos(a) * Math.sin(s)
- , c = r * Math.cos(s)
- , u = r * Math.sin(a) * Math.sin(s);
- n ? t.copyFromFloats(l, Math.abs(c), u) : x.TransformCoordinatesFromFloatsToRef(l, Math.abs(c), u, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this.radius,this.directionRandomizer);
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("radiusRange", this.radiusRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return "#define HEMISPHERICEMITTER"
- }
- ,
- e.prototype.getClassName = function() {
- return "HemisphericParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.radius = this.radius,
- e.radiusRange = this.radiusRange,
- e.directionRandomizer = this.directionRandomizer,
- e
- }
- ,
- e.prototype.parse = function(e) {
- this.radius = e.radius,
- this.radiusRange = e.radiusRange,
- this.directionRandomizer = e.directionRandomizer
- }
- ,
- e
- }()
- , mf = function() {
- function e() {
- this.direction1 = new x(0,1,0),
- this.direction2 = new x(0,1,0)
- }
- return e.prototype.startDirectionFunction = function(e, t, i, n) {
- var r = d.RandomRange(this.direction1.x, this.direction2.x)
- , o = d.RandomRange(this.direction1.y, this.direction2.y)
- , a = d.RandomRange(this.direction1.z, this.direction2.z);
- n ? t.copyFromFloats(r, o, a) : x.TransformNormalFromFloatsToRef(r, o, a, e, t)
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- n ? t.copyFromFloats(0, 0, 0) : x.TransformCoordinatesFromFloatsToRef(0, 0, 0, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return "#define POINTEMITTER"
- }
- ,
- e.prototype.getClassName = function() {
- return "PointParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.direction1 = this.direction1.asArray(),
- e.direction2 = this.direction2.asArray(),
- e
- }
- ,
- e.prototype.parse = function(e) {
- x.FromArrayToRef(e.direction1, 0, this.direction1),
- x.FromArrayToRef(e.direction2, 0, this.direction2)
- }
- ,
- e
- }()
- , gf = function() {
- function e(e, t, i) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1),
- void 0 === i && (i = 0),
- this.radius = e,
- this.radiusRange = t,
- this.directionRandomizer = i
- }
- return e.prototype.startDirectionFunction = function(e, t, i, n) {
- var r = i.position.subtract(e.getTranslation()).normalize()
- , o = d.RandomRange(0, this.directionRandomizer)
- , a = d.RandomRange(0, this.directionRandomizer)
- , s = d.RandomRange(0, this.directionRandomizer);
- r.x += o,
- r.y += a,
- r.z += s,
- r.normalize(),
- n ? t.copyFrom(r) : x.TransformNormalFromFloatsToRef(r.x, r.y, r.z, e, t)
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- var r = this.radius - d.RandomRange(0, this.radius * this.radiusRange)
- , o = d.RandomRange(0, 1)
- , a = d.RandomRange(0, 2 * Math.PI)
- , s = Math.acos(2 * o - 1)
- , l = r * Math.cos(a) * Math.sin(s)
- , c = r * Math.cos(s)
- , u = r * Math.sin(a) * Math.sin(s);
- n ? t.copyFromFloats(l, c, u) : x.TransformCoordinatesFromFloatsToRef(l, c, u, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this.radius,this.directionRandomizer);
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("radiusRange", this.radiusRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return "#define SPHEREEMITTER"
- }
- ,
- e.prototype.getClassName = function() {
- return "SphereParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.radius = this.radius,
- e.radiusRange = this.radiusRange,
- e.directionRandomizer = this.directionRandomizer,
- e
- }
- ,
- e.prototype.parse = function(e) {
- this.radius = e.radius,
- this.radiusRange = e.radiusRange,
- this.directionRandomizer = e.directionRandomizer
- }
- ,
- e
- }()
- , vf = function(e) {
- function t(t, i, n) {
- void 0 === t && (t = 1),
- void 0 === i && (i = new x(0,1,0)),
- void 0 === n && (n = new x(0,1,0));
- var r = e.call(this, t) || this;
- return r.direction1 = i,
- r.direction2 = n,
- r
- }
- return U(t, e),
- t.prototype.startDirectionFunction = function(e, t) {
- var i = d.RandomRange(this.direction1.x, this.direction2.x)
- , n = d.RandomRange(this.direction1.y, this.direction2.y)
- , r = d.RandomRange(this.direction1.z, this.direction2.z);
- x.TransformNormalFromFloatsToRef(i, n, r, e, t)
- }
- ,
- t.prototype.clone = function() {
- var e = new t(this.radius,this.direction1,this.direction2);
- return fe.DeepCopy(this, e),
- e
- }
- ,
- t.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("radiusRange", this.radiusRange),
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2)
- }
- ,
- t.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3)
- }
- ,
- t.prototype.getEffectDefines = function() {
- return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER"
- }
- ,
- t.prototype.getClassName = function() {
- return "SphereDirectedParticleEmitter"
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.direction1 = this.direction1.asArray(),
- t.direction2 = this.direction2.asArray(),
- t
- }
- ,
- t.prototype.parse = function(t) {
- e.prototype.parse.call(this, t),
- this.direction1.copyFrom(t.direction1),
- this.direction2.copyFrom(t.direction2)
- }
- ,
- t
- }(gf)
- , yf = function() {
- function e() {
- this.particlePositionGenerator = function() {}
- ,
- this.particleDestinationGenerator = function() {}
- }
- return e.prototype.startDirectionFunction = function(e, t, i, n) {
- var r = I.Vector3[0];
- if (this.particleDestinationGenerator) {
- this.particleDestinationGenerator(-1, i, r);
- var o = I.Vector3[1];
- r.subtractToRef(i.position, o),
- o.scaleToRef(1 / i.lifeTime, r)
- } else
- r.set(0, 0, 0);
- n ? t.copyFrom(r) : x.TransformNormalToRef(r, e, t)
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- var r = I.Vector3[0];
- this.particlePositionGenerator ? this.particlePositionGenerator(-1, i, r) : r.set(0, 0, 0),
- n ? t.copyFrom(r) : x.TransformCoordinatesToRef(r, e, t)
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {}
- ,
- e.prototype.buildUniformLayout = function(e) {}
- ,
- e.prototype.getEffectDefines = function() {
- return "#define CUSTOMEMITTER"
- }
- ,
- e.prototype.getClassName = function() {
- return "CustomParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e
- }
- ,
- e.prototype.parse = function(e) {}
- ,
- e
- }()
- , bf = function() {
- function e(e) {
- void 0 === e && (e = null),
- this._indices = null,
- this._positions = null,
- this._normals = null,
- this._storedNormal = x.Zero(),
- this._mesh = null,
- this.direction1 = new x(0,1,0),
- this.direction2 = new x(0,1,0),
- this.useMeshNormalsForDirection = !0,
- this.mesh = e
- }
- return Object.defineProperty(e.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(Bi.PositionKind),
- this._normals = e.getVerticesData(Bi.NormalKind)) : (this._indices = null,
- this._positions = null,
- this._normals = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.startDirectionFunction = function(e, t, i, n) {
- if (this.useMeshNormalsForDirection && this._normals)
- x.TransformNormalToRef(this._storedNormal, e, t);
- else {
- var r = d.RandomRange(this.direction1.x, this.direction2.x)
- , o = d.RandomRange(this.direction1.y, this.direction2.y)
- , a = d.RandomRange(this.direction1.z, this.direction2.z);
- n ? t.copyFromFloats(r, o, a) : x.TransformNormalFromFloatsToRef(r, o, a, e, t)
- }
- }
- ,
- e.prototype.startPositionFunction = function(e, t, i, n) {
- if (this._indices && this._positions) {
- var r = 3 * Math.random() * (this._indices.length / 3) | 0
- , o = Math.random()
- , a = Math.random() * (1 - o)
- , s = 1 - o - a
- , l = this._indices[r]
- , c = this._indices[r + 1]
- , u = this._indices[r + 2]
- , h = I.Vector3[0]
- , d = I.Vector3[1]
- , p = I.Vector3[2]
- , f = I.Vector3[3];
- x.FromArrayToRef(this._positions, 3 * l, h),
- x.FromArrayToRef(this._positions, 3 * c, d),
- x.FromArrayToRef(this._positions, 3 * u, p),
- f.x = o * h.x + a * d.x + s * p.x,
- f.y = o * h.y + a * d.y + s * p.y,
- f.z = o * h.z + a * d.z + s * p.z,
- n ? t.copyFromFloats(f.x, f.y, f.z) : x.TransformCoordinatesFromFloatsToRef(f.x, f.y, f.z, e, t),
- this.useMeshNormalsForDirection && this._normals && (x.FromArrayToRef(this._normals, 3 * l, h),
- x.FromArrayToRef(this._normals, 3 * c, d),
- x.FromArrayToRef(this._normals, 3 * u, p),
- this._storedNormal.x = o * h.x + a * d.x + s * p.x,
- this._storedNormal.y = o * h.y + a * d.y + s * p.y,
- this._storedNormal.z = o * h.z + a * d.z + s * p.z)
- }
- }
- ,
- e.prototype.clone = function() {
- var t = new e(this.mesh);
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.applyToShader = function(e) {
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2)
- }
- ,
- e.prototype.buildUniformLayout = function(e) {
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return ""
- }
- ,
- e.prototype.getClassName = function() {
- return "MeshParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var e, t = {};
- return t.type = this.getClassName(),
- t.direction1 = this.direction1.asArray(),
- t.direction2 = this.direction2.asArray(),
- t.meshId = null === (e = this.mesh) || void 0 === e ? void 0 : e.id,
- t.useMeshNormalsForDirection = this.useMeshNormalsForDirection,
- t
- }
- ,
- e.prototype.parse = function(e, t) {
- x.FromArrayToRef(e.direction1, 0, this.direction1),
- x.FromArrayToRef(e.direction2, 0, this.direction2),
- e.meshId && t && (this.mesh = t.getLastMeshById(e.meshId)),
- this.useMeshNormalsForDirection = e.useMeshNormalsForDirection
- }
- ,
- e
- }()
- , Tf = function() {
- function e(t) {
- this.animations = [],
- this.renderingGroupId = 0,
- this.emitter = x.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 x(10,10,10),
- this.onAnimationEnd = null,
- this.blendMode = e.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 A(0,0),
- this.beginAnimationOnStart = !1,
- this.beginAnimationFrom = 0,
- this.beginAnimationTo = 60,
- this.beginAnimationLoop = !1,
- this.worldOffset = new x(0,0,0),
- this.gravity = x.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 N(1,1,1,1),
- this.color2 = new N(1,1,1,1),
- this.colorDead = new N(0,0,0,1),
- this.textureMask = new N(1,1,1,1),
- this._isSubEmitter = !1,
- this._billboardMode = a.PARTICLES_BILLBOARDMODE_ALL,
- this._isBillboardBased = !0,
- this._imageProcessingConfigurationDefines = new xi,
- this.id = t,
- this.name = t
- }
- return Object.defineProperty(e.prototype, "noiseTexture", {
- get: function() {
- return this._noiseTexture
- },
- set: function(e) {
- this._noiseTexture !== e && (this._noiseTexture = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isAnimationSheetEnabled", {
- get: function() {
- return this._isAnimationSheetEnabled
- },
- set: function(e) {
- this._isAnimationSheetEnabled != e && (this._isAnimationSheetEnabled = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype._hasTargetStopDurationDependantGradient = function() {
- return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0
- }
- ,
- e.prototype.getDragGradients = function() {
- return this._dragGradients
- }
- ,
- e.prototype.getLimitVelocityGradients = function() {
- return this._limitVelocityGradients
- }
- ,
- e.prototype.getColorGradients = function() {
- return this._colorGradients
- }
- ,
- e.prototype.getSizeGradients = function() {
- return this._sizeGradients
- }
- ,
- e.prototype.getColorRemapGradients = function() {
- return this._colorRemapGradients
- }
- ,
- e.prototype.getAlphaRemapGradients = function() {
- return this._alphaRemapGradients
- }
- ,
- e.prototype.getLifeTimeGradients = function() {
- return this._lifeTimeGradients
- }
- ,
- e.prototype.getAngularSpeedGradients = function() {
- return this._angularSpeedGradients
- }
- ,
- e.prototype.getVelocityGradients = function() {
- return this._velocityGradients
- }
- ,
- e.prototype.getStartSizeGradients = function() {
- return this._startSizeGradients
- }
- ,
- e.prototype.getEmitRateGradients = function() {
- return this._emitRateGradients
- }
- ,
- Object.defineProperty(e.prototype, "direction1", {
- get: function() {
- return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : x.Zero()
- },
- set: function(e) {
- this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "direction2", {
- get: function() {
- return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : x.Zero()
- },
- set: function(e) {
- this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "minEmitBox", {
- get: function() {
- return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : x.Zero()
- },
- set: function(e) {
- this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "maxEmitBox", {
- get: function() {
- return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : x.Zero()
- },
- set: function(e) {
- this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "billboardMode", {
- get: function() {
- return this._billboardMode
- },
- set: function(e) {
- this._billboardMode !== e && (this._billboardMode = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isBillboardBased", {
- get: function() {
- return this._isBillboardBased
- },
- set: function(e) {
- this._isBillboardBased !== e && (this._isBillboardBased = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- this._attachImageProcessingConfiguration(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachImageProcessingConfiguration = function(e) {
- e !== this._imageProcessingConfiguration && (!e && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = e)
- }
- ,
- e.prototype._reset = function() {}
- ,
- e.prototype._removeGradientAndTexture = function(e, t, i) {
- if (!t)
- return this;
- for (var n = 0, r = 0, o = t; r < o.length; r++) {
- if (o[r].gradient === e) {
- t.splice(n, 1);
- break
- }
- n++
- }
- return i && i.dispose(),
- this
- }
- ,
- e.prototype.createPointEmitter = function(e, t) {
- var i = new mf;
- return i.direction1 = e,
- i.direction2 = t,
- this.particleEmitterType = i,
- i
- }
- ,
- e.prototype.createHemisphericEmitter = function(e, t) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1);
- var i = new _f(e,t);
- return this.particleEmitterType = i,
- i
- }
- ,
- e.prototype.createSphereEmitter = function(e, t) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1);
- var i = new gf(e,t);
- return this.particleEmitterType = i,
- i
- }
- ,
- e.prototype.createDirectedSphereEmitter = function(e, t, i) {
- void 0 === e && (e = 1),
- void 0 === t && (t = new x(0,1,0)),
- void 0 === i && (i = new x(0,1,0));
- var n = new vf(e,t,i);
- return this.particleEmitterType = n,
- n
- }
- ,
- e.prototype.createCylinderEmitter = function(e, t, i, n) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1),
- void 0 === i && (i = 1),
- void 0 === n && (n = 0);
- var r = new pf(e,t,i,n);
- return this.particleEmitterType = r,
- r
- }
- ,
- e.prototype.createDirectedCylinderEmitter = function(e, t, i, n, r) {
- void 0 === e && (e = 1),
- void 0 === t && (t = 1),
- void 0 === i && (i = 1),
- void 0 === n && (n = new x(0,1,0)),
- void 0 === r && (r = new x(0,1,0));
- var o = new ff(e,t,i,n,r);
- return this.particleEmitterType = o,
- o
- }
- ,
- e.prototype.createConeEmitter = function(e, t) {
- void 0 === e && (e = 1),
- void 0 === t && (t = Math.PI / 4);
- var i = new df(e,t);
- return this.particleEmitterType = i,
- i
- }
- ,
- e.prototype.createBoxEmitter = function(e, t, i, n) {
- var r = new hf;
- return this.particleEmitterType = r,
- this.direction1 = e,
- this.direction2 = t,
- this.minEmitBox = i,
- this.maxEmitBox = n,
- r
- }
- ,
- e.BLENDMODE_ONEONE = 0,
- e.BLENDMODE_STANDARD = 1,
- e.BLENDMODE_ADD = 2,
- e.BLENDMODE_MULTIPLY = 3,
- e.BLENDMODE_MULTIPLYADD = 4,
- e
- }()
- , Ef = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("rgba", Op.Color4, !0),
- i.registerInput("rgb ", Op.Color3, !0),
- i.registerOutput("rgb", Op.Color3),
- i.registerOutput("r", Op.Float),
- i.registerOutput("g", Op.Float),
- i.registerOutput("b", Op.Float),
- i.registerOutput("a", Op.Float),
- i.inputsAreExclusive = !0,
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ColorSplitterBlock"
- }
- ,
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgbIn", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgbOut", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "r", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "g", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._inputRename = function(e) {
- return "rgb " === e ? "rgbIn" : e
- }
- ,
- t.prototype._outputRename = function(e) {
- return "rgb" === e ? "rgbOut" : e
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.rgba.isConnected ? this.rgba : this.rgbIn;
- if (i.isConnected) {
- var n = this._outputs[0]
- , r = this._outputs[1]
- , o = this._outputs[2]
- , a = this._outputs[3]
- , s = this._outputs[4];
- return n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".rgb;\r\n")),
- r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".r;\r\n")),
- o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = ".concat(i.associatedVariableName, ".g;\r\n")),
- a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".b;\r\n")),
- s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".a;\r\n")),
- this
- }
- }
- ,
- t
- }(Wp);
- y("BABYLON.ColorSplitterBlock", Ef);
- var Sf = function() {
- function e(e) {
- this.name = Wi.NAME_PROCEDURALTEXTURE,
- this.scene = e,
- this.scene.proceduralTextures = new Array
- }
- return e.prototype.register = function() {
- this.scene._beforeClearStage.registerStep(Wi.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {}
- ,
- e.prototype._beforeClear = function() {
- if (this.scene.proceduralTexturesEnabled) {
- gi.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
- for (var e = 0; e < this.scene.proceduralTextures.length; e++) {
- var t = this.scene.proceduralTextures[e];
- t._shouldRender() && t.render()
- }
- gi.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0)
- }
- }
- ,
- e
- }();
- Pt.ShadersStore.proceduralVertexShader = "attribute vec2 position;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var Af, xf = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === o && (o = null),
- void 0 === s && (s = !0),
- void 0 === l && (l = !1),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
- var u = e.call(this, null, r, !s) || this;
- u.isEnabled = !0,
- u.autoClear = !0,
- u.onGeneratedObservable = new h,
- u.onBeforeGenerationObservable = new h,
- u.nodeMaterialSource = null,
- u._textures = {},
- u._currentRefreshId = -1,
- u._frameId = -1,
- u._refreshRate = 1,
- u._vertexBuffers = {},
- u._uniforms = new Array,
- u._samplers = new Array,
- u._floats = {},
- u._ints = {},
- u._floatsArrays = {},
- u._colors3 = {},
- u._colors4 = {},
- u._vectors2 = {},
- u._vectors3 = {},
- u._matrices = {},
- u._fallbackTextureUsed = !1,
- u._cachedDefines = null,
- u._contentUpdateId = -1,
- u._rtWrapper = null;
- var d = (r = u.getScene() || E.LastCreatedScene)._getComponent(Wi.NAME_PROCEDURALTEXTURE);
- d || (d = new Sf(r),
- r._addComponent(d)),
- r.proceduralTextures.push(u),
- u._fullEngine = r.getEngine(),
- u.name = t,
- u.isRenderTarget = !0,
- u._size = i,
- u._textureType = c,
- u._generateMipMaps = s,
- u._drawWrapper = new Gt(u._fullEngine),
- u.setFragment(n),
- u._fallbackTexture = o;
- var p = u._createRtWrapper(l, i, s, c);
- u._texture = p.texture;
- var f = [];
- return f.push(1, 1),
- f.push(-1, 1),
- f.push(-1, -1),
- f.push(1, -1),
- u._vertexBuffers[Bi.PositionKind] = new Bi(u._fullEngine,f,Bi.PositionKind,!1,!1,2),
- u._createIndexBuffer(),
- u
- }
- return U(t, e),
- t.prototype._createRtWrapper = function(e, t, i, n) {
- return e ? (this._rtWrapper = this._fullEngine.createRenderTargetCubeTexture(t, {
- generateMipMaps: i,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- type: n
- }),
- this.setFloat("face", 0)) : this._rtWrapper = this._fullEngine.createRenderTargetTexture(t, {
- generateMipMaps: i,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- type: n
- }),
- this._rtWrapper
- }
- ,
- t.prototype.getEffect = function() {
- return this._drawWrapper.effect
- }
- ,
- t.prototype._setEffect = function(e) {
- this._drawWrapper.effect = e
- }
- ,
- t.prototype.getContent = function() {
- var e = this;
- return this._contentData && this._frameId === this._contentUpdateId || (this._contentData ? this._contentData.then((function(t) {
- e._contentData = e.readPixels(0, 0, t),
- e._contentUpdateId = e._frameId
- }
- )) : (this._contentData = this.readPixels(0, 0),
- this._contentUpdateId = this._frameId)),
- this._contentData
- }
- ,
- t.prototype._createIndexBuffer = function() {
- var e = this._fullEngine
- , t = [];
- t.push(0),
- t.push(1),
- t.push(2),
- t.push(0),
- t.push(2),
- t.push(3),
- this._indexBuffer = e.createIndexBuffer(t)
- }
- ,
- t.prototype._rebuild = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && e._rebuild(),
- this._createIndexBuffer(),
- this.refreshRate === ns.REFRESHRATE_RENDER_ONCE && (this.refreshRate = ns.REFRESHRATE_RENDER_ONCE)
- }
- ,
- t.prototype.reset = function() {
- var e;
- null === (e = this._drawWrapper.effect) || void 0 === e || e.dispose()
- }
- ,
- t.prototype._getDefines = function() {
- return ""
- }
- ,
- t.prototype.isReady = function() {
- var e, t = this, i = this._fullEngine;
- if (this.nodeMaterialSource)
- return this._drawWrapper.effect.isReady();
- if (!this._fragment)
- return !1;
- if (this._fallbackTextureUsed)
- return !0;
- if (!this._texture)
- return !1;
- var n = this._getDefines();
- return !(!this._drawWrapper.effect || n !== this._cachedDefines || !this._drawWrapper.effect.isReady()) || (e = void 0 !== this._fragment.fragmentElement ? {
- vertex: "procedural",
- fragmentElement: this._fragment.fragmentElement
- } : {
- vertex: "procedural",
- fragment: this._fragment
- },
- this._cachedDefines !== n && (this._cachedDefines = n,
- this._drawWrapper.effect = i.createEffect(e, [Bi.PositionKind], this._uniforms, this._samplers, n, void 0, void 0, (function() {
- var e;
- null === (e = t._rtWrapper) || void 0 === e || e.dispose(),
- t._rtWrapper = t._texture = null,
- t._fallbackTexture && (t._texture = t._fallbackTexture._texture,
- t._texture && t._texture.incrementReferences()),
- t._fallbackTextureUsed = !0
- }
- ))),
- this._drawWrapper.effect.isReady())
- }
- ,
- t.prototype.resetRefreshCounter = function() {
- this._currentRefreshId = -1
- }
- ,
- t.prototype.setFragment = function(e) {
- this._fragment = e
- }
- ,
- Object.defineProperty(t.prototype, "refreshRate", {
- get: function() {
- return this._refreshRate
- },
- set: function(e) {
- this._refreshRate = e,
- this.resetRefreshCounter()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._shouldRender = function() {
- return this.isEnabled && this.isReady() && this._texture ? !this._fallbackTextureUsed && (-1 === this._currentRefreshId || this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
- this._frameId++,
- !0) : (this._currentRefreshId++,
- !1)) : (this._texture && (this._texture.isReady = !1),
- !1)
- }
- ,
- t.prototype.getRenderSize = function() {
- return this._size
- }
- ,
- t.prototype.resize = function(e, t) {
- if (!this._fallbackTextureUsed && this._rtWrapper && this._texture) {
- var i = this._texture.isCube;
- this._rtWrapper.dispose();
- var n = this._createRtWrapper(i, e, t, this._textureType);
- this._texture = n.texture,
- this._size = e,
- this._generateMipMaps = t
- }
- }
- ,
- t.prototype._checkUniform = function(e) {
- -1 === this._uniforms.indexOf(e) && this._uniforms.push(e)
- }
- ,
- t.prototype.setTexture = function(e, t) {
- return -1 === this._samplers.indexOf(e) && this._samplers.push(e),
- this._textures[e] = t,
- this
- }
- ,
- t.prototype.setFloat = function(e, t) {
- return this._checkUniform(e),
- this._floats[e] = t,
- this
- }
- ,
- t.prototype.setInt = function(e, t) {
- return this._checkUniform(e),
- this._ints[e] = t,
- this
- }
- ,
- t.prototype.setFloats = function(e, t) {
- return this._checkUniform(e),
- this._floatsArrays[e] = t,
- this
- }
- ,
- t.prototype.setColor3 = function(e, t) {
- return this._checkUniform(e),
- this._colors3[e] = t,
- this
- }
- ,
- t.prototype.setColor4 = function(e, t) {
- return this._checkUniform(e),
- this._colors4[e] = t,
- this
- }
- ,
- t.prototype.setVector2 = function(e, t) {
- return this._checkUniform(e),
- this._vectors2[e] = t,
- this
- }
- ,
- t.prototype.setVector3 = function(e, t) {
- return this._checkUniform(e),
- this._vectors3[e] = t,
- this
- }
- ,
- t.prototype.setMatrix = function(e, t) {
- return this._checkUniform(e),
- this._matrices[e] = t,
- this
- }
- ,
- t.prototype.render = function(e) {
- var t, i, n = this.getScene();
- if (n) {
- var r = this._fullEngine;
- if (r.enableEffect(this._drawWrapper),
- this.onBeforeGenerationObservable.notifyObservers(this),
- r.setState(!1),
- !this.nodeMaterialSource) {
- for (var o in this._textures)
- this._drawWrapper.effect.setTexture(o, this._textures[o]);
- for (var a in this._ints)
- this._drawWrapper.effect.setInt(a, this._ints[a]);
- for (var s in this._floats)
- this._drawWrapper.effect.setFloat(s, this._floats[s]);
- for (var l in this._floatsArrays)
- this._drawWrapper.effect.setArray(l, this._floatsArrays[l]);
- for (var c in this._colors3)
- this._drawWrapper.effect.setColor3(c, this._colors3[c]);
- for (var u in this._colors4) {
- var h = this._colors4[u];
- this._drawWrapper.effect.setFloat4(u, h.r, h.g, h.b, h.a)
- }
- for (var d in this._vectors2)
- this._drawWrapper.effect.setVector2(d, this._vectors2[d]);
- for (var p in this._vectors3)
- this._drawWrapper.effect.setVector3(p, this._vectors3[p]);
- for (var f in this._matrices)
- this._drawWrapper.effect.setMatrix(f, this._matrices[f])
- }
- if (this._texture && this._rtWrapper) {
- if (null === (t = r._debugPushGroup) || void 0 === t || t.call(r, "procedural texture generation for ".concat(this.name), 1),
- this.isCube)
- for (var _ = 0; _ < 6; _++)
- r.bindFramebuffer(this._rtWrapper, _, void 0, void 0, !0),
- r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
- this._drawWrapper.effect.setFloat("face", _),
- this.autoClear && r.clear(n.clearColor, !0, !1, !1),
- r.drawElementsType(Or.TriangleFillMode, 0, 6);
- else
- r.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0),
- r.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
- this.autoClear && r.clear(n.clearColor, !0, !1, !1),
- r.drawElementsType(Or.TriangleFillMode, 0, 6);
- r.unBindFramebuffer(this._rtWrapper, this.isCube),
- this.isCube && r.generateMipMapsForCubemap(this._texture),
- null === (i = r._debugPopGroup) || void 0 === i || i.call(r, 1),
- this.onGenerated && this.onGenerated(),
- this.onGeneratedObservable.notifyObservers(this)
- }
- }
- }
- ,
- t.prototype.clone = function() {
- var e = this.getSize()
- , i = new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);
- return i.hasAlpha = this.hasAlpha,
- i.level = this.level,
- i.coordinatesMode = this.coordinatesMode,
- i
- }
- ,
- t.prototype.dispose = function() {
- var t = this.getScene();
- if (t) {
- var i = t.proceduralTextures.indexOf(this);
- i >= 0 && t.proceduralTextures.splice(i, 1);
- var n = this._vertexBuffers[Bi.PositionKind];
- n && (n.dispose(),
- this._vertexBuffers[Bi.PositionKind] = null),
- this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null),
- this.onGeneratedObservable.clear(),
- this.onBeforeGenerationObservable.clear(),
- e.prototype.dispose.call(this)
- }
- }
- ,
- k([Ce()], t.prototype, "isEnabled", void 0),
- k([Ce()], t.prototype, "autoClear", void 0),
- k([Ce()], t.prototype, "_generateMipMaps", void 0),
- k([Ce()], t.prototype, "_size", void 0),
- k([Ce()], t.prototype, "refreshRate", null),
- t
- }(io);
- y("BABYLON.ProceduralTexture", xf),
- function(e) {
- e[e.Cos = 0] = "Cos",
- e[e.Sin = 1] = "Sin",
- e[e.Abs = 2] = "Abs",
- e[e.Exp = 3] = "Exp",
- e[e.Exp2 = 4] = "Exp2",
- e[e.Round = 5] = "Round",
- e[e.Floor = 6] = "Floor",
- e[e.Ceiling = 7] = "Ceiling",
- e[e.Sqrt = 8] = "Sqrt",
- e[e.Log = 9] = "Log",
- e[e.Tan = 10] = "Tan",
- e[e.ArcTan = 11] = "ArcTan",
- e[e.ArcCos = 12] = "ArcCos",
- e[e.ArcSin = 13] = "ArcSin",
- e[e.Fract = 14] = "Fract",
- e[e.Sign = 15] = "Sign",
- e[e.Radians = 16] = "Radians",
- e[e.Degrees = 17] = "Degrees"
- }(Af || (Af = {}));
- var Rf = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.operation = Af.Cos,
- i.registerInput("input", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "TrigonometryBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = "";
- switch (this.operation) {
- case Af.Cos:
- n = "cos";
- break;
- case Af.Sin:
- n = "sin";
- break;
- case Af.Abs:
- n = "abs";
- break;
- case Af.Exp:
- n = "exp";
- break;
- case Af.Exp2:
- n = "exp2";
- break;
- case Af.Round:
- n = "round";
- break;
- case Af.Floor:
- n = "floor";
- break;
- case Af.Ceiling:
- n = "ceil";
- break;
- case Af.Sqrt:
- n = "sqrt";
- break;
- case Af.Log:
- n = "log";
- break;
- case Af.Tan:
- n = "tan";
- break;
- case Af.ArcTan:
- n = "atan";
- break;
- case Af.ArcCos:
- n = "acos";
- break;
- case Af.ArcSin:
- n = "asin";
- break;
- case Af.Fract:
- n = "fract";
- break;
- case Af.Sign:
- n = "sign";
- break;
- case Af.Radians:
- n = "radians";
- break;
- case Af.Degrees:
- n = "degrees"
- }
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(n, "(").concat(this.input.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.operation = this.operation,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.operation = t.operation
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".operation = BABYLON.TrigonometryBlockOperations.").concat(Af[this.operation], ";\r\n")
- }
- ,
- t
- }(Wp);
- y("BABYLON.TrigonometryBlock", Rf);
- var Cf, Pf, Mf = {
- effect: null,
- subMesh: null
- }, If = function(e) {
- function t() {
- var t = e.call(this) || this;
- return t.NORMAL = !1,
- t.TANGENT = !1,
- t.UV1 = !1,
- t.UV2 = !1,
- t.UV3 = !1,
- t.UV4 = !1,
- t.UV5 = !1,
- t.UV6 = !1,
- t.NUM_BONE_INFLUENCERS = 0,
- t.BonesPerMesh = 0,
- t.BONETEXTURE = !1,
- t.MORPHTARGETS = !1,
- t.MORPHTARGETS_NORMAL = !1,
- t.MORPHTARGETS_TANGENT = !1,
- t.MORPHTARGETS_UV = !1,
- t.NUM_MORPH_INFLUENCERS = 0,
- t.MORPHTARGETS_TEXTURE = !1,
- t.IMAGEPROCESSING = !1,
- t.VIGNETTE = !1,
- t.VIGNETTEBLENDMODEMULTIPLY = !1,
- t.VIGNETTEBLENDMODEOPAQUE = !1,
- t.TONEMAPPING = !1,
- t.TONEMAPPING_ACES = !1,
- t.CONTRAST = !1,
- t.EXPOSURE = !1,
- t.COLORCURVES = !1,
- t.COLORGRADING = !1,
- t.COLORGRADING3D = !1,
- t.SAMPLER3DGREENDEPTH = !1,
- t.SAMPLER3DBGRMAP = !1,
- t.IMAGEPROCESSINGPOSTPROCESS = !1,
- t.SKIPFINALCOLORCLAMP = !1,
- t.BUMPDIRECTUV = 0,
- t.rebuild(),
- t
- }
- return U(t, e),
- t.prototype.setValue = function(e, t, i) {
- void 0 === i && (i = !1),
- void 0 === this[e] && this._keys.push(e),
- i && this[e] !== t && this.markAsUnprocessed(),
- this[e] = t
- }
- ,
- t
- }(Si), Of = function(e) {
- function t(i, n, r) {
- void 0 === r && (r = {});
- var o = e.call(this, i, n || E.LastCreatedScene) || this;
- return o._buildId = t._BuildIdGenerator++,
- o._buildWasSuccessful = !1,
- o._cachedWorldViewMatrix = new P,
- o._cachedWorldViewProjectionMatrix = new P,
- o._optimizers = new Array,
- o._animationFrame = -1,
- o.BJSNODEMATERIALEDITOR = o._getGlobalNodeMaterialEditor(),
- o.editorData = null,
- o.ignoreAlpha = !1,
- o.maxSimultaneousLights = 4,
- o.onBuildObservable = new h,
- o._vertexOutputNodes = new Array,
- o._fragmentOutputNodes = new Array,
- o.attachedBlocks = new Array,
- o._mode = cf.Material,
- o.forceAlphaBlending = !1,
- o._options = V({
- emitComments: !1
- }, r),
- o._attachImageProcessingConfiguration(null),
- o
- }
- return U(t, e),
- t.prototype._getGlobalNodeMaterialEditor = function() {
- return "undefined" != typeof NODEEDITOR ? NODEEDITOR : "undefined" != typeof BABYLON && void 0 !== BABYLON.NodeEditor ? BABYLON : void 0
- }
- ,
- Object.defineProperty(t.prototype, "options", {
- get: function() {
- return this._options
- },
- set: function(e) {
- this._options = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- this._attachImageProcessingConfiguration(e),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "mode", {
- get: function() {
- return this._mode
- },
- set: function(e) {
- this._mode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "buildId", {
- get: function() {
- return this._buildId
- },
- set: function(e) {
- this._buildId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "NodeMaterial"
- }
- ,
- t.prototype._attachImageProcessingConfiguration = function(e) {
- var t = this;
- e !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingConfiguration = e || this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add((function() {
- t._markAllSubMeshesAsImageProcessingDirty()
- }
- ))))
- }
- ,
- t.prototype.getBlockByName = function(e) {
- for (var t = null, i = 0, n = this.attachedBlocks; i < n.length; i++) {
- var r = n[i];
- if (r.name === e) {
- if (t)
- return gi.Warn("More than one block was found with the name `" + e + "`"),
- t;
- t = r
- }
- }
- return t
- }
- ,
- t.prototype.getBlockByPredicate = function(e) {
- for (var t = 0, i = this.attachedBlocks; t < i.length; t++) {
- var n = i[t];
- if (e(n))
- return n
- }
- return null
- }
- ,
- t.prototype.getInputBlockByPredicate = function(e) {
- for (var t = 0, i = this.attachedBlocks; t < i.length; t++) {
- var n = i[t];
- if (n.isInput && e(n))
- return n
- }
- return null
- }
- ,
- t.prototype.getInputBlocks = function() {
- for (var e = [], t = 0, i = this.attachedBlocks; t < i.length; t++) {
- var n = i[t];
- n.isInput && e.push(n)
- }
- return e
- }
- ,
- t.prototype.registerOptimizer = function(e) {
- if (!(this._optimizers.indexOf(e) > -1))
- return this._optimizers.push(e),
- this
- }
- ,
- t.prototype.unregisterOptimizer = function(e) {
- var t = this._optimizers.indexOf(e);
- if (-1 !== t)
- return this._optimizers.splice(t, 1),
- this
- }
- ,
- t.prototype.addOutputNode = function(e) {
- if (null === e.target)
- throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
- return 0 != (e.target & Dp.Vertex) && this._addVertexOutputNode(e),
- 0 != (e.target & Dp.Fragment) && this._addFragmentOutputNode(e),
- this
- }
- ,
- t.prototype.removeOutputNode = function(e) {
- return null === e.target || (0 != (e.target & Dp.Vertex) && this._removeVertexOutputNode(e),
- 0 != (e.target & Dp.Fragment) && this._removeFragmentOutputNode(e)),
- this
- }
- ,
- t.prototype._addVertexOutputNode = function(e) {
- if (-1 === this._vertexOutputNodes.indexOf(e))
- return e.target = Dp.Vertex,
- this._vertexOutputNodes.push(e),
- this
- }
- ,
- t.prototype._removeVertexOutputNode = function(e) {
- var t = this._vertexOutputNodes.indexOf(e);
- if (-1 !== t)
- return this._vertexOutputNodes.splice(t, 1),
- this
- }
- ,
- t.prototype._addFragmentOutputNode = function(e) {
- if (-1 === this._fragmentOutputNodes.indexOf(e))
- return e.target = Dp.Fragment,
- this._fragmentOutputNodes.push(e),
- this
- }
- ,
- t.prototype._removeFragmentOutputNode = function(e) {
- var t = this._fragmentOutputNodes.indexOf(e);
- if (-1 !== t)
- return this._fragmentOutputNodes.splice(t, 1),
- this
- }
- ,
- t.prototype.needAlphaBlending = function() {
- return !this.ignoreAlpha && (this.forceAlphaBlending || this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending)
- }
- ,
- t.prototype.needAlphaTesting = function() {
- return this._sharedData && this._sharedData.hints.needAlphaTesting
- }
- ,
- t.prototype._initializeBlock = function(e, t, i, n) {
- if (void 0 === n && (n = !0),
- e.initialize(t),
- n && e.autoConfigure(this),
- e._preparationId = this._buildId,
- -1 === this.attachedBlocks.indexOf(e)) {
- if (e.isUnique)
- for (var r = e.getClassName(), o = 0, a = this.attachedBlocks; o < a.length; o++)
- if (a[o].getClassName() === r)
- throw "Cannot have multiple blocks of type ".concat(r, " in the same NodeMaterial");
- this.attachedBlocks.push(e)
- }
- for (var s = 0, l = e.inputs; s < l.length; s++) {
- var c = l[s];
- c.associatedVariableName = "";
- var u = c.connectedPoint;
- if (u) {
- var h = u.ownerBlock;
- h !== e && ((h.target === Dp.VertexAndFragment || t.target === Dp.Fragment && h.target === Dp.Vertex && h._preparationId !== this._buildId) && i.push(h),
- this._initializeBlock(h, t, i, n))
- }
- }
- for (var d = 0, p = e.outputs; d < p.length; d++)
- p[d].associatedVariableName = ""
- }
- ,
- t.prototype._resetDualBlocks = function(e, t) {
- e.target === Dp.VertexAndFragment && (e.buildId = t);
- for (var i = 0, n = e.inputs; i < n.length; i++) {
- var r = n[i].connectedPoint;
- if (r) {
- var o = r.ownerBlock;
- o !== e && this._resetDualBlocks(o, t)
- }
- }
- }
- ,
- t.prototype.removeBlock = function(e) {
- var t = this.attachedBlocks.indexOf(e);
- t > -1 && this.attachedBlocks.splice(t, 1),
- e.isFinalMerger && this.removeOutputNode(e)
- }
- ,
- t.prototype.build = function(e, i, n) {
- void 0 === e && (e = !1),
- void 0 === i && (i = !0),
- void 0 === n && (n = !0),
- this._buildWasSuccessful = !1;
- var r = this.getScene().getEngine()
- , o = this._mode === cf.Particle;
- if (0 === this._vertexOutputNodes.length && !o)
- throw "You must define at least one vertexOutputNode";
- if (0 === this._fragmentOutputNodes.length)
- throw "You must define at least one fragmentOutputNode";
- this._vertexCompilationState = new kp,
- this._vertexCompilationState.supportUniformBuffers = r.supportsUniformBuffers,
- this._vertexCompilationState.target = Dp.Vertex,
- this._fragmentCompilationState = new kp,
- this._fragmentCompilationState.supportUniformBuffers = r.supportsUniformBuffers,
- this._fragmentCompilationState.target = Dp.Fragment,
- this._sharedData = new Gp,
- 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 = e,
- this._sharedData.scene = this.getScene(),
- this._sharedData.allowEmptyVertexProgram = o;
- for (var a = [], s = [], l = 0, c = this._vertexOutputNodes; l < c.length; l++) {
- var u = c[l];
- a.push(u),
- this._initializeBlock(u, this._vertexCompilationState, s, n)
- }
- for (var h = 0, d = this._fragmentOutputNodes; h < d.length; h++) {
- var p = d[h];
- s.push(p),
- this._initializeBlock(p, this._fragmentCompilationState, a, n)
- }
- this.optimize();
- for (var f = 0, _ = a; f < _.length; f++)
- (u = _[f]).build(this._vertexCompilationState, a);
- 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 m = 0, g = s; m < g.length; m++)
- p = g[m],
- this._resetDualBlocks(p, this._buildId - 1);
- for (var v = 0, y = s; v < y.length; v++)
- (p = y[v]).build(this._fragmentCompilationState, s);
- this._vertexCompilationState.finalize(this._vertexCompilationState),
- this._fragmentCompilationState.finalize(this._fragmentCompilationState),
- i && (this._buildId = t._BuildIdGenerator++),
- this._sharedData.emitErrors(),
- e && (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 b = 0, T = this.getScene().meshes; b < T.length; b++) {
- var E = T[b];
- if (E.subMeshes)
- for (var S = 0, A = E.subMeshes; S < A.length; S++) {
- var x = A[S];
- if (x.getMaterial() === this && x.materialDefines) {
- var R = x.materialDefines;
- R.markAllAsDirty(),
- R.reset()
- }
- }
- }
- }
- ,
- t.prototype.optimize = function() {
- for (var e = 0, t = this._optimizers; e < t.length; e++)
- t[e].optimize(this._vertexOutputNodes, this._fragmentOutputNodes)
- }
- ,
- t.prototype._prepareDefinesForAttributes = function(e, t) {
- var i = t.NORMAL
- , n = t.TANGENT;
- t.NORMAL = e.isVerticesDataPresent(Bi.NormalKind),
- t.TANGENT = e.isVerticesDataPresent(Bi.TangentKind);
- for (var r = !1, o = 1; o <= a.MAX_SUPPORTED_UV_SETS; ++o) {
- var s = t["UV" + o];
- t["UV" + o] = e.isVerticesDataPresent("uv".concat(1 === o ? "" : o)),
- r = r || t["UV" + o] !== s
- }
- (i !== t.NORMAL || n !== t.TANGENT || r) && t.markAsAttributesDirty()
- }
- ,
- t.prototype.createPostProcess = function(e, t, i, n, r, o, s) {
- return void 0 === t && (t = 1),
- void 0 === i && (i = a.TEXTURE_NEAREST_SAMPLINGMODE),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === s && (s = a.TEXTUREFORMAT_RGBA),
- this.mode !== cf.PostProcess ? (console.log("Incompatible material mode"),
- null) : this._createEffectForPostProcess(null, e, t, i, n, r, o, s)
- }
- ,
- t.prototype.createEffectForPostProcess = function(e) {
- this._createEffectForPostProcess(e)
- }
- ,
- t.prototype._createEffectForPostProcess = function(e, t, i, n, r, o, s, l) {
- var c = this;
- void 0 === i && (i = 1),
- void 0 === n && (n = a.TEXTURE_NEAREST_SAMPLINGMODE),
- void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === l && (l = a.TEXTUREFORMAT_RGBA);
- var u = this.name + this._buildId
- , h = new If
- , d = new Sr(u + "PostProcess",this.getScene())
- , p = this._buildId;
- return this._processDefines(d, h),
- Mt.RegisterShader(u, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString),
- e ? e.updateEffect(h.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, {
- maxSimultaneousLights: this.maxSimultaneousLights
- }, void 0, void 0, u, u) : e = new Ba(this.name + "PostProcess",u,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,n,r,o,h.toString(),s,u,{
- maxSimultaneousLights: this.maxSimultaneousLights
- },!1,l),
- e.nodeMaterialSource = this,
- e.onApplyObservable.add((function(t) {
- p !== c._buildId && (delete Mt.ShadersStore[u + "VertexShader"],
- delete Mt.ShadersStore[u + "PixelShader"],
- u = c.name + c._buildId,
- h.markAllAsDirty(),
- p = c._buildId),
- c._processDefines(d, h) && (Mt.RegisterShader(u, c._fragmentCompilationState._builtCompilationString, c._vertexCompilationState._builtCompilationString),
- Xt.SetImmediate((function() {
- return e.updateEffect(h.toString(), c._fragmentCompilationState.uniforms, c._fragmentCompilationState.samplers, {
- maxSimultaneousLights: c.maxSimultaneousLights
- }, void 0, void 0, u, u)
- }
- ))),
- c._checkInternals(t)
- }
- )),
- e
- }
- ,
- t.prototype.createProceduralTexture = function(e, t) {
- var i = this;
- if (this.mode !== cf.ProceduralTexture)
- return console.log("Incompatible material mode"),
- null;
- var n = this.name + this._buildId
- , r = new xf(n,e,null,t)
- , o = new Sr(n + "Procedural",this.getScene());
- o.reservedDataStore = {
- hidden: !0
- };
- var a = new If
- , s = this._processDefines(o, a);
- Mt.RegisterShader(n, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
- var l = this.getScene().getEngine().createEffect({
- vertexElement: n,
- fragmentElement: n
- }, [Bi.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, a.toString(), null == s ? void 0 : s.fallbacks, void 0);
- r.nodeMaterialSource = this,
- r._setEffect(l);
- var c = this._buildId;
- return r.onBeforeGenerationObservable.add((function() {
- c !== i._buildId && (delete Mt.ShadersStore[n + "VertexShader"],
- delete Mt.ShadersStore[n + "PixelShader"],
- n = i.name + i._buildId,
- a.markAllAsDirty(),
- c = i._buildId);
- var e = i._processDefines(o, a);
- e && (Mt.RegisterShader(n, i._fragmentCompilationState._builtCompilationString, i._vertexCompilationState._builtCompilationString),
- Xt.SetImmediate((function() {
- l = i.getScene().getEngine().createEffect({
- vertexElement: n,
- fragmentElement: n
- }, [Bi.PositionKind], i._fragmentCompilationState.uniforms, i._fragmentCompilationState.samplers, a.toString(), null == e ? void 0 : e.fallbacks, void 0),
- r._setEffect(l)
- }
- ))),
- i._checkInternals(l)
- }
- )),
- r
- }
- ,
- t.prototype._createEffectForParticles = function(e, t, i, n, r, o, a, s) {
- var l = this;
- void 0 === s && (s = "");
- var c = this.name + this._buildId + "_" + t;
- o || (o = new If),
- a || (a = this.getScene().getMeshByName(this.name + "Particle")) || ((a = new Sr(this.name + "Particle",this.getScene())).reservedDataStore = {
- hidden: !0
- });
- var u = this._buildId
- , h = []
- , d = s;
- if (!r) {
- var p = this._processDefines(a, o);
- Mt.RegisterShader(c, this._fragmentCompilationState._builtCompilationString),
- e.fillDefines(h, t),
- d = h.join("\n"),
- r = this.getScene().getEngine().createEffectForParticles(c, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, o.toString() + "\n" + d, null == p ? void 0 : p.fallbacks, i, n, e),
- e.setCustomEffect(r, t)
- }
- r.onBindObservable.add((function(r) {
- u !== l._buildId && (delete Mt.ShadersStore[c + "PixelShader"],
- c = l.name + l._buildId + "_" + t,
- o.markAllAsDirty(),
- u = l._buildId),
- h.length = 0,
- e.fillDefines(h, t);
- var p = h.join("\n");
- p !== d && (o.markAllAsDirty(),
- d = p);
- var f = l._processDefines(a, o);
- if (f)
- return Mt.RegisterShader(c, l._fragmentCompilationState._builtCompilationString),
- r = l.getScene().getEngine().createEffectForParticles(c, l._fragmentCompilationState.uniforms, l._fragmentCompilationState.samplers, o.toString() + "\n" + d, null == f ? void 0 : f.fallbacks, i, n, e),
- e.setCustomEffect(r, t),
- void l._createEffectForParticles(e, t, i, n, r, o, a, s);
- l._checkInternals(r)
- }
- ))
- }
- ,
- t.prototype._checkInternals = function(e) {
- if (this._sharedData.animatedInputs) {
- var t = this.getScene()
- , i = t.getFrameId();
- if (this._animationFrame !== i) {
- for (var n = 0, r = this._sharedData.animatedInputs; n < r.length; n++)
- r[n].animate(t);
- this._animationFrame = i
- }
- }
- for (var o = 0, a = this._sharedData.bindableBlocks; o < a.length; o++)
- a[o].bind(e, this);
- for (var s = 0, l = this._sharedData.inputBlocks; s < l.length; s++)
- l[s]._transmit(e, this.getScene(), this)
- }
- ,
- t.prototype.createEffectForParticles = function(e, t, i) {
- this.mode === cf.Particle ? (this._createEffectForParticles(e, Tf.BLENDMODE_ONEONE, t, i),
- this._createEffectForParticles(e, Tf.BLENDMODE_MULTIPLY, t, i)) : console.log("Incompatible material mode")
- }
- ,
- t.prototype._processDefines = function(e, t, i, n) {
- var r = this;
- void 0 === i && (i = !1);
- var o = null;
- if (this._sharedData.blocksWithDefines.forEach((function(n) {
- n.initializeDefines(e, r, t, i)
- }
- )),
- this._sharedData.blocksWithDefines.forEach((function(o) {
- o.prepareDefines(e, r, t, i, n)
- }
- )),
- t.isDirty) {
- var a = t._areLightsDisposed;
- t.markAsProcessed(),
- this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString,
- this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString,
- this._sharedData.repeatableContentBlocks.forEach((function(i) {
- i.replaceRepeatableContent(r._vertexCompilationState, r._fragmentCompilationState, e, t)
- }
- ));
- var s = [];
- this._sharedData.dynamicUniformBlocks.forEach((function(e) {
- e.updateUniformsAndSamples(r._vertexCompilationState, r, t, s)
- }
- ));
- var l = this._vertexCompilationState.uniforms;
- this._fragmentCompilationState.uniforms.forEach((function(e) {
- -1 === l.indexOf(e) && l.push(e)
- }
- ));
- var c = this._vertexCompilationState.samplers;
- this._fragmentCompilationState.samplers.forEach((function(e) {
- -1 === c.indexOf(e) && c.push(e)
- }
- ));
- var u = new ys;
- this._sharedData.blocksWithFallbacks.forEach((function(t) {
- t.provideFallbacks(e, u)
- }
- )),
- o = {
- lightDisposed: a,
- uniformBuffers: s,
- mergedUniforms: l,
- mergedSamplers: c,
- fallbacks: u
- }
- }
- return o
- }
- ,
- t.prototype.isReadyForSubMesh = function(e, t, i) {
- var n = this;
- if (void 0 === i && (i = !1),
- !this._buildWasSuccessful)
- return !1;
- var r = this.getScene();
- if (this._sharedData.animatedInputs) {
- var o = r.getFrameId();
- if (this._animationFrame !== o) {
- for (var a = 0, s = this._sharedData.animatedInputs; a < s.length; a++)
- s[a].animate(r);
- this._animationFrame = o
- }
- }
- if (t.effect && this.isFrozen && t.effect._wasPreviouslyReady)
- return !0;
- t.materialDefines || (t.materialDefines = new If);
- var l = t.materialDefines;
- if (this._isReadyForSubMesh(t))
- return !0;
- var c = r.getEngine();
- if (this._prepareDefinesForAttributes(e, l),
- this._sharedData.blockingBlocks.some((function(t) {
- return !t.isReady(e, n, l, i)
- }
- )))
- return !1;
- var u = this._processDefines(e, l, i, t);
- if (u) {
- var h = t.effect
- , d = l.toString()
- , p = c.createEffect({
- vertex: "nodeMaterial" + this._buildId,
- fragment: "nodeMaterial" + this._buildId,
- vertexSource: this._vertexCompilationState.compilationString,
- fragmentSource: this._fragmentCompilationState.compilationString
- }, {
- attributes: this._vertexCompilationState.attributes,
- uniformsNames: u.mergedUniforms,
- uniformBuffersNames: u.uniformBuffers,
- samplers: u.mergedSamplers,
- defines: d,
- fallbacks: u.fallbacks,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousLights: this.maxSimultaneousLights,
- maxSimultaneousMorphTargets: l.NUM_MORPH_INFLUENCERS
- }
- }, c);
- if (p)
- if (this._onEffectCreatedObservable && (Mf.effect = p,
- Mf.subMesh = t,
- this._onEffectCreatedObservable.notifyObservers(Mf)),
- this.allowShaderHotSwapping && h && !p.isReady()) {
- if (p = h,
- l.markAsUnprocessed(),
- u.lightDisposed)
- return l._areLightsDisposed = !0,
- !1
- } else
- r.resetCachedMaterial(),
- t.setEffect(p, l, this._materialContext)
- }
- return !(!t.effect || !t.effect.isReady() || (l._renderId = r.getRenderId(),
- t.effect._wasPreviouslyReady = !0,
- 0))
- }
- ,
- Object.defineProperty(t.prototype, "compiledShaders", {
- get: function() {
- return "// Vertex shader\r\n".concat(this._vertexCompilationState.compilationString, "\r\n\r\n// Fragment shader\r\n").concat(this._fragmentCompilationState.compilationString)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.bindOnlyWorldMatrix = function(e) {
- var t = this.getScene();
- if (this._activeEffect) {
- var i = this._sharedData.hints;
- i.needWorldViewMatrix && e.multiplyToRef(t.getViewMatrix(), this._cachedWorldViewMatrix),
- i.needWorldViewProjectionMatrix && e.multiplyToRef(t.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
- for (var n = 0, r = this._sharedData.inputBlocks; n < r.length; n++)
- r[n]._transmitWorld(this._activeEffect, e, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix)
- }
- }
- ,
- t.prototype.bindForSubMesh = function(e, t, i) {
- var n = this.getScene()
- , r = i.effect;
- if (r) {
- this._activeEffect = r,
- this.bindOnlyWorldMatrix(e);
- var o = this._mustRebind(n, r, t.visibility)
- , a = this._sharedData;
- if (o) {
- for (var s = 0, l = a.bindableBlocks; s < l.length; s++)
- l[s].bind(r, this, t, i);
- for (var c = 0, u = a.forcedBindableBlocks; c < u.length; c++)
- u[c].bind(r, this, t, i);
- for (var h = 0, d = a.inputBlocks; h < d.length; h++)
- d[h]._transmit(r, n, this)
- } else if (!this.isFrozen)
- for (var p = 0, f = a.forcedBindableBlocks; p < f.length; p++)
- f[p].bind(r, this, t, i);
- this._afterBind(t, this._activeEffect)
- }
- }
- ,
- t.prototype.getActiveTextures = function() {
- var t = e.prototype.getActiveTextures.call(this);
- return this._sharedData && t.push.apply(t, this._sharedData.textureBlocks.filter((function(e) {
- return e.texture
- }
- )).map((function(e) {
- return e.texture
- }
- ))),
- t
- }
- ,
- t.prototype.getTextureBlocks = function() {
- return this._sharedData ? this._sharedData.textureBlocks : []
- }
- ,
- t.prototype.hasTexture = function(t) {
- if (e.prototype.hasTexture.call(this, t))
- return !0;
- if (!this._sharedData)
- return !1;
- for (var i = 0, n = this._sharedData.textureBlocks; i < n.length; i++)
- if (n[i].texture === t)
- return !0;
- return !1
- }
- ,
- t.prototype.dispose = function(t, i, n) {
- if (i)
- for (var r = 0, o = this.getTextureBlocks().filter((function(e) {
- return e.texture
- }
- )).map((function(e) {
- return e.texture
- }
- )); r < o.length; r++)
- o[r].dispose();
- for (var a = 0, s = this.attachedBlocks; a < s.length; a++)
- s[a].dispose();
- 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),
- e.prototype.dispose.call(this, t, i, n)
- }
- ,
- t.prototype._createNodeEditor = function() {
- this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
- nodeMaterial: this
- })
- }
- ,
- t.prototype.edit = function(e) {
- var i = this;
- return new Promise((function(n) {
- if (i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(),
- void 0 === i.BJSNODEMATERIALEDITOR) {
- var r = e && e.editorURL ? e.editorURL : t.EditorURL;
- gi.LoadScript(r, (function() {
- i.BJSNODEMATERIALEDITOR = i.BJSNODEMATERIALEDITOR || i._getGlobalNodeMaterialEditor(),
- i._createNodeEditor(),
- n()
- }
- ))
- } else
- i._createNodeEditor(),
- n()
- }
- ))
- }
- ,
- t.prototype.clear = function() {
- this._vertexOutputNodes = [],
- this._fragmentOutputNodes = [],
- this.attachedBlocks = []
- }
- ,
- t.prototype.setToDefault = function() {
- this.clear(),
- this.editorData = null;
- var e = new tf("Position");
- e.setAsAttribute("position");
- var t = new tf("World");
- t.setAsSystemValue(Qp.World);
- var i = new Hp("WorldPos");
- e.connectTo(i),
- t.connectTo(i);
- var n = new tf("ViewProjection");
- n.setAsSystemValue(Qp.ViewProjection);
- var r = new Hp("WorldPos * ViewProjectionTransform");
- i.connectTo(r),
- n.connectTo(r);
- var o = new jp("VertexOutput");
- r.connectTo(o);
- var a = new tf("color");
- a.value = new N(.8,.8,.8,1);
- var s = new Zp("FragmentOutput");
- a.connectTo(s),
- this.addOutputNode(o),
- this.addOutputNode(s),
- this._mode = cf.Material
- }
- ,
- t.prototype.setToDefaultPostProcess = function() {
- this.clear(),
- this.editorData = null;
- var e = new tf("Position");
- e.setAsAttribute("position2d");
- var t = new tf("Constant1");
- t.isConstant = !0,
- t.value = 1;
- var i = new sf("Position3D");
- e.connectTo(i),
- t.connectTo(i, {
- input: "w"
- });
- var n = new jp("VertexOutput");
- i.connectTo(n);
- var r = new tf("Scale");
- r.visibleInInspector = !0,
- r.value = new A(1,1);
- var o = new lf("uv0");
- e.connectTo(o);
- var a = new uf("UV scale");
- o.connectTo(a),
- r.connectTo(a);
- var s = new nf("CurrentScreen");
- a.connectTo(s),
- s.texture = new io("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());
- var l = new Zp("FragmentOutput");
- s.connectTo(l, {
- output: "rgba"
- }),
- this.addOutputNode(n),
- this.addOutputNode(l),
- this._mode = cf.PostProcess
- }
- ,
- t.prototype.setToDefaultProceduralTexture = function() {
- this.clear(),
- this.editorData = null;
- var e = new tf("Position");
- e.setAsAttribute("position2d");
- var t = new tf("Constant1");
- t.isConstant = !0,
- t.value = 1;
- var i = new sf("Position3D");
- e.connectTo(i),
- t.connectTo(i, {
- input: "w"
- });
- var n = new jp("VertexOutput");
- i.connectTo(n);
- var r = new tf("Time");
- r.value = 0,
- r.min = 0,
- r.max = 0,
- r.isBoolean = !1,
- r.matrixMode = 0,
- r.animationType = qp.Time,
- r.isConstant = !1;
- var o = new tf("Color3");
- o.value = new D(1,1,1),
- o.isConstant = !1;
- var a = new Zp("FragmentOutput")
- , s = new sf("VectorMerger");
- s.visibleInInspector = !1;
- var l = new Rf("Cos");
- l.operation = Af.Cos,
- e.connectTo(s),
- r.output.connectTo(l.input),
- l.output.connectTo(s.z),
- s.xyzOut.connectTo(a.rgb),
- this.addOutputNode(n),
- this.addOutputNode(a),
- this._mode = cf.ProceduralTexture
- }
- ,
- t.prototype.setToDefaultParticle = function() {
- this.clear(),
- this.editorData = null;
- var e = new tf("uv");
- e.setAsAttribute("particle_uv");
- var t = new rf("ParticleTexture");
- e.connectTo(t);
- var i = new tf("Color");
- i.setAsAttribute("particle_color");
- var n = new uf("Texture * Color");
- t.connectTo(n),
- i.connectTo(n);
- var r = new of("ParticleRampGradient");
- n.connectTo(r);
- var o = new Ef("ColorSplitter");
- i.connectTo(o);
- var a = new af("ParticleBlendMultiply");
- r.connectTo(a),
- t.connectTo(a, {
- output: "a"
- }),
- o.connectTo(a, {
- output: "a"
- });
- var s = new Zp("FragmentOutput");
- a.connectTo(s),
- this.addOutputNode(s),
- this._mode = cf.Particle
- }
- ,
- t.prototype.loadAsync = function(e, t) {
- var i = this;
- return void 0 === t && (t = ""),
- this.getScene()._loadFileAsync(e).then((function(e) {
- var n = JSON.parse(e);
- i.loadFromSerialization(n, t)
- }
- ))
- }
- ,
- t.prototype._gatherBlocks = function(e, t) {
- if (-1 === t.indexOf(e)) {
- t.push(e);
- for (var i = 0, n = e.inputs; i < n.length; i++) {
- var r = n[i].connectedPoint;
- if (r) {
- var o = r.ownerBlock;
- o !== e && this._gatherBlocks(o, t)
- }
- }
- }
- }
- ,
- t.prototype.generateCode = function() {
- for (var e = [], t = [], i = ["const", "var", "let"], n = 0, r = this._vertexOutputNodes; n < r.length; n++) {
- var o = r[n];
- this._gatherBlocks(o, t)
- }
- for (var a = [], s = 0, l = this._fragmentOutputNodes; s < l.length; s++)
- o = l[s],
- this._gatherBlocks(o, a);
- for (var c = 'var nodeMaterial = new BABYLON.NodeMaterial("'.concat(this.name || "node material", '");\r\n'), u = 0, h = t; u < h.length; u++)
- (b = h[u]).isInput && -1 === e.indexOf(b) && (c += b._dumpCode(i, e));
- for (var d = 0, p = a; d < p.length; d++)
- (b = p[d]).isInput && -1 === e.indexOf(b) && (c += b._dumpCode(i, e));
- e = [],
- c += "\r\n// Connections\r\n";
- for (var f = 0, _ = this._vertexOutputNodes; f < _.length; f++)
- c += (b = _[f])._dumpCodeForOutputConnections(e);
- for (var m = 0, g = this._fragmentOutputNodes; m < g.length; m++)
- c += (b = g[m])._dumpCodeForOutputConnections(e);
- c += "\r\n// Output nodes\r\n";
- for (var v = 0, y = this._vertexOutputNodes; v < y.length; v++) {
- var b = y[v];
- c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\r\n")
- }
- for (var T = 0, E = this._fragmentOutputNodes; T < E.length; T++)
- b = E[T],
- c += "nodeMaterial.addOutputNode(".concat(b._codeVariableName, ");\r\n");
- return c + "nodeMaterial.build();\r\n"
- }
- ,
- t.prototype.serialize = function(e) {
- var t = e ? {} : Ge.Serialize(this);
- t.editorData = JSON.parse(JSON.stringify(this.editorData));
- var i = [];
- if (e)
- i = e;
- else {
- t.customType = "BABYLON.NodeMaterial",
- t.outputNodes = [];
- for (var n = 0, r = this._vertexOutputNodes; n < r.length; n++) {
- var o = r[n];
- this._gatherBlocks(o, i),
- t.outputNodes.push(o.uniqueId)
- }
- for (var a = 0, s = this._fragmentOutputNodes; a < s.length; a++)
- o = s[a],
- this._gatherBlocks(o, i),
- -1 === t.outputNodes.indexOf(o.uniqueId) && t.outputNodes.push(o.uniqueId)
- }
- t.blocks = [];
- for (var l = 0, c = i; l < c.length; l++) {
- var u = c[l];
- t.blocks.push(u.serialize())
- }
- if (!e)
- for (var h = 0, d = this.attachedBlocks; h < d.length; h++)
- u = d[h],
- -1 === i.indexOf(u) && t.blocks.push(u.serialize());
- return t
- }
- ,
- t.prototype._restoreConnections = function(e, t, i) {
- for (var n = 0, r = e.outputs; n < r.length; n++)
- for (var o = r[n], a = 0, s = t.blocks; a < s.length; a++) {
- var l = s[a]
- , c = i[l.id];
- if (c)
- for (var u = 0, h = l.inputs; u < h.length; u++) {
- var d = h[u];
- if (i[d.targetBlockId] !== e || d.targetConnectionName !== o.name)
- ;
- else {
- var p = c.getInputByName(d.inputName);
- if (!p || p.isConnected)
- continue;
- o.connectTo(p, !0),
- this._restoreConnections(c, t, i)
- }
- }
- }
- }
- ,
- t.prototype.loadFromSerialization = function(e, t, i) {
- var n;
- void 0 === t && (t = ""),
- void 0 === i && (i = !1),
- i || this.clear();
- for (var r = {}, o = 0, a = e.blocks; o < a.length; o++) {
- var s = b((c = a[o]).customType);
- s && ((u = new s)._deserialize(c, this.getScene(), t),
- r[c.id] = u,
- this.attachedBlocks.push(u))
- }
- for (var l = 0; l < e.blocks.length; l++) {
- var c, u;
- (u = r[(c = e.blocks[l]).id]) && (u.inputs.length && !i || this._restoreConnections(u, e, r))
- }
- if (e.outputNodes)
- for (var h = 0, d = e.outputNodes; h < d.length; h++) {
- var p = d[h];
- this.addOutputNode(r[p])
- }
- if (e.locations || e.editorData && e.editorData.locations) {
- for (var f = e.locations || e.editorData.locations, _ = 0, m = f; _ < m.length; _++) {
- var g = m[_];
- r[g.blockId] && (g.blockId = r[g.blockId].uniqueId)
- }
- i && this.editorData && this.editorData.locations && f.concat(this.editorData.locations),
- e.locations ? this.editorData = {
- locations: f
- } : (this.editorData = e.editorData,
- this.editorData.locations = f);
- var v = [];
- for (var y in r)
- v[y] = r[y].uniqueId;
- this.editorData.map = v
- }
- this.comment = e.comment,
- void 0 !== e.forceAlphaBlending && (this.forceAlphaBlending = e.forceAlphaBlending),
- i || (this._mode = null !== (n = e.mode) && void 0 !== n ? n : cf.Material)
- }
- ,
- t.prototype.clone = function(e, i) {
- var n = this;
- void 0 === i && (i = !1);
- var r = this.serialize()
- , o = Ge.Clone((function() {
- return new t(e,n.getScene(),n.options)
- }
- ), this);
- return o.id = e,
- o.name = e,
- o.loadFromSerialization(r),
- o._buildId = this._buildId,
- o.build(!1, !i),
- o
- }
- ,
- t.Parse = function(e, i, n) {
- void 0 === n && (n = "");
- var r = Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n);
- return r.loadFromSerialization(e, n),
- r.build(),
- r
- }
- ,
- t.ParseFromFileAsync = function(e, i, n, r) {
- void 0 === r && (r = "");
- var o = new t(e,n);
- return new Promise((function(e, t) {
- return o.loadAsync(i, r).then((function() {
- o.build(),
- e(o)
- }
- )).catch(t)
- }
- ))
- }
- ,
- t.ParseFromSnippetAsync = function(e, i, n, r) {
- var o = this;
- return void 0 === n && (n = ""),
- "_BLANK" === e ? Promise.resolve(this.CreateDefault("blank", i)) : new Promise((function(a, s) {
- var l = new Ye;
- l.addEventListener("readystatechange", (function() {
- if (4 == l.readyState)
- if (200 == l.status) {
- var o = JSON.parse(JSON.parse(l.responseText).jsonPayload)
- , c = JSON.parse(o.nodeMaterial);
- r || ((r = Ge.Parse((function() {
- return new t(e,i)
- }
- ), c, i, n)).uniqueId = i.getUniqueId()),
- r.loadFromSerialization(c),
- r.snippetId = e;
- try {
- r.build(),
- a(r)
- } catch (e) {
- s(e)
- }
- } else
- s("Unable to load the snippet " + e)
- }
- )),
- l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")),
- l.send()
- }
- ))
- }
- ,
- t.CreateDefault = function(e, i) {
- var n = new t(e,i);
- return n.setToDefault(),
- n.build(),
- n
- }
- ,
- t._BuildIdGenerator = 0,
- t.EditorURL = "https://unpkg.com/babylonjs-node-editor@".concat(vr.Version, "/babylon.nodeEditor.js"),
- t.SnippetUrl = "https://snippet.babylonjs.com",
- t.IgnoreTexturesAtLoadTime = !1,
- k([Ce()], t.prototype, "ignoreAlpha", void 0),
- k([Ce()], t.prototype, "maxSimultaneousLights", void 0),
- k([Ce("mode")], t.prototype, "_mode", void 0),
- k([Ce("comment")], t.prototype, "comment", void 0),
- k([Ce()], t.prototype, "forceAlphaBlending", void 0),
- t
- }(gs);
- y("BABYLON.NodeMaterial", Of),
- hr.prototype._projectOnTrianglesToRef = function(e, t, i, n, r, o) {
- for (var a = I.Vector3[0], s = I.Vector3[1], l = 1 / 0, c = this.indexStart; c < this.indexStart + this.indexCount - (3 - n); c += n) {
- var u = i[c]
- , h = i[c + 1]
- , d = i[c + 2];
- if (r && 4294967295 === d)
- c += 2;
- else {
- var p = t[u]
- , f = t[h]
- , _ = t[d];
- if (p && f && _) {
- var m = x.ProjectOnTriangleToRef(e, p, f, _, s);
- m < l && (a.copyFrom(s),
- l = m)
- }
- }
- }
- return o.copyFrom(a),
- l
- }
- ,
- hr.prototype._projectOnUnIndexedTrianglesToRef = function(e, t, i, n) {
- for (var r = I.Vector3[0], o = I.Vector3[1], a = 1 / 0, s = this.verticesStart; s < this.verticesStart + this.verticesCount; s += 3) {
- var l = t[s]
- , c = t[s + 1]
- , u = t[s + 2]
- , h = x.ProjectOnTriangleToRef(e, l, c, u, o);
- h < a && (r.copyFrom(o),
- a = h)
- }
- return n.copyFrom(r),
- a
- }
- ,
- hr.prototype.projectToRef = function(e, t, i, n) {
- var r = this.getMaterial();
- if (!r)
- return -1;
- var o = 3
- , s = !1;
- switch (r.fillMode) {
- case a.MATERIAL_PointListDrawMode:
- case a.MATERIAL_LineLoopDrawMode:
- case a.MATERIAL_LineStripDrawMode:
- case a.MATERIAL_TriangleFanDrawMode:
- return -1;
- case a.MATERIAL_TriangleStripDrawMode:
- o = 1,
- s = !0
- }
- return r.fillMode === a.MATERIAL_LineListDrawMode ? -1 : !i.length && this._mesh._unIndexed ? this._projectOnUnIndexedTrianglesToRef(e, t, i, n) : this._projectOnTrianglesToRef(e, t, i, o, s, n)
- }
- ,
- function(e) {
- e[e.DEHYDRATED = 0] = "DEHYDRATED",
- e[e.HOVER = 1] = "HOVER",
- e[e.TOUCH = 2] = "TOUCH"
- }(Cf || (Cf = {})),
- function(e) {
- e[e.DISABLED = 0] = "DISABLED",
- e[e.CENTERED_ON_CONTROLLER = 1] = "CENTERED_ON_CONTROLLER",
- e[e.CENTERED_IN_FRONT = 2] = "CENTERED_IN_FRONT"
- }(Pf || (Pf = {}));
- var Df = function(e) {
- function t(i, n) {
- var r = e.call(this, i) || this;
- return r._options = n,
- r._tmpRay = new _o(new x,new x),
- r._attachController = function(e) {
- if (!r._controllers[e.uniqueId]) {
- var i = r._generateNewTouchPointMesh()
- , n = i.touchCollisionMesh
- , o = i.touchCollisionMeshFunction
- , a = i.hydrateCollisionMeshFunction
- , s = r._generateVisualCue();
- switch (r._controllers[e.uniqueId] = {
- xrController: e,
- meshUnderPointer: null,
- nearInteractionTargetMesh: null,
- pick: null,
- stalePick: null,
- touchCollisionMesh: n,
- touchCollisionMeshFunction: o,
- hydrateCollisionMeshFunction: a,
- currentAnimationState: Cf.DEHYDRATED,
- grabRay: new _o(new x,new x),
- hoverInteraction: !1,
- nearInteraction: !1,
- grabInteraction: !1,
- id: t._IdCounter++,
- pickedPointVisualCue: s
- },
- r._attachedController ? !r._options.enableNearInteractionOnAllControllers && r._options.preferredHandedness && e.inputSource.handedness === r._options.preferredHandedness && (r._attachedController = e.uniqueId) : r._options.enableNearInteractionOnAllControllers || (r._attachedController = e.uniqueId),
- e.inputSource.targetRayMode) {
- case "tracked-pointer":
- return r._attachNearInteractionMode(e);
- case "gaze":
- case "screen":
- return null
- }
- }
- }
- ,
- r._controllers = {},
- r._farInteractionFeature = null,
- r.selectionMeshDefaultColor = new D(.8,.8,.8),
- r.selectionMeshPickedColor = new D(.3,.3,1),
- r._hoverRadius = .1,
- r._pickRadius = .02,
- r._controllerPickRadius = .03,
- r._nearGrabLengthScale = 5,
- r._scene = r._xrSessionManager.scene,
- void 0 === r._options.nearInteractionControllerMode && (r._options.nearInteractionControllerMode = Pf.CENTERED_IN_FRONT),
- r._options.farInteractionFeature && (r._farInteractionFeature = r._options.farInteractionFeature),
- r
- }
- return U(t, e),
- t.prototype.attach = function() {
- var t = this;
- return !!e.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(e) {
- t._detachController(e.uniqueId)
- }
- )),
- this._scene.constantlyUpdateMeshUnderPointer = !0,
- !0)
- }
- ,
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
- t._detachController(e)
- }
- )),
- !0)
- }
- ,
- t.prototype.getMeshUnderPointer = function(e) {
- return this._controllers[e] ? this._controllers[e].meshUnderPointer : null
- }
- ,
- t.prototype.getXRControllerByPointerId = function(e) {
- for (var t = Object.keys(this._controllers), i = 0; i < t.length; ++i)
- if (this._controllers[t[i]].id === e)
- return this._controllers[t[i]].xrController || null;
- return null
- }
- ,
- t.prototype.setFarInteractionFeature = function(e) {
- this._farInteractionFeature = e
- }
- ,
- t.prototype._nearPickPredicate = function(e) {
- return e.isEnabled() && e.isVisible && e.isPickable && e.isNearPickable
- }
- ,
- t.prototype._nearGrabPredicate = function(e) {
- return e.isEnabled() && e.isVisible && e.isPickable && e.isNearGrabbable
- }
- ,
- t.prototype._nearInteractionPredicate = function(e) {
- return e.isEnabled() && e.isVisible && e.isPickable && (e.isNearPickable || e.isNearGrabbable)
- }
- ,
- t.prototype._controllerAvailablePredicate = function(e, t) {
- for (var i = e; i; ) {
- if (i.reservedDataStore && i.reservedDataStore.nearInteraction && i.reservedDataStore.nearInteraction.excludedControllerId === t)
- return !1;
- i = i.parent
- }
- return !0
- }
- ,
- t.prototype._handleTransitionAnimation = function(e, t) {
- var i;
- if (e.currentAnimationState !== t && this._options.nearInteractionControllerMode === Pf.CENTERED_IN_FRONT && !(null === (i = e.xrController) || void 0 === i ? void 0 : i.inputSource.hand)) {
- if (t > e.currentAnimationState)
- switch (e.currentAnimationState) {
- case Cf.DEHYDRATED:
- if (e.hydrateCollisionMeshFunction(!0),
- t === Cf.HOVER)
- break;
- case Cf.HOVER:
- if (e.touchCollisionMeshFunction(!0),
- t === Cf.TOUCH)
- break
- }
- else
- switch (e.currentAnimationState) {
- case Cf.TOUCH:
- if (e.touchCollisionMeshFunction(!1),
- t === Cf.HOVER)
- break;
- case Cf.HOVER:
- if (e.hydrateCollisionMeshFunction(!1),
- t === Cf.DEHYDRATED)
- break
- }
- e.currentAnimationState = t
- }
- }
- ,
- t.prototype._processTouchPoint = function(e, t, i) {
- var n, r = this._controllers[e];
- r.grabRay.origin.copyFrom(t),
- i.toEulerAnglesToRef(I.Vector3[0]),
- r.grabRay.direction.copyFrom(I.Vector3[0]),
- this._options.nearInteractionControllerMode !== Pf.CENTERED_IN_FRONT || (null === (n = r.xrController) || void 0 === n ? void 0 : n.inputSource.hand) || (r.xrController.getWorldPointerRayToRef(this._tmpRay),
- r.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),
- r.grabRay.length = this._nearGrabLengthScale * this._hoverRadius,
- r.touchCollisionMesh.position.copyFrom(r.grabRay.origin)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t = this;
- Object.keys(this._controllers).forEach((function(i) {
- var n, r = t._controllers[i], o = null === (n = r.xrController) || void 0 === n ? void 0 : n.inputSource.hand;
- if ((t._options.enableNearInteractionOnAllControllers || i === t._attachedController) && r.xrController && (o || t._options.nearInteractionControllerMode && r.xrController.inputSource.gamepad)) {
- if (r.hoverInteraction = !1,
- r.nearInteraction = !1,
- r.xrController) {
- if (o) {
- var a = o.get("index-finger-tip");
- if (a) {
- var s = e.getJointPose(a, t._xrSessionManager.referenceSpace);
- if (s && s.transform) {
- var l = t._scene.useRightHandedSystem ? 1 : -1;
- I.Vector3[0].set(s.transform.position.x, s.transform.position.y, s.transform.position.z * l),
- I.Quaternion[0].set(s.transform.orientation.x, s.transform.orientation.y, s.transform.orientation.z * l, s.transform.orientation.w * l),
- t._processTouchPoint(i, I.Vector3[0], I.Quaternion[0])
- }
- }
- } else if (r.xrController.inputSource.gamepad && t._options.nearInteractionControllerMode !== Pf.DISABLED) {
- var c = r.xrController.pointer;
- r.xrController.grip && t._options.nearInteractionControllerMode === Pf.CENTERED_ON_CONTROLLER && (c = r.xrController.grip),
- t._processTouchPoint(i, c.position, c.rotationQuaternion)
- }
- var u = function(e, t) {
- return t && t.hit ? e && e.hit ? t.distance < e.distance ? t : e : t : e
- }
- , h = function(e) {
- var t = new Ui
- , i = !1
- , n = e && e.pickedPoint && e.hit;
- return (null == e ? void 0 : e.pickedPoint) && (i = 0 === e.pickedPoint.x && 0 === e.pickedPoint.y && 0 === e.pickedPoint.z),
- n && !i && (t = e),
- t
- };
- if (!r.grabInteraction) {
- var d = null
- , p = null;
- t._options.useUtilityLayer && t._utilityLayerScene && (p = t._pickWithSphere(r, t._hoverRadius, t._utilityLayerScene, (function(e) {
- return t._nearInteractionPredicate(e)
- }
- )));
- var f = u(t._pickWithSphere(r, t._hoverRadius, t._scene, (function(e) {
- return t._nearInteractionPredicate(e)
- }
- )), p);
- if (f && f.hit && (d = h(f)).hit && (r.hoverInteraction = !0),
- r.hoverInteraction) {
- var _ = null
- , m = o ? t._pickRadius : t._controllerPickRadius;
- t._options.useUtilityLayer && t._utilityLayerScene && (_ = t._pickWithSphere(r, m, t._utilityLayerScene, (function(e) {
- return t._nearPickPredicate(e)
- }
- )));
- var g = h(u(t._pickWithSphere(r, m, t._scene, (function(e) {
- return t._nearPickPredicate(e)
- }
- )), _));
- g.hit && (d = g,
- r.nearInteraction = !0)
- }
- r.stalePick = r.pick,
- r.pick = d,
- r.pick && r.pick.pickedPoint && r.pick.hit ? (r.meshUnderPointer = r.pick.pickedMesh,
- r.pickedPointVisualCue.position.copyFrom(r.pick.pickedPoint),
- r.pickedPointVisualCue.isVisible = !0,
- t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(r.id, !0)) : (r.meshUnderPointer = null,
- r.pickedPointVisualCue.isVisible = !1,
- t._farInteractionFeature && t._farInteractionFeature.attached && t._farInteractionFeature._setPointerSelectionDisabledByPointerId(r.id, !1))
- }
- var v = Cf.DEHYDRATED;
- r.grabInteraction || r.nearInteraction ? v = Cf.TOUCH : r.hoverInteraction && (v = Cf.HOVER),
- t._handleTransitionAnimation(r, v)
- }
- } else
- r.pick = null
- }
- ))
- }
- ,
- Object.defineProperty(t.prototype, "_utilityLayerScene", {
- get: function() {
- return this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._generateVisualCue = function() {
- var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
- , t = Dl("nearInteraction", {
- diameter: .0105
- }, e);
- t.bakeCurrentTransformIntoVertices(),
- t.isPickable = !1,
- t.isVisible = !1,
- t.rotationQuaternion = C.Identity();
- var i = new Os("targetMat",e);
- return i.specularColor = D.Black(),
- i.emissiveColor = this.selectionMeshDefaultColor,
- i.backFaceCulling = !1,
- t.material = i,
- t
- }
- ,
- t.prototype._isControllerReadyForNearInteraction = function(e) {
- return !this._farInteractionFeature || this._farInteractionFeature._getPointerSelectionDisabledByPointerId(e)
- }
- ,
- t.prototype._attachNearInteractionMode = function(e) {
- var t = this
- , i = this._controllers[e.uniqueId]
- , n = {
- pointerId: i.id,
- pointerType: "xr"
- };
- i.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add((function() {
- (t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController) && i.xrController && (i.xrController.inputSource.hand || t._options.nearInteractionControllerMode && i.xrController.inputSource.gamepad) && (i.pick && (i.pick.ray = i.grabRay),
- i.pick && t._isControllerReadyForNearInteraction(i.id) && t._scene.simulatePointerMove(i.pick, n),
- i.nearInteraction && i.pick && i.pick.hit ? i.nearInteractionTargetMesh || (t._scene.simulatePointerDown(i.pick, n),
- i.nearInteractionTargetMesh = i.meshUnderPointer) : i.nearInteractionTargetMesh && i.stalePick && (t._scene.simulatePointerUp(i.stalePick, n),
- i.nearInteractionTargetMesh = null))
- }
- ));
- var r = function(r) {
- t._options.enableNearInteractionOnAllControllers || e.uniqueId === t._attachedController && t._isControllerReadyForNearInteraction(i.id) ? (i.pick && (i.pick.ray = i.grabRay),
- r && i.pick && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) ? (i.grabInteraction = !0,
- i.pickedPointVisualCue.isVisible = !1,
- t._scene.simulatePointerDown(i.pick, n)) : !r && i.pick && i.grabInteraction && (t._scene.simulatePointerUp(i.pick, n),
- i.grabInteraction = !1,
- i.pickedPointVisualCue.isVisible = !0)) : !r || t._options.enableNearInteractionOnAllControllers || t._options.disableSwitchOnClick || (t._attachedController = e.uniqueId)
- };
- if (e.inputSource.gamepad) {
- var o = function(e) {
- i.squeezeComponent = e.getComponent("grasp"),
- i.squeezeComponent ? i.onSqueezeButtonChangedObserver = i.squeezeComponent.onButtonStateChangedObservable.add((function(e) {
- if (e.changes.pressed) {
- var t = e.changes.pressed.current;
- r(t)
- }
- }
- )) : (i.selectionComponent = e.getMainComponent(),
- i.onButtonChangedObserver = i.selectionComponent.onButtonStateChangedObservable.add((function(e) {
- if (e.changes.pressed) {
- var t = e.changes.pressed.current;
- r(t)
- }
- }
- )))
- };
- e.motionController ? o(e.motionController) : e.onMotionControllerInitObservable.add(o)
- } else {
- var a = function(e) {
- i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && i.meshUnderPointer && t._nearGrabPredicate(i.meshUnderPointer) && (i.grabInteraction = !0,
- i.pickedPointVisualCue.isVisible = !1,
- t._scene.simulatePointerDown(i.pick, n))
- }
- , s = function(e) {
- i.xrController && e.inputSource === i.xrController.inputSource && i.pick && t._isControllerReadyForNearInteraction(i.id) && (t._scene.simulatePointerUp(i.pick, n),
- i.grabInteraction = !1,
- i.pickedPointVisualCue.isVisible = !0)
- };
- i.eventListeners = {
- selectend: s,
- selectstart: a
- },
- this._xrSessionManager.session.addEventListener("selectstart", a),
- this._xrSessionManager.session.addEventListener("selectend", s)
- }
- }
- ,
- t.prototype._detachController = function(e) {
- var t = this
- , i = this._controllers[e];
- if (i && (i.squeezeComponent && i.onSqueezeButtonChangedObserver && i.squeezeComponent.onButtonStateChangedObservable.remove(i.onSqueezeButtonChangedObserver),
- i.selectionComponent && i.onButtonChangedObserver && i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),
- i.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),
- i.eventListeners && Object.keys(i.eventListeners).forEach((function(e) {
- var n = i.eventListeners && i.eventListeners[e];
- n && t._xrSessionManager.session.removeEventListener(e, n)
- }
- )),
- i.touchCollisionMesh.dispose(),
- i.pickedPointVisualCue.dispose(),
- this._xrSessionManager.runInXRFrame((function() {
- var e = {
- pointerId: i.id,
- pointerType: "xr"
- };
- t._scene.simulatePointerUp(new Ui, e)
- }
- )),
- delete this._controllers[e],
- this._attachedController === e)) {
- var n = Object.keys(this._controllers);
- n.length ? this._attachedController = n[0] : this._attachedController = ""
- }
- }
- ,
- t.prototype._generateNewTouchPointMesh = function() {
- var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._scene
- , t = Dl("PickSphere", {
- diameter: 1
- }, e);
- t.isVisible = !1,
- this._options.motionControllerOrbMaterial ? t.material = this._options.motionControllerOrbMaterial : Of.ParseFromSnippetAsync("8RUNKL#3", e).then((function(e) {
- t.material = e
- }
- ));
- var i = new Bn;
- i.setEasingMode(Mn.EASINGMODE_EASEINOUT);
- var n = new x(this._controllerPickRadius,this._controllerPickRadius,this._controllerPickRadius)
- , r = this._controllerPickRadius * (4 / 3)
- , o = new x(r,r,r)
- , a = this._controllerPickRadius * (7 / 6)
- , s = new x(a,a,a)
- , l = .8 * this._controllerPickRadius
- , c = new x(l,l,l)
- , u = 1.5 * this._controllerPickRadius
- , h = [{
- frame: 0,
- value: n
- }, {
- frame: 10,
- value: new x(u,u,u)
- }, {
- frame: 18,
- value: o
- }]
- , d = [{
- frame: 0,
- value: o
- }, {
- frame: 10,
- value: c
- }, {
- frame: 18,
- value: n
- }]
- , p = [{
- frame: 0,
- value: x.ZeroReadOnly
- }, {
- frame: 12,
- value: s
- }, {
- frame: 15,
- value: n
- }]
- , f = [{
- frame: 0,
- value: n
- }, {
- frame: 10,
- value: x.ZeroReadOnly
- }, {
- frame: 15,
- value: x.ZeroReadOnly
- }]
- , _ = new Qe("touch","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , m = new Qe("release","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , g = new Qe("hydrate","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT)
- , v = new Qe("dehydrate","scaling",60,Qe.ANIMATIONTYPE_VECTOR3,Qe.ANIMATIONLOOPMODE_CONSTANT);
- return _.setEasingFunction(i),
- m.setEasingFunction(i),
- g.setEasingFunction(i),
- v.setEasingFunction(i),
- _.setKeys(h),
- m.setKeys(d),
- g.setKeys(p),
- v.setKeys(f),
- {
- touchCollisionMesh: t,
- touchCollisionMeshFunction: function(i) {
- var n = i ? _ : m;
- e.beginDirectAnimation(t, [n], 0, 18, !1, 1)
- },
- hydrateCollisionMeshFunction: function(i) {
- var n = i ? g : v;
- i && (t.isVisible = !0),
- e.beginDirectAnimation(t, [n], 0, 15, !1, 1, (function() {
- i || (t.isVisible = !1)
- }
- ))
- }
- }
- }
- ,
- t.prototype._pickWithSphere = function(e, i, n, r) {
- var o = new Ui;
- if (o.distance = 1 / 0,
- e.touchCollisionMesh && e.xrController)
- for (var a = e.touchCollisionMesh.position, s = ir.CreateFromCenterAndRadius(a, i), l = 0; l < n.meshes.length; l++) {
- var c = n.meshes[l];
- if (r(c) && this._controllerAvailablePredicate(c, e.xrController.uniqueId)) {
- var u = t.PickMeshWithSphere(c, s);
- u && u.hit && u.distance < o.distance && (o.hit = u.hit,
- o.pickedMesh = c,
- o.pickedPoint = u.pickedPoint,
- o.aimTransform = e.xrController.pointer,
- o.gripTransform = e.xrController.grip || null,
- o.originMesh = e.touchCollisionMesh,
- o.distance = u.distance)
- }
- }
- return o
- }
- ,
- t.PickMeshWithSphere = function(e, t, i) {
- void 0 === i && (i = !1);
- var n = e.subMeshes
- , r = new Ui
- , o = e.getBoundingInfo();
- if (!e._generatePointsArray())
- return r;
- if (!e.subMeshes || !o)
- return r;
- if (!i && !ir.Intersects(o.boundingSphere, t))
- return r;
- var a, s, l, c = I.Vector3[0], u = I.Vector3[1], h = 1 / 0, d = I.Vector3[2], p = I.Matrix[0];
- p.copyFrom(e.getWorldMatrix()),
- p.invert(),
- x.TransformCoordinatesToRef(t.center, p, d);
- for (var f = 0; f < n.length; f++)
- n[f].projectToRef(d, e._positions, e.getIndices(), u),
- x.TransformCoordinatesToRef(u, e.getWorldMatrix(), u),
- a = x.Distance(u, t.center),
- l = x.Distance(u, e.getAbsolutePosition()),
- -1 !== (s = x.Distance(t.center, e.getAbsolutePosition())) && -1 !== l && l > s && (a = 0,
- u.copyFrom(t.center)),
- -1 !== a && a < h && (h = a,
- c.copyFrom(u));
- return h < t.radius && (r.hit = !0,
- r.distance = h,
- r.pickedMesh = e,
- r.pickedPoint = c.clone()),
- r
- }
- ,
- t._IdCounter = 200,
- t.Name = Io.NEAR_INTERACTION,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(Df.Name, (function(e, t) {
- return function() {
- return new Df(e,t)
- }
- }
- ), Df.Version, !0);
- var Nf, Lf = function() {
- function e(e, t, i) {
- this.element = e,
- this.sessionMode = t,
- this.referenceSpaceType = i
- }
- return e.prototype.update = function(e) {}
- ,
- e
- }(), Ff = function() {}, wf = function() {
- function e(e, t) {
- var i = this;
- if (this._scene = e,
- this.options = t,
- this._activeButton = null,
- this._buttons = [],
- this.activeButtonChangedObservable = new h,
- this._onSessionGranted = function(e) {
- i._helper && i._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;",
- !t.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted),
- "undefined" != typeof window && window.location && "http:" === window.location.protocol && "localhost" !== window.location.hostname)
- throw gi.Warn("WebXR can only be served over HTTPS"),
- new Error("WebXR can only be served over HTTPS");
- if (t.customButtons)
- this._buttons = t.customButtons;
- else {
- var n = t.sessionMode || "immersive-vr"
- , r = t.referenceSpaceType || "local-floor"
- , o = ".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(" + ("undefined" == typeof SVGSVGElement ? "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") + "); 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) }";
- o += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';
- var a = document.createElement("style");
- a.appendChild(document.createTextNode(o)),
- document.getElementsByTagName("head")[0].appendChild(a);
- var s = document.createElement("button");
- s.className = "babylonVRicon",
- s.title = "".concat(n, " - ").concat(r),
- this._buttons.push(new Lf(s,n,r)),
- this._buttons[this._buttons.length - 1].update = function(e) {
- this.element.style.display = null === e || e === this ? "" : "none",
- s.className = "babylonVRicon" + (e === this ? " vrdisplaypresenting" : "")
- }
- ,
- this._updateButtons(null)
- }
- var l = e.getEngine().getInputElement();
- l && l.parentNode && (l.parentNode.appendChild(this.overlay),
- e.onDisposeObservable.addOnce((function() {
- i.dispose()
- }
- )))
- }
- return e.prototype.setHelperAsync = function(e, t) {
- return G(this, void 0, void 0, (function() {
- var i, n = this;
- return z(this, (function(r) {
- switch (r.label) {
- case 0:
- return this._helper = e,
- this._renderTarget = t,
- i = this._buttons.map((function(t) {
- return e.sessionManager.isSessionSupportedAsync(t.sessionMode)
- }
- )),
- e.onStateChangedObservable.add((function(e) {
- e == Ns.NOT_IN_XR && n._updateButtons(null)
- }
- )),
- [4, Promise.all(i)];
- case 1:
- return r.sent().forEach((function(e, t) {
- e ? (n.overlay.appendChild(n._buttons[t].element),
- n._buttons[t].element.onclick = n._enterXRWithButtonIndex.bind(n, t)) : gi.Warn('Session mode "'.concat(n._buttons[t].sessionMode, '" not supported in browser'))
- }
- )),
- [2]
- }
- }
- ))
- }
- ))
- }
- ,
- e.CreateAsync = function(t, i, n) {
- return G(this, void 0, void 0, (function() {
- var r;
- return z(this, (function(o) {
- switch (o.label) {
- case 0:
- return [4, (r = new e(t,n)).setHelperAsync(i, n.renderTarget || void 0)];
- case 1:
- return o.sent(),
- [2, r]
- }
- }
- ))
- }
- ))
- }
- ,
- e.prototype._enterXRWithButtonIndex = function(e) {
- return void 0 === e && (e = 0),
- G(this, void 0, void 0, (function() {
- var t, i, n;
- return z(this, (function(r) {
- switch (r.label) {
- case 0:
- return this._helper.state != Ns.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()];
- case 1:
- return r.sent(),
- this._updateButtons(null),
- [3, 6];
- case 2:
- if (this._helper.state != Ns.NOT_IN_XR)
- return [3, 6];
- r.label = 3;
- case 3:
- return r.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 r.sent(),
- this._updateButtons(this._buttons[e]),
- [3, 6];
- case 5:
- return t = r.sent(),
- this._updateButtons(null),
- i = this._buttons[e].element,
- n = i.title,
- i.title = "Error entering XR session : " + n,
- i.classList.add("xr-error"),
- this.options.onError && this.options.onError(t),
- [3, 6];
- case 6:
- return [2]
- }
- }
- ))
- }
- ))
- }
- ,
- e.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)
- }
- ,
- e.prototype._updateButtons = function(e) {
- var t = this;
- this._activeButton = e,
- this._buttons.forEach((function(e) {
- e.update(t._activeButton)
- }
- )),
- this.activeButtonChangedObservable.notifyObservers(this._activeButton)
- }
- ,
- e
- }();
- function Bf(e) {
- var t, i = 0, n = Date.now();
- e.observableParameters = null !== (t = e.observableParameters) && void 0 !== t ? t : {};
- var r = e.contextObservable.add((function(t) {
- var o = Date.now()
- , a = {
- startTime: n,
- currentTime: o,
- deltaTime: i = o - n,
- completeRate: i / e.timeout,
- payload: t
- };
- e.onTick && e.onTick(a),
- e.breakCondition && e.breakCondition() && (e.contextObservable.remove(r),
- e.onAborted && e.onAborted(a)),
- i >= e.timeout && (e.contextObservable.remove(r),
- e.onEnded && e.onEnded(a))
- }
- ), e.observableParameters.mask, e.observableParameters.insertFirst, e.observableParameters.scope);
- return r
- }
- !function(e) {
- e[e.INIT = 0] = "INIT",
- e[e.STARTED = 1] = "STARTED",
- e[e.ENDED = 2] = "ENDED"
- }(Nf || (Nf = {}));
- var Uf = function() {
- function e(e) {
- var t, i, n = this;
- this.onEachCountObservable = new h,
- this.onTimerAbortedObservable = new h,
- this.onTimerEndedObservable = new h,
- this.onStateChangedObservable = new h,
- this._observer = null,
- this._breakOnNextTick = !1,
- this._tick = function(e) {
- var t = Date.now();
- n._timer = t - n._startTime;
- var i = {
- startTime: n._startTime,
- currentTime: t,
- deltaTime: n._timer,
- completeRate: n._timer / n._timeToEnd,
- payload: e
- }
- , r = n._breakOnNextTick || n._breakCondition(i);
- r || n._timer >= n._timeToEnd ? n._stop(i, r) : n.onEachCountObservable.notifyObservers(i)
- }
- ,
- this._setState(Nf.INIT),
- this._contextObservable = e.contextObservable,
- this._observableParameters = null !== (t = e.observableParameters) && void 0 !== t ? t : {},
- this._breakCondition = null !== (i = e.breakCondition) && void 0 !== i ? i : function() {
- return !1
- }
- ,
- this._timeToEnd = e.timeout,
- e.onEnded && this.onTimerEndedObservable.add(e.onEnded),
- e.onTick && this.onEachCountObservable.add(e.onTick),
- e.onAborted && this.onTimerAbortedObservable.add(e.onAborted)
- }
- return Object.defineProperty(e.prototype, "breakCondition", {
- set: function(e) {
- this._breakCondition = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.clearObservables = function() {
- this.onEachCountObservable.clear(),
- this.onTimerAbortedObservable.clear(),
- this.onTimerEndedObservable.clear(),
- this.onStateChangedObservable.clear()
- }
- ,
- e.prototype.start = function(e) {
- if (void 0 === e && (e = this._timeToEnd),
- this._state === Nf.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(Nf.STARTED)
- }
- ,
- e.prototype.stop = function() {
- this._state === Nf.STARTED && (this._breakOnNextTick = !0)
- }
- ,
- e.prototype.dispose = function() {
- this._observer && this._contextObservable.remove(this._observer),
- this.clearObservables()
- }
- ,
- e.prototype._setState = function(e) {
- this._state = e,
- this.onStateChangedObservable.notifyObservers(this._state)
- }
- ,
- e.prototype._stop = function(e, t) {
- void 0 === t && (t = !1),
- this._contextObservable.remove(this._observer),
- this._setState(Nf.ENDED),
- t ? this.onTimerAbortedObservable.notifyObservers(e) : this.onTimerEndedObservable.notifyObservers(e)
- }
- ,
- e
- }()
- , Vf = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n._options = i,
- n._controllers = {},
- n._snappedToPoint = !1,
- n._tmpRay = new _o(new x,new x),
- n._tmpVector = new x,
- n._tmpQuaternion = new C,
- n.skipNextTeleportation = !1,
- n.backwardsMovementEnabled = !0,
- n.backwardsTeleportationDistance = .7,
- n.parabolicCheckRadius = 5,
- n.parabolicRayEnabled = !0,
- n.straightRayEnabled = !0,
- n.rotationAngle = Math.PI / 8,
- n.onTargetMeshPositionUpdatedObservable = new h,
- n.teleportationEnabled = !0,
- n._rotationEnabled = !0,
- n._attachController = function(e) {
- if (!(n._controllers[e.uniqueId] || n._options.forceHandedness && e.inputSource.handedness !== n._options.forceHandedness)) {
- n._controllers[e.uniqueId] = {
- xrController: e,
- teleportationState: {
- forward: !1,
- backwards: !1,
- rotating: !1,
- currentRotation: 0,
- baseRotation: 0
- }
- };
- var t = n._controllers[e.uniqueId];
- if ("tracked-pointer" === t.xrController.inputSource.targetRayMode && t.xrController.inputSource.gamepad) {
- var i = function() {
- if (e.motionController) {
- var i = e.motionController.getComponentOfType(Ap.THUMBSTICK_TYPE) || e.motionController.getComponentOfType(Ap.TOUCHPAD_TYPE);
- if (!i || n._options.useMainComponentOnly) {
- var r = e.motionController.getMainComponent();
- if (!r)
- return;
- t.teleportationComponent = r,
- t.onButtonChangedObserver = r.onButtonStateChangedObservable.add((function() {
- n.teleportationEnabled && r.changes.pressed && (r.changes.pressed.current ? (t.teleportationState.forward = !0,
- n._currentTeleportationControllerId = t.xrController.uniqueId,
- t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
- t.teleportationState.currentRotation = 0,
- Bf({
- timeout: n._options.timeToTeleport || 3e3,
- contextObservable: n._xrSessionManager.onXRFrameObservable,
- breakCondition: function() {
- return !r.pressed
- },
- onEnded: function() {
- n._currentTeleportationControllerId === t.xrController.uniqueId && t.teleportationState.forward && n._teleportForward(e.uniqueId)
- }
- })) : (t.teleportationState.forward = !1,
- n._currentTeleportationControllerId = ""))
- }
- ))
- } else
- t.teleportationComponent = i,
- t.onAxisChangedObserver = i.onAxisValueChangedObservable.add((function(i) {
- if (i.y <= .7 && t.teleportationState.backwards && (t.teleportationState.backwards = !1),
- i.y > .7 && !t.teleportationState.forward && n.backwardsMovementEnabled && !n.snapPointsOnly && !t.teleportationState.backwards) {
- t.teleportationState.backwards = !0,
- n._tmpQuaternion.copyFrom(n._options.xrInput.xrCamera.rotationQuaternion),
- n._tmpQuaternion.toEulerAnglesToRef(n._tmpVector),
- n._tmpVector.x = 0,
- n._tmpVector.z = 0,
- C.FromEulerVectorToRef(n._tmpVector, n._tmpQuaternion),
- n._tmpVector.set(0, 0, n.backwardsTeleportationDistance * (n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
- n._tmpVector.rotateByQuaternionToRef(n._tmpQuaternion, n._tmpVector),
- n._tmpVector.addInPlace(n._options.xrInput.xrCamera.position),
- n._tmpRay.origin.copyFrom(n._tmpVector),
- n._tmpRay.length = n._options.xrInput.xrCamera.realWorldHeight + .1,
- n._tmpRay.direction.set(0, -1, 0);
- var r = n._xrSessionManager.scene.pickWithRay(n._tmpRay, (function(e) {
- return -1 !== n._floorMeshes.indexOf(e)
- }
- ));
- r && r.pickedPoint && (n._options.xrInput.xrCamera.position.x = r.pickedPoint.x,
- n._options.xrInput.xrCamera.position.z = r.pickedPoint.z)
- }
- if (i.y < -.7 && !n._currentTeleportationControllerId && !t.teleportationState.rotating && n.teleportationEnabled && (t.teleportationState.forward = !0,
- n._currentTeleportationControllerId = t.xrController.uniqueId,
- t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),
- i.x) {
- if (t.teleportationState.forward)
- n._currentTeleportationControllerId === t.xrController.uniqueId && (n.rotationEnabled ? setTimeout((function() {
- t.teleportationState.currentRotation = Math.atan2(i.x, i.y * (n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1))
- }
- )) : t.teleportationState.currentRotation = 0);
- else if (!t.teleportationState.rotating && Math.abs(i.x) > .7) {
- t.teleportationState.rotating = !0;
- var o = n.rotationAngle * (i.x > 0 ? 1 : -1) * (n._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
- C.FromEulerAngles(0, o, 0).multiplyToRef(n._options.xrInput.xrCamera.rotationQuaternion, n._options.xrInput.xrCamera.rotationQuaternion)
- }
- } else
- t.teleportationState.rotating = !1;
- 0 === i.x && 0 === i.y && t.teleportationState.forward && n._teleportForward(e.uniqueId)
- }
- ))
- }
- };
- e.motionController ? i() : e.onMotionControllerInitObservable.addOnce((function() {
- i()
- }
- ))
- } else
- n._xrSessionManager.scene.onPointerObservable.add((function(i) {
- i.type === Xi.POINTERDOWN ? (t.teleportationState.forward = !0,
- n._currentTeleportationControllerId = t.xrController.uniqueId,
- t.teleportationState.baseRotation = n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
- t.teleportationState.currentRotation = 0,
- Bf({
- timeout: n._options.timeToTeleport || 3e3,
- contextObservable: n._xrSessionManager.onXRFrameObservable,
- onEnded: function() {
- n._currentTeleportationControllerId === t.xrController.uniqueId && t.teleportationState.forward && n._teleportForward(e.uniqueId)
- }
- })) : i.type === Xi.POINTERUP && (t.teleportationState.forward = !1,
- n._currentTeleportationControllerId = "")
- }
- ))
- }
- }
- ,
- n._options.teleportationTargetMesh || n._createDefaultTargetMesh(),
- n._floorMeshes = n._options.floorMeshes || [],
- n._snapToPositions = n._options.snapPositions || [],
- n._setTargetMeshVisibility(!1),
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "rotationEnabled", {
- get: function() {
- return this._rotationEnabled
- },
- set: function(e) {
- if (this._rotationEnabled = e,
- this._options.teleportationTargetMesh) {
- var t = this._options.teleportationTargetMesh.getChildMeshes(!1, (function(e) {
- return "rotationCone" === e.name
- }
- ));
- t[0] && t[0].setEnabled(e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "teleportationTargetMesh", {
- get: function() {
- return this._options.teleportationTargetMesh || null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "snapPointsOnly", {
- get: function() {
- return !!this._options.snapPointsOnly
- },
- set: function(e) {
- this._options.snapPointsOnly = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addFloorMesh = function(e) {
- this._floorMeshes.push(e)
- }
- ,
- t.prototype.addBlockerMesh = function(e) {
- this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [],
- this._options.pickBlockerMeshes.push(e)
- }
- ,
- t.prototype.addSnapPoint = function(e) {
- this._snapToPositions.push(e)
- }
- ,
- t.prototype.attach = function() {
- var t = this;
- return !!e.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(e) {
- t._detachController(e.uniqueId)
- }
- )),
- !0)
- }
- ,
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
- t._detachController(e)
- }
- )),
- this._setTargetMeshVisibility(!1),
- this._currentTeleportationControllerId = "",
- this._controllers = {},
- !0)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.dispose(!1, !0)
- }
- ,
- t.prototype.removeFloorMesh = function(e) {
- var t = this._floorMeshes.indexOf(e);
- -1 !== t && this._floorMeshes.splice(t, 1)
- }
- ,
- t.prototype.removeBlockerMesh = function(e) {
- this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [];
- var t = this._options.pickBlockerMeshes.indexOf(e);
- -1 !== t && this._options.pickBlockerMeshes.splice(t, 1)
- }
- ,
- t.prototype.removeFloorMeshByName = function(e) {
- var t = this._xrSessionManager.scene.getMeshByName(e);
- t && this.removeFloorMesh(t)
- }
- ,
- t.prototype.removeSnapPoint = function(e) {
- var t = this._snapToPositions.indexOf(e);
- if (-1 === t)
- for (var i = 0; i < this._snapToPositions.length; ++i)
- if (this._snapToPositions[i].equals(e)) {
- t = i;
- break
- }
- return -1 !== t && (this._snapToPositions.splice(t, 1),
- !0)
- }
- ,
- t.prototype.setSelectionFeature = function(e) {
- this._selectionFeature = e
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t = this
- , i = this._xrSessionManager.currentFrame
- , n = this._xrSessionManager.scene;
- if (this.attach && i) {
- var r = this._options.teleportationTargetMesh;
- if (this._currentTeleportationControllerId) {
- if (!r)
- return;
- r.rotationQuaternion = r.rotationQuaternion || new C;
- var o = this._controllers[this._currentTeleportationControllerId];
- if (o && o.teleportationState.forward) {
- C.RotationYawPitchRollToRef(o.teleportationState.currentRotation + o.teleportationState.baseRotation, 0, 0, r.rotationQuaternion);
- var a = !1;
- if (o.xrController.getWorldPointerRayToRef(this._tmpRay),
- this.straightRayEnabled) {
- if ((s = n.pickWithRay(this._tmpRay, (function(e) {
- if (t._options.pickBlockerMeshes && -1 !== t._options.pickBlockerMeshes.indexOf(e))
- return !0;
- var i = t._floorMeshes.indexOf(e);
- return -1 !== i && t._floorMeshes[i].absolutePosition.y < t._options.xrInput.xrCamera.globalPosition.y
- }
- ))) && s.pickedMesh && this._options.pickBlockerMeshes && -1 !== this._options.pickBlockerMeshes.indexOf(s.pickedMesh))
- return;
- s && s.pickedPoint && (a = !0,
- this._setTargetMeshPosition(s),
- this._setTargetMeshVisibility(!0),
- this._showParabolicPath(s))
- }
- if (this.parabolicRayEnabled && !a) {
- var s, l = o.xrController.pointer.rotationQuaternion.toEulerAngles().x, c = Math.PI / 2 - Math.abs(l) + 1, u = this.parabolicCheckRadius * c;
- if (this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2 * u), this._tmpVector),
- this._tmpVector.y = this._tmpRay.origin.y,
- this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(u)),
- this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction),
- this._tmpRay.direction.normalize(),
- (s = n.pickWithRay(this._tmpRay, (function(e) {
- return !(!t._options.pickBlockerMeshes || -1 === t._options.pickBlockerMeshes.indexOf(e)) || -1 !== t._floorMeshes.indexOf(e)
- }
- ))) && s.pickedMesh && this._options.pickBlockerMeshes && -1 !== this._options.pickBlockerMeshes.indexOf(s.pickedMesh))
- return;
- s && s.pickedPoint && (a = !0,
- this._setTargetMeshPosition(s),
- this._setTargetMeshVisibility(!0),
- this._showParabolicPath(s))
- }
- this._setTargetMeshVisibility(a)
- } else
- this._setTargetMeshVisibility(!1)
- } else
- this._setTargetMeshVisibility(!1)
- }
- }
- ,
- t.prototype._createDefaultTargetMesh = function() {
- this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
- var e = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
- , t = il("teleportationTarget", {
- width: 2,
- height: 2,
- subdivisions: 2
- }, e);
- t.isPickable = !1;
- var i = new Ds("teleportationPlaneDynamicTexture",512,e,!0);
- i.hasAlpha = !0;
- var n = i.getContext();
- n.beginPath(),
- n.arc(256, 256, 200, 0, 2 * Math.PI, !1),
- n.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444",
- n.fill(),
- n.lineWidth = 10,
- n.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF",
- n.stroke(),
- n.closePath(),
- i.update();
- var r = new Os("teleportationPlaneMaterial",e);
- r.diffuseTexture = i,
- t.material = r;
- var o = qs("torusTeleportation", {
- diameter: .75,
- thickness: .1,
- tessellation: 20
- }, e);
- if (o.isPickable = !1,
- o.parent = t,
- !this._options.defaultTargetMeshOptions.disableAnimation) {
- var a = new Qe("animationInnerCircle","position.y",30,Qe.ANIMATIONTYPE_FLOAT,Qe.ANIMATIONLOOPMODE_CYCLE)
- , s = [];
- s.push({
- frame: 0,
- value: 0
- }),
- s.push({
- frame: 30,
- value: .4
- }),
- s.push({
- frame: 60,
- value: 0
- }),
- a.setKeys(s);
- var l = new kn;
- l.setEasingMode(Mn.EASINGMODE_EASEINOUT),
- a.setEasingFunction(l),
- o.animations = [],
- o.animations.push(a),
- e.beginAnimation(o, 0, 60, !0)
- }
- var c = Ys("rotationCone", {
- diameterTop: 0,
- tessellation: 4
- }, e);
- if (c.isPickable = !1,
- c.scaling.set(.5, .12, .2),
- c.rotate(vn.X, Math.PI / 2),
- c.position.z = .6,
- c.parent = o,
- this._options.defaultTargetMeshOptions.torusArrowMaterial)
- o.material = this._options.defaultTargetMeshOptions.torusArrowMaterial,
- c.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
- else {
- var u = new Os("torusConsMat",e);
- u.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting,
- u.disableLighting ? u.emissiveColor = new D(.3,.3,1) : u.diffuseColor = new D(.3,.3,1),
- u.alpha = .9,
- o.material = u,
- c.material = u,
- this._teleportationRingMaterial = u
- }
- void 0 !== this._options.renderingGroupId && (t.renderingGroupId = this._options.renderingGroupId,
- o.renderingGroupId = this._options.renderingGroupId,
- c.renderingGroupId = this._options.renderingGroupId),
- this._options.teleportationTargetMesh = t
- }
- ,
- t.prototype._detachController = function(e) {
- var t = this._controllers[e];
- t && (t.teleportationComponent && (t.onAxisChangedObserver && t.teleportationComponent.onAxisValueChangedObservable.remove(t.onAxisChangedObserver),
- t.onButtonChangedObserver && t.teleportationComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver)),
- delete this._controllers[e])
- }
- ,
- t.prototype._findClosestSnapPointWithRadius = function(e, t) {
- void 0 === t && (t = this._options.snapToPositionRadius || .8);
- var i = null
- , n = Number.MAX_VALUE;
- if (this._snapToPositions.length) {
- var r = t * t;
- this._snapToPositions.forEach((function(t) {
- var o = x.DistanceSquared(t, e);
- o <= r && o < n && (n = o,
- i = t)
- }
- ))
- }
- return i
- }
- ,
- t.prototype._setTargetMeshPosition = function(e) {
- var t = e.pickedPoint;
- if (this._options.teleportationTargetMesh && t) {
- var i = this._findClosestSnapPointWithRadius(t);
- this._snappedToPoint = !!i,
- 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(i || t),
- this._options.teleportationTargetMesh.position.y += .01,
- this.onTargetMeshPositionUpdatedObservable.notifyObservers(e)
- }
- }
- ,
- t.prototype._setTargetMeshVisibility = function(e) {
- this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible !== e && (this._options.teleportationTargetMesh.isVisible = e,
- this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach((function(t) {
- t.isVisible = e
- }
- )),
- e ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(),
- this._quadraticBezierCurve = null),
- this._selectionFeature && this._selectionFeature.attach()))
- }
- ,
- t.prototype._showParabolicPath = function(e) {
- if (e.pickedPoint) {
- var t = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || El.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
- , i = this._controllers[this._currentTeleportationControllerId]
- , n = Pn.CreateQuadraticBezier(i.xrController.pointer.absolutePosition, e.ray.origin, e.pickedPoint, 25);
- this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(n.getPoints(), e) : this._quadraticBezierCurve = Jl("teleportation path line", {
- points: n.getPoints(),
- instance: this._quadraticBezierCurve,
- updatable: !0
- }, t),
- this._quadraticBezierCurve.isPickable = !1,
- void 0 !== this._options.renderingGroupId && (this._quadraticBezierCurve.renderingGroupId = this._options.renderingGroupId)
- }
- }
- ,
- t.prototype._teleportForward = function(e) {
- var t = this._controllers[e];
- if (t && t.teleportationState.forward && this.teleportationEnabled && (t.teleportationState.forward = !1,
- this._currentTeleportationControllerId = "",
- !this.snapPointsOnly || this._snappedToPoint))
- if (this.skipNextTeleportation)
- this.skipNextTeleportation = !1;
- else if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) {
- var i = 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 += i,
- C.FromEulerAngles(0, t.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)
- }
- }
- ,
- t.Name = Io.TELEPORTATION,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(Vf.Name, (function(e, t) {
- return function() {
- return new Vf(e,t)
- }
- }
- ), Vf.Version, !0);
- var kf = function() {}
- , Gf = function() {
- function e() {}
- return e.CreateAsync = function(t, i) {
- void 0 === i && (i = {});
- var n = new e;
- if (t.onDisposeObservable.addOnce((function() {
- n.dispose()
- }
- )),
- !i.disableDefaultUI) {
- var r = V({
- renderTarget: n.renderTarget
- }, i.uiOptions || {});
- i.optionalFeatures && ("boolean" == typeof i.optionalFeatures ? r.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : r.optionalFeatures = i.optionalFeatures),
- n.enterExitUI = new wf(t,r)
- }
- return Sp.CreateAsync(t).then((function(e) {
- if (n.baseExperience = e,
- i.ignoreNativeCameraTransformation && (n.baseExperience.camera.compensateOnFirstFrame = !1),
- n.input = new Fp(e.sessionManager,e.camera,V({
- controllerOptions: {
- renderingGroupId: i.renderingGroupId
- }
- }, i.inputOptions || {})),
- !i.disablePointerSelection) {
- var t = V(V({}, i.pointerSelectionOptions), {
- xrInput: n.input,
- renderingGroupId: i.renderingGroupId
- });
- n.pointerSelection = n.baseExperience.featuresManager.enableFeature(Bp.Name, i.useStablePlugins ? "stable" : "latest", t),
- i.disableTeleportation || (n.teleportation = n.baseExperience.featuresManager.enableFeature(Vf.Name, i.useStablePlugins ? "stable" : "latest", {
- floorMeshes: i.floorMeshes,
- xrInput: n.input,
- renderingGroupId: i.renderingGroupId
- }),
- n.teleportation.setSelectionFeature(n.pointerSelection))
- }
- return i.disableNearInteraction || (n.nearInteraction = n.baseExperience.featuresManager.enableFeature(Df.Name, i.useStablePlugins ? "stable" : "latest", {
- xrInput: n.input,
- farInteractionFeature: n.pointerSelection,
- renderingGroupId: i.renderingGroupId,
- useUtilityLayer: !0,
- enableNearInteractionOnAllControllers: !0
- })),
- n.renderTarget = n.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions),
- i.disableDefaultUI ? void 0 : n.enterExitUI.setHelperAsync(n.baseExperience, n.renderTarget)
- }
- )).then((function() {
- return n
- }
- )).catch((function(e) {
- return K.Error("Error initializing XR"),
- K.Error(e),
- n
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- this.baseExperience && this.baseExperience.dispose(),
- this.input && this.input.dispose(),
- this.enterExitUI && this.enterExitUI.dispose(),
- this.renderTarget && this.renderTarget.dispose()
- }
- ,
- e
- }()
- , zf = !0;
- function Wf(e) {
- for (; e.firstChild; )
- e.removeChild(e.firstChild);
- e.srcObject = null,
- e.src = "",
- e.removeAttribute("src")
- }
- mn.prototype.createDefaultLight = function(e) {
- if (void 0 === e && (e = !1),
- e && this.lights)
- for (var t = 0; t < this.lights.length; t++)
- this.lights[t].dispose();
- 0 === this.lights.length && new ds("default light",x.Up(),this)
- }
- ,
- mn.prototype.createDefaultCamera = function(e, t, i) {
- if (void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- t && this.activeCamera && (this.activeCamera.dispose(),
- this.activeCamera = null),
- !this.activeCamera) {
- var n = this.getWorldExtends((function(e) {
- return e.isVisible && e.isEnabled()
- }
- ))
- , r = n.max.subtract(n.min)
- , o = n.min.add(r.scale(.5))
- , a = void 0
- , s = 1.5 * r.length();
- if (isFinite(s) || (s = 1,
- o.copyFromFloats(0, 0, 0)),
- e) {
- var l = new _a("default camera",-Math.PI / 2,Math.PI / 2,s,o,this);
- l.lowerRadiusLimit = .01 * s,
- l.wheelPrecision = 100 / s,
- a = l
- } else {
- var c = new pa("default camera",new x(o.x,o.y,-s),this);
- c.setTarget(o),
- a = c
- }
- a.minZ = .01 * s,
- a.maxZ = 1e3 * s,
- a.speed = .2 * s,
- this.activeCamera = a,
- i && a.attachControl()
- }
- }
- ,
- mn.prototype.createDefaultCameraOrLight = function(e, t, i) {
- void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- this.createDefaultLight(t),
- this.createDefaultCamera(e, t, i)
- }
- ,
- mn.prototype.createDefaultSkybox = function(e, t, i, n, r) {
- if (void 0 === t && (t = !1),
- void 0 === i && (i = 1e3),
- void 0 === n && (n = 0),
- void 0 === r && (r = !0),
- !e)
- return K.Warn("Can not create default skybox without environment texture."),
- null;
- r && e && (this.environmentTexture = e);
- var o = Ml("hdrSkyBox", {
- size: i
- }, this);
- if (t) {
- var a = new op("skyBox",this);
- a.backFaceCulling = !1,
- a.reflectionTexture = e.clone(),
- a.reflectionTexture && (a.reflectionTexture.coordinatesMode = io.SKYBOX_MODE),
- a.microSurface = 1 - n,
- a.disableLighting = !0,
- a.twoSidedLighting = !0,
- o.material = a
- } else {
- var s = new Os("skyBox",this);
- s.backFaceCulling = !1,
- s.reflectionTexture = e.clone(),
- s.reflectionTexture && (s.reflectionTexture.coordinatesMode = io.SKYBOX_MODE),
- s.disableLighting = !0,
- o.material = s
- }
- return o.isPickable = !1,
- o.infiniteDistance = !0,
- o.ignoreCameraMaxZ = !0,
- o
- }
- ,
- mn.prototype.createDefaultEnvironment = function(e) {
- return kd ? new kd(e,this) : null
- }
- ,
- mn.prototype.createDefaultVRExperience = function(e) {
- return void 0 === e && (e = {}),
- new hl(this,e)
- }
- ,
- mn.prototype.createDefaultXRExperienceAsync = function(e) {
- return void 0 === e && (e = {}),
- Gf.CreateAsync(this, e).then((function(e) {
- return e
- }
- ))
- }
- ;
- var Hf = function(e) {
- function t(t, i, n, r, o, a, s, l) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !1),
- void 0 === a && (a = io.TRILINEAR_SAMPLINGMODE),
- void 0 === s && (s = {});
- var c = e.call(this, null, n, !r, o) || this;
- c._onUserActionRequestedObservable = null,
- c._stillImageCaptured = !1,
- c._displayingPosterTexture = !1,
- c._frameId = -1,
- c._currentSrc = null,
- c._errorFound = !1,
- c._createInternalTexture = function() {
- if (null != c._texture) {
- if (!c._displayingPosterTexture)
- return;
- c._texture.dispose(),
- c._displayingPosterTexture = !1
- }
- if (!c._getEngine().needPOTTextures || gi.IsExponentOfTwo(c.video.videoWidth) && gi.IsExponentOfTwo(c.video.videoHeight) ? (c.wrapU = io.WRAP_ADDRESSMODE,
- c.wrapV = io.WRAP_ADDRESSMODE) : (c.wrapU = io.CLAMP_ADDRESSMODE,
- c.wrapV = io.CLAMP_ADDRESSMODE,
- c._generateMipMaps = !1),
- c._texture = c._getEngine().createDynamicTexture(c.video.videoWidth, c.video.videoHeight, c._generateMipMaps, c.samplingMode),
- c.video.autoplay || c._settings.poster)
- c._updateInternalTexture(),
- c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c);
- else {
- var e = c.video.onplaying
- , t = c.video.muted;
- c.video.muted = !0,
- c.video.onplaying = function() {
- c.video.muted = t,
- c.video.onplaying = e,
- c._updateInternalTexture(),
- c._errorFound || c.video.pause(),
- c.onLoadObservable.hasObservers() && c.onLoadObservable.notifyObservers(c)
- }
- ,
- c._handlePlay()
- }
- }
- ,
- c._reset = function() {
- null != c._texture && (c._displayingPosterTexture || (c._texture.dispose(),
- c._texture = null))
- }
- ,
- c._updateInternalTexture = function() {
- if (null != c._texture && !(c.video.readyState < c.video.HAVE_CURRENT_DATA || c._displayingPosterTexture)) {
- var e = c.getScene().getFrameId();
- c._frameId !== e && (c._frameId = e,
- c._getEngine().updateVideoTexture(c._texture, c.video, c._invertY))
- }
- }
- ,
- c._settings = V({
- autoPlay: !0,
- loop: !0,
- autoUpdateTexture: !0
- }, s),
- c._onError = l,
- c._generateMipMaps = r,
- c._initialSamplingMode = a,
- c.autoUpdateTexture = c._settings.autoUpdateTexture,
- c._currentSrc = i,
- c.name = t || c._getName(i),
- c.video = c._getVideo(i),
- s.poster && (c.video.poster = s.poster),
- void 0 !== s.autoPlay && (c.video.autoplay = s.autoPlay),
- void 0 !== s.loop && (c.video.loop = s.loop),
- void 0 !== s.muted && (c.video.muted = s.muted),
- c.video.setAttribute("playsinline", ""),
- c.video.addEventListener("paused", c._updateInternalTexture),
- c.video.addEventListener("seeked", c._updateInternalTexture),
- c.video.addEventListener("emptied", c._reset),
- c._createInternalTextureOnEvent = s.poster && !s.autoPlay ? "play" : "canplay",
- c.video.addEventListener(c._createInternalTextureOnEvent, c._createInternalTexture),
- s.autoPlay && c._handlePlay();
- var u = c.video.readyState >= c.video.HAVE_CURRENT_DATA;
- return !s.poster || s.autoPlay && u ? u && c._createInternalTexture() : (c._texture = c._getEngine().createTexture(s.poster, !1, !c.invertY, n),
- c._displayingPosterTexture = !0),
- c
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "onUserActionRequestedObservable", {
- get: function() {
- return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new h),
- this._onUserActionRequestedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._processError = function(e) {
- this._errorFound = !0,
- this._onError ? this._onError(null == e ? void 0 : e.message) : K.Error(null == e ? void 0 : e.message)
- }
- ,
- t.prototype._handlePlay = function() {
- var e = this;
- this._errorFound = !1,
- this.video.play().catch((function(t) {
- if ("NotAllowedError" === (null == t ? void 0 : t.name)) {
- if (e._onUserActionRequestedObservable && e._onUserActionRequestedObservable.hasObservers())
- return void e._onUserActionRequestedObservable.notifyObservers(e);
- if (!e.video.muted)
- return K.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),
- e.video.muted = !0,
- e._errorFound = !1,
- void e.video.play().catch((function(t) {
- e._processError(t)
- }
- ))
- }
- e._processError(t)
- }
- ))
- }
- ,
- t.prototype.getClassName = function() {
- return "VideoTexture"
- }
- ,
- t.prototype._getName = function(e) {
- return e instanceof HTMLVideoElement ? e.currentSrc : "object" == typeof e ? e.toString() : e
- }
- ,
- t.prototype._getVideo = function(e) {
- if (e.isNative)
- return e;
- if (e instanceof HTMLVideoElement)
- return gi.SetCorsBehavior(e.currentSrc, e),
- e;
- var t = document.createElement("video");
- return "string" == typeof e ? (gi.SetCorsBehavior(e, t),
- t.src = e) : (gi.SetCorsBehavior(e[0], t),
- e.forEach((function(e) {
- var i = document.createElement("source");
- i.src = e,
- t.appendChild(i)
- }
- ))),
- this.onDisposeObservable.addOnce((function() {
- Wf(t)
- }
- )),
- t
- }
- ,
- t.prototype._rebuild = function() {
- this.update()
- }
- ,
- t.prototype.update = function() {
- this.autoUpdateTexture && this.updateTexture(!0)
- }
- ,
- t.prototype.updateTexture = function(e) {
- e && (this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0,
- this._updateInternalTexture()))
- }
- ,
- t.prototype.updateURL = function(e) {
- this.video.src = e,
- this._currentSrc = e
- }
- ,
- t.prototype.clone = function() {
- return new t(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)
- }
- ,
- t.prototype.dispose = function() {
- e.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()
- }
- ,
- t.CreateFromStreamAsync = function(e, i, n, r) {
- void 0 === r && (r = !0);
- var o = e.getEngine().createVideoElement(n);
- return e.getEngine()._badOS && (document.body.appendChild(o),
- o.style.transform = "scale(0.0001, 0.0001)",
- o.style.opacity = "0",
- o.style.position = "fixed",
- o.style.bottom = "0px",
- o.style.right = "0px"),
- o.setAttribute("autoplay", ""),
- o.setAttribute("muted", "true"),
- o.setAttribute("playsinline", ""),
- o.muted = !0,
- void 0 !== o.mozSrcObject ? o.mozSrcObject = i : "object" == typeof o.srcObject ? o.srcObject = i : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
- o.src = window.URL && window.URL.createObjectURL(i)),
- new Promise((function(i) {
- var n = function() {
- var a = new t("video",o,e,!0,r);
- e.getEngine()._badOS && a.onDisposeObservable.addOnce((function() {
- o.remove()
- }
- )),
- a.onDisposeObservable.addOnce((function() {
- Wf(o)
- }
- )),
- i(a),
- o.removeEventListener("playing", n)
- };
- o.addEventListener("playing", n),
- o.play()
- }
- ))
- }
- ,
- t.CreateFromWebCamAsync = function(e, t, i, n) {
- var r, o = this;
- if (void 0 === i && (i = !1),
- void 0 === n && (n = !0),
- t && t.deviceId && (r = {
- exact: t.deviceId
- }),
- navigator.mediaDevices)
- return navigator.mediaDevices.getUserMedia({
- video: t,
- audio: i
- }).then((function(i) {
- return o.CreateFromStreamAsync(e, i, t, n)
- }
- ));
- var a = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
- return a && a({
- video: {
- deviceId: r,
- width: {
- min: t && t.minWidth || 256,
- max: t && t.maxWidth || 640
- },
- height: {
- min: t && t.minHeight || 256,
- max: t && t.maxHeight || 480
- }
- },
- audio: i
- }, (function(i) {
- return o.CreateFromStreamAsync(e, i, t, n)
- }
- ), (function(e) {
- K.Error(e.name)
- }
- )),
- Promise.reject("No support for userMedia on this device")
- }
- ,
- t.CreateFromWebCam = function(e, t, i, n, r) {
- void 0 === n && (n = !1),
- void 0 === r && (r = !0),
- this.CreateFromWebCamAsync(e, i, n, r).then((function(e) {
- t && t(e)
- }
- )).catch((function(e) {
- K.Error(e.name)
- }
- ))
- }
- ,
- t
- }(io)
- , Xf = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "videoTexture", {
- get: function() {
- return this._texture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "videoMode", {
- get: function() {
- return this.textureMode
- },
- set: function(e) {
- this.textureMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._initTexture = function(e, t, i) {
- var n = this
- , r = {
- loop: i.loop,
- autoPlay: i.autoPlay,
- autoUpdateTexture: !0,
- poster: i.poster
- }
- , o = new Hf((this.name || "videoDome") + "_texture",e,t,i.generateMipMaps,this._useDirectMapping,io.TRILINEAR_SAMPLINGMODE,r);
- return i.clickToPlay && (this._pointerObserver = t.onPointerObservable.add((function(e) {
- e.type !== Xi.POINTERUP && n._texture.video.play()
- }
- ))),
- this._textureObserver = o.onLoadObservable.add((function() {
- n.onLoadObservable.notifyObservers()
- }
- )),
- o
- }
- ,
- t.prototype.dispose = function(t, i) {
- void 0 === i && (i = !1),
- this._texture.onLoadObservable.remove(this._textureObserver),
- this._scene.onPointerObservable.remove(this._pointerObserver),
- e.prototype.dispose.call(this, t, i)
- }
- ,
- t.MODE_MONOSCOPIC = Gd.MODE_MONOSCOPIC,
- t.MODE_TOPBOTTOM = Gd.MODE_TOPBOTTOM,
- t.MODE_SIDEBYSIDE = Gd.MODE_SIDEBYSIDE,
- t
- }(Gd)
- , jf = function() {
- function e(e) {
- this.engine = e,
- this._captureGPUFrameTime = !1,
- this._captureShaderCompilationTime = !1,
- this._shaderCompilationTime = new un,
- this._onBeginFrameObserver = null,
- this._onEndFrameObserver = null,
- this._onBeforeShaderCompilationObserver = null,
- this._onAfterShaderCompilationObserver = null
- }
- return Object.defineProperty(e.prototype, "gpuFrameTimeCounter", {
- get: function() {
- return this.engine.getGPUFrameTimeCounter()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.prototype, "shaderCompilationTimeCounter", {
- get: function() {
- return this._shaderCompilationTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureShaderCompilationTime", {
- get: function() {
- return this._captureShaderCompilationTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureShaderCompilationTime && (this._captureShaderCompilationTime = e,
- e ? (this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add((function() {
- t._shaderCompilationTime.fetchNewFrame(),
- t._shaderCompilationTime.beginMonitoring()
- }
- )),
- this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add((function() {
- t._shaderCompilationTime.endMonitoring()
- }
- ))) : (this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
- this._onBeforeShaderCompilationObserver = null,
- this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
- this._onAfterShaderCompilationObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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
- }
- ,
- e
- }()
- , Yf = function() {
- function e(e) {
- var t = this;
- this.scene = e,
- this._captureActiveMeshesEvaluationTime = !1,
- this._activeMeshesEvaluationTime = new un,
- this._captureRenderTargetsRenderTime = !1,
- this._renderTargetsRenderTime = new un,
- this._registerBeforeRenderTime = new un,
- this._onBeforeRegisterBeforeRenderObserver = null,
- this._onAfterRegisterBeforeRenderObserver = null,
- this._RTT1Time = new un,
- this._onBeforeRTT1Observer = null,
- this._onAfterRTT1Observer = null,
- this._registerAfterRenderTime = new un,
- this._onBeforeRegisterAfterRenderObserver = null,
- this._onAfterRegisterAfterRenderObserver = null,
- this._captureFrameTime = !1,
- this._frameTime = new un,
- this._captureRenderTime = !1,
- this._renderTime = new un,
- this._captureInterFrameTime = !1,
- this._interFrameTime = new un,
- this._captureParticlesRenderTime = !1,
- this._particlesRenderTime = new un,
- this._captureSpritesRenderTime = !1,
- this._spritesRenderTime = new un,
- this._capturePhysicsTime = !1,
- this._physicsTime = new un,
- this._captureAnimationsTime = !1,
- this._animationsTime = new un,
- this._captureCameraRenderTime = !1,
- this._cameraRenderTime = new un,
- 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() {
- t._captureActiveMeshesEvaluationTime && t._activeMeshesEvaluationTime.fetchNewFrame(),
- t._captureRenderTargetsRenderTime && t._renderTargetsRenderTime.fetchNewFrame(),
- t._captureFrameTime && (gi.StartPerformanceCounter("Scene rendering"),
- t._frameTime.beginMonitoring()),
- t._captureInterFrameTime && t._interFrameTime.endMonitoring(),
- t._captureParticlesRenderTime && t._particlesRenderTime.fetchNewFrame(),
- t._captureSpritesRenderTime && t._spritesRenderTime.fetchNewFrame(),
- t._captureAnimationsTime && t._animationsTime.beginMonitoring(),
- t.scene.getEngine()._drawCalls.fetchNewFrame()
- }
- )),
- this._onAfterRenderObserver = e.onAfterRenderObservable.add((function() {
- t._captureFrameTime && (gi.EndPerformanceCounter("Scene rendering"),
- t._frameTime.endMonitoring()),
- t._captureRenderTime && t._renderTime.endMonitoring(!1),
- t._captureInterFrameTime && t._interFrameTime.beginMonitoring()
- }
- )),
- this._onBeforeRegisterBeforeRenderObserver = e.onBeforeRunRegisterBeforeRenderObservable.add(function() {
- t._registerBeforeRenderTime.beginMonitoring()
- }),
- this._onAfterRegisterBeforeRenderObserver = e.onAfterRunRegisterBeforeRenderObservable.add(function() {
- t._registerBeforeRenderTime.endMonitoring()
- }),
- this._onBeforeRegisterAfterRenderObserver = e.onBeforeRunRegisterAfterRenderObservable.add(function() {
- t._registerAfterRenderTime.beginMonitoring()
- }),
- this._onAfterRegisterAfterRenderObserver = e.onAfterRunRegisterAfterRenderObservable.add(function() {
- t._registerAfterRenderTime.endMonitoring()
- }),
- this._onBeforeRTT1Observer = e.onBeforeRTT1Observable.add(function() {
- t._RTT1Time.beginMonitoring()
- }),
- this._onAfterRTT1Observer = e.onAfterRTT1Observable.add(function() {
- t._RTT1Time.endMonitoring()
- })
- }
- return Object.defineProperty(e.prototype, "activeMeshesEvaluationTimeCounter", {
- get: function() {
- return this._activeMeshesEvaluationTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureActiveMeshesEvaluationTime", {
- get: function() {
- return this._captureActiveMeshesEvaluationTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureActiveMeshesEvaluationTime && (this._captureActiveMeshesEvaluationTime = e,
- e ? (this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add((function() {
- gi.StartPerformanceCounter("Active meshes evaluation"),
- t._activeMeshesEvaluationTime.beginMonitoring()
- }
- )),
- this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add((function() {
- gi.EndPerformanceCounter("Active meshes evaluation"),
- t._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(e.prototype, "renderTargetsRenderTimeCounter", {
- get: function() {
- return this._renderTargetsRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "registerBeforeTimeCounter", {
- get: function() {
- return this._registerBeforeRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "getRTT1TimeCounter", {
- get: function() {
- return this._RTT1Time
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "registerAfterTimeCounter", {
- get: function() {
- return this._registerAfterRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureRenderTargetsRenderTime", {
- get: function() {
- return this._captureRenderTargetsRenderTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureRenderTargetsRenderTime && (this._captureRenderTargetsRenderTime = e,
- e ? (this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add((function() {
- gi.StartPerformanceCounter("Render targets rendering"),
- t._renderTargetsRenderTime.beginMonitoring()
- }
- )),
- this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add((function() {
- gi.EndPerformanceCounter("Render targets rendering"),
- t._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(e.prototype, "particlesRenderTimeCounter", {
- get: function() {
- return this._particlesRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureParticlesRenderTime", {
- get: function() {
- return this._captureParticlesRenderTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureParticlesRenderTime && (this._captureParticlesRenderTime = e,
- e ? (this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add((function() {
- gi.StartPerformanceCounter("Particles"),
- t._particlesRenderTime.beginMonitoring()
- }
- )),
- this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add((function() {
- gi.EndPerformanceCounter("Particles"),
- t._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(e.prototype, "spritesRenderTimeCounter", {
- get: function() {
- return this._spritesRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureSpritesRenderTime", {
- get: function() {
- return this._captureSpritesRenderTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureSpritesRenderTime && (this._captureSpritesRenderTime = e,
- this.scene.spriteManagers && (e ? (this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add((function() {
- gi.StartPerformanceCounter("Sprites"),
- t._spritesRenderTime.beginMonitoring()
- }
- )),
- this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add((function() {
- gi.EndPerformanceCounter("Sprites"),
- t._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(e.prototype, "physicsTimeCounter", {
- get: function() {
- return this._physicsTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "capturePhysicsTime", {
- get: function() {
- return this._capturePhysicsTime
- },
- set: function(e) {
- var t = this;
- e !== this._capturePhysicsTime && this.scene.onBeforePhysicsObservable && (this._capturePhysicsTime = e,
- e ? (this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add((function() {
- gi.StartPerformanceCounter("Physics"),
- t._physicsTime.beginMonitoring()
- }
- )),
- this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add((function() {
- gi.EndPerformanceCounter("Physics"),
- t._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(e.prototype, "animationsTimeCounter", {
- get: function() {
- return this._animationsTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureAnimationsTime", {
- get: function() {
- return this._captureAnimationsTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureAnimationsTime && (this._captureAnimationsTime = e,
- e ? this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add((function() {
- t._animationsTime.endMonitoring()
- }
- )) : (this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
- this._onAfterAnimationsObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "frameTimeCounter", {
- get: function() {
- return this._frameTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureFrameTime", {
- get: function() {
- return this._captureFrameTime
- },
- set: function(e) {
- this._captureFrameTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "interFrameTimeCounter", {
- get: function() {
- return this._interFrameTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureInterFrameTime", {
- get: function() {
- return this._captureInterFrameTime
- },
- set: function(e) {
- this._captureInterFrameTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderTimeCounter", {
- get: function() {
- return this._renderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureRenderTime", {
- get: function() {
- return this._captureRenderTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureRenderTime && (this._captureRenderTime = e,
- e ? (this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add((function() {
- t._renderTime.beginMonitoring(),
- gi.StartPerformanceCounter("Main render")
- }
- )),
- this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add((function() {
- t._renderTime.endMonitoring(!1),
- gi.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(e.prototype, "cameraRenderTimeCounter", {
- get: function() {
- return this._cameraRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "captureCameraRenderTime", {
- get: function() {
- return this._captureCameraRenderTime
- },
- set: function(e) {
- var t = this;
- e !== this._captureCameraRenderTime && (this._captureCameraRenderTime = e,
- e ? (this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add((function(e) {
- t._cameraRenderTime.beginMonitoring(),
- gi.StartPerformanceCounter("Rendering camera ".concat(e.name))
- }
- )),
- this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add((function(e) {
- t._cameraRenderTime.endMonitoring(!1),
- gi.EndPerformanceCounter("Rendering camera ".concat(e.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(e.prototype, "drawCallsCounter", {
- get: function() {
- return this.scene.getEngine()._drawCalls
- },
- enumerable: !1,
- configurable: !0
- }),
- e.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
- }
- ,
- e
- }();
- Pt.ShadersStore.glowMapGenerationPixelShader = "#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include<helperFunctions>\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef DIFFUSE_ISLINEAR\nalbedoTexture=toGammaSpace(albedoTexture);\n#endif\n#ifdef GLOW\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\nfinalColor.a=albedoTexture.a;\n#endif\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a<ALPHATESTVALUE)\ndiscard;\n#endif\n#ifdef EMISSIVE\nvec4 emissive=texture2D(emissiveSampler,vUVEmissive);\n#ifdef EMISSIVE_ISLINEAR\nemissive=toGammaSpace(emissive);\n#endif\ngl_FragColor=emissive*finalColor;\n#else\ngl_FragColor=finalColor;\n#endif\n#ifdef HIGHLIGHT\ngl_FragColor.a=glowColor.a;\n#endif\n}";
- Pt.ShadersStore.glowMapGenerationVertexShader = "attribute vec3 position;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;\nvarying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(positionUpdated,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n}";
- var Kf = function() {
- function e(t, 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 N
- },
- this.neutralColor = new N,
- this.isEnabled = !0,
- this.disableBoundingBoxesFromEffectLayer = !1,
- this.onDisposeObservable = new h,
- this.onBeforeRenderMainTextureObservable = new h,
- this.onBeforeComposeObservable = new h,
- this.onBeforeRenderMeshToEffect = new h,
- this.onAfterRenderMeshToEffect = new h,
- this.onAfterComposeObservable = new h,
- this.onSizeChangedObservable = new h,
- this._materialForRendering = {},
- this.name = t,
- this._scene = i || E.LastCreatedScene,
- e._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(e.prototype, "camera", {
- get: function() {
- return this._effectLayerOptions.camera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderingGroupId", {
- get: function() {
- return this._effectLayerOptions.renderingGroupId
- },
- set: function(e) {
- this._effectLayerOptions.renderingGroupId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mainTexture", {
- get: function() {
- return this._mainTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setMaterialForRendering = function(e, t) {
- if (this._mainTexture.setMaterialForRendering(e, t),
- Array.isArray(e))
- for (var i = 0; i < e.length; ++i) {
- var n = e[i];
- t ? this._materialForRendering[n.uniqueId] = [n, t] : delete this._materialForRendering[n.uniqueId]
- }
- else
- t ? this._materialForRendering[e.uniqueId] = [e, t] : delete this._materialForRendering[e.uniqueId]
- }
- ,
- e.prototype._numInternalDraws = function() {
- return 1
- }
- ,
- e.prototype._init = function(e) {
- this._effectLayerOptions = V({
- mainTextureRatio: .5,
- alphaBlendingMode: a.ALPHA_COMBINE,
- camera: null,
- renderingGroupId: -1
- }, e),
- this._setMainTextureSize(),
- this._createMainTexture(),
- this._createTextureAndPostProcesses()
- }
- ,
- e.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)
- }
- ,
- e.prototype._generateVertexBuffer = function() {
- var e = [];
- e.push(1, 1),
- e.push(-1, 1),
- e.push(-1, -1),
- e.push(1, -1);
- var t = new Bi(this._engine,e,Bi.PositionKind,!1,!1,2);
- this._vertexBuffers[Bi.PositionKind] = t
- }
- ,
- e.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 ? vr.GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width,
- this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? vr.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)
- }
- ,
- e.prototype._createMainTexture = function() {
- var e = this;
- for (var t in this._mainTexture = new ns("EffectLayerMainRTT",{
- width: this._mainTextureDesiredSize.width,
- height: this._mainTextureDesiredSize.height
- },this._scene,!1,!0,a.TEXTURETYPE_UNSIGNED_INT),
- this._mainTexture.activeCamera = this._effectLayerOptions.camera,
- this._mainTexture.wrapU = io.CLAMP_ADDRESSMODE,
- this._mainTexture.wrapV = io.CLAMP_ADDRESSMODE,
- this._mainTexture.anisotropicFilteringLevel = 1,
- this._mainTexture.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
- this._mainTexture.renderParticles = !1,
- this._mainTexture.renderList = null,
- this._mainTexture.ignoreCameraViewport = !0,
- this._materialForRendering) {
- var i = this._materialForRendering[t]
- , n = i[0]
- , r = i[1];
- this._mainTexture.setMaterialForRendering(n, r)
- }
- if (this._mainTexture.customIsReadyFunction = function(t, i) {
- if (!t.isReady(!1))
- return !1;
- if (0 === i && t.subMeshes)
- for (var n = 0; n < t.subMeshes.length; ++n) {
- var r = t.subMeshes[n]
- , o = r.getMaterial()
- , a = r.getRenderingMesh();
- if (o) {
- var s = a._getInstancesRenderList(r._id, !!r.getReplacementMesh()).hardwareInstancedRendering[r._id] || a.hasThinInstances;
- if (e._setEmissiveTextureAndColor(a, r, o),
- !e._isReady(r, s, e._emissiveTextureAndColor.texture))
- return !1
- }
- }
- return !0
- }
- ,
- this._mainTexture.customRenderFunction = function(t, i, n, r) {
- var o;
- e.onBeforeRenderMainTextureObservable.notifyObservers(e);
- var a = e._scene.getEngine();
- if (r.length) {
- for (a.setColorWrite(!1),
- o = 0; o < r.length; o++)
- e._renderSubMesh(r.data[o]);
- a.setColorWrite(!0)
- }
- for (o = 0; o < t.length; o++)
- e._renderSubMesh(t.data[o]);
- for (o = 0; o < i.length; o++)
- e._renderSubMesh(i.data[o]);
- var s = a.getAlphaMode();
- for (o = 0; o < n.length; o++)
- e._renderSubMesh(n.data[o], !0);
- a.setAlphaMode(s)
- }
- ,
- this._mainTexture.onClearObservable.add((function(t) {
- t.clear(e.neutralColor, !0, !0, !0)
- }
- )),
- this._scene.getBoundingBoxRenderer) {
- var o = this._scene.getBoundingBoxRenderer().enabled;
- this._mainTexture.onBeforeBindObservable.add((function() {
- e._scene.getBoundingBoxRenderer().enabled = !e.disableBoundingBoxesFromEffectLayer && o
- }
- )),
- this._mainTexture.onAfterUnbindObservable.add((function() {
- e._scene.getBoundingBoxRenderer().enabled = o
- }
- ))
- }
- }
- ,
- e.prototype._addCustomEffectDefines = function(e) {}
- ,
- e.prototype._isReady = function(e, t, i) {
- var n, r = this._scene.getEngine(), o = e.getMesh(), a = null === (n = o._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === n ? void 0 : n[r.currentRenderPassId];
- if (a)
- return a.isReadyForSubMesh(o, e, t);
- var s = e.getMaterial();
- if (!s)
- return !1;
- if (this._useMeshMaterial(e.getRenderingMesh()))
- return s.isReadyForSubMesh(e.getMesh(), e, t);
- var l = []
- , c = [Bi.PositionKind]
- , u = !1
- , h = !1;
- if (s) {
- var d = s.needAlphaTesting()
- , p = s.getAlphaTestTexture()
- , f = p && p.hasAlpha && (s.useAlphaFromDiffuseTexture || s._useAlphaFromAlbedoTexture);
- p && (d || f) && (l.push("#define DIFFUSE"),
- o.isVerticesDataPresent(Bi.UV2Kind) && 1 === p.coordinatesIndex ? (l.push("#define DIFFUSEUV2"),
- h = !0) : o.isVerticesDataPresent(Bi.UVKind) && (l.push("#define DIFFUSEUV1"),
- u = !0),
- d && (l.push("#define ALPHATEST"),
- l.push("#define ALPHATESTVALUE 0.4")),
- p.gammaSpace || l.push("#define DIFFUSE_ISLINEAR"));
- var _ = s.opacityTexture;
- _ && (l.push("#define OPACITY"),
- o.isVerticesDataPresent(Bi.UV2Kind) && 1 === _.coordinatesIndex ? (l.push("#define OPACITYUV2"),
- h = !0) : o.isVerticesDataPresent(Bi.UVKind) && (l.push("#define OPACITYUV1"),
- u = !0))
- }
- i && (l.push("#define EMISSIVE"),
- o.isVerticesDataPresent(Bi.UV2Kind) && 1 === i.coordinatesIndex ? (l.push("#define EMISSIVEUV2"),
- h = !0) : o.isVerticesDataPresent(Bi.UVKind) && (l.push("#define EMISSIVEUV1"),
- u = !0),
- i.gammaSpace || l.push("#define EMISSIVE_ISLINEAR")),
- o.isVerticesDataPresent(Bi.ColorKind) && o.hasVertexAlpha && (c.push(Bi.ColorKind),
- l.push("#define VERTEXALPHA")),
- u && (c.push(Bi.UVKind),
- l.push("#define UV1")),
- h && (c.push(Bi.UV2Kind),
- l.push("#define UV2"));
- var m = new ys;
- if (o.useBones && o.computeBonesUsingShaders) {
- c.push(Bi.MatricesIndicesKind),
- c.push(Bi.MatricesWeightsKind),
- o.numBoneInfluencers > 4 && (c.push(Bi.MatricesIndicesExtraKind),
- c.push(Bi.MatricesWeightsExtraKind)),
- l.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers);
- var g = o.skeleton;
- g && g.isUsingTextureForMatrices ? l.push("#define BONETEXTURE") : l.push("#define BonesPerMesh " + (g ? g.bones.length + 1 : 0)),
- o.numBoneInfluencers > 0 && m.addCPUSkinningFallback(0, o)
- } else
- l.push("#define NUM_BONE_INFLUENCERS 0");
- var v = o.morphTargetManager
- , y = 0;
- v && v.numInfluencers > 0 && (l.push("#define MORPHTARGETS"),
- y = v.numInfluencers,
- l.push("#define NUM_MORPH_INFLUENCERS " + y),
- v.isUsingTextureForTargets && l.push("#define MORPHTARGETS_TEXTURE"),
- Mr.PrepareAttributesForMorphTargetsInfluencers(c, o, y)),
- t && (l.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(c),
- e.getRenderingMesh().hasThinInstances && l.push("#define THIN_INSTANCES")),
- this._addCustomEffectDefines(l);
- var b = e._getDrawWrapper(void 0, !0)
- , T = b.defines
- , E = l.join("\n");
- return T !== E && b.setEffect(this._engine.createEffect("glowMapGeneration", c, ["world", "mBones", "viewProjection", "glowColor", "morphTargetInfluences", "boneTextureWidth", "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], E, m, void 0, void 0, {
- maxSimultaneousMorphTargets: y
- }), E),
- b.effect.isReady()
- }
- ,
- e.prototype.render = function() {
- for (var e = 0; e < this._postProcesses.length; e++)
- if (!this._postProcesses[e].isReady())
- return;
- var t = this._scene.getEngine()
- , i = this._numInternalDraws()
- , n = !0;
- for (e = 0; e < i; ++e)
- (o = this._mergeDrawWrapper[e]) || (o = this._mergeDrawWrapper[e] = new Gt(this._engine)).setEffect(this._createMergeEffect()),
- n = n && o.effect.isReady();
- if (n) {
- this.onBeforeComposeObservable.notifyObservers(this);
- var r = t.getAlphaMode();
- for (e = 0; e < i; ++e) {
- var o = this._mergeDrawWrapper[e];
- t.enableEffect(o),
- t.setState(!1),
- t.bindBuffers(this._vertexBuffers, this._indexBuffer, o.effect),
- t.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),
- this._internalRender(o.effect, e)
- }
- t.setAlphaMode(r),
- this.onAfterComposeObservable.notifyObservers(this);
- var a = this._mainTexture.getSize();
- this._setMainTextureSize(),
- a.width === this._mainTextureDesiredSize.width && a.height === this._mainTextureDesiredSize.height || 0 === this._mainTextureDesiredSize.width || 0 === this._mainTextureDesiredSize.height || (this.onSizeChangedObservable.notifyObservers(this),
- this._disposeTextureAndPostProcesses(),
- this._createMainTexture(),
- this._createTextureAndPostProcesses())
- }
- }
- ,
- e.prototype.hasMesh = function(e) {
- return -1 === this.renderingGroupId || e.renderingGroupId === this.renderingGroupId
- }
- ,
- e.prototype.shouldRender = function() {
- return this.isEnabled && this._shouldRender
- }
- ,
- e.prototype._shouldRenderMesh = function(e) {
- return !0
- }
- ,
- e.prototype._canRenderMesh = function(e, t) {
- return !t.needAlphaBlendingForMesh(e)
- }
- ,
- e.prototype._shouldRenderEmissiveTextureForMesh = function() {
- return !0
- }
- ,
- e.prototype._renderSubMesh = function(e, t) {
- var i, n;
- if (void 0 === t && (t = !1),
- this.shouldRender()) {
- var r = e.getMaterial()
- , o = e.getMesh()
- , a = e.getReplacementMesh()
- , s = e.getRenderingMesh()
- , l = e.getEffectiveMesh()
- , c = this._scene
- , u = c.getEngine();
- if (l._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- r && this._canRenderMesh(s, r)) {
- var h = null !== (i = s.overrideMaterialSideOrientation) && void 0 !== i ? i : r.sideOrientation;
- l._getWorldMatrixDeterminant() < 0 && (h = h === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation);
- var d = h === Or.ClockWiseSideOrientation;
- u.setState(r.backFaceCulling, r.zOffset, void 0, d, r.cullBackFaces, void 0, r.zOffsetUnits);
- var p = s._getInstancesRenderList(e._id, !!a);
- if (!p.mustReturn && this._shouldRenderMesh(s)) {
- var f = p.hardwareInstancedRendering[e._id] || s.hasThinInstances;
- if (this._setEmissiveTextureAndColor(s, e, r),
- this.onBeforeRenderMeshToEffect.notifyObservers(o),
- this._useMeshMaterial(s))
- s.render(e, f, a || void 0);
- else if (this._isReady(e, f, this._emissiveTextureAndColor.texture)) {
- var _ = null === (n = l._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === n ? void 0 : n[u.currentRenderPassId]
- , m = e._getDrawWrapper();
- if (!m && _ && (m = _._getDrawWrapper()),
- !m)
- return;
- var g = m.effect;
- if (u.enableEffect(m),
- !f) {
- var v = c.forcePointsCloud ? Or.PointFillMode : c.forceWireframe ? Or.WireFrameFillMode : r.fillMode;
- s._bind(e, g, v)
- }
- if (_ ? _.bindForSubMesh(l.getWorldMatrix(), l, e) : (g.setMatrix("viewProjection", c.getTransformMatrix()),
- g.setMatrix("world", l.getWorldMatrix()),
- g.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a)),
- !_) {
- var y = r.needAlphaTesting()
- , b = r.getAlphaTestTexture()
- , T = b && b.hasAlpha && (r.useAlphaFromDiffuseTexture || r._useAlphaFromAlbedoTexture);
- b && (y || T) && (g.setTexture("diffuseSampler", b),
- (E = b.getTextureMatrix()) && g.setMatrix("diffuseMatrix", E));
- var E, S = r.opacityTexture;
- if (S && (g.setTexture("opacitySampler", S),
- g.setFloat("opacityIntensity", S.level),
- (E = S.getTextureMatrix()) && g.setMatrix("opacityMatrix", E)),
- this._emissiveTextureAndColor.texture && (g.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture),
- g.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())),
- s.useBones && s.computeBonesUsingShaders && s.skeleton) {
- var A = s.skeleton;
- if (A.isUsingTextureForMatrices) {
- var x = A.getTransformMatrixTexture(s);
- if (!x)
- return;
- g.setTexture("boneSampler", x),
- g.setFloat("boneTextureWidth", 4 * (A.bones.length + 1))
- } else
- g.setMatrices("mBones", A.getTransformMatrices(s))
- }
- Mr.BindMorphTargetParameters(s, g),
- s.morphTargetManager && s.morphTargetManager.isUsingTextureForTargets && s.morphTargetManager._bind(g),
- t && u.setAlphaMode(r.alphaMode)
- }
- s._processRendering(l, e, g, r.fillMode, p, f, (function(e, t) {
- return g.setMatrix("world", t)
- }
- ))
- } else
- this._mainTexture.resetRefreshCounter();
- this.onAfterRenderMeshToEffect.notifyObservers(o)
- }
- }
- }
- }
- ,
- e.prototype._useMeshMaterial = function(e) {
- return !1
- }
- ,
- e.prototype._rebuild = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && e._rebuild(),
- this._generateIndexBuffer()
- }
- ,
- e.prototype._disposeTextureAndPostProcesses = function() {
- this._mainTexture.dispose();
- for (var e = 0; e < this._postProcesses.length; e++)
- this._postProcesses[e] && this._postProcesses[e].dispose();
- for (this._postProcesses = [],
- e = 0; e < this._textures.length; e++)
- this._textures[e] && this._textures[e].dispose();
- this._textures = []
- }
- ,
- e.prototype.dispose = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[Bi.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null);
- for (var t = 0, i = this._mergeDrawWrapper; t < i.length; t++)
- i[t].dispose();
- this._mergeDrawWrapper = [],
- this._disposeTextureAndPostProcesses();
- var n = this._scene.effectLayers.indexOf(this, 0);
- n > -1 && this._scene.effectLayers.splice(n, 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()
- }
- ,
- e.prototype.getClassName = function() {
- return "EffectLayer"
- }
- ,
- e.Parse = function(e, t, i) {
- return gi.Instantiate(e.customType).Parse(e, t, i)
- }
- ,
- e._SceneComponentInitialization = function(e) {
- throw be("EffectLayerSceneComponent")
- }
- ,
- k([Ce()], e.prototype, "name", void 0),
- k([Fe()], e.prototype, "neutralColor", void 0),
- k([Ce()], e.prototype, "isEnabled", void 0),
- k([Ve()], e.prototype, "camera", null),
- k([Ce()], e.prototype, "renderingGroupId", null),
- k([Ce()], e.prototype, "disableBoundingBoxesFromEffectLayer", void 0),
- e
- }();
- o.AddParser(Wi.NAME_EFFECTLAYER, (function(e, t, i, n) {
- if (e.effectLayers) {
- i.effectLayers || (i.effectLayers = new Array);
- for (var r = 0; r < e.effectLayers.length; r++) {
- var o = Kf.Parse(e.effectLayers[r], t, n);
- i.effectLayers.push(o)
- }
- }
- }
- )),
- o.prototype.removeEffectLayer = function(e) {
- var t = this.effectLayers.indexOf(e);
- return -1 !== t && this.effectLayers.splice(t, 1),
- t
- }
- ,
- o.prototype.addEffectLayer = function(e) {
- this.effectLayers.push(e)
- }
- ;
- var Qf = function() {
- function e(e) {
- this.name = Wi.NAME_EFFECTLAYER,
- this._renderEffects = !1,
- this._needStencil = !1,
- this._previousStencilState = !1,
- this.scene = e || E.LastCreatedScene,
- this.scene && (this._engine = this.scene.getEngine(),
- this.scene.effectLayers = new Array)
- }
- return e.prototype.register = function() {
- this.scene._isReadyForMeshStage.registerStep(Wi.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh),
- this.scene._cameraDrawRenderTargetStage.registerStep(Wi.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture),
- this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil),
- this.scene._afterRenderingGroupDrawStage.registerStep(Wi.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup),
- this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack),
- this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera)
- }
- ,
- e.prototype.rebuild = function() {
- for (var e = 0, t = this.scene.effectLayers; e < t.length; e++)
- t[e]._rebuild()
- }
- ,
- e.prototype.serialize = function(e) {
- e.effectLayers = [];
- for (var t = 0, i = this.scene.effectLayers; t < i.length; t++) {
- var n = i[t];
- n.serialize && e.effectLayers.push(n.serialize())
- }
- }
- ,
- e.prototype.addFromContainer = function(e) {
- var t = this;
- e.effectLayers && e.effectLayers.forEach((function(e) {
- t.scene.addEffectLayer(e)
- }
- ))
- }
- ,
- e.prototype.removeFromContainer = function(e, t) {
- var i = this;
- e.effectLayers && e.effectLayers.forEach((function(e) {
- i.scene.removeEffectLayer(e),
- t && e.dispose()
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- for (var e = this.scene.effectLayers; e.length; )
- e[0].dispose()
- }
- ,
- e.prototype._isReadyForMesh = function(e, t) {
- for (var i = this._engine.currentRenderPassId, n = 0, r = this.scene.effectLayers; n < r.length; n++) {
- var o = r[n];
- if (o.hasMesh(e)) {
- var a = o._mainTexture;
- this._engine.currentRenderPassId = a.renderPassId;
- for (var s = 0, l = e.subMeshes; s < l.length; s++) {
- var c = l[s];
- if (!o.isReady(c, t))
- return this._engine.currentRenderPassId = i,
- !1
- }
- }
- }
- return this._engine.currentRenderPassId = i,
- !0
- }
- ,
- e.prototype._renderMainTexture = function(e) {
- this._renderEffects = !1,
- this._needStencil = !1;
- var t = !1
- , i = this.scene.effectLayers;
- if (i && i.length > 0) {
- this._previousStencilState = this._engine.getStencilBuffer();
- for (var n = 0, r = i; n < r.length; n++) {
- var o = r[n];
- if (o.shouldRender() && (!o.camera || o.camera.cameraRigMode === Rr.RIG_MODE_NONE && e === o.camera || o.camera.cameraRigMode !== Rr.RIG_MODE_NONE && o.camera._rigCameras.indexOf(e) > -1)) {
- this._renderEffects = !0,
- this._needStencil = this._needStencil || o.needStencil();
- var a = o._mainTexture;
- a._shouldRender() && (this.scene.incrementRenderId(),
- a.render(!1, !1),
- t = !0)
- }
- }
- this.scene.incrementRenderId()
- }
- return t
- }
- ,
- e.prototype._setStencil = function() {
- this._needStencil && this._engine.setStencilBuffer(!0)
- }
- ,
- e.prototype._setStencilBack = function() {
- this._needStencil && this._engine.setStencilBuffer(this._previousStencilState)
- }
- ,
- e.prototype._draw = function(e) {
- if (this._renderEffects) {
- this._engine.setDepthBuffer(!1);
- for (var t = this.scene.effectLayers, i = 0; i < t.length; i++) {
- var n = t[i];
- n.renderingGroupId === e && n.shouldRender() && n.render()
- }
- this._engine.setDepthBuffer(!0)
- }
- }
- ,
- e.prototype._drawCamera = function() {
- this._renderEffects && this._draw(-1)
- }
- ,
- e.prototype._drawRenderingGroup = function(e) {
- !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(e)
- }
- ,
- e
- }();
- Kf._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_EFFECTLAYER);
- t || (t = new Qf(e),
- e._addComponent(t))
- }
- ;
- Pt.ShadersStore.glowMapMergePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\nuniform float offset;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);\nbaseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);\nbaseColor.a=alpha;\nbaseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\n#if LDR\nbaseColor=clamp(baseColor,0.,1.0);\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.glowMapMergeVertexShader = "attribute vec2 position;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}",
- o.prototype.getGlowLayerByName = function(e) {
- for (var t = 0; t < this.effectLayers.length; t++)
- if (this.effectLayers[t].name === e && this.effectLayers[t].getEffectName() === qf.EffectName)
- return this.effectLayers[t];
- return null
- }
- ;
- var qf = function(e) {
- function t(i, n, r) {
- var o = e.call(this, i, n) || this;
- return o._intensity = 1,
- o._includedOnlyMeshes = [],
- o._excludedMeshes = [],
- o._meshesUsingTheirOwnMaterials = [],
- o.neutralColor = new N(0,0,0,1),
- o._options = V({
- mainTextureRatio: t.DefaultTextureRatio,
- blurKernelSize: 32,
- mainTextureFixedSize: void 0,
- camera: null,
- mainTextureSamples: 1,
- renderingGroupId: -1,
- ldrMerge: !1,
- alphaBlendingMode: a.ALPHA_ADD
- }, r),
- o._init({
- alphaBlendingMode: o._options.alphaBlendingMode,
- camera: o._options.camera,
- mainTextureFixedSize: o._options.mainTextureFixedSize,
- mainTextureRatio: o._options.mainTextureRatio,
- renderingGroupId: o._options.renderingGroupId
- }),
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "blurKernelSize", {
- get: function() {
- return this._horizontalBlurPostprocess1.kernel
- },
- set: function(e) {
- this._horizontalBlurPostprocess1.kernel = e,
- this._verticalBlurPostprocess1.kernel = e,
- this._horizontalBlurPostprocess2.kernel = e,
- this._verticalBlurPostprocess2.kernel = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "intensity", {
- get: function() {
- return this._intensity
- },
- set: function(e) {
- this._intensity = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getEffectName = function() {
- return t.EffectName
- }
- ,
- t.prototype._createMergeEffect = function() {
- var e = "#define EMISSIVE \n";
- return this._options.ldrMerge && (e += "#define LDR \n"),
- this._engine.createEffect("glowMapMerge", [Bi.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], e)
- }
- ,
- t.prototype._createTextureAndPostProcesses = function() {
- var e = this
- , t = this._mainTextureDesiredSize.width
- , i = this._mainTextureDesiredSize.height;
- t = this._engine.needPOTTextures ? vr.GetExponentOfTwo(t, this._maxSize) : t,
- i = this._engine.needPOTTextures ? vr.GetExponentOfTwo(i, this._maxSize) : i;
- var n;
- n = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT,
- this._blurTexture1 = new ns("GlowLayerBlurRTT",{
- width: t,
- height: i
- },this._scene,!1,!0,n),
- this._blurTexture1.wrapU = io.CLAMP_ADDRESSMODE,
- this._blurTexture1.wrapV = io.CLAMP_ADDRESSMODE,
- this._blurTexture1.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
- this._blurTexture1.renderParticles = !1,
- this._blurTexture1.ignoreCameraViewport = !0;
- var r = Math.floor(t / 2)
- , o = Math.floor(i / 2);
- this._blurTexture2 = new ns("GlowLayerBlurRTT2",{
- width: r,
- height: o
- },this._scene,!1,!0,n),
- this._blurTexture2.wrapU = io.CLAMP_ADDRESSMODE,
- this._blurTexture2.wrapV = io.CLAMP_ADDRESSMODE,
- this._blurTexture2.updateSamplingMode(io.BILINEAR_SAMPLINGMODE),
- this._blurTexture2.renderParticles = !1,
- this._blurTexture2.ignoreCameraViewport = !0,
- this._textures = [this._blurTexture1, this._blurTexture2],
- this._horizontalBlurPostprocess1 = new Fd("GlowLayerHBP1",new A(1,0),this._options.blurKernelSize / 2,{
- width: t,
- height: i
- },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
- this._horizontalBlurPostprocess1.width = t,
- this._horizontalBlurPostprocess1.height = i,
- this._horizontalBlurPostprocess1.externalTextureSamplerBinding = !0,
- this._horizontalBlurPostprocess1.onApplyObservable.add((function(t) {
- t.setTexture("textureSampler", e._mainTexture)
- }
- )),
- this._verticalBlurPostprocess1 = new Fd("GlowLayerVBP1",new A(0,1),this._options.blurKernelSize / 2,{
- width: t,
- height: i
- },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
- this._horizontalBlurPostprocess2 = new Fd("GlowLayerHBP2",new A(1,0),this._options.blurKernelSize / 2,{
- width: r,
- height: o
- },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
- this._horizontalBlurPostprocess2.width = r,
- this._horizontalBlurPostprocess2.height = o,
- this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0,
- this._horizontalBlurPostprocess2.onApplyObservable.add((function(t) {
- t.setTexture("textureSampler", e._blurTexture1)
- }
- )),
- this._verticalBlurPostprocess2 = new Fd("GlowLayerVBP2",new A(0,1),this._options.blurKernelSize / 2,{
- width: r,
- height: o
- },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
- 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 t = e._blurTexture1.renderTarget;
- if (t) {
- e._scene.postProcessManager.directRender(e._postProcesses1, t, !0);
- var i = e._blurTexture2.renderTarget;
- i && e._scene.postProcessManager.directRender(e._postProcesses2, i, !0),
- e._engine.unBindFramebuffer(null != i ? i : t, !0)
- }
- }
- )),
- this._postProcesses.map((function(e) {
- e.autoClear = !1
- }
- ))
- }
- ,
- t.prototype.isReady = function(t, i) {
- var n = t.getMaterial()
- , r = t.getRenderingMesh();
- if (!n || !r)
- return !1;
- var o = n.emissiveTexture;
- return e.prototype._isReady.call(this, t, i, o)
- }
- ,
- t.prototype.needStencil = function() {
- return !1
- }
- ,
- t.prototype._canRenderMesh = function(e, t) {
- return !0
- }
- ,
- t.prototype._internalRender = function(e) {
- e.setTexture("textureSampler", this._blurTexture1),
- e.setTexture("textureSampler2", this._blurTexture2),
- e.setFloat("offset", this._intensity);
- var t = this._engine
- , i = t.getStencilBuffer();
- t.setStencilBuffer(!1),
- t.drawElementsType(Or.TriangleFillMode, 0, 6),
- t.setStencilBuffer(i)
- }
- ,
- t.prototype._setEmissiveTextureAndColor = function(e, t, i) {
- var n, r = 1;
- this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(e, t, i) : i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture,
- this._emissiveTextureAndColor.texture && (r = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null,
- this.customEmissiveColorSelector ? this.customEmissiveColorSelector(e, t, i, this._emissiveTextureAndColor.color) : i.emissiveColor ? (r *= null !== (n = i.emissiveIntensity) && void 0 !== n ? n : 1,
- this._emissiveTextureAndColor.color.set(i.emissiveColor.r * r, i.emissiveColor.g * r, i.emissiveColor.b * r, i.alpha)) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a)
- }
- ,
- t.prototype._shouldRenderMesh = function(e) {
- return this.hasMesh(e)
- }
- ,
- t.prototype._addCustomEffectDefines = function(e) {
- e.push("#define GLOW")
- }
- ,
- t.prototype.addExcludedMesh = function(e) {
- -1 === this._excludedMeshes.indexOf(e.uniqueId) && this._excludedMeshes.push(e.uniqueId)
- }
- ,
- t.prototype.removeExcludedMesh = function(e) {
- var t = this._excludedMeshes.indexOf(e.uniqueId);
- -1 !== t && this._excludedMeshes.splice(t, 1)
- }
- ,
- t.prototype.addIncludedOnlyMesh = function(e) {
- -1 === this._includedOnlyMeshes.indexOf(e.uniqueId) && this._includedOnlyMeshes.push(e.uniqueId)
- }
- ,
- t.prototype.removeIncludedOnlyMesh = function(e) {
- var t = this._includedOnlyMeshes.indexOf(e.uniqueId);
- -1 !== t && this._includedOnlyMeshes.splice(t, 1)
- }
- ,
- t.prototype.hasMesh = function(t) {
- return !!e.prototype.hasMesh.call(this, t) && (this._includedOnlyMeshes.length ? -1 !== this._includedOnlyMeshes.indexOf(t.uniqueId) : !this._excludedMeshes.length || -1 === this._excludedMeshes.indexOf(t.uniqueId))
- }
- ,
- t.prototype._useMeshMaterial = function(e) {
- return 0 != this._meshesUsingTheirOwnMaterials.length && this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId) > -1
- }
- ,
- t.prototype.referenceMeshToUseItsOwnMaterial = function(e) {
- var t = this;
- e.resetDrawCache(this._mainTexture.renderPassId),
- this._meshesUsingTheirOwnMaterials.push(e.uniqueId),
- e.onDisposeObservable.add((function() {
- t._disposeMesh(e)
- }
- ))
- }
- ,
- t.prototype.unReferenceMeshFromUsingItsOwnMaterial = function(e) {
- for (var t = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId); t >= 0; )
- this._meshesUsingTheirOwnMaterials.splice(t, 1),
- t = this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);
- e.resetDrawCache(this._mainTexture.renderPassId)
- }
- ,
- t.prototype._disposeMesh = function(e) {
- this.removeIncludedOnlyMesh(e),
- this.removeExcludedMesh(e)
- }
- ,
- t.prototype.getClassName = function() {
- return "GlowLayer"
- }
- ,
- t.prototype.serialize = function() {
- var e, t = Ge.Serialize(this);
- if (t.customType = "BABYLON.GlowLayer",
- t.includedMeshes = [],
- this._includedOnlyMeshes.length)
- for (e = 0; e < this._includedOnlyMeshes.length; e++)
- (i = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[e])) && t.includedMeshes.push(i.id);
- if (t.excludedMeshes = [],
- this._excludedMeshes.length)
- for (e = 0; e < this._excludedMeshes.length; e++) {
- var i;
- (i = this._scene.getMeshByUniqueId(this._excludedMeshes[e])) && t.excludedMeshes.push(i.id)
- }
- return t
- }
- ,
- t.Parse = function(e, i, n) {
- var r, o = Ge.Parse((function() {
- return new t(e.name,i,e.options)
- }
- ), e, i, n);
- for (r = 0; r < e.excludedMeshes.length; r++)
- (a = i.getMeshById(e.excludedMeshes[r])) && o.addExcludedMesh(a);
- for (r = 0; r < e.includedMeshes.length; r++) {
- var a;
- (a = i.getMeshById(e.includedMeshes[r])) && o.addIncludedOnlyMesh(a)
- }
- return o
- }
- ,
- t.EffectName = "GlowLayer",
- t.DefaultBlurKernelSize = 32,
- t.DefaultTextureRatio = .5,
- k([Ce()], t.prototype, "blurKernelSize", null),
- k([Ce()], t.prototype, "intensity", null),
- k([Ce("options")], t.prototype, "_options", void 0),
- t
- }(Kf);
- y("BABYLON.GlowLayer", qf);
- Pt.ShadersStore.glowBlurPostProcessPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",
- o.prototype.getHighlightLayerByName = function(e) {
- for (var t, i = 0; i < (null === (t = this.effectLayers) || void 0 === t ? void 0 : t.length); i++)
- if (this.effectLayers[i].name === e && this.effectLayers[i].getEffectName() === Jf.EffectName)
- return this.effectLayers[i];
- return null
- }
- ;
- var Zf = function(e) {
- function t(t, i, n, r, o, a, s, l) {
- void 0 === a && (a = io.BILINEAR_SAMPLINGMODE);
- var c = e.call(this, t, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, r, o, a, s, l) || this;
- return c.direction = i,
- c.kernel = n,
- c.onApplyObservable.add((function(e) {
- e.setFloat2("screenSize", c.width, c.height),
- e.setVector2("direction", c.direction),
- e.setFloat("blurWidth", c.kernel)
- }
- )),
- c
- }
- return U(t, e),
- t
- }(Ba)
- , Jf = function(e) {
- function t(i, n, r) {
- var o = e.call(this, i, n) || this;
- return o.name = i,
- o.innerGlow = !0,
- o.outerGlow = !0,
- o.onBeforeBlurObservable = new h,
- o.onAfterBlurObservable = new h,
- o._instanceGlowingMeshStencilReference = t.GlowingMeshStencilReference++,
- o._meshes = {},
- o._excludedMeshes = {},
- o.neutralColor = t.NeutralColor,
- o._engine.isStencilEnable || K.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),
- o._options = V({
- mainTextureRatio: .5,
- blurTextureSizeRatio: .5,
- blurHorizontalSize: 1,
- blurVerticalSize: 1,
- alphaBlendingMode: a.ALPHA_COMBINE,
- camera: null,
- renderingGroupId: -1
- }, r),
- o._init({
- alphaBlendingMode: o._options.alphaBlendingMode,
- camera: o._options.camera,
- mainTextureFixedSize: o._options.mainTextureFixedSize,
- mainTextureRatio: o._options.mainTextureRatio,
- renderingGroupId: o._options.renderingGroupId
- }),
- o._shouldRender = !1,
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "blurHorizontalSize", {
- get: function() {
- return this._horizontalBlurPostprocess.kernel
- },
- set: function(e) {
- this._horizontalBlurPostprocess.kernel = e,
- this._options.blurHorizontalSize = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "blurVerticalSize", {
- get: function() {
- return this._verticalBlurPostprocess.kernel
- },
- set: function(e) {
- this._verticalBlurPostprocess.kernel = e,
- this._options.blurVerticalSize = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getEffectName = function() {
- return t.EffectName
- }
- ,
- t.prototype._numInternalDraws = function() {
- return 2
- }
- ,
- t.prototype._createMergeEffect = function() {
- return this._engine.createEffect("glowMapMerge", [Bi.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : void 0)
- }
- ,
- t.prototype._createTextureAndPostProcesses = function() {
- var e = this
- , t = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio
- , i = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
- t = this._engine.needPOTTextures ? vr.GetExponentOfTwo(t, this._maxSize) : t,
- i = this._engine.needPOTTextures ? vr.GetExponentOfTwo(i, this._maxSize) : i;
- var n;
- n = this._engine.getCaps().textureHalfFloatRender ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_INT,
- this._blurTexture = new ns("HighlightLayerBlurRTT",{
- width: t,
- height: i
- },this._scene,!1,!0,n),
- this._blurTexture.wrapU = io.CLAMP_ADDRESSMODE,
- this._blurTexture.wrapV = io.CLAMP_ADDRESSMODE,
- this._blurTexture.anisotropicFilteringLevel = 16,
- this._blurTexture.updateSamplingMode(io.TRILINEAR_SAMPLINGMODE),
- this._blurTexture.renderParticles = !1,
- this._blurTexture.ignoreCameraViewport = !0,
- this._textures = [this._blurTexture],
- this._options.alphaBlendingMode === a.ALPHA_COMBINE ? (this._downSamplePostprocess = new Ua("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
- this._downSamplePostprocess.externalTextureSamplerBinding = !0,
- this._downSamplePostprocess.onApplyObservable.add((function(t) {
- t.setTexture("textureSampler", e._mainTexture)
- }
- )),
- this._horizontalBlurPostprocess = new Zf("HighlightLayerHBP",new A(1,0),this._options.blurHorizontalSize,1,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
- this._horizontalBlurPostprocess.onApplyObservable.add((function(e) {
- e.setFloat2("screenSize", t, i)
- }
- )),
- this._verticalBlurPostprocess = new Zf("HighlightLayerVBP",new A(0,1),this._options.blurVerticalSize,1,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
- this._verticalBlurPostprocess.onApplyObservable.add((function(e) {
- e.setFloat2("screenSize", t, i)
- }
- )),
- this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new Fd("HighlightLayerHBP",new A(1,0),this._options.blurHorizontalSize / 2,{
- width: t,
- height: i
- },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
- this._horizontalBlurPostprocess.width = t,
- this._horizontalBlurPostprocess.height = i,
- this._horizontalBlurPostprocess.externalTextureSamplerBinding = !0,
- this._horizontalBlurPostprocess.onApplyObservable.add((function(t) {
- t.setTexture("textureSampler", e._mainTexture)
- }
- )),
- this._verticalBlurPostprocess = new Fd("HighlightLayerVBP",new A(0,1),this._options.blurVerticalSize / 2,{
- width: t,
- height: i
- },null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),
- this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]),
- this._mainTexture.onAfterUnbindObservable.add((function() {
- e.onBeforeBlurObservable.notifyObservers(e);
- var t = e._blurTexture.renderTarget;
- t && (e._scene.postProcessManager.directRender(e._postProcesses, t, !0),
- e._engine.unBindFramebuffer(t, !0)),
- e.onAfterBlurObservable.notifyObservers(e)
- }
- )),
- this._postProcesses.map((function(e) {
- e.autoClear = !1
- }
- ))
- }
- ,
- t.prototype.needStencil = function() {
- return !0
- }
- ,
- t.prototype.isReady = function(t, i) {
- var n = t.getMaterial()
- , r = t.getRenderingMesh();
- if (!n || !r || !this._meshes)
- return !1;
- var o = null
- , a = this._meshes[r.uniqueId];
- return a && a.glowEmissiveOnly && n && (o = n.emissiveTexture),
- e.prototype._isReady.call(this, t, i, o)
- }
- ,
- t.prototype._internalRender = function(e, t) {
- e.setTexture("textureSampler", this._blurTexture);
- var i = this._engine;
- i.cacheStencilState(),
- i.setStencilOperationPass(a.REPLACE),
- i.setStencilOperationFail(a.KEEP),
- i.setStencilOperationDepthFail(a.KEEP),
- i.setStencilMask(0),
- i.setStencilBuffer(!0),
- i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),
- this.outerGlow && 0 === t && (e.setFloat("offset", 0),
- i.setStencilFunction(a.NOTEQUAL),
- i.drawElementsType(Or.TriangleFillMode, 0, 6)),
- this.innerGlow && 1 === t && (e.setFloat("offset", 1),
- i.setStencilFunction(a.EQUAL),
- i.drawElementsType(Or.TriangleFillMode, 0, 6)),
- i.restoreStencilState()
- }
- ,
- t.prototype.shouldRender = function() {
- return !!e.prototype.shouldRender.call(this) && !!this._meshes
- }
- ,
- t.prototype._shouldRenderMesh = function(t) {
- return !(this._excludedMeshes && this._excludedMeshes[t.uniqueId] || !e.prototype.hasMesh.call(this, t))
- }
- ,
- t.prototype._canRenderMesh = function(e, t) {
- return !0
- }
- ,
- t.prototype._addCustomEffectDefines = function(e) {
- e.push("#define HIGHLIGHT")
- }
- ,
- t.prototype._setEmissiveTextureAndColor = function(e, t, i) {
- var n = this._meshes[e.uniqueId];
- n ? this._emissiveTextureAndColor.color.set(n.color.r, n.color.g, n.color.b, 1) : this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a),
- n && n.glowEmissiveOnly && i ? (this._emissiveTextureAndColor.texture = i.emissiveTexture,
- this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null
- }
- ,
- t.prototype.addExcludedMesh = function(e) {
- this._excludedMeshes && (this._excludedMeshes[e.uniqueId] || (this._excludedMeshes[e.uniqueId] = {
- mesh: e,
- beforeBind: e.onBeforeBindObservable.add((function(e) {
- e.getEngine().setStencilBuffer(!1)
- }
- )),
- afterRender: e.onAfterRenderObservable.add((function(e) {
- e.getEngine().setStencilBuffer(!0)
- }
- ))
- }))
- }
- ,
- t.prototype.removeExcludedMesh = function(e) {
- if (this._excludedMeshes) {
- var t = this._excludedMeshes[e.uniqueId];
- t && (t.beforeBind && e.onBeforeBindObservable.remove(t.beforeBind),
- t.afterRender && e.onAfterRenderObservable.remove(t.afterRender)),
- this._excludedMeshes[e.uniqueId] = null
- }
- }
- ,
- t.prototype.hasMesh = function(t) {
- return !!this._meshes && !!e.prototype.hasMesh.call(this, t) && void 0 !== this._meshes[t.uniqueId] && null !== this._meshes[t.uniqueId]
- }
- ,
- t.prototype.addMesh = function(e, t, i) {
- var n = this;
- if (void 0 === i && (i = !1),
- this._meshes) {
- var r = this._meshes[e.uniqueId];
- r ? r.color = t : (this._meshes[e.uniqueId] = {
- mesh: e,
- color: t,
- observerHighlight: e.onBeforeBindObservable.add((function(e) {
- n.isEnabled && (n._excludedMeshes && n._excludedMeshes[e.uniqueId] ? n._defaultStencilReference(e) : e.getScene().getEngine().setStencilFunctionReference(n._instanceGlowingMeshStencilReference))
- }
- )),
- observerDefault: e.onAfterRenderObservable.add((function(e) {
- n.isEnabled && n._defaultStencilReference(e)
- }
- )),
- glowEmissiveOnly: i
- },
- e.onDisposeObservable.add((function() {
- n._disposeMesh(e)
- }
- ))),
- this._shouldRender = !0
- }
- }
- ,
- t.prototype.removeMesh = function(e) {
- if (this._meshes) {
- var t = this._meshes[e.uniqueId];
- for (var i in t && (t.observerHighlight && e.onBeforeBindObservable.remove(t.observerHighlight),
- t.observerDefault && e.onAfterRenderObservable.remove(t.observerDefault),
- delete this._meshes[e.uniqueId]),
- this._shouldRender = !1,
- this._meshes)
- if (this._meshes[i]) {
- this._shouldRender = !0;
- break
- }
- }
- }
- ,
- t.prototype.removeAllMeshes = function() {
- if (this._meshes)
- for (var e in this._meshes)
- if (Object.prototype.hasOwnProperty.call(this._meshes, e)) {
- var t = this._meshes[e];
- t && this.removeMesh(t.mesh)
- }
- }
- ,
- t.prototype._defaultStencilReference = function(e) {
- e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference)
- }
- ,
- t.prototype._disposeMesh = function(e) {
- this.removeMesh(e),
- this.removeExcludedMesh(e)
- }
- ,
- t.prototype.dispose = function() {
- if (this._meshes) {
- for (var t in this._meshes)
- (i = this._meshes[t]) && i.mesh && (i.observerHighlight && i.mesh.onBeforeBindObservable.remove(i.observerHighlight),
- i.observerDefault && i.mesh.onAfterRenderObservable.remove(i.observerDefault));
- this._meshes = null
- }
- if (this._excludedMeshes) {
- for (var t in this._excludedMeshes) {
- var i;
- (i = this._excludedMeshes[t]) && (i.beforeBind && i.mesh.onBeforeBindObservable.remove(i.beforeBind),
- i.afterRender && i.mesh.onAfterRenderObservable.remove(i.afterRender))
- }
- this._excludedMeshes = null
- }
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.getClassName = function() {
- return "HighlightLayer"
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- if (e.customType = "BABYLON.HighlightLayer",
- e.meshes = [],
- this._meshes)
- for (var t in this._meshes) {
- var i = this._meshes[t];
- i && e.meshes.push({
- glowEmissiveOnly: i.glowEmissiveOnly,
- color: i.color.asArray(),
- meshId: i.mesh.id
- })
- }
- if (e.excludedMeshes = [],
- this._excludedMeshes)
- for (var n in this._excludedMeshes) {
- var r = this._excludedMeshes[n];
- r && e.excludedMeshes.push(r.mesh.id)
- }
- return e
- }
- ,
- t.Parse = function(e, i, n) {
- var r, o = Ge.Parse((function() {
- return new t(e.name,i,e.options)
- }
- ), e, i, n);
- for (r = 0; r < e.excludedMeshes.length; r++)
- (a = i.getMeshById(e.excludedMeshes[r])) && o.addExcludedMesh(a);
- for (r = 0; r < e.meshes.length; r++) {
- var a, s = e.meshes[r];
- (a = i.getMeshById(s.meshId)) && o.addMesh(a, D.FromArray(s.color), s.glowEmissiveOnly)
- }
- return o
- }
- ,
- t.EffectName = "HighlightLayer",
- t.NeutralColor = new N(0,0,0,0),
- t.GlowingMeshStencilReference = 2,
- t.NormalMeshStencilReference = 1,
- k([Ce()], t.prototype, "innerGlow", void 0),
- k([Ce()], t.prototype, "outerGlow", void 0),
- k([Ce()], t.prototype, "blurHorizontalSize", null),
- k([Ce()], t.prototype, "blurVerticalSize", null),
- k([Ce("options")], t.prototype, "_options", void 0),
- t
- }(Kf);
- y("BABYLON.HighlightLayer", Jf);
- var $f = function() {
- function e(e) {
- this.name = Wi.NAME_LAYER,
- this.scene = e || E.LastCreatedScene,
- this.scene && (this._engine = this.scene.getEngine(),
- this.scene.layers = new Array)
- }
- return e.prototype.register = function() {
- this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground),
- this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground),
- this.scene._beforeRenderTargetDrawStage.registerStep(Wi.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground),
- this.scene._afterRenderTargetDrawStage.registerStep(Wi.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground)
- }
- ,
- e.prototype.rebuild = function() {
- for (var e = 0, t = this.scene.layers; e < t.length; e++)
- t[e]._rebuild()
- }
- ,
- e.prototype.dispose = function() {
- for (var e = this.scene.layers; e.length; )
- e[0].dispose()
- }
- ,
- e.prototype._draw = function(e) {
- var t = this.scene.layers;
- if (t.length) {
- this._engine.setDepthBuffer(!1);
- for (var i = 0, n = t; i < n.length; i++) {
- var r = n[i];
- e(r) && r.render()
- }
- this._engine.setDepthBuffer(!0)
- }
- }
- ,
- e.prototype._drawCameraPredicate = function(e, t, i) {
- return !e.renderOnlyInRenderTargetTextures && e.isBackground === t && 0 != (e.layerMask & i)
- }
- ,
- e.prototype._drawCameraBackground = function(e) {
- var t = this;
- this._draw((function(i) {
- return t._drawCameraPredicate(i, !0, e.layerMask)
- }
- ))
- }
- ,
- e.prototype._drawCameraForeground = function(e) {
- var t = this;
- this._draw((function(i) {
- return t._drawCameraPredicate(i, !1, e.layerMask)
- }
- ))
- }
- ,
- e.prototype._drawRenderTargetPredicate = function(e, t, i, n) {
- return e.renderTargetTextures.length > 0 && e.isBackground === t && e.renderTargetTextures.indexOf(n) > -1 && 0 != (e.layerMask & i)
- }
- ,
- e.prototype._drawRenderTargetBackground = function(e) {
- var t = this;
- this._draw((function(i) {
- return t._drawRenderTargetPredicate(i, !0, t.scene.activeCamera.layerMask, e)
- }
- ))
- }
- ,
- e.prototype._drawRenderTargetForeground = function(e) {
- var t = this;
- this._draw((function(i) {
- return t._drawRenderTargetPredicate(i, !1, t.scene.activeCamera.layerMask, e)
- }
- ))
- }
- ,
- e.prototype.addFromContainer = function(e) {
- var t = this;
- e.layers && e.layers.forEach((function(e) {
- t.scene.layers.push(e)
- }
- ))
- }
- ,
- e.prototype.removeFromContainer = function(e, t) {
- var i = this;
- void 0 === t && (t = !1),
- e.layers && e.layers.forEach((function(e) {
- var n = i.scene.layers.indexOf(e);
- -1 !== n && i.scene.layers.splice(n, 1),
- t && e.dispose()
- }
- ))
- }
- ,
- e
- }();
- Pt.ShadersStore.layerPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec4 color;\n#include<helperFunctions>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.layerVertexShader = "attribute vec2 position;\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var e_ = function() {
- function e(e, t, i, n, r) {
- this.name = e,
- this.scale = new A(1,1),
- this.offset = new A(0,0),
- this.alphaBlendingMode = a.ALPHA_COMBINE,
- this.layerMask = 268435455,
- this.renderTargetTextures = [],
- this.renderOnlyInRenderTargetTextures = !1,
- this.isEnabled = !0,
- this._vertexBuffers = {},
- this.onDisposeObservable = new h,
- this.onBeforeRenderObservable = new h,
- this.onAfterRenderObservable = new h,
- this.texture = t ? new io(t,i,!0) : null,
- this.isBackground = void 0 === n || n,
- this.color = void 0 === r ? new N(1,1,1,1) : r,
- this._scene = i || E.LastCreatedScene;
- var o = this._scene._getComponent(Wi.NAME_LAYER);
- o || (o = new $f(this._scene),
- this._scene._addComponent(o)),
- this._scene.layers.push(this);
- var s = this._scene.getEngine();
- this._drawWrapper = new Gt(s);
- var l = [];
- l.push(1, 1),
- l.push(-1, 1),
- l.push(-1, -1),
- l.push(1, -1);
- var c = new Bi(s,l,Bi.PositionKind,!1,!1,2);
- this._vertexBuffers[Bi.PositionKind] = c,
- this._createIndexBuffer()
- }
- return Object.defineProperty(e.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeRender", {
- set: function(e) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onAfterRender", {
- set: function(e) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createIndexBuffer = function() {
- var e = this._scene.getEngine()
- , t = [];
- t.push(0),
- t.push(1),
- t.push(2),
- t.push(0),
- t.push(2),
- t.push(3),
- this._indexBuffer = e.createIndexBuffer(t)
- }
- ,
- e.prototype._rebuild = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && e._rebuild(),
- this._createIndexBuffer()
- }
- ,
- e.prototype.render = function() {
- if (this.isEnabled) {
- var e = this._scene.getEngine()
- , t = "";
- this.alphaTest && (t = "#define ALPHATEST"),
- this.texture && !this.texture.gammaSpace && (t += "\r\n#define LINEAR"),
- this._previousDefines !== t && (this._previousDefines = t,
- this._drawWrapper.effect = e.createEffect("layer", [Bi.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], t));
- var i = this._drawWrapper.effect;
- i && i.isReady() && this.texture && this.texture.isReady() && (this.onBeforeRenderObservable.notifyObservers(this),
- e.enableEffect(this._drawWrapper),
- e.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),
- e.bindBuffers(this._vertexBuffers, this._indexBuffer, i),
- this.alphaTest ? e.drawElementsType(Or.TriangleFillMode, 0, 6) : (e.setAlphaMode(this.alphaBlendingMode),
- e.drawElementsType(Or.TriangleFillMode, 0, 6),
- e.setAlphaMode(a.ALPHA_DISABLE)),
- this.onAfterRenderObservable.notifyObservers(this))
- }
- }
- ,
- e.prototype.dispose = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[Bi.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null),
- this.texture && (this.texture.dispose(),
- this.texture = null),
- this.renderTargetTextures = [];
- var t = this._scene.layers.indexOf(this);
- this._scene.layers.splice(t, 1),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onAfterRenderObservable.clear(),
- this.onBeforeRenderObservable.clear()
- }
- ,
- e
- }()
- , t_ = function() {
- function e(e, t, i, n, r) {
- this.size = e,
- this.position = t,
- this.alphaMode = a.ALPHA_ONEONE,
- this.color = i || new D(1,1,1),
- this.texture = n ? new io(n,r.getScene(),!0) : null,
- this._system = r;
- var o = r.scene.getEngine();
- this._drawWrapper = new Gt(o),
- this._drawWrapper.effect = o.createEffect("lensFlare", [Bi.PositionKind], ["color", "viewportMatrix"], ["textureSampler"], ""),
- r.lensFlares.push(this)
- }
- return e.AddFlare = function(t, i, n, r, o) {
- return new e(t,i,n,r,o)
- }
- ,
- e.prototype.dispose = function() {
- this.texture && this.texture.dispose();
- var e = this._system.lensFlares.indexOf(this);
- this._system.lensFlares.splice(e, 1)
- }
- ,
- e
- }();
- Pt.ShadersStore.lensFlarePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.lensFlareVertexShader = "attribute vec2 position;\nuniform mat4 viewportMatrix;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var i_ = function() {
- function e(t, i, n) {
- this.name = t,
- this.lensFlares = new Array,
- this.borderLimit = 300,
- this.viewportBorder = 0,
- this.layerMask = 268435455,
- this._vertexBuffers = {},
- this._isEnabled = !0,
- this._scene = n || E.LastCreatedScene,
- e._SceneComponentInitialization(this._scene),
- this._emitter = i,
- this.id = t,
- n.lensFlareSystems.push(this),
- this.meshesSelectionPredicate = function(e) {
- return n.activeCamera && e.material && e.isVisible && e.isEnabled() && e.isBlocker && 0 != (e.layerMask & n.activeCamera.layerMask)
- }
- ;
- var r = n.getEngine()
- , o = [];
- o.push(1, 1),
- o.push(-1, 1),
- o.push(-1, -1),
- o.push(1, -1),
- this._vertexBuffers[Bi.PositionKind] = new Bi(r,o,Bi.PositionKind,!1,!1,2),
- this._createIndexBuffer()
- }
- return Object.defineProperty(e.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createIndexBuffer = 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)
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype.getEmitter = function() {
- return this._emitter
- }
- ,
- e.prototype.setEmitter = function(e) {
- this._emitter = e
- }
- ,
- e.prototype.getEmitterPosition = function() {
- return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position
- }
- ,
- e.prototype.computeEffectivePosition = function(e) {
- var t = this.getEmitterPosition();
- t = x.Project(t, P.Identity(), this._scene.getTransformMatrix(), e),
- this._positionX = t.x,
- this._positionY = t.y,
- t = x.TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix()),
- this.viewportBorder > 0 && (e.x -= this.viewportBorder,
- e.y -= this.viewportBorder,
- e.width += 2 * this.viewportBorder,
- e.height += 2 * this.viewportBorder,
- t.x += this.viewportBorder,
- t.y += this.viewportBorder,
- this._positionX += this.viewportBorder,
- this._positionY += this.viewportBorder);
- var i = this._scene.useRightHandedSystem;
- return !!(t.z > 0 && !i || t.z < 0 && i) && (this._positionX > e.x && this._positionX < e.x + e.width && this._positionY > e.y && (this._positionY,
- e.y,
- e.height),
- !0)
- }
- ,
- e.prototype._isVisible = function() {
- if (!this._isEnabled || !this._scene.activeCamera)
- return !1;
- var e = this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition)
- , t = e.length();
- e.normalize();
- var i = new _o(this._scene.activeCamera.globalPosition,e)
- , n = this._scene.pickWithRay(i, this.meshesSelectionPredicate, !0);
- return !n || !n.hit || n.distance > t
- }
- ,
- e.prototype.render = function() {
- if (!this._scene.activeCamera)
- return !1;
- var e, t, i = this._scene.getEngine(), n = this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0), i.getRenderHeight(!0));
- if (!this.computeEffectivePosition(n))
- return !1;
- if (!this._isVisible())
- return !1;
- var r = (e = this._positionX < this.borderLimit + n.x ? this.borderLimit + n.x - this._positionX : this._positionX > n.x + n.width - this.borderLimit ? this._positionX - n.x - n.width + this.borderLimit : 0) > (t = this._positionY < this.borderLimit + n.y ? this.borderLimit + n.y - this._positionY : this._positionY > n.y + n.height - this.borderLimit ? this._positionY - n.y - n.height + this.borderLimit : 0) ? e : t;
- (r -= this.viewportBorder) > this.borderLimit && (r = this.borderLimit);
- var o = 1 - d.Clamp(r / this.borderLimit, 0, 1);
- if (o < 0)
- return !1;
- o > 1 && (o = 1),
- this.viewportBorder > 0 && (n.x += this.viewportBorder,
- n.y += this.viewportBorder,
- n.width -= 2 * this.viewportBorder,
- n.height -= 2 * this.viewportBorder,
- this._positionX -= this.viewportBorder,
- this._positionY -= this.viewportBorder);
- var s = n.x + n.width / 2
- , l = n.y + n.height / 2
- , c = s - this._positionX
- , u = l - this._positionY;
- i.setState(!1),
- i.setDepthBuffer(!1);
- for (var h = 0; h < this.lensFlares.length; h++) {
- var p = this.lensFlares[h];
- if (p._drawWrapper.effect.isReady() && (!p.texture || p.texture.isReady())) {
- i.enableEffect(p._drawWrapper),
- i.bindBuffers(this._vertexBuffers, this._indexBuffer, p._drawWrapper.effect),
- i.setAlphaMode(p.alphaMode);
- var f = s - c * p.position
- , _ = l - u * p.position
- , m = p.size
- , g = p.size * i.getAspectRatio(this._scene.activeCamera, !0)
- , v = f / (n.width + 2 * n.x) * 2 - 1
- , y = 1 - _ / (n.height + 2 * n.y) * 2
- , b = P.FromValues(m / 2, 0, 0, 0, 0, g / 2, 0, 0, 0, 0, 1, 0, v, y, 0, 1);
- p._drawWrapper.effect.setMatrix("viewportMatrix", b),
- p._drawWrapper.effect.setTexture("textureSampler", p.texture),
- p._drawWrapper.effect.setFloat4("color", p.color.r * o, p.color.g * o, p.color.b * o, 1),
- i.drawElementsType(Or.TriangleFillMode, 0, 6)
- }
- }
- return i.setDepthBuffer(!0),
- i.setAlphaMode(a.ALPHA_DISABLE),
- !0
- }
- ,
- e.prototype.rebuild = function() {
- var e;
- for (var t in this._createIndexBuffer(),
- this._vertexBuffers)
- null === (e = this._vertexBuffers[t]) || void 0 === e || e._rebuild()
- }
- ,
- e.prototype.dispose = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- for (e && (e.dispose(),
- this._vertexBuffers[Bi.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null); this.lensFlares.length; )
- this.lensFlares[0].dispose();
- var t = this._scene.lensFlareSystems.indexOf(this);
- this._scene.lensFlareSystems.splice(t, 1)
- }
- ,
- e.Parse = function(t, i, n) {
- var r = i.getLastEntryById(t.emitterId)
- , o = t.name || "lensFlareSystem#" + t.emitterId
- , a = new e(o,r,i);
- a.id = t.id || o,
- a.borderLimit = t.borderLimit;
- for (var s = 0; s < t.flares.length; s++) {
- var l = t.flares[s];
- t_.AddFlare(l.size, l.position, D.FromArray(l.color), l.textureName ? n + l.textureName : "", a)
- }
- return a
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- e.id = this.id,
- e.name = this.name,
- e.emitterId = this.getEmitter().id,
- e.borderLimit = this.borderLimit,
- e.flares = [];
- for (var t = 0; t < this.lensFlares.length; t++) {
- var i = this.lensFlares[t];
- e.flares.push({
- size: i.size,
- position: i.position,
- color: i.color.asArray(),
- textureName: gi.GetFilename(i.texture ? i.texture.name : "")
- })
- }
- return e
- }
- ,
- e._SceneComponentInitialization = function(e) {
- throw be("LensFlareSystemSceneComponent")
- }
- ,
- e
- }();
- o.AddParser(Wi.NAME_LENSFLARESYSTEM, (function(e, t, i, n) {
- if (void 0 !== e.lensFlareSystems && null !== e.lensFlareSystems) {
- i.lensFlareSystems || (i.lensFlareSystems = new Array);
- for (var r = 0, o = e.lensFlareSystems.length; r < o; r++) {
- var a = e.lensFlareSystems[r]
- , s = i_.Parse(a, t, n);
- i.lensFlareSystems.push(s)
- }
- }
- }
- )),
- o.prototype.getLensFlareSystemByName = function(e) {
- for (var t = 0; t < this.lensFlareSystems.length; t++)
- if (this.lensFlareSystems[t].name === e)
- return this.lensFlareSystems[t];
- return null
- }
- ,
- o.prototype.getLensFlareSystemById = function(e) {
- for (var t = 0; t < this.lensFlareSystems.length; t++)
- if (this.lensFlareSystems[t].id === e)
- return this.lensFlareSystems[t];
- return null
- }
- ,
- o.prototype.getLensFlareSystemByID = function(e) {
- return this.getLensFlareSystemById(e)
- }
- ,
- o.prototype.removeLensFlareSystem = function(e) {
- var t = this.lensFlareSystems.indexOf(e);
- return -1 !== t && this.lensFlareSystems.splice(t, 1),
- t
- }
- ,
- o.prototype.addLensFlareSystem = function(e) {
- this.lensFlareSystems.push(e)
- }
- ;
- var n_ = function() {
- function e(e) {
- this.name = Wi.NAME_LENSFLARESYSTEM,
- this.scene = e,
- e.lensFlareSystems = new Array
- }
- return e.prototype.register = function() {
- this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw)
- }
- ,
- e.prototype.rebuild = function() {
- for (var e = 0; e < this.scene.lensFlareSystems.length; e++)
- this.scene.lensFlareSystems[e].rebuild()
- }
- ,
- e.prototype.addFromContainer = function(e) {
- var t = this;
- e.lensFlareSystems && e.lensFlareSystems.forEach((function(e) {
- t.scene.addLensFlareSystem(e)
- }
- ))
- }
- ,
- e.prototype.removeFromContainer = function(e, t) {
- var i = this;
- e.lensFlareSystems && e.lensFlareSystems.forEach((function(e) {
- i.scene.removeLensFlareSystem(e),
- t && e.dispose()
- }
- ))
- }
- ,
- e.prototype.serialize = function(e) {
- e.lensFlareSystems = [];
- for (var t = 0, i = this.scene.lensFlareSystems; t < i.length; t++) {
- var n = i[t];
- e.lensFlareSystems.push(n.serialize())
- }
- }
- ,
- e.prototype.dispose = function() {
- for (var e = this.scene.lensFlareSystems; e.length; )
- e[0].dispose()
- }
- ,
- e.prototype._draw = function(e) {
- if (this.scene.lensFlaresEnabled) {
- var t = this.scene.lensFlareSystems;
- gi.StartPerformanceCounter("Lens flares", t.length > 0);
- for (var i = 0, n = t; i < n.length; i++) {
- var r = n[i];
- 0 != (e.layerMask & r.layerMask) && r.render()
- }
- gi.EndPerformanceCounter("Lens flares", t.length > 0)
- }
- }
- ,
- e
- }();
- i_._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_LENSFLARESYSTEM);
- t || (t = new n_(e),
- e._addComponent(t))
- }
- ;
- Pt.IncludesShadersStore.bayerDitherFunctions = "float bayerDither2(vec2 _P) {\nreturn mod(2.0*_P.y+_P.x+1.0,4.0);\n}\nfloat bayerDither4(vec2 _P) {\nvec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5*mod(_P,4.0)); \nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);\n}\nfloat bayerDither8(vec2 _P) {\nvec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5 *mod(_P,4.0)); \nvec2 P4=floor(0.25*mod(_P,8.0)); \nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);\n}\n";
- Pt.IncludesShadersStore.shadowMapFragmentExtraDeclaration = "#if SM_FLOAT==0\n#include<packingFunctions>\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#include<bayerDitherFunctions>\nuniform float softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nuniform vec3 lightDataSM;\nvarying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";
- Pt.IncludesShadersStore.shadowMapFragment = "float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\n#if SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\ndepthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\ndepthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_FragDepth=clamp(1.0-depthSM,0.0,1.0);\n#else\ngl_FragDepth=clamp(depthSM,0.0,1.0); \n#endif\n#elif SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#if SM_ESM==1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT==1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";
- Pt.ShadersStore.shadowMapPixelShader = "#include<shadowMapFragmentExtraDeclaration>\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\nif (alphaFromAlphaTexture<0.4)\ndiscard;\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#ifdef ALPHATEST\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;\n#endif\n#endif\n#include<shadowMapFragment>\n}";
- Pt.IncludesShadersStore.sceneVertexDeclaration = "uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec4 vEyePosition;\n";
- Pt.IncludesShadersStore.meshVertexDeclaration = "uniform mat4 world;\nuniform float visibility;\n";
- Pt.IncludesShadersStore.shadowMapVertexDeclaration = "#include<sceneVertexDeclaration>\n#include<meshVertexDeclaration>\n";
- Pt.IncludesShadersStore.shadowMapUboDeclaration = "layout(std140,column_major) uniform;\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n";
- Pt.IncludesShadersStore.shadowMapVertexExtraDeclaration = "#if SM_NORMALBIAS==1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n";
- Pt.IncludesShadersStore.shadowMapVertexNormalBias = "#if SM_NORMALBIAS==1\n#if SM_DIRECTIONINLIGHTDATA==1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;\nvec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);\nfloat sinNLSM=sqrt(1.0-ndlSM*ndlSM);\nfloat normalBiasSM=biasAndScaleSM.y*sinNLSM;\nworldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";
- Pt.IncludesShadersStore.shadowMapVertexMetric = "#if SM_USEDISTANCE==1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE==1\n#ifdef IS_NDC_HALF_ZRANGE\n#define BIASFACTOR 0.5\n#else\n#define BIASFACTOR 1.0\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#else\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#endif\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nzSM=gl_Position.z;\ngl_Position.z=0.0;\n#elif SM_USEDISTANCE==0\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\nvDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n";
- Pt.ShadersStore.shadowMapVertexShader = "attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#endif\n#include<helperFunctions>\n#include<__decl__shadowMapVertex>\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<shadowMapVertexExtraDeclaration>\n#include<clipPlaneVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));\nvNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include<shadowMapVertexNormalBias>\ngl_Position=viewProjection*worldPos;\n#include<shadowMapVertexMetric>\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<clipPlaneVertex>\n}";
- Pt.ShadersStore.depthBoxBlurPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";
- Pt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow = "#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";
- var r_ = function() {
- function e(t, i, n) {
- this.onBeforeShadowMapRenderObservable = new h,
- this.onAfterShadowMapRenderObservable = new h,
- this.onBeforeShadowMapRenderMeshObservable = new h,
- this.onAfterShadowMapRenderMeshObservable = new h,
- this._bias = 5e-5,
- this._normalBias = 0,
- this._blurBoxOffset = 1,
- this._blurScale = 2,
- this._blurKernel = 1,
- this._useKernelBlur = !1,
- this._filter = e.FILTER_NONE,
- this._filteringQuality = e.QUALITY_HIGH,
- this._contactHardeningLightSizeUVRatio = .1,
- this._darkness = 0,
- this._transparencyShadow = !1,
- this.enableSoftTransparentShadow = !1,
- this.frustumEdgeFalloff = 0,
- this.forceBackFacesOnly = !1,
- this._lightDirection = x.Zero(),
- this._viewMatrix = P.Zero(),
- this._projectionMatrix = P.Zero(),
- this._transformMatrix = P.Zero(),
- this._cachedPosition = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cachedDirection = new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._currentFaceIndex = 0,
- this._currentFaceIndexCache = 0,
- this._defaultTextureMatrix = P.Identity(),
- this._mapSize = t,
- 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 "'.concat(this._light.name, '")')))),
- e._SceneComponentInitialization(this._scene);
- var r = this._scene.getEngine().getCaps();
- n ? r.textureFloatRender && r.textureFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_FLOAT : r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_HALF_FLOAT : this._textureType = a.TEXTURETYPE_UNSIGNED_INT : r.textureHalfFloatRender && r.textureHalfFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_HALF_FLOAT : r.textureFloatRender && r.textureFloatLinearFiltering ? this._textureType = a.TEXTURETYPE_FLOAT : this._textureType = a.TEXTURETYPE_UNSIGNED_INT,
- this._initializeGenerator(),
- this._applyFilterValues()
- }
- return Object.defineProperty(e.prototype, "bias", {
- get: function() {
- return this._bias
- },
- set: function(e) {
- this._bias = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normalBias", {
- get: function() {
- return this._normalBias
- },
- set: function(e) {
- this._normalBias = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurBoxOffset", {
- get: function() {
- return this._blurBoxOffset
- },
- set: function(e) {
- this._blurBoxOffset !== e && (this._blurBoxOffset = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurScale", {
- get: function() {
- return this._blurScale
- },
- set: function(e) {
- this._blurScale !== e && (this._blurScale = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurKernel", {
- get: function() {
- return this._blurKernel
- },
- set: function(e) {
- this._blurKernel !== e && (this._blurKernel = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useKernelBlur", {
- get: function() {
- return this._useKernelBlur
- },
- set: function(e) {
- this._useKernelBlur !== e && (this._useKernelBlur = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthScale", {
- get: function() {
- return void 0 !== this._depthScale ? this._depthScale : this._light.getDepthScale()
- },
- set: function(e) {
- this._depthScale = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._validateFilter = function(e) {
- return e
- }
- ,
- Object.defineProperty(e.prototype, "filter", {
- get: function() {
- return this._filter
- },
- set: function(t) {
- if (t = this._validateFilter(t),
- this._light.needCube()) {
- if (t === e.FILTER_BLUREXPONENTIALSHADOWMAP)
- return void (this.useExponentialShadowMap = !0);
- if (t === e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)
- return void (this.useCloseExponentialShadowMap = !0);
- if (t === e.FILTER_PCF || t === e.FILTER_PCSS)
- return void (this.usePoissonSampling = !0)
- }
- t !== e.FILTER_PCF && t !== e.FILTER_PCSS || this._scene.getEngine()._features.supportShadowSamplers ? this._filter !== t && (this._filter = t,
- this._disposeBlurPostProcesses(),
- this._applyFilterValues(),
- this._light._markMeshesAsLightDirty()) : this.usePoissonSampling = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "usePoissonSampling", {
- get: function() {
- return this.filter === e.FILTER_POISSONSAMPLING
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_POISSONSAMPLING);
- (t || this.filter === e.FILTER_POISSONSAMPLING) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useExponentialShadowMap", {
- get: function() {
- return this.filter === e.FILTER_EXPONENTIALSHADOWMAP
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);
- (t || this.filter === e.FILTER_EXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useBlurExponentialShadowMap", {
- get: function() {
- return this.filter === e.FILTER_BLUREXPONENTIALSHADOWMAP
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);
- (t || this.filter === e.FILTER_BLUREXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useCloseExponentialShadowMap", {
- get: function() {
- return this.filter === e.FILTER_CLOSEEXPONENTIALSHADOWMAP
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);
- (t || this.filter === e.FILTER_CLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useBlurCloseExponentialShadowMap", {
- get: function() {
- return this.filter === e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
- (t || this.filter === e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "usePercentageCloserFiltering", {
- get: function() {
- return this.filter === e.FILTER_PCF
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_PCF);
- (t || this.filter === e.FILTER_PCF) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.prototype, "useContactHardeningShadow", {
- get: function() {
- return this.filter === e.FILTER_PCSS
- },
- set: function(t) {
- var i = this._validateFilter(e.FILTER_PCSS);
- (t || this.filter === e.FILTER_PCSS) && (this.filter = t ? i : e.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "contactHardeningLightSizeUVRatio", {
- get: function() {
- return this._contactHardeningLightSizeUVRatio
- },
- set: function(e) {
- this._contactHardeningLightSizeUVRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "darkness", {
- get: function() {
- return this._darkness
- },
- set: function(e) {
- this.setDarkness(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getDarkness = function() {
- return this._darkness
- }
- ,
- e.prototype.setDarkness = function(e) {
- return this._darkness = e >= 1 ? 1 : e <= 0 ? 0 : e,
- this
- }
- ,
- Object.defineProperty(e.prototype, "transparencyShadow", {
- get: function() {
- return this._transparencyShadow
- },
- set: function(e) {
- this.setTransparencyShadow(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setTransparencyShadow = function(e) {
- return this._transparencyShadow = e,
- this
- }
- ,
- e.prototype.getShadowMap = function() {
- return this._shadowMap
- }
- ,
- e.prototype.getShadowMapForRendering = function() {
- return this._shadowMap2 ? this._shadowMap2 : this._shadowMap
- }
- ,
- e.prototype.getClassName = function() {
- return e.CLASSNAME
- }
- ,
- e.prototype.addShadowCaster = function(e, t) {
- if (void 0 === t && (t = !0),
- !this._shadowMap)
- return this;
- if (this._shadowMap.renderList || (this._shadowMap.renderList = []),
- -1 === this._shadowMap.renderList.indexOf(e) && this._shadowMap.renderList.push(e),
- t)
- for (var i = 0, n = e.getChildMeshes(); i < n.length; i++) {
- var r = n[i];
- -1 === this._shadowMap.renderList.indexOf(r) && this._shadowMap.renderList.push(r)
- }
- return this
- }
- ,
- e.prototype.removeShadowCaster = function(e, t) {
- if (void 0 === t && (t = !0),
- !this._shadowMap || !this._shadowMap.renderList)
- return this;
- var i = this._shadowMap.renderList.indexOf(e);
- if (-1 !== i && this._shadowMap.renderList.splice(i, 1),
- t)
- for (var n = 0, r = e.getChildren(); n < r.length; n++) {
- var o = r[n];
- this.removeShadowCaster(o)
- }
- return this
- }
- ,
- e.prototype.getLight = function() {
- return this._light
- }
- ,
- Object.defineProperty(e.prototype, "mapSize", {
- get: function() {
- return this._mapSize
- },
- set: function(e) {
- this._mapSize = e,
- this._light._markMeshesAsLightDirty(),
- this.recreateShadowMap()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._initializeGenerator = function() {
- this._light._markMeshesAsLightDirty(),
- this._initializeShadowMap()
- }
- ,
- e.prototype._createTargetRenderTexture = function() {
- var e = this._scene.getEngine();
- e._features.supportDepthStencilTexture ? (this._shadowMap = new ns(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),
- this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0)) : this._shadowMap = new ns(this._light.name + "_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())
- }
- ,
- e.prototype._initializeShadowMap = function() {
- var t = this;
- if (this._createTargetRenderTexture(),
- null !== this._shadowMap) {
- this._shadowMap.wrapU = io.CLAMP_ADDRESSMODE,
- this._shadowMap.wrapV = io.CLAMP_ADDRESSMODE,
- this._shadowMap.anisotropicFilteringLevel = 1,
- this._shadowMap.updateSamplingMode(io.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() {
- return !0
- }
- ;
- var i = this._scene.getEngine();
- this._shadowMap.onBeforeBindObservable.add((function() {
- var e;
- t._currentSceneUBO = t._scene.getSceneUniformBuffer(),
- null === (e = i._debugPushGroup) || void 0 === e || e.call(i, "shadow map generation for pass id ".concat(i.currentRenderPassId), 1)
- }
- )),
- this._shadowMap.onBeforeRenderObservable.add((function(n) {
- t._sceneUBOs && t._scene.setSceneUniformBuffer(t._sceneUBOs[0]),
- t._currentFaceIndex = n,
- t._filter === e.FILTER_PCF && i.setColorWrite(!1),
- t.getTransformMatrix(),
- t._scene.setTransformMatrix(t._viewMatrix, t._projectionMatrix),
- t._useUBO && (t._scene.getSceneUniformBuffer().unbindEffect(),
- t._scene.finalizeSceneUbo())
- }
- )),
- this._shadowMap.onAfterUnbindObservable.add((function() {
- var n, r;
- if (t._sceneUBOs && t._scene.setSceneUniformBuffer(t._currentSceneUBO),
- t._scene.updateTransformMatrix(),
- t._filter === e.FILTER_PCF && i.setColorWrite(!0),
- t.useBlurExponentialShadowMap || t.useBlurCloseExponentialShadowMap) {
- var o = t.getShadowMapForRendering();
- o && (t._scene.postProcessManager.directRender(t._blurPostProcesses, o.renderTarget, !0),
- i.unBindFramebuffer(o.renderTarget, !0),
- null === (r = i._debugPopGroup) || void 0 === r || r.call(i, 1))
- } else
- null === (n = i._debugPopGroup) || void 0 === n || n.call(i, 1)
- }
- ));
- var n = new N(0,0,0,0)
- , r = new N(1,1,1,1);
- this._shadowMap.onClearObservable.add((function(i) {
- t._filter === e.FILTER_PCF ? i.clear(r, !1, !0, !1) : t.useExponentialShadowMap || t.useBlurExponentialShadowMap ? i.clear(n, !0, !0, !1) : i.clear(r, !0, !0, !1)
- }
- )),
- this._shadowMap.onResizeObservable.add((function(e) {
- t._storedUniqueId = t._shadowMap.uniqueId,
- t._mapSize = e.getRenderSize(),
- t._light._markMeshesAsLightDirty(),
- t.recreateShadowMap()
- }
- ));
- for (var o = zi.MIN_RENDERINGGROUPS; o < zi.MAX_RENDERINGGROUPS; o++)
- this._shadowMap.setRenderingAutoClearDepthStencil(o, !1)
- }
- }
- ,
- e.prototype._initializeBlurRTTAndPostProcesses = function() {
- var e = this
- , t = this._scene.getEngine()
- , i = this._mapSize / this.blurScale;
- this.useKernelBlur && 1 === this.blurScale || (this._shadowMap2 = new ns(this._light.name + "_shadowMap2",i,this._scene,!1,!0,this._textureType,void 0,void 0,!1),
- this._shadowMap2.wrapU = io.CLAMP_ADDRESSMODE,
- this._shadowMap2.wrapV = io.CLAMP_ADDRESSMODE,
- this._shadowMap2.updateSamplingMode(io.BILINEAR_SAMPLINGMODE)),
- this.useKernelBlur ? (this._kernelBlurXPostprocess = new Fd(this._light.name + "KernelBlurX",new A(1,0),this.blurKernel,1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),
- this._kernelBlurXPostprocess.width = i,
- this._kernelBlurXPostprocess.height = i,
- this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0,
- this._kernelBlurXPostprocess.onApplyObservable.add((function(t) {
- t.setTexture("textureSampler", e._shadowMap)
- }
- )),
- this._kernelBlurYPostprocess = new Fd(this._light.name + "KernelBlurY",new A(0,1),this.blurKernel,1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),
- this._kernelBlurXPostprocess.autoClear = !1,
- this._kernelBlurYPostprocess.autoClear = !1,
- this._textureType === a.TEXTURETYPE_UNSIGNED_INT && (this._kernelBlurXPostprocess.packedFloat = !0,
- this._kernelBlurYPostprocess.packedFloat = !0),
- this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess]) : (this._boxBlurPostprocess = new Ba(this._light.name + "DepthBoxBlur","depthBoxBlur",["screenSize", "boxOffset"],[],1,null,io.BILINEAR_SAMPLINGMODE,t,!1,"#define OFFSET " + this._blurBoxOffset,this._textureType),
- this._boxBlurPostprocess.externalTextureSamplerBinding = !0,
- this._boxBlurPostprocess.onApplyObservable.add((function(t) {
- t.setFloat2("screenSize", i, i),
- t.setTexture("textureSampler", e._shadowMap)
- }
- )),
- this._boxBlurPostprocess.autoClear = !1,
- this._blurPostProcesses = [this._boxBlurPostprocess])
- }
- ,
- e.prototype._renderForShadowMap = function(e, t, i, n) {
- var r;
- if (n.length)
- for (r = 0; r < n.length; r++)
- this._renderSubMeshForShadowMap(n.data[r]);
- for (r = 0; r < e.length; r++)
- this._renderSubMeshForShadowMap(e.data[r]);
- for (r = 0; r < t.length; r++)
- this._renderSubMeshForShadowMap(t.data[r]);
- if (this._transparencyShadow)
- for (r = 0; r < i.length; r++)
- this._renderSubMeshForShadowMap(i.data[r], !0);
- else
- for (r = 0; r < i.length; r++)
- i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
- }
- ,
- e.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, t, i) {
- t.setMatrix("viewProjection", this.getTransformMatrix())
- }
- ,
- e.prototype._renderSubMeshForShadowMap = function(e, t) {
- var i, n;
- void 0 === t && (t = !1);
- var r = e.getRenderingMesh()
- , o = e.getEffectiveMesh()
- , s = this._scene
- , l = s.getEngine()
- , c = e.getMaterial();
- if (o._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- c && 0 !== e.verticesCount && e._renderId !== s.getRenderId()) {
- var u = o._getWorldMatrixDeterminant() < 0
- , h = null !== (i = r.overrideMaterialSideOrientation) && void 0 !== i ? i : c.sideOrientation;
- u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation);
- var d = h === a.MATERIAL_ClockWiseSideOrientation;
- l.setState(c.backFaceCulling, void 0, void 0, d, c.cullBackFaces);
- var p = r._getInstancesRenderList(e._id, !!e.getReplacementMesh());
- if (!p.mustReturn) {
- var f = l.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || r.hasThinInstances);
- if (!this.customAllowRendering || this.customAllowRendering(e))
- if (this.isReady(e, f, t)) {
- e._renderId = s.getRenderId();
- var _ = c.shadowDepthWrapper
- , m = null !== (n = null == _ ? void 0 : _.getEffect(e, this, l.currentRenderPassId)) && void 0 !== n ? n : e._getDrawWrapper()
- , g = Gt.GetEffect(m);
- if (l.enableEffect(m),
- f || r._bind(e, g, c.fillMode),
- this.getTransformMatrix(),
- g.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale),
- this.getLight().getTypeID() === Cr.LIGHTTYPEID_DIRECTIONALLIGHT ? g.setVector3("lightDataSM", this._cachedDirection) : g.setVector3("lightDataSM", this._cachedPosition),
- s.activeCamera && g.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(s.activeCamera), this.getLight().getDepthMinZ(s.activeCamera) + this.getLight().getDepthMaxZ(s.activeCamera)),
- t && this.enableSoftTransparentShadow && g.setFloat("softTransparentShadowSM", o.visibility * c.alpha),
- _)
- e._setMainDrawWrapperOverride(m),
- _.standalone ? _.baseMaterial.bindForSubMesh(o.getWorldMatrix(), r, e) : c.bindForSubMesh(o.getWorldMatrix(), r, e),
- e._setMainDrawWrapperOverride(null);
- else {
- if (c && c.needAlphaTesting()) {
- var v = c.getAlphaTestTexture();
- v && (g.setTexture("diffuseSampler", v),
- g.setMatrix("diffuseMatrix", v.getTextureMatrix() || this._defaultTextureMatrix))
- }
- if (r.useBones && r.computeBonesUsingShaders && r.skeleton) {
- var y = r.skeleton;
- if (y.isUsingTextureForMatrices) {
- var b = y.getTransformMatrixTexture(r);
- if (!b)
- return;
- g.setTexture("boneSampler", b),
- g.setFloat("boneTextureWidth", 4 * (y.bones.length + 1))
- } else
- g.setMatrices("mBones", y.getTransformMatrices(r))
- }
- Mr.BindMorphTargetParameters(r, g),
- r.morphTargetManager && r.morphTargetManager.isUsingTextureForTargets && r.morphTargetManager._bind(g),
- Mr.BindClipPlane(g, s)
- }
- this._useUBO || _ || this._bindCustomEffectForRenderSubMeshForShadowMap(e, g, o),
- Mr.BindSceneUniformBuffer(g, this._scene.getSceneUniformBuffer()),
- this._scene.getSceneUniformBuffer().bindUniformBuffer();
- var T = o.getWorldMatrix();
- f && (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
- o.transferToEffect(T)),
- this.forceBackFacesOnly && l.setState(!0, 0, !1, !0, c.cullBackFaces),
- this.onBeforeShadowMapRenderMeshObservable.notifyObservers(r),
- this.onBeforeShadowMapRenderObservable.notifyObservers(g),
- r._processRendering(o, e, g, c.fillMode, p, f, (function(e, t) {
- o === r || e ? (o.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
- o.transferToEffect(e ? t : T)) : (r.getMeshUniformBuffer().bindToEffect(g, "Mesh"),
- r.transferToEffect(t))
- }
- )),
- this.forceBackFacesOnly && l.setState(!0, 0, !1, !1, c.cullBackFaces),
- this.onAfterShadowMapRenderObservable.notifyObservers(g),
- this.onAfterShadowMapRenderMeshObservable.notifyObservers(r)
- } else
- this._shadowMap && this._shadowMap.resetRefreshCounter()
- }
- }
- }
- ,
- e.prototype._applyFilterValues = function() {
- this._shadowMap && (this.filter === e.FILTER_NONE || this.filter === e.FILTER_PCSS ? this._shadowMap.updateSamplingMode(io.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(io.BILINEAR_SAMPLINGMODE))
- }
- ,
- e.prototype.forceCompilation = function(e, t) {
- var i = this
- , n = V({
- useInstances: !1
- }, t)
- , r = this.getShadowMap();
- if (r) {
- var o = r.renderList;
- if (o) {
- for (var a = new Array, s = 0, l = o; s < l.length; s++) {
- var c = l[s];
- a.push.apply(a, c.subMeshes)
- }
- if (0 !== a.length) {
- var u = 0
- , h = function() {
- var t, r;
- if (i._scene && i._scene.getEngine()) {
- for (; i.isReady(a[u], n.useInstances, null !== (r = null === (t = a[u].getMaterial()) || void 0 === t ? void 0 : t.needAlphaBlendingForMesh(a[u].getMesh())) && void 0 !== r && r); )
- if (++u >= a.length)
- return void (e && e(i));
- setTimeout(h, 16)
- }
- };
- h()
- } else
- e && e(this)
- } else
- e && e(this)
- } else
- e && e(this)
- }
- ,
- e.prototype.forceCompilationAsync = function(e) {
- var t = this;
- return new Promise((function(i) {
- t.forceCompilation((function() {
- i()
- }
- ), e)
- }
- ))
- }
- ,
- e.prototype._isReadyCustomDefines = function(e, t, i) {}
- ,
- e.prototype._prepareShadowDefines = function(e, t, i, n) {
- i.push("#define SM_FLOAT " + (this._textureType !== a.TEXTURETYPE_UNSIGNED_INT ? "1" : "0")),
- i.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")),
- i.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
- var r = e.getMesh();
- return i.push("#define SM_NORMALBIAS " + (this.normalBias && r.isVerticesDataPresent(Bi.NormalKind) ? "1" : "0")),
- i.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Cr.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")),
- i.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")),
- i.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && n ? "1" : "0")),
- this._isReadyCustomDefines(i, e, t),
- i
- }
- ,
- e.prototype.isReady = function(e, t, i) {
- var n = e.getMaterial()
- , r = null == n ? void 0 : n.shadowDepthWrapper
- , o = [];
- if (this._prepareShadowDefines(e, t, o, i),
- r) {
- if (!r.isReadyForSubMesh(e, o, this, t, this._scene.getEngine().currentRenderPassId))
- return !1
- } else {
- var a = e._getDrawWrapper(void 0, !0)
- , s = a.effect
- , l = a.defines
- , c = [Bi.PositionKind]
- , u = e.getMesh();
- if (this.normalBias && u.isVerticesDataPresent(Bi.NormalKind) && (c.push(Bi.NormalKind),
- o.push("#define NORMAL"),
- u.nonUniformScaling && o.push("#define NONUNIFORMSCALING")),
- n && n.needAlphaTesting()) {
- var h = n.getAlphaTestTexture();
- if (h) {
- if (!h.isReady())
- return !1;
- o.push("#define ALPHATEST"),
- u.isVerticesDataPresent(Bi.UVKind) && (c.push(Bi.UVKind),
- o.push("#define UV1")),
- u.isVerticesDataPresent(Bi.UV2Kind) && 1 === h.coordinatesIndex && (c.push(Bi.UV2Kind),
- o.push("#define UV2"))
- }
- }
- var d = new ys;
- if (u.useBones && u.computeBonesUsingShaders && u.skeleton) {
- c.push(Bi.MatricesIndicesKind),
- c.push(Bi.MatricesWeightsKind),
- u.numBoneInfluencers > 4 && (c.push(Bi.MatricesIndicesExtraKind),
- c.push(Bi.MatricesWeightsExtraKind));
- var p = u.skeleton;
- o.push("#define NUM_BONE_INFLUENCERS " + u.numBoneInfluencers),
- u.numBoneInfluencers > 0 && d.addCPUSkinningFallback(0, u),
- p.isUsingTextureForMatrices ? o.push("#define BONETEXTURE") : o.push("#define BonesPerMesh " + (p.bones.length + 1))
- } else
- o.push("#define NUM_BONE_INFLUENCERS 0");
- var f = u.morphTargetManager
- , _ = 0;
- f && f.numInfluencers > 0 && (o.push("#define MORPHTARGETS"),
- _ = f.numInfluencers,
- o.push("#define NUM_MORPH_INFLUENCERS " + _),
- f.isUsingTextureForTargets && o.push("#define MORPHTARGETS_TEXTURE"),
- Mr.PrepareAttributesForMorphTargetsInfluencers(c, u, _));
- var m = this._scene;
- if (m.clipPlane && o.push("#define CLIPPLANE"),
- m.clipPlane2 && o.push("#define CLIPPLANE2"),
- m.clipPlane3 && o.push("#define CLIPPLANE3"),
- m.clipPlane4 && o.push("#define CLIPPLANE4"),
- m.clipPlane5 && o.push("#define CLIPPLANE5"),
- m.clipPlane6 && o.push("#define CLIPPLANE6"),
- t && (o.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(c),
- e.getRenderingMesh().hasThinInstances && o.push("#define THIN_INSTANCES")),
- this.customShaderOptions && this.customShaderOptions.defines)
- for (var g = 0, v = this.customShaderOptions.defines; g < v.length; g++) {
- var y = v[g];
- -1 === o.indexOf(y) && o.push(y)
- }
- var b = o.join("\n");
- if (l !== b) {
- l = b;
- var T = "shadowMap"
- , E = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"]
- , S = ["diffuseSampler", "boneSampler", "morphTargets"];
- if (this.customShaderOptions) {
- if (T = this.customShaderOptions.shaderName,
- this.customShaderOptions.attributes)
- for (var A = 0, x = this.customShaderOptions.attributes; A < x.length; A++) {
- var R = x[A];
- -1 === c.indexOf(R) && c.push(R)
- }
- if (this.customShaderOptions.uniforms)
- for (var C = 0, P = this.customShaderOptions.uniforms; C < P.length; C++) {
- var M = P[C];
- -1 === E.indexOf(M) && E.push(M)
- }
- if (this.customShaderOptions.samplers)
- for (var I = 0, O = this.customShaderOptions.samplers; I < O.length; I++) {
- var D = O[I];
- -1 === S.indexOf(D) && S.push(D)
- }
- }
- var N = this._scene.getEngine();
- s = N.createEffect(T, {
- attributes: c,
- uniformsNames: E,
- uniformBuffersNames: ["Scene", "Mesh"],
- samplers: S,
- defines: b,
- fallbacks: d,
- onCompiled: null,
- onError: null,
- indexParameters: {
- maxSimultaneousMorphTargets: _
- }
- }, N),
- a.setEffect(s, l)
- }
- if (!s.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())
- }
- ,
- e.prototype.prepareDefines = function(t, i) {
- var n = this._scene
- , r = this._light;
- n.shadowsEnabled && r.shadowEnabled && (t["SHADOW" + i] = !0,
- this.useContactHardeningShadow ? (t["SHADOWPCSS" + i] = !0,
- this._filteringQuality === e.QUALITY_LOW ? t["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === e.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePercentageCloserFiltering ? (t["SHADOWPCF" + i] = !0,
- this._filteringQuality === e.QUALITY_LOW ? t["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === e.QUALITY_MEDIUM && (t["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePoissonSampling ? t["SHADOWPOISSON" + i] = !0 : this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? t["SHADOWESM" + i] = !0 : (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (t["SHADOWCLOSEESM" + i] = !0),
- r.needCube() && (t["SHADOWCUBE" + i] = !0))
- }
- ,
- e.prototype.bindShadowLight = function(t, i) {
- var n = this._light
- , r = this._scene;
- if (r.shadowsEnabled && n.shadowEnabled) {
- var o = r.activeCamera;
- if (o) {
- var a = this.getShadowMap();
- a && (n.needCube() || i.setMatrix("lightMatrix" + t, this.getTransformMatrix()),
- this._filter === e.FILTER_PCF ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()),
- n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a.getSize().width, 1 / a.getSize().width, this.frustumEdgeFalloff, t)) : this._filter === e.FILTER_PCSS ? (i.setDepthStencilTexture("shadowSampler" + t, this.getShadowMapForRendering()),
- i.setTexture("depthSampler" + t, this.getShadowMapForRendering()),
- n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a.getSize().width, this._contactHardeningLightSizeUVRatio * a.getSize().width, this.frustumEdgeFalloff, t)) : (i.setTexture("shadowSampler" + t, this.getShadowMapForRendering()),
- n._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / a.getSize().width, this.depthScale, this.frustumEdgeFalloff, t)),
- n._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(o), this.getLight().getDepthMinZ(o) + this.getLight().getDepthMaxZ(o), t))
- }
- }
- }
- ,
- e.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 t = this._light.position;
- if (this._light.computeTransformedInformation() && (t = this._light.transformedPosition),
- x.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection),
- 1 === Math.abs(x.Dot(this._lightDirection, x.Up())) && (this._lightDirection.z = 1e-13),
- this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !t.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
- this._cachedPosition.copyFrom(t),
- this._cachedDirection.copyFrom(this._lightDirection),
- P.LookAtLHToRef(t, t.add(this._lightDirection), x.Up(), this._viewMatrix);
- var i = this.getShadowMap();
- if (i) {
- var n = i.renderList;
- n && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, n)
- }
- this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix)
- }
- return this._transformMatrix
- }
- ,
- e.prototype.recreateShadowMap = function() {
- var e = this._shadowMap;
- if (e) {
- var t = e.renderList;
- if (this._disposeRTTandPostProcesses(),
- this._initializeGenerator(),
- this.filter = this._filter,
- this._applyFilterValues(),
- t) {
- this._shadowMap.renderList || (this._shadowMap.renderList = []);
- for (var i = 0, n = t; i < n.length; i++) {
- var r = n[i];
- this._shadowMap.renderList.push(r)
- }
- } else
- this._shadowMap.renderList = null
- }
- }
- ,
- e.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 = []
- }
- ,
- e.prototype._disposeRTTandPostProcesses = function() {
- this._shadowMap && (this._shadowMap.dispose(),
- this._shadowMap = null),
- this._disposeBlurPostProcesses()
- }
- ,
- e.prototype._disposeSceneUBOs = function() {
- if (this._sceneUBOs) {
- for (var e = 0, t = this._sceneUBOs; e < t.length; e++)
- t[e].dispose();
- this._sceneUBOs = []
- }
- }
- ,
- e.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()
- }
- ,
- e.prototype.serialize = function() {
- var e = {}
- , t = this.getShadowMap();
- if (!t)
- return e;
- if (e.className = this.getClassName(),
- e.lightId = this._light.id,
- e.id = this.id,
- e.mapSize = t.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 = [],
- t.renderList)
- for (var i = 0; i < t.renderList.length; i++) {
- var n = t.renderList[i];
- e.renderList.push(n.id)
- }
- return e
- }
- ,
- e.Parse = function(t, i, n) {
- for (var r = i.getLightById(t.lightId), o = n ? n(t.mapSize, r) : new e(t.mapSize,r), a = o.getShadowMap(), s = 0; s < t.renderList.length; s++)
- i.getMeshesById(t.renderList[s]).forEach((function(e) {
- a && (a.renderList || (a.renderList = []),
- a.renderList.push(e))
- }
- ));
- return void 0 !== t.id && (o.id = t.id),
- o.forceBackFacesOnly = !!t.forceBackFacesOnly,
- void 0 !== t.darkness && o.setDarkness(t.darkness),
- t.transparencyShadow && o.setTransparencyShadow(!0),
- void 0 !== t.frustumEdgeFalloff && (o.frustumEdgeFalloff = t.frustumEdgeFalloff),
- void 0 !== t.bias && (o.bias = t.bias),
- void 0 !== t.normalBias && (o.normalBias = t.normalBias),
- t.usePercentageCloserFiltering ? o.usePercentageCloserFiltering = !0 : t.useContactHardeningShadow ? o.useContactHardeningShadow = !0 : t.usePoissonSampling ? o.usePoissonSampling = !0 : t.useExponentialShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurExponentialShadowMap ? o.useBlurExponentialShadowMap = !0 : t.useCloseExponentialShadowMap ? o.useCloseExponentialShadowMap = !0 : t.useBlurCloseExponentialShadowMap ? o.useBlurCloseExponentialShadowMap = !0 : t.useVarianceShadowMap ? o.useExponentialShadowMap = !0 : t.useBlurVarianceShadowMap && (o.useBlurExponentialShadowMap = !0),
- void 0 !== t.contactHardeningLightSizeUVRatio && (o.contactHardeningLightSizeUVRatio = t.contactHardeningLightSizeUVRatio),
- void 0 !== t.filteringQuality && (o.filteringQuality = t.filteringQuality),
- t.depthScale && (o.depthScale = t.depthScale),
- t.blurScale && (o.blurScale = t.blurScale),
- t.blurBoxOffset && (o.blurBoxOffset = t.blurBoxOffset),
- t.useKernelBlur && (o.useKernelBlur = t.useKernelBlur),
- t.blurKernel && (o.blurKernel = t.blurKernel),
- o
- }
- ,
- e.CLASSNAME = "ShadowGenerator",
- e.FILTER_NONE = 0,
- e.FILTER_EXPONENTIALSHADOWMAP = 1,
- e.FILTER_POISSONSAMPLING = 2,
- e.FILTER_BLUREXPONENTIALSHADOWMAP = 3,
- e.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4,
- e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5,
- e.FILTER_PCF = 6,
- e.FILTER_PCSS = 7,
- e.QUALITY_HIGH = 0,
- e.QUALITY_MEDIUM = 1,
- e.QUALITY_LOW = 2,
- e._SceneComponentInitialization = function(e) {
- throw be("ShadowGeneratorSceneComponent")
- }
- ,
- e
- }();
- Pt.ShadersStore.depthPixelShader = "#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\n#ifdef PACKED\n#include<packingFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n}";
- Pt.ShadersStore.depthVertexShader = "attribute vec3 position;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));\n#else\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#endif\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";
- var o_ = function() {
- function e(t, i, n, r, o) {
- void 0 === i && (i = a.TEXTURETYPE_FLOAT),
- void 0 === n && (n = null),
- void 0 === r && (r = !1),
- void 0 === o && (o = io.TRILINEAR_SAMPLINGMODE);
- var s = this;
- this.enabled = !0,
- this.forceDepthWriteTransparentMeshes = !1,
- this.useOnlyInActiveCamera = !1,
- this._scene = t,
- this._storeNonLinearDepth = r,
- this.isPacked = i === a.TEXTURETYPE_UNSIGNED_BYTE,
- this.isPacked ? this._clearColor = new N(1,1,1,1) : this._clearColor = new N(1,0,0,1),
- e._SceneComponentInitialization(this._scene);
- var l = t.getEngine();
- this._camera = n,
- o !== io.NEAREST_SAMPLINGMODE && (i !== a.TEXTURETYPE_FLOAT || l._caps.textureFloatLinearFiltering || (o = io.NEAREST_SAMPLINGMODE),
- i !== a.TEXTURETYPE_HALF_FLOAT || l._caps.textureHalfFloatLinearFiltering || (o = io.NEAREST_SAMPLINGMODE));
- var c = this.isPacked || !l._features.supportExtendedTextureFormats ? a.TEXTUREFORMAT_RGBA : a.TEXTUREFORMAT_R;
- this._depthMap = new ns("DepthRenderer",{
- width: l.getRenderWidth(),
- height: l.getRenderHeight()
- },this._scene,!1,!0,i,!1,o,void 0,void 0,void 0,c),
- this._depthMap.wrapU = io.CLAMP_ADDRESSMODE,
- this._depthMap.wrapV = io.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(e) {
- e.clear(s._clearColor, !0, !0, !0)
- }
- )),
- this._depthMap.onBeforeBindObservable.add((function() {
- var e;
- null === (e = l._debugPushGroup) || void 0 === e || e.call(l, "depth renderer", 1)
- }
- )),
- this._depthMap.onAfterUnbindObservable.add((function() {
- var e;
- null === (e = l._debugPopGroup) || void 0 === e || e.call(l, 1)
- }
- )),
- this._depthMap.customIsReadyFunction = function(e, t) {
- if (!e.isReady(!1))
- return !1;
- if (0 === t && e.subMeshes)
- for (var i = 0; i < e.subMeshes.length; ++i) {
- var n = e.subMeshes[i]
- , r = n.getRenderingMesh()
- , o = r._getInstancesRenderList(n._id, !!n.getReplacementMesh())
- , a = l.getCaps().instancedArrays && (null !== o.visibleInstances[n._id] && void 0 !== o.visibleInstances[n._id] || r.hasThinInstances);
- if (!s.isReady(n, a))
- return !1
- }
- return !0
- }
- ;
- var u = function(e) {
- var t, i, n = e.getRenderingMesh(), r = e.getEffectiveMesh(), o = s._scene, l = o.getEngine(), c = e.getMaterial();
- if (r._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- c && !r.infiniteDistance && !c.disableDepthWrite && 0 !== e.verticesCount && e._renderId !== o.getRenderId()) {
- var u = r._getWorldMatrixDeterminant() < 0
- , h = null !== (t = n.overrideMaterialSideOrientation) && void 0 !== t ? t : c.sideOrientation;
- u && (h = h === a.MATERIAL_ClockWiseSideOrientation ? a.MATERIAL_CounterClockWiseSideOrientation : a.MATERIAL_ClockWiseSideOrientation);
- var d = h === a.MATERIAL_ClockWiseSideOrientation;
- l.setState(c.backFaceCulling, 0, !1, d, c.cullBackFaces);
- var p = n._getInstancesRenderList(e._id, !!e.getReplacementMesh());
- if (!p.mustReturn) {
- var f = l.getCaps().instancedArrays && (null !== p.visibleInstances[e._id] && void 0 !== p.visibleInstances[e._id] || n.hasThinInstances)
- , _ = s._camera || o.activeCamera;
- if (s.isReady(e, f) && _) {
- e._renderId = o.getRenderId();
- var m = null === (i = r._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[l.currentRenderPassId]
- , g = e._getDrawWrapper();
- !g && m && (g = m._getDrawWrapper());
- var v = _.mode === Rr.ORTHOGRAPHIC_CAMERA;
- if (!g)
- return;
- var y = g.effect;
- l.enableEffect(g),
- f || n._bind(e, y, c.fillMode),
- m ? m.bindForSubMesh(r.getWorldMatrix(), r, e) : (y.setMatrix("viewProjection", o.getTransformMatrix()),
- y.setMatrix("world", r.getWorldMatrix()));
- var b = void 0
- , T = void 0;
- if (v ? (b = !l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : 1,
- T = l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : 1) : (b = l.useReverseDepthBuffer && l.isNDCHalfZRange ? _.minZ : l.isNDCHalfZRange ? 0 : _.minZ,
- T = l.useReverseDepthBuffer && l.isNDCHalfZRange ? 0 : _.maxZ),
- y.setFloat2("depthValues", b, b + T),
- !m) {
- if (c && c.needAlphaTesting()) {
- var E = c.getAlphaTestTexture();
- E && (y.setTexture("diffuseSampler", E),
- y.setMatrix("diffuseMatrix", E.getTextureMatrix()))
- }
- if (n.useBones && n.computeBonesUsingShaders && n.skeleton) {
- var S = n.skeleton;
- if (S.isUsingTextureForMatrices) {
- var A = S.getTransformMatrixTexture(n);
- if (!A)
- return;
- y.setTexture("boneSampler", A),
- y.setFloat("boneTextureWidth", 4 * (S.bones.length + 1))
- } else
- y.setMatrices("mBones", S.getTransformMatrices(n))
- }
- Mr.BindMorphTargetParameters(n, y),
- n.morphTargetManager && n.morphTargetManager.isUsingTextureForTargets && n.morphTargetManager._bind(y)
- }
- n._processRendering(r, e, y, c.fillMode, p, f, (function(e, t) {
- return y.setMatrix("world", t)
- }
- ))
- }
- }
- }
- };
- this._depthMap.customRenderFunction = function(e, t, i, n) {
- var r;
- if (n.length)
- for (r = 0; r < n.length; r++)
- u(n.data[r]);
- for (r = 0; r < e.length; r++)
- u(e.data[r]);
- for (r = 0; r < t.length; r++)
- u(t.data[r]);
- if (s.forceDepthWriteTransparentMeshes)
- for (r = 0; r < i.length; r++)
- u(i.data[r]);
- else
- for (r = 0; r < i.length; r++)
- i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
- }
- }
- return e.prototype.setMaterialForRendering = function(e, t) {
- this._depthMap.setMaterialForRendering(e, t)
- }
- ,
- e.prototype.isReady = function(e, t) {
- var i, n = this._scene.getEngine(), r = e.getMesh(), o = null === (i = r._internalAbstractMeshDataInfo._materialForRenderPass) || void 0 === i ? void 0 : i[n.currentRenderPassId];
- if (o)
- return o.isReadyForSubMesh(r, e, t);
- var a = e.getMaterial();
- if (!a || a.disableDepthWrite)
- return !1;
- var s = []
- , l = [Bi.PositionKind];
- if (a && a.needAlphaTesting() && a.getAlphaTestTexture() && (s.push("#define ALPHATEST"),
- r.isVerticesDataPresent(Bi.UVKind) && (l.push(Bi.UVKind),
- s.push("#define UV1")),
- r.isVerticesDataPresent(Bi.UV2Kind) && (l.push(Bi.UV2Kind),
- s.push("#define UV2"))),
- r.useBones && r.computeBonesUsingShaders) {
- l.push(Bi.MatricesIndicesKind),
- l.push(Bi.MatricesWeightsKind),
- r.numBoneInfluencers > 4 && (l.push(Bi.MatricesIndicesExtraKind),
- l.push(Bi.MatricesWeightsExtraKind)),
- s.push("#define NUM_BONE_INFLUENCERS " + r.numBoneInfluencers),
- s.push("#define BonesPerMesh " + (r.skeleton ? r.skeleton.bones.length + 1 : 0));
- var c = e.getRenderingMesh().skeleton;
- (null == c ? void 0 : c.isUsingTextureForMatrices) && s.push("#define BONETEXTURE")
- } else
- s.push("#define NUM_BONE_INFLUENCERS 0");
- var u = r.morphTargetManager
- , h = 0;
- u && u.numInfluencers > 0 && (h = u.numInfluencers,
- s.push("#define MORPHTARGETS"),
- s.push("#define NUM_MORPH_INFLUENCERS " + h),
- u.isUsingTextureForTargets && s.push("#define MORPHTARGETS_TEXTURE"),
- Mr.PrepareAttributesForMorphTargetsInfluencers(l, r, h)),
- t && (s.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(l),
- e.getRenderingMesh().hasThinInstances && s.push("#define THIN_INSTANCES")),
- this._storeNonLinearDepth && s.push("#define NONLINEARDEPTH"),
- this.isPacked && s.push("#define PACKED");
- var d = e._getDrawWrapper(void 0, !0)
- , p = d.defines
- , f = s.join("\n");
- return p !== f && d.setEffect(n.createEffect("depth", l, ["world", "mBones", "boneTextureWidth", "viewProjection", "diffuseMatrix", "depthValues", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"], ["diffuseSampler", "morphTargets", "boneSampler"], f, void 0, void 0, void 0, {
- maxSimultaneousMorphTargets: h
- }), f),
- d.effect.isReady()
- }
- ,
- e.prototype.getDepthMap = function() {
- return this._depthMap
- }
- ,
- e.prototype.dispose = function() {
- var e = [];
- for (var t in this._scene._depthRenderer)
- this._scene._depthRenderer[t] === this && e.push(t);
- if (e.length > 0) {
- this._depthMap.dispose();
- for (var i = 0, n = e; i < n.length; i++)
- t = n[i],
- delete this._scene._depthRenderer[t]
- }
- }
- ,
- e._SceneComponentInitialization = function(e) {
- throw be("DepthRendererSceneComponent")
- }
- ,
- e
- }();
- Pt.ShadersStore.minmaxReduxPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nfloat f1=texelFetch(sourceTexture,coord,0).r;\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\nfloat minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(MAIN)\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*vec2(texSize-1));\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\nfloat minz=min(f1.x,f2.x);\nfloat maxz=max(f1.y,f2.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(LAST)\nvoid main(void)\n{\nglFragColor=vec4(0.);\nif (true) { \ndiscard;\n}\n}\n#endif\n";
- var a_ = function() {
- function e(e) {
- var t = this;
- this.onAfterReductionPerformed = new h,
- this._forceFullscreenViewport = !0,
- this._activated = !1,
- this._camera = e,
- this._postProcessManager = new Vi(e.getScene()),
- this._onContextRestoredObserver = e.getEngine().onContextRestoredObservable.add((function() {
- t._postProcessManager._rebuild()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "sourceTexture", {
- get: function() {
- return this._sourceTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setSourceTexture = function(e, t, i, n) {
- var r = this;
- if (void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT),
- void 0 === n && (n = !0),
- e !== this._sourceTexture) {
- this.dispose(!1),
- this._sourceTexture = e,
- this._reductionSteps = [],
- this._forceFullscreenViewport = n;
- var o = this._camera.getScene()
- , s = new Ba("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define INITIAL" + (t ? "\n#define DEPTH_REDUX" : ""),i,void 0,void 0,void 0,a.TEXTUREFORMAT_RG);
- s.autoClear = !1,
- s.forceFullscreenViewport = n;
- var l = this._sourceTexture.getRenderWidth()
- , c = this._sourceTexture.getRenderHeight();
- s.onApply = function(e, t) {
- return function(i) {
- i.setTexture("sourceTexture", r._sourceTexture),
- i.setFloat2("texSize", e, t)
- }
- }(l, c),
- this._reductionSteps.push(s);
- for (var u = 1; l > 1 || c > 1; ) {
- l = Math.max(Math.round(l / 2), 1),
- c = Math.max(Math.round(c / 2), 1);
- var h = new Ba("Reduction phase " + u,"minmaxRedux",["texSize"],null,{
- width: l,
- height: c
- },null,a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define " + (1 == l && 1 == c ? "LAST" : 1 == l || 1 == c ? "ONEBEFORELAST" : "MAIN"),i,void 0,void 0,void 0,a.TEXTUREFORMAT_RG);
- h.autoClear = !1,
- h.forceFullscreenViewport = n,
- h.onApply = function(e, t) {
- return function(i) {
- 1 == e || 1 == t ? i.setInt2("texSize", e, t) : i.setFloat2("texSize", e, t)
- }
- }(l, c),
- this._reductionSteps.push(h),
- u++,
- 1 == l && 1 == c && h.onAfterRenderObservable.add(function(e, t, i) {
- var n = new Float32Array(4 * e * t)
- , a = {
- min: 0,
- max: 0
- };
- return function() {
- o.getEngine()._readTexturePixels(i.inputTexture.texture, e, t, -1, 0, n, !1),
- a.min = n[0],
- a.max = n[1],
- r.onAfterReductionPerformed.notifyObservers(a)
- }
- }(l, c, h))
- }
- }
- }
- ,
- Object.defineProperty(e.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(e.prototype, "activated", {
- get: function() {
- return this._activated
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.activate = function() {
- var e = this;
- !this._onAfterUnbindObserver && this._sourceTexture && (this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add((function() {
- var t, i, n = e._camera.getScene().getEngine();
- null === (t = n._debugPushGroup) || void 0 === t || t.call(n, "min max reduction", 1),
- e._reductionSteps[0].activate(e._camera),
- e._postProcessManager.directRender(e._reductionSteps, e._reductionSteps[0].inputTexture, e._forceFullscreenViewport),
- n.unBindFramebuffer(e._reductionSteps[0].inputTexture, !1),
- null === (i = n._debugPopGroup) || void 0 === i || i.call(n, 1)
- }
- )),
- this._activated = !0)
- }
- ,
- e.prototype.deactivate = function() {
- this._onAfterUnbindObserver && this._sourceTexture && (this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
- this._onAfterUnbindObserver = null,
- this._activated = !1)
- }
- ,
- e.prototype.dispose = function(e) {
- if (void 0 === e && (e = !0),
- e && (this.onAfterReductionPerformed.clear(),
- this._onContextRestoredObserver && (this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null)),
- this.deactivate(),
- this._reductionSteps) {
- for (var t = 0; t < this._reductionSteps.length; ++t)
- this._reductionSteps[t].dispose();
- this._reductionSteps = null
- }
- this._postProcessManager && e && this._postProcessManager.dispose(),
- this._sourceTexture = null
- }
- ,
- e
- }()
- , s_ = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "depthRenderer", {
- get: function() {
- return this._depthRenderer
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setDepthRenderer = function(t, i, n) {
- void 0 === t && (t = null),
- void 0 === i && (i = a.TEXTURETYPE_HALF_FLOAT),
- void 0 === n && (n = !0);
- var r = this._camera.getScene();
- this._depthRenderer && (delete r._depthRenderer[this._depthRendererId],
- this._depthRenderer.dispose(),
- this._depthRenderer = null),
- null === t && (r._depthRenderer || (r._depthRenderer = {}),
- (t = this._depthRenderer = new o_(r,i,this._camera,!1,a.TEXTURE_NEAREST_SAMPLINGMODE)).enabled = !1,
- this._depthRendererId = "minmax" + this._camera.id,
- r._depthRenderer[this._depthRendererId] = t),
- e.prototype.setSourceTexture.call(this, t.getDepthMap(), !0, i, n)
- }
- ,
- t.prototype.setSourceTexture = function(t, i, n, r) {
- void 0 === n && (n = a.TEXTURETYPE_HALF_FLOAT),
- void 0 === r && (r = !0),
- e.prototype.setSourceTexture.call(this, t, i, n, r)
- }
- ,
- t.prototype.activate = function() {
- this._depthRenderer && (this._depthRenderer.enabled = !0),
- e.prototype.activate.call(this)
- }
- ,
- t.prototype.deactivate = function() {
- e.prototype.deactivate.call(this),
- this._depthRenderer && (this._depthRenderer.enabled = !1)
- }
- ,
- t.prototype.dispose = function(t) {
- if (void 0 === t && (t = !0),
- e.prototype.dispose.call(this, t),
- this._depthRenderer && t) {
- var i = this._depthRenderer.getDepthMap().getScene();
- i && delete i._depthRenderer[this._depthRendererId],
- this._depthRenderer.dispose(),
- this._depthRenderer = null
- }
- }
- ,
- t
- }(a_)
- , l_ = x.Up()
- , c_ = x.Zero()
- , u_ = new x
- , h_ = new x
- , d_ = new P
- , p_ = function(e) {
- function t(i, n, r) {
- var o = this;
- return t.IsSupported ? ((o = e.call(this, i, n, r) || this).usePercentageCloserFiltering = !0,
- o) : (K.Error("CascadedShadowMap is not supported by the current engine."),
- o)
- }
- return U(t, e),
- t.prototype._validateFilter = function(e) {
- return e === r_.FILTER_NONE || e === r_.FILTER_PCF || e === r_.FILTER_PCSS ? e : (console.error('Unsupported filter "' + e + '"!'),
- r_.FILTER_NONE)
- }
- ,
- Object.defineProperty(t.prototype, "numCascades", {
- get: function() {
- return this._numCascades
- },
- set: function(e) {
- (e = Math.min(Math.max(e, t.MIN_CASCADES_COUNT), t.MAX_CASCADES_COUNT)) !== this._numCascades && (this._numCascades = e,
- this.recreateShadowMap(),
- this._recreateSceneUBOs())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "freezeShadowCastersBoundingInfo", {
- get: function() {
- return this._freezeShadowCastersBoundingInfo
- },
- set: function(e) {
- this._freezeShadowCastersBoundingInfoObservable && e && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
- this._freezeShadowCastersBoundingInfoObservable = null),
- this._freezeShadowCastersBoundingInfoObservable || e || (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))),
- this._freezeShadowCastersBoundingInfo = e,
- e && this._computeShadowCastersBoundingInfo()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.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 e = this._shadowMap.renderList, t = 0; t < e.length; t++)
- if (r = e[t]) {
- var i = r.getBoundingInfo().boundingBox;
- this._scbiMin.minimizeInPlace(i.minimumWorld),
- this._scbiMax.maximizeInPlace(i.maximumWorld)
- }
- var n = this._scene.meshes;
- for (t = 0; t < n.length; t++) {
- var r;
- (r = n[t]) && r.isVisible && r.isEnabled && r.receiveShadows && (i = r.getBoundingInfo().boundingBox,
- this._scbiMin.minimizeInPlace(i.minimumWorld),
- this._scbiMax.maximizeInPlace(i.maximumWorld))
- }
- }
- this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax)
- }
- ,
- Object.defineProperty(t.prototype, "shadowCastersBoundingInfo", {
- get: function() {
- return this._shadowCastersBoundingInfo
- },
- set: function(e) {
- this._shadowCastersBoundingInfo = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setMinMaxDistance = function(e, t) {
- this._minDistance === e && this._maxDistance === t || (e > t && (e = 0,
- t = 1),
- e < 0 && (e = 0),
- t > 1 && (t = 1),
- this._minDistance = e,
- this._maxDistance = t,
- this._breaksAreDirty = !0)
- }
- ,
- Object.defineProperty(t.prototype, "minDistance", {
- get: function() {
- return this._minDistance
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "maxDistance", {
- get: function() {
- return this._maxDistance
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return t.CLASSNAME
- }
- ,
- t.prototype.getCascadeMinExtents = function(e) {
- return e >= 0 && e < this._numCascades ? this._cascadeMinExtents[e] : null
- }
- ,
- t.prototype.getCascadeMaxExtents = function(e) {
- return e >= 0 && e < this._numCascades ? this._cascadeMaxExtents[e] : null
- }
- ,
- Object.defineProperty(t.prototype, "shadowMaxZ", {
- get: function() {
- return this._scene && this._scene.activeCamera ? this._shadowMaxZ : 0
- },
- set: function(e) {
- this._scene && this._scene.activeCamera ? this._shadowMaxZ === e || e < this._scene.activeCamera.minZ || e > this._scene.activeCamera.maxZ || (this._shadowMaxZ = e,
- this._light._markMeshesAsLightDirty(),
- this._breaksAreDirty = !0) : this._shadowMaxZ = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "debug", {
- get: function() {
- return this._debug
- },
- set: function(e) {
- this._debug = e,
- this._light._markMeshesAsLightDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthClamp", {
- get: function() {
- return this._depthClamp
- },
- set: function(e) {
- this._depthClamp = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cascadeBlendPercentage", {
- get: function() {
- return this._cascadeBlendPercentage
- },
- set: function(e) {
- this._cascadeBlendPercentage = e,
- this._light._markMeshesAsLightDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lambda", {
- get: function() {
- return this._lambda
- },
- set: function(e) {
- var t = Math.min(Math.max(e, 0), 1);
- this._lambda != t && (this._lambda = t,
- this._breaksAreDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getCascadeViewMatrix = function(e) {
- return e >= 0 && e < this._numCascades ? this._viewMatrices[e] : null
- }
- ,
- t.prototype.getCascadeProjectionMatrix = function(e) {
- return e >= 0 && e < this._numCascades ? this._projectionMatrices[e] : null
- }
- ,
- t.prototype.getCascadeTransformMatrix = function(e) {
- return e >= 0 && e < this._numCascades ? this._transformMatrices[e] : null
- }
- ,
- t.prototype.setDepthRenderer = function(e) {
- this._depthRenderer = e,
- this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer)
- }
- ,
- Object.defineProperty(t.prototype, "autoCalcDepthBounds", {
- get: function() {
- return this._autoCalcDepthBounds
- },
- set: function(e) {
- var t = this
- , i = this._scene.activeCamera;
- if (i) {
- if (this._autoCalcDepthBounds = e,
- !e)
- return this._depthReducer && this._depthReducer.deactivate(),
- void this.setMinMaxDistance(0, 1);
- this._depthReducer || (this._depthReducer = new s_(i),
- this._depthReducer.onAfterReductionPerformed.add((function(e) {
- var i = e.min
- , n = e.max;
- i >= n && (i = 0,
- n = 1),
- i == t._minDistance && n == t._maxDistance || t.setMinMaxDistance(i, n)
- }
- )),
- this._depthReducer.setDepthRenderer(this._depthRenderer)),
- this._depthReducer.activate()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "autoCalcDepthBoundsRefreshRate", {
- get: function() {
- var e, t, i;
- return null !== (i = null === (t = null === (e = this._depthReducer) || void 0 === e ? void 0 : e.depthRenderer) || void 0 === t ? void 0 : t.getDepthMap().refreshRate) && void 0 !== i ? i : -1
- },
- set: function(e) {
- var t;
- (null === (t = this._depthReducer) || void 0 === t ? void 0 : t.depthRenderer) && (this._depthReducer.depthRenderer.getDepthMap().refreshRate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.splitFrustum = function() {
- this._breaksAreDirty = !0
- }
- ,
- t.prototype._splitFrustum = function() {
- var e = this._scene.activeCamera;
- if (e) {
- for (var t = e.minZ, i = e.maxZ, n = i - t, r = this._minDistance, o = t + r * n, a = t + (this._shadowMaxZ < i && this._shadowMaxZ >= t ? Math.min((this._shadowMaxZ - t) / (i - t), this._maxDistance) : this._maxDistance) * n, s = a - o, l = a / o, c = 0; c < this._cascades.length; ++c) {
- var u = (c + 1) / this._numCascades
- , h = o * Math.pow(l, u)
- , d = o + s * u
- , p = this._lambda * (h - d) + d;
- this._cascades[c].prevBreakDistance = 0 === c ? r : this._cascades[c - 1].breakDistance,
- this._cascades[c].breakDistance = (p - t) / n,
- this._viewSpaceFrustumsZ[c] = p,
- this._frustumLengths[c] = (this._cascades[c].breakDistance - this._cascades[c].prevBreakDistance) * n
- }
- this._breaksAreDirty = !1
- }
- }
- ,
- t.prototype._computeMatrices = function() {
- var e = this._scene;
- if (e.activeCamera) {
- x.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection),
- 1 === Math.abs(x.Dot(this._lightDirection, x.Up())) && (this._lightDirection.z = 1e-13),
- this._cachedDirection.copyFrom(this._lightDirection);
- for (var t = e.getEngine().useReverseDepthBuffer, i = 0; i < this._numCascades; ++i) {
- this._computeFrustumInWorldSpace(i),
- this._computeCascadeFrustum(i),
- this._cascadeMaxExtents[i].subtractToRef(this._cascadeMinExtents[i], u_),
- this._frustumCenter[i].addToRef(this._lightDirection.scale(this._cascadeMinExtents[i].z), this._shadowCameraPos[i]),
- P.LookAtLHToRef(this._shadowCameraPos[i], this._frustumCenter[i], l_, this._viewMatrices[i]);
- var n = 0
- , r = u_.z
- , o = this._shadowCastersBoundingInfo;
- o.update(this._viewMatrices[i]),
- r = Math.min(r, o.boundingBox.maximumWorld.z),
- n = this._depthClamp && this.filter !== r_.FILTER_PCSS ? Math.max(n, o.boundingBox.minimumWorld.z) : Math.min(n, o.boundingBox.minimumWorld.z),
- P.OrthoOffCenterLHToRef(this._cascadeMinExtents[i].x, this._cascadeMaxExtents[i].x, this._cascadeMinExtents[i].y, this._cascadeMaxExtents[i].y, t ? r : n, t ? n : r, this._projectionMatrices[i], e.getEngine().isNDCHalfZRange),
- this._cascadeMinExtents[i].z = n,
- this._cascadeMaxExtents[i].z = r,
- this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]),
- x.TransformCoordinatesToRef(c_, this._transformMatrices[i], u_),
- u_.scaleInPlace(this._mapSize / 2),
- h_.copyFromFloats(Math.round(u_.x), Math.round(u_.y), Math.round(u_.z)),
- h_.subtractInPlace(u_).scaleInPlace(2 / this._mapSize),
- P.TranslationToRef(h_.x, h_.y, 0, d_),
- this._projectionMatrices[i].multiplyToRef(d_, this._projectionMatrices[i]),
- this._viewMatrices[i].multiplyToRef(this._projectionMatrices[i], this._transformMatrices[i]),
- this._transformMatrices[i].copyToArray(this._transformMatricesAsArray, 16 * i)
- }
- }
- }
- ,
- t.prototype._computeFrustumInWorldSpace = function(e) {
- if (this._scene.activeCamera) {
- var i = this._cascades[e].prevBreakDistance
- , n = this._cascades[e].breakDistance
- , r = this._scene.getEngine().isNDCHalfZRange;
- this._scene.activeCamera.getViewMatrix();
- for (var o = P.Invert(this._scene.activeCamera.getTransformationMatrix()), a = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, s = 0; s < t._FrustumCornersNDCSpace.length; ++s)
- u_.copyFrom(t._FrustumCornersNDCSpace[(s + a) % t._FrustumCornersNDCSpace.length]),
- r && -1 === u_.z && (u_.z = 0),
- x.TransformCoordinatesToRef(u_, o, this._frustumCornersWorldSpace[e][s]);
- for (s = 0; s < t._FrustumCornersNDCSpace.length / 2; ++s)
- u_.copyFrom(this._frustumCornersWorldSpace[e][s + 4]).subtractInPlace(this._frustumCornersWorldSpace[e][s]),
- h_.copyFrom(u_).scaleInPlace(i),
- u_.scaleInPlace(n),
- u_.addInPlace(this._frustumCornersWorldSpace[e][s]),
- this._frustumCornersWorldSpace[e][s + 4].copyFrom(u_),
- this._frustumCornersWorldSpace[e][s].addInPlace(h_)
- }
- }
- ,
- t.prototype._computeCascadeFrustum = function(e) {
- if (this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
- this._cascadeMaxExtents[e].copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
- this._frustumCenter[e].copyFromFloats(0, 0, 0),
- this._scene.activeCamera) {
- for (var t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)
- this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][t]);
- if (this._frustumCenter[e].scaleInPlace(1 / this._frustumCornersWorldSpace[e].length),
- this.stabilizeCascades) {
- var i = 0;
- for (t = 0; t < this._frustumCornersWorldSpace[e].length; ++t) {
- var n = this._frustumCornersWorldSpace[e][t].subtractToRef(this._frustumCenter[e], u_).length();
- i = Math.max(i, n)
- }
- i = Math.ceil(16 * i) / 16,
- this._cascadeMaxExtents[e].copyFromFloats(i, i, i),
- this._cascadeMinExtents[e].copyFromFloats(-i, -i, -i)
- } else {
- var r = this._frustumCenter[e];
- for (this._frustumCenter[e].addToRef(this._lightDirection, u_),
- P.LookAtLHToRef(r, u_, l_, d_),
- t = 0; t < this._frustumCornersWorldSpace[e].length; ++t)
- x.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][t], d_, u_),
- this._cascadeMinExtents[e].minimizeInPlace(u_),
- this._cascadeMaxExtents[e].maximizeInPlace(u_)
- }
- }
- }
- ,
- t.prototype._recreateSceneUBOs = function() {
- if (this._disposeSceneUBOs(),
- this._sceneUBOs)
- for (var e = 0; e < this._numCascades; ++e)
- this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "'.concat(this._light.name, '" cascade #').concat(e, ")")))
- }
- ,
- Object.defineProperty(t, "IsSupported", {
- get: function() {
- var e = E.LastCreatedEngine;
- return !!e && e._features.supportCSM
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._initializeGenerator = function() {
- var i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T;
- this.penumbraDarkness = null !== (i = this.penumbraDarkness) && void 0 !== i ? i : 1,
- this._numCascades = null !== (n = this._numCascades) && void 0 !== n ? n : t.DEFAULT_CASCADES_COUNT,
- this.stabilizeCascades = null !== (r = this.stabilizeCascades) && void 0 !== r && r,
- this._freezeShadowCastersBoundingInfoObservable = null !== (o = this._freezeShadowCastersBoundingInfoObservable) && void 0 !== o ? o : null,
- this.freezeShadowCastersBoundingInfo = null !== (a = this.freezeShadowCastersBoundingInfo) && void 0 !== a && a,
- this._scbiMin = null !== (s = this._scbiMin) && void 0 !== s ? s : new x(0,0,0),
- this._scbiMax = null !== (l = this._scbiMax) && void 0 !== l ? l : new x(0,0,0),
- this._shadowCastersBoundingInfo = null !== (c = this._shadowCastersBoundingInfo) && void 0 !== c ? c : new sr(new x(0,0,0),new x(0,0,0)),
- this._breaksAreDirty = null === (u = this._breaksAreDirty) || void 0 === u || u,
- this._minDistance = null !== (h = this._minDistance) && void 0 !== h ? h : 0,
- this._maxDistance = null !== (d = this._maxDistance) && void 0 !== d ? d : 1,
- this._currentLayer = null !== (p = this._currentLayer) && void 0 !== p ? p : 0,
- this._shadowMaxZ = null !== (m = null !== (f = this._shadowMaxZ) && void 0 !== f ? f : null === (_ = this._scene.activeCamera) || void 0 === _ ? void 0 : _.maxZ) && void 0 !== m ? m : 1e4,
- this._debug = null !== (g = this._debug) && void 0 !== g && g,
- this._depthClamp = null === (v = this._depthClamp) || void 0 === v || v,
- this._cascadeBlendPercentage = null !== (y = this._cascadeBlendPercentage) && void 0 !== y ? y : .1,
- this._lambda = null !== (b = this._lambda) && void 0 !== b ? b : .5,
- this._autoCalcDepthBounds = null !== (T = this._autoCalcDepthBounds) && void 0 !== T && T,
- this._recreateSceneUBOs(),
- e.prototype._initializeGenerator.call(this)
- }
- ,
- t.prototype._createTargetRenderTexture = function() {
- var e = this._scene.getEngine()
- , t = {
- width: this._mapSize,
- height: this._mapSize,
- layers: this.numCascades
- };
- this._shadowMap = new ns(this._light.name + "_CSMShadowMap",t,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),
- this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer ? a.GREATER : a.LESS, !0)
- }
- ,
- t.prototype._initializeShadowMap = function() {
- var i = this;
- if (e.prototype._initializeShadowMap.call(this),
- null !== this._shadowMap) {
- this._transformMatricesAsArray = new Float32Array(16 * this._numCascades),
- this._viewSpaceFrustumsZ = new Array(this._numCascades),
- this._frustumLengths = new Array(this._numCascades),
- this._lightSizeUVCorrection = new Array(2 * this._numCascades),
- 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 n = 0; n < this._numCascades; ++n) {
- this._cascades[n] = {
- prevBreakDistance: 0,
- breakDistance: 0
- },
- this._viewMatrices[n] = P.Zero(),
- this._projectionMatrices[n] = P.Zero(),
- this._transformMatrices[n] = P.Zero(),
- this._cascadeMinExtents[n] = new x,
- this._cascadeMaxExtents[n] = new x,
- this._frustumCenter[n] = new x,
- this._shadowCameraPos[n] = new x,
- this._frustumCornersWorldSpace[n] = new Array(t._FrustumCornersNDCSpace.length);
- for (var r = 0; r < t._FrustumCornersNDCSpace.length; ++r)
- this._frustumCornersWorldSpace[n][r] = new x
- }
- var o = this._scene.getEngine();
- this._shadowMap.onBeforeBindObservable.clear(),
- this._shadowMap.onBeforeRenderObservable.clear(),
- this._shadowMap.onBeforeRenderObservable.add((function(e) {
- i._sceneUBOs && i._scene.setSceneUniformBuffer(i._sceneUBOs[e]),
- i._currentLayer = e,
- i._filter === r_.FILTER_PCF && o.setColorWrite(!1),
- i._scene.setTransformMatrix(i.getCascadeViewMatrix(e), i.getCascadeProjectionMatrix(e)),
- i._useUBO && (i._scene.getSceneUniformBuffer().unbindEffect(),
- i._scene.finalizeSceneUbo())
- }
- )),
- this._shadowMap.onBeforeBindObservable.add((function() {
- var e;
- i._currentSceneUBO = i._scene.getSceneUniformBuffer(),
- null === (e = o._debugPushGroup) || void 0 === e || e.call(o, "cascaded shadow map generation for pass id ".concat(o.currentRenderPassId), 1),
- i._breaksAreDirty && i._splitFrustum(),
- i._computeMatrices()
- }
- )),
- this._splitFrustum()
- }
- }
- ,
- t.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, t) {
- t.setMatrix("viewProjection", this.getCascadeTransformMatrix(this._currentLayer))
- }
- ,
- t.prototype._isReadyCustomDefines = function(e) {
- e.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== r_.FILTER_PCSS ? "1" : "0"))
- }
- ,
- t.prototype.prepareDefines = function(t, i) {
- e.prototype.prepareDefines.call(this, t, i);
- var n = this._scene
- , r = this._light;
- if (n.shadowsEnabled && r.shadowEnabled) {
- t["SHADOWCSM" + i] = !0,
- t["SHADOWCSMDEBUG" + i] = this.debug,
- t["SHADOWCSMNUM_CASCADES" + i] = this.numCascades,
- t["SHADOWCSM_RIGHTHANDED" + i] = n.useRightHandedSystem;
- var o = n.activeCamera;
- o && this._shadowMaxZ < o.maxZ && (t["SHADOWCSMUSESHADOWMAXZ" + i] = !0),
- 0 === this.cascadeBlendPercentage && (t["SHADOWCSMNOBLEND" + i] = !0)
- }
- }
- ,
- t.prototype.bindShadowLight = function(e, t) {
- var i = this._light
- , n = this._scene;
- if (n.shadowsEnabled && i.shadowEnabled) {
- var r = n.activeCamera;
- if (r) {
- var o = this.getShadowMap();
- if (o) {
- var a = o.getSize().width;
- if (t.setMatrices("lightMatrix" + e, this._transformMatricesAsArray),
- t.setArray("viewFrustumZ" + e, this._viewSpaceFrustumsZ),
- t.setFloat("cascadeBlendFactor" + e, 0 === this.cascadeBlendPercentage ? 1e4 : 1 / this.cascadeBlendPercentage),
- t.setArray("frustumLengths" + e, this._frustumLengths),
- this._filter === r_.FILTER_PCF)
- t.setDepthStencilTexture("shadowSampler" + e, o),
- i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a, 1 / a, this.frustumEdgeFalloff, e);
- else if (this._filter === r_.FILTER_PCSS) {
- for (var s = 0; s < this._numCascades; ++s)
- this._lightSizeUVCorrection[2 * s + 0] = 0 === s ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[s].x - this._cascadeMinExtents[s].x),
- this._lightSizeUVCorrection[2 * s + 1] = 0 === s ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[s].y - this._cascadeMinExtents[s].y),
- this._depthCorrection[s] = 0 === s ? 1 : (this._cascadeMaxExtents[s].z - this._cascadeMinExtents[s].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
- t.setDepthStencilTexture("shadowSampler" + e, o),
- t.setTexture("depthSampler" + e, o),
- t.setArray2("lightSizeUVCorrection" + e, this._lightSizeUVCorrection),
- t.setArray("depthCorrection" + e, this._depthCorrection),
- t.setFloat("penumbraDarkness" + e, this.penumbraDarkness),
- i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / a, this._contactHardeningLightSizeUVRatio * a, this.frustumEdgeFalloff, e)
- } else
- t.setTexture("shadowSampler" + e, o),
- i._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), a, 1 / a, this.frustumEdgeFalloff, e);
- i._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(r), this.getLight().getDepthMinZ(r) + this.getLight().getDepthMaxZ(r), e)
- }
- }
- }
- }
- ,
- t.prototype.getTransformMatrix = function() {
- return this.getCascadeTransformMatrix(0)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
- this._freezeShadowCastersBoundingInfoObservable = null),
- this._depthReducer && (this._depthReducer.dispose(),
- this._depthReducer = null)
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this)
- , i = this.getShadowMap();
- if (!i)
- return t;
- if (t.numCascades = this._numCascades,
- t.debug = this._debug,
- t.stabilizeCascades = this.stabilizeCascades,
- t.lambda = this._lambda,
- t.cascadeBlendPercentage = this.cascadeBlendPercentage,
- t.depthClamp = this._depthClamp,
- t.autoCalcDepthBounds = this.autoCalcDepthBounds,
- t.shadowMaxZ = this._shadowMaxZ,
- t.penumbraDarkness = this.penumbraDarkness,
- t.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo,
- t.minDistance = this.minDistance,
- t.maxDistance = this.maxDistance,
- t.renderList = [],
- i.renderList)
- for (var n = 0; n < i.renderList.length; n++) {
- var r = i.renderList[n];
- t.renderList.push(r.id)
- }
- return t
- }
- ,
- t.Parse = function(e, i) {
- var n = r_.Parse(e, i, (function(e, i) {
- return new t(e,i)
- }
- ));
- return void 0 !== e.numCascades && (n.numCascades = e.numCascades),
- void 0 !== e.debug && (n.debug = e.debug),
- void 0 !== e.stabilizeCascades && (n.stabilizeCascades = e.stabilizeCascades),
- void 0 !== e.lambda && (n.lambda = e.lambda),
- void 0 !== e.cascadeBlendPercentage && (n.cascadeBlendPercentage = e.cascadeBlendPercentage),
- void 0 !== e.depthClamp && (n.depthClamp = e.depthClamp),
- void 0 !== e.autoCalcDepthBounds && (n.autoCalcDepthBounds = e.autoCalcDepthBounds),
- void 0 !== e.shadowMaxZ && (n.shadowMaxZ = e.shadowMaxZ),
- void 0 !== e.penumbraDarkness && (n.penumbraDarkness = e.penumbraDarkness),
- void 0 !== e.freezeShadowCastersBoundingInfo && (n.freezeShadowCastersBoundingInfo = e.freezeShadowCastersBoundingInfo),
- void 0 !== e.minDistance && void 0 !== e.maxDistance && n.setMinMaxDistance(e.minDistance, e.maxDistance),
- n
- }
- ,
- t._FrustumCornersNDCSpace = [new x(-1,1,-1), new x(1,1,-1), new x(1,-1,-1), new x(-1,-1,-1), new x(-1,1,1), new x(1,1,1), new x(1,-1,1), new x(-1,-1,1)],
- t.CLASSNAME = "CascadedShadowGenerator",
- t.DEFAULT_CASCADES_COUNT = 4,
- t.MIN_CASCADES_COUNT = 2,
- t.MAX_CASCADES_COUNT = 4,
- t._SceneComponentInitialization = function(e) {
- throw be("ShadowGeneratorSceneComponent")
- }
- ,
- t
- }(r_);
- o.AddParser(Wi.NAME_SHADOWGENERATOR, (function(e, t) {
- if (void 0 !== e.shadowGenerators && null !== e.shadowGenerators)
- for (var i = 0, n = e.shadowGenerators.length; i < n; i++) {
- var r = e.shadowGenerators[i];
- r.className === p_.CLASSNAME ? p_.Parse(r, t) : r_.Parse(r, t)
- }
- }
- ));
- var f_ = function() {
- function e(e) {
- this.name = Wi.NAME_SHADOWGENERATOR,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.serialize = function(e) {
- e.shadowGenerators = [];
- for (var t = 0, i = this.scene.lights; t < i.length; t++) {
- var n = i[t].getShadowGenerator();
- n && e.shadowGenerators.push(n.serialize())
- }
- }
- ,
- e.prototype.addFromContainer = function(e) {}
- ,
- e.prototype.removeFromContainer = function(e, t) {}
- ,
- e.prototype.dispose = function() {}
- ,
- e.prototype._gatherRenderTargets = function(e) {
- var t = this.scene;
- if (this.scene.shadowsEnabled)
- for (var i = 0; i < t.lights.length; i++) {
- var n = t.lights[i]
- , r = n.getShadowGenerator();
- if (n.isEnabled() && n.shadowEnabled && r) {
- var o = r.getShadowMap();
- -1 !== t.textures.indexOf(o) && e.push(o)
- }
- }
- }
- ,
- e
- }();
- r_._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_SHADOWGENERATOR);
- t || (t = new f_(e),
- e._addComponent(t))
- }
- ,
- Xe.AddNodeConstructor("Light_Type_0", (function(e, t) {
- return function() {
- return new __(e,x.Zero(),t)
- }
- }
- ));
- var __ = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, n) || this;
- return r._shadowAngle = Math.PI / 2,
- r.position = i,
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "shadowAngle", {
- get: function() {
- return this._shadowAngle
- },
- set: function(e) {
- this._shadowAngle = e,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "direction", {
- get: function() {
- return this._direction
- },
- set: function(e) {
- var t = this.needCube();
- this._direction = e,
- this.needCube() !== t && this._shadowGenerator && this._shadowGenerator.recreateShadowMap()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "PointLight"
- }
- ,
- t.prototype.getTypeID = function() {
- return Cr.LIGHTTYPEID_POINTLIGHT
- }
- ,
- t.prototype.needCube = function() {
- return !this.direction
- }
- ,
- t.prototype.getShadowDirection = function(t) {
- if (this.direction)
- return e.prototype.getShadowDirection.call(this, t);
- switch (t) {
- case 0:
- return new x(1,0,0);
- case 1:
- return new x(-1,0,0);
- case 2:
- return new x(0,-1,0);
- case 3:
- return new x(0,1,0);
- case 4:
- return new x(0,0,1);
- case 5:
- return new x(0,0,-1)
- }
- return x.Zero()
- }
- ,
- t.prototype._setDefaultShadowProjectionMatrix = function(e, t, i) {
- var n = this.getScene().activeCamera;
- if (n) {
- var r = void 0 !== this.shadowMinZ ? this.shadowMinZ : n.minZ
- , o = void 0 !== this.shadowMaxZ ? this.shadowMaxZ : n.maxZ
- , a = this.getScene().getEngine().useReverseDepthBuffer;
- P.PerspectiveFovLHToRef(this.shadowAngle, 1, a ? o : r, a ? r : o, e, !0, this._scene.getEngine().isNDCHalfZRange, void 0, a)
- }
- }
- ,
- t.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()
- }
- ,
- t.prototype.transferToEffect = function(e, t) {
- return this.computeTransformedInformation() ? this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0, t) : this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, t),
- this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, t),
- this
- }
- ,
- t.prototype.transferToNodeMaterialEffect = function(e, t) {
- return this.computeTransformedInformation() ? e.setFloat3(t, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z) : e.setFloat3(t, this.position.x, this.position.y, this.position.z),
- this
- }
- ,
- t.prototype.prepareLightSpecificDefines = function(e, t) {
- e["POINTLIGHT" + t] = !0
- }
- ,
- k([Ce()], t.prototype, "shadowAngle", null),
- t
- }(xd)
- , m_ = function() {
- function e(e, t, i) {
- void 0 === t && (t = ""),
- void 0 === i && (i = "black");
- var n = this;
- this._renderingCanvas = e,
- this._loadingText = t,
- this._loadingDivBackgroundColor = i,
- this._resizeLoadingUI = function() {
- var e = n._renderingCanvas.getBoundingClientRect()
- , t = window.getComputedStyle(n._renderingCanvas).position;
- n._loadingDiv && (n._loadingDiv.style.position = "fixed" === t ? "fixed" : "absolute",
- n._loadingDiv.style.left = e.left + "px",
- n._loadingDiv.style.top = e.top + "px",
- n._loadingDiv.style.width = e.width + "px",
- n._loadingDiv.style.height = e.height + "px")
- }
- }
- return e.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",
- this._style.innerHTML = "@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",
- document.getElementsByTagName("head")[0].appendChild(this._style);
- var t = !!window.SVGSVGElement
- , i = new Image;
- e.DefaultLogoUrl ? i.src = e.DefaultLogoUrl : i.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+" : "https://cdn.babylonjs.com/Assets/babylonLogo.png",
- i.style.width = "150px",
- i.style.gridColumn = "1",
- i.style.gridRow = "1",
- i.style.top = "50%",
- i.style.left = "50%",
- i.style.transform = "translate(-50%, -50%)",
- i.style.position = "absolute";
- var n = document.createElement("div");
- n.style.width = "300px",
- n.style.gridColumn = "1",
- n.style.gridRow = "1",
- n.style.top = "50%",
- n.style.left = "50%",
- n.style.transform = "translate(-50%, -50%)",
- n.style.position = "absolute";
- var r = new Image;
- if (e.DefaultSpinnerUrl ? r.src = e.DefaultSpinnerUrl : r.src = t ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==" : "https://cdn.babylonjs.com/Assets/loadingIcon.png",
- r.style.animation = "spin1 0.75s infinite linear",
- r.style.webkitAnimation = "spin1 0.75s infinite linear",
- r.style.transformOrigin = "50% 50%",
- r.style.webkitTransformOrigin = "50% 50%",
- !t) {
- var o = {
- w: 16,
- h: 18.5
- }
- , a = {
- w: 30,
- h: 30
- };
- i.style.width = "".concat(o.w, "vh"),
- i.style.height = "".concat(o.h, "vh"),
- i.style.left = "calc(50% - ".concat(o.w / 2, "vh)"),
- i.style.top = "calc(50% - ".concat(o.h / 2, "vh)"),
- r.style.width = "".concat(a.w, "vh"),
- r.style.height = "".concat(a.h, "vh"),
- r.style.left = "calc(50% - ".concat(a.w / 2, "vh)"),
- r.style.top = "calc(50% - ".concat(a.h / 2, "vh)")
- }
- n.appendChild(r),
- this._loadingDiv.appendChild(i),
- this._loadingDiv.appendChild(n),
- this._resizeLoadingUI(),
- window.addEventListener("resize", this._resizeLoadingUI),
- this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor,
- document.body.appendChild(this._loadingDiv),
- this._loadingDiv.style.opacity = "1"
- }
- }
- ,
- e.prototype.hideLoadingUI = function() {
- var e = this;
- this._loadingDiv && (this._loadingDiv.style.opacity = "0",
- this._loadingDiv.addEventListener("transitionend", (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)
- }
- )))
- }
- ,
- Object.defineProperty(e.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(e.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
- }),
- e.DefaultLogoUrl = "",
- e.DefaultSpinnerUrl = "",
- e
- }();
- vr.DefaultLoadingScreenFactory = function(e) {
- return new m_(e)
- }
- ;
- var g_ = function() {
- function e() {}
- return e.ConvertPanoramaToCubemap = function(e, t, i, n) {
- if (!e)
- throw "ConvertPanoramaToCubemap: input cannot be null";
- if (e.length != t * i * 3)
- throw "ConvertPanoramaToCubemap: input size is wrong";
- return {
- front: this.CreateCubemapTexture(n, this.FACE_FRONT, e, t, i),
- back: this.CreateCubemapTexture(n, this.FACE_BACK, e, t, i),
- left: this.CreateCubemapTexture(n, this.FACE_LEFT, e, t, i),
- right: this.CreateCubemapTexture(n, this.FACE_RIGHT, e, t, i),
- up: this.CreateCubemapTexture(n, this.FACE_UP, e, t, i),
- down: this.CreateCubemapTexture(n, this.FACE_DOWN, e, t, i),
- size: n,
- type: a.TEXTURETYPE_FLOAT,
- format: a.TEXTUREFORMAT_RGB,
- gammaSpace: !1
- }
- }
- ,
- e.CreateCubemapTexture = function(e, t, i, n, r) {
- for (var o = new ArrayBuffer(e * e * 4 * 3), a = new Float32Array(o), s = t[1].subtract(t[0]).scale(1 / e), l = t[3].subtract(t[2]).scale(1 / e), c = 1 / e, u = 0, h = 0; h < e; h++) {
- for (var d = t[0], p = t[2], f = 0; f < e; f++) {
- var _ = p.subtract(d).scale(u).add(d);
- _.normalize();
- var m = this.CalcProjectionSpherical(_, i, n, r);
- a[h * e * 3 + 3 * f + 0] = m.r,
- a[h * e * 3 + 3 * f + 1] = m.g,
- a[h * e * 3 + 3 * f + 2] = m.b,
- d = d.add(s),
- p = p.add(l)
- }
- u += c
- }
- return a
- }
- ,
- e.CalcProjectionSpherical = function(e, t, i, n) {
- for (var r = Math.atan2(e.z, e.x), o = Math.acos(e.y); r < -Math.PI; )
- r += 2 * Math.PI;
- for (; r > Math.PI; )
- r -= 2 * Math.PI;
- var a = r / Math.PI
- , s = o / Math.PI;
- a = .5 * a + .5;
- var l = Math.round(a * i);
- l < 0 ? l = 0 : l >= i && (l = i - 1);
- var c = Math.round(s * n);
- c < 0 ? c = 0 : c >= n && (c = n - 1);
- var u = n - c - 1;
- return {
- r: t[u * i * 3 + 3 * l + 0],
- g: t[u * i * 3 + 3 * l + 1],
- b: t[u * i * 3 + 3 * l + 2]
- }
- }
- ,
- e.FACE_LEFT = [new x(-1,-1,-1), new x(1,-1,-1), new x(-1,1,-1), new x(1,1,-1)],
- e.FACE_RIGHT = [new x(1,-1,1), new x(-1,-1,1), new x(1,1,1), new x(-1,1,1)],
- e.FACE_FRONT = [new x(1,-1,-1), new x(1,-1,1), new x(1,1,-1), new x(1,1,1)],
- e.FACE_BACK = [new x(-1,-1,1), new x(-1,-1,-1), new x(-1,1,1), new x(-1,1,-1)],
- e.FACE_DOWN = [new x(1,1,-1), new x(1,1,1), new x(-1,1,-1), new x(-1,1,1)],
- e.FACE_UP = [new x(-1,-1,-1), new x(-1,-1,1), new x(1,-1,-1), new x(1,-1,1)],
- e
- }()
- , v_ = function() {
- function e() {}
- return e._Ldexp = function(e, t) {
- return t > 1023 ? e * Math.pow(2, 1023) * Math.pow(2, t - 1023) : t < -1074 ? e * Math.pow(2, -1074) * Math.pow(2, t + 1074) : e * Math.pow(2, t)
- }
- ,
- e._Rgbe2float = function(e, t, i, n, r, o) {
- r > 0 ? (r = this._Ldexp(1, r - 136),
- e[o + 0] = t * r,
- e[o + 1] = i * r,
- e[o + 2] = n * r) : (e[o + 0] = 0,
- e[o + 1] = 0,
- e[o + 2] = 0)
- }
- ,
- e._ReadStringLine = function(e, t) {
- for (var i = "", n = "", r = t; r < e.length - t && "\n" != (n = String.fromCharCode(e[r])); r++)
- i += n;
- return i
- }
- ,
- e.RGBE_ReadHeader = function(e) {
- var t, i, n = this._ReadStringLine(e, 0);
- if ("#" != n[0] || "?" != n[1])
- throw "Bad HDR Format.";
- var r = !1
- , o = !1
- , a = 0;
- do {
- a += n.length + 1,
- "FORMAT=32-bit_rle_rgbe" == (n = this._ReadStringLine(e, a)) ? o = !0 : 0 == n.length && (r = !0)
- } while (!r);
- if (!o)
- throw "HDR Bad header format, unsupported FORMAT";
- a += n.length + 1,
- n = this._ReadStringLine(e, a);
- var s = /^-Y (.*) \+X (.*)$/g.exec(n);
- if (!s || s.length < 3)
- throw "HDR Bad header format, no size";
- if (i = parseInt(s[2]),
- t = parseInt(s[1]),
- i < 8 || i > 32767)
- throw "HDR Bad header format, unsupported size";
- return {
- height: t,
- width: i,
- dataPosition: a += n.length + 1
- }
- }
- ,
- e.GetCubeMapTextureData = function(e, t) {
- var i = new Uint8Array(e)
- , n = this.RGBE_ReadHeader(i)
- , r = this.RGBE_ReadPixels(i, n);
- return g_.ConvertPanoramaToCubemap(r, n.width, n.height, t)
- }
- ,
- e.RGBE_ReadPixels = function(e, t) {
- return this._RGBEReadPixelsRLE(e, t)
- }
- ,
- e._RGBEReadPixelsRLE = function(e, t) {
- for (var i, n, r, o, a, s = t.height, l = t.width, c = t.dataPosition, u = 0, h = 0, d = 0, p = new ArrayBuffer(4 * l), f = new Uint8Array(p), _ = new ArrayBuffer(t.width * t.height * 4 * 3), m = new Float32Array(_); s > 0; ) {
- if (i = e[c++],
- n = e[c++],
- r = e[c++],
- o = e[c++],
- 2 != i || 2 != n || 128 & r || t.width < 8 || t.width > 32767)
- return this._RGBEReadPixelsNOTRLE(e, t);
- if ((r << 8 | o) != l)
- throw "HDR Bad header format, wrong scan line width";
- for (u = 0,
- d = 0; d < 4; d++)
- for (h = (d + 1) * l; u < h; )
- if (i = e[c++],
- n = e[c++],
- i > 128) {
- if (0 == (a = i - 128) || a > h - u)
- throw "HDR Bad Format, bad scanline data (run)";
- for (; a-- > 0; )
- f[u++] = n
- } else {
- if (0 == (a = i) || a > h - u)
- throw "HDR Bad Format, bad scanline data (non-run)";
- if (f[u++] = n,
- --a > 0)
- for (var g = 0; g < a; g++)
- f[u++] = e[c++]
- }
- for (d = 0; d < l; d++)
- i = f[d],
- n = f[d + l],
- r = f[d + 2 * l],
- o = f[d + 3 * l],
- this._Rgbe2float(m, i, n, r, o, (t.height - s) * l * 3 + 3 * d);
- s--
- }
- return m
- }
- ,
- e._RGBEReadPixelsNOTRLE = function(e, t) {
- for (var i, n, r, o, a, s = t.height, l = t.width, c = t.dataPosition, u = new ArrayBuffer(t.width * t.height * 4 * 3), h = new Float32Array(u); s > 0; ) {
- for (a = 0; a < t.width; a++)
- i = e[c++],
- n = e[c++],
- r = e[c++],
- o = e[c++],
- this._Rgbe2float(h, i, n, r, o, (t.height - s) * l * 3 + 3 * a);
- s--
- }
- return h
- }
- ,
- e
- }()
- , y_ = function() {
- function e(t, i) {
- var n;
- void 0 === i && (i = e._DefaultOptions);
- var r = this;
- this._engine = t,
- this._fullscreenViewport = new xr(0,0,1,1),
- i = V(V({}, e._DefaultOptions), i),
- this._vertexBuffers = ((n = {})[Bi.PositionKind] = new Bi(t,i.positions,Bi.PositionKind,!1,!1,2),
- n),
- this._indexBuffer = t.createIndexBuffer(i.indices),
- this._onContextRestoredObserver = t.onContextRestoredObservable.add((function() {
- for (var e in r._indexBuffer = t.createIndexBuffer(i.indices),
- r._vertexBuffers)
- r._vertexBuffers[e]._rebuild()
- }
- ))
- }
- return e.prototype.setViewport = function(e) {
- void 0 === e && (e = this._fullscreenViewport),
- this._engine.setViewport(e)
- }
- ,
- e.prototype.bindBuffers = function(e) {
- this._engine.bindBuffers(this._vertexBuffers, this._indexBuffer, e)
- }
- ,
- e.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({})
- }
- ,
- e.prototype.restoreStates = function() {
- this._engine.depthCullingState.depthTest = !0,
- this._engine.stencilState.stencilTest = !0
- }
- ,
- e.prototype.draw = function() {
- this._engine.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6)
- }
- ,
- e.prototype._isRenderTargetTexture = function(e) {
- return void 0 !== e.renderTarget
- }
- ,
- e.prototype.render = function(e, t) {
- if (void 0 === t && (t = null),
- e.effect.isReady()) {
- this.setViewport();
- var i = null === t ? null : this._isRenderTargetTexture(t) ? t.renderTarget : t;
- i && this._engine.bindFramebuffer(i),
- this.applyEffectWrapper(e),
- this.draw(),
- i && this._engine.unBindFramebuffer(i),
- this.restoreStates()
- }
- }
- ,
- e.prototype.dispose = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && (e.dispose(),
- delete this._vertexBuffers[Bi.PositionKind]),
- this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
- this._onContextRestoredObserver && (this._engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null)
- }
- ,
- e._DefaultOptions = {
- positions: [1, 1, -1, 1, -1, -1, 1, -1],
- indices: [0, 1, 2, 0, 2, 3]
- },
- e
- }()
- , b_ = function() {
- function e(e) {
- var t, i = this;
- this.onApplyObservable = new h;
- var n = e.uniformNames || [];
- e.vertexShader ? t = {
- fragmentSource: e.fragmentShader,
- vertexSource: e.vertexShader,
- spectorName: e.name || "effectWrapper"
- } : (n.push("scale"),
- t = {
- fragmentSource: e.fragmentShader,
- vertex: "postprocess",
- spectorName: e.name || "effectWrapper"
- },
- this.onApplyObservable.add((function() {
- i.effect.setFloat2("scale", 1, 1)
- }
- )));
- var r = e.defines ? e.defines.join("\n") : "";
- this._drawWrapper = new Gt(e.engine),
- e.useShaderStore ? (t.fragment = t.fragmentSource,
- t.vertex || (t.vertex = t.vertexSource),
- delete t.fragmentSource,
- delete t.vertexSource,
- this.effect = e.engine.createEffect(t, e.attributeNames || ["position"], n, e.samplerNames, r, void 0, e.onCompiled, void 0, void 0, e.shaderLanguage)) : (this.effect = new Mt(t,e.attributeNames || ["position"],n,e.samplerNames,e.engine,r,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(e.prototype, "effect", {
- get: function() {
- return this._drawWrapper.effect
- },
- set: function(e) {
- this._drawWrapper.effect = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this._onContextRestoredObserver && (this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null),
- this.effect.dispose()
- }
- ,
- e
- }();
- Pt.ShadersStore.hdrFilteringVertexShader = "attribute vec2 position;\nvarying vec3 direction;\nuniform vec3 up;\nuniform vec3 right;\nuniform vec3 front;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nmat3 view=mat3(up,right,front);\ndirection=view*vec3(position,1.0);\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- Pt.ShadersStore.hdrFilteringPixelShader = "#include<helperFunctions>\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nuniform float alphaG;\nuniform samplerCube inputTexture;\nuniform vec2 vFilteringInfo;\nuniform float hdrScale;\nvarying vec3 direction;\nvoid main() {\nvec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);\ngl_FragColor=vec4(color*hdrScale,1.0);\n}";
- var T_ = function() {
- function e(e, t) {
- void 0 === t && (t = {}),
- this._lodGenerationOffset = 0,
- this._lodGenerationScale = .8,
- this.quality = a.TEXTURE_FILTERING_QUALITY_OFFLINE,
- this.hdrScale = 1,
- this._engine = e,
- this.hdrScale = t.hdrScale || this.hdrScale,
- this.quality = t.hdrScale || this.quality
- }
- return e.prototype._createRenderTarget = function(e) {
- var t = a.TEXTURETYPE_UNSIGNED_BYTE;
- this._engine.getCaps().textureHalfFloatRender ? t = a.TEXTURETYPE_HALF_FLOAT : this._engine.getCaps().textureFloatRender && (t = a.TEXTURETYPE_FLOAT);
- var i = this._engine.createRenderTargetCubeTexture(e, {
- format: a.TEXTUREFORMAT_RGBA,
- type: t,
- createMipMaps: !0,
- generateMipMaps: !1,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE
- });
- return this._engine.updateTextureWrappingMode(i.texture, a.TEXTURE_CLAMP_ADDRESSMODE, a.TEXTURE_CLAMP_ADDRESSMODE, a.TEXTURE_CLAMP_ADDRESSMODE),
- this._engine.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, i.texture, !0),
- i
- }
- ,
- e.prototype._prefilterInternal = function(e) {
- var t = e.getSize().width
- , i = d.ILog2(t) + 1
- , n = this._effectWrapper.effect
- , r = this._createRenderTarget(t);
- this._effectRenderer.setViewport();
- var o = e.getInternalTexture();
- o && this._engine.updateTextureSamplingMode(a.TEXTURE_TRILINEAR_SAMPLINGMODE, o, !0),
- this._effectRenderer.applyEffectWrapper(this._effectWrapper);
- var s = [[new x(0,0,-1), new x(0,-1,0), new x(1,0,0)], [new x(0,0,1), new x(0,-1,0), new x(-1,0,0)], [new x(1,0,0), new x(0,0,1), new x(0,1,0)], [new x(1,0,0), new x(0,0,-1), new x(0,-1,0)], [new x(1,0,0), new x(0,-1,0), new x(0,0,1)], [new x(-1,0,0), new x(0,-1,0), new x(0,0,-1)]];
- n.setFloat("hdrScale", this.hdrScale),
- n.setFloat2("vFilteringInfo", e.getSize().width, i),
- n.setTexture("inputTexture", e);
- for (var l = 0; l < 6; l++) {
- n.setVector3("up", s[l][0]),
- n.setVector3("right", s[l][1]),
- n.setVector3("front", s[l][2]);
- for (var c = 0; c < i; c++) {
- this._engine.bindFramebuffer(r, l, void 0, void 0, !0, c),
- this._effectRenderer.applyEffectWrapper(this._effectWrapper);
- var u = Math.pow(2, (c - this._lodGenerationOffset) / this._lodGenerationScale) / t;
- 0 === c && (u = 0),
- n.setFloat("alphaG", u),
- this._effectRenderer.draw()
- }
- }
- return this._effectRenderer.restoreStates(),
- this._engine.restoreDefaultFramebuffer(),
- this._engine._releaseTexture(e._texture),
- r._swapAndDie(e._texture),
- e._prefiltered = !0,
- e
- }
- ,
- e.prototype._createEffect = function(e, t) {
- var i = [];
- return e.gammaSpace && i.push("#define GAMMA_INPUT"),
- i.push("#define NUM_SAMPLES " + this.quality + "u"),
- new b_({
- engine: this._engine,
- name: "hdrFiltering",
- vertexShader: "hdrFiltering",
- fragmentShader: "hdrFiltering",
- samplerNames: ["inputTexture"],
- uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"],
- useShaderStore: !0,
- defines: i,
- onCompiled: t
- })
- }
- ,
- e.prototype.isReady = function(e) {
- return e.isReady() && this._effectWrapper.effect.isReady()
- }
- ,
- e.prototype.prefilter = function(e, t) {
- var i = this;
- return void 0 === t && (t = null),
- this._engine._features.allowTexturePrefiltering ? new Promise((function(n) {
- i._effectRenderer = new y_(i._engine),
- i._effectWrapper = i._createEffect(e),
- i._effectWrapper.effect.executeWhenCompiled((function() {
- i._prefilterInternal(e),
- i._effectRenderer.dispose(),
- i._effectWrapper.dispose(),
- n(),
- t && t()
- }
- ))
- }
- )) : (K.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."))
- }
- ,
- e
- }()
- , E_ = function(e) {
- function t(t, i, n, r, o, s, l, c, u) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !0),
- void 0 === s && (s = !1),
- void 0 === l && (l = !1),
- void 0 === c && (c = null),
- void 0 === u && (u = null);
- var d, p = this;
- return (p = e.call(this, i) || this)._generateHarmonics = !0,
- p._onError = null,
- p._isBlocking = !0,
- p._rotationY = 0,
- p.boundingBoxPosition = x.Zero(),
- p.onLoadObservable = new h,
- t ? (p._coordinatesMode = io.CUBIC_MODE,
- p.name = t,
- p.url = t,
- p.hasAlpha = !1,
- p.isCube = !0,
- p._textureMatrix = P.Identity(),
- p._prefilterOnLoad = l,
- p._onLoad = function() {
- p.onLoadObservable.notifyObservers(p),
- c && c()
- }
- ,
- p._onError = u,
- p.gammaSpace = s,
- p._noMipmap = r,
- p._size = n,
- p._generateHarmonics = o,
- p._texture = p._getFromCache(t, p._noMipmap),
- p._texture ? p._texture.isReady ? gi.SetImmediate((function() {
- return p._onLoad()
- }
- )) : p._texture.onLoadedObservable.add(p._onLoad) : (null === (d = p.getScene()) || void 0 === d ? void 0 : d.useDelayedTextureLoading) ? p.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : p._loadTexture(),
- p) : p
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "isBlocking", {
- get: function() {
- return this._isBlocking
- },
- set: function(e) {
- this._isBlocking = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationY", {
- get: function() {
- return this._rotationY
- },
- set: function(e) {
- this._rotationY = e,
- this.setReflectionTextureMatrix(P.RotationY(this._rotationY))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "boundingBoxSize", {
- get: function() {
- return this._boundingBoxSize
- },
- set: function(e) {
- if (!this._boundingBoxSize || !this._boundingBoxSize.equals(e)) {
- this._boundingBoxSize = e;
- var t = this.getScene();
- t && t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "HDRCubeTexture"
- }
- ,
- t.prototype._loadTexture = function() {
- var e = this
- , i = this._getEngine()
- , n = i.getCaps()
- , r = a.TEXTURETYPE_UNSIGNED_BYTE;
- if (n.textureFloat && n.textureFloatLinearFiltering ? r = a.TEXTURETYPE_FLOAT : n.textureHalfFloat && n.textureHalfFloatLinearFiltering && (r = a.TEXTURETYPE_HALF_FLOAT),
- i._features.allowTexturePrefiltering && this._prefilterOnLoad) {
- var o = this._onLoad
- , s = new T_(i);
- this._onLoad = function() {
- s.prefilter(e, o)
- }
- }
- this._texture = i.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, a.TEXTUREFORMAT_RGB, r, this._noMipmap, (function(i) {
- e.lodGenerationOffset = 0,
- e.lodGenerationScale = .8;
- var n = v_.GetCubeMapTextureData(i, e._size);
- if (e._generateHarmonics) {
- var o = wc.ConvertCubeMapToSphericalPolynomial(n);
- e.sphericalPolynomial = o
- }
- for (var s = [], l = null, c = null, u = 0; u < 6; u++) {
- r === a.TEXTURETYPE_HALF_FLOAT ? c = new Uint16Array(e._size * e._size * 3) : r === a.TEXTURETYPE_UNSIGNED_BYTE && (l = new Uint8Array(e._size * e._size * 3));
- var h = n[t._FacesMapping[u]];
- if (e.gammaSpace || c || l)
- for (var d = 0; d < e._size * e._size; d++)
- if (e.gammaSpace && (h[3 * d + 0] = Math.pow(h[3 * d + 0], p),
- h[3 * d + 1] = Math.pow(h[3 * d + 1], p),
- h[3 * d + 2] = Math.pow(h[3 * d + 2], p)),
- c && (c[3 * d + 0] = Oc(h[3 * d + 0]),
- c[3 * d + 1] = Oc(h[3 * d + 1]),
- c[3 * d + 2] = Oc(h[3 * d + 2])),
- l) {
- var f = Math.max(255 * h[3 * d + 0], 0)
- , _ = Math.max(255 * h[3 * d + 1], 0)
- , m = Math.max(255 * h[3 * d + 2], 0)
- , g = Math.max(Math.max(f, _), m);
- if (g > 255) {
- var v = 255 / g;
- f *= v,
- _ *= v,
- m *= v
- }
- l[3 * d + 0] = f,
- l[3 * d + 1] = _,
- l[3 * d + 2] = m
- }
- c ? s.push(c) : l ? s.push(l) : s.push(h)
- }
- return s
- }
- ), null, this._onLoad, this._onError)
- }
- ,
- t.prototype.clone = function() {
- var e = new t(this.url,this.getScene() || this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);
- return e.level = this.level,
- e.wrapU = this.wrapU,
- e.wrapV = this.wrapV,
- e.coordinatesIndex = this.coordinatesIndex,
- e.coordinatesMode = this.coordinatesMode,
- e
- }
- ,
- t.prototype.delayLoad = function() {
- this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = a.DELAYLOADSTATE_LOADED,
- this._texture = this._getFromCache(this.url, this._noMipmap),
- this._texture || this._loadTexture())
- }
- ,
- t.prototype.getReflectionTextureMatrix = function() {
- return this._textureMatrix
- }
- ,
- t.prototype.setReflectionTextureMatrix = function(e) {
- var t, i = this;
- this._textureMatrix = e,
- e.updateFlag !== this._textureMatrix.updateFlag && e.isIdentity() !== this._textureMatrix.isIdentity() && (null === (t = this.getScene()) || void 0 === t || t.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return -1 !== e.getActiveTextures().indexOf(i)
- }
- )))
- }
- ,
- t.prototype.dispose = function() {
- this.onLoadObservable.clear(),
- e.prototype.dispose.call(this)
- }
- ,
- t.Parse = function(e, i, n) {
- var r = null;
- return e.name && !e.isRenderTarget && ((r = new t(n + e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name = e.name,
- r.hasAlpha = e.hasAlpha,
- r.level = e.level,
- r.coordinatesMode = e.coordinatesMode,
- r.isBlocking = e.isBlocking),
- r && (e.boundingBoxPosition && (r.boundingBoxPosition = x.FromArray(e.boundingBoxPosition)),
- e.boundingBoxSize && (r.boundingBoxSize = x.FromArray(e.boundingBoxSize)),
- e.rotationY && (r.rotationY = e.rotationY)),
- r
- }
- ,
- t.prototype.serialize = function() {
- if (!this.name)
- return null;
- var e = {};
- return e.name = this.name,
- e.hasAlpha = this.hasAlpha,
- e.isCube = !0,
- e.level = this.level,
- e.size = this._size,
- e.coordinatesMode = this.coordinatesMode,
- e.useInGammaSpace = this.gammaSpace,
- e.generateHarmonics = this._generateHarmonics,
- e.customType = "BABYLON.HDRCubeTexture",
- e.noMipmap = this._noMipmap,
- e.isBlocking = this._isBlocking,
- e.rotationY = this._rotationY,
- e
- }
- ,
- t._FacesMapping = ["right", "left", "up", "down", "front", "back"],
- t
- }(Zr);
- y("BABYLON.HDRCubeTexture", E_);
- var S_ = function() {
- function e(e, t, i) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 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 h,
- this._onDataLayoutChanged = new h,
- this._animationPropertiesOverride = null,
- this._scene = i || E.LastCreatedScene,
- this.influence = t,
- this._scene && (this._uniqueId = this._scene.getUniqueId())
- }
- return Object.defineProperty(e.prototype, "influence", {
- get: function() {
- return this._influence
- },
- set: function(e) {
- if (this._influence !== e) {
- var t = this._influence;
- this._influence = e,
- this.onInfluenceChanged.hasObservers() && this.onInfluenceChanged.notifyObservers(0 === t || 0 === e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.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(e.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasPositions", {
- get: function() {
- return !!this._positions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasNormals", {
- get: function() {
- return !!this._normals
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasTangents", {
- get: function() {
- return !!this._tangents
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasUVs", {
- get: function() {
- return !!this._uvs
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setPositions = function(e) {
- var t = this.hasPositions;
- this._positions = e,
- t !== this.hasPositions && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- e.prototype.getPositions = function() {
- return this._positions
- }
- ,
- e.prototype.setNormals = function(e) {
- var t = this.hasNormals;
- this._normals = e,
- t !== this.hasNormals && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- e.prototype.getNormals = function() {
- return this._normals
- }
- ,
- e.prototype.setTangents = function(e) {
- var t = this.hasTangents;
- this._tangents = e,
- t !== this.hasTangents && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- e.prototype.getTangents = function() {
- return this._tangents
- }
- ,
- e.prototype.setUVs = function(e) {
- var t = this.hasUVs;
- this._uvs = e,
- t !== this.hasUVs && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- e.prototype.getUVs = function() {
- return this._uvs
- }
- ,
- e.prototype.clone = function() {
- var t = this
- , i = Ge.Clone((function() {
- return new e(t.name,t.influence,t._scene)
- }
- ), this);
- return i._positions = this._positions,
- i._normals = this._normals,
- i._tangents = this._tangents,
- i._uvs = this._uvs,
- i
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- return e.name = this.name,
- e.influence = this.influence,
- e.positions = Array.prototype.slice.call(this.getPositions()),
- null != this.id && (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())),
- Ge.AppendSerializedAnimations(this, e),
- e
- }
- ,
- e.prototype.getClassName = function() {
- return "MorphTarget"
- }
- ,
- e.Parse = function(t, i) {
- var n = new e(t.name,t.influence);
- if (n.setPositions(t.positions),
- null != t.id && (n.id = t.id),
- t.normals && n.setNormals(t.normals),
- t.tangents && n.setTangents(t.tangents),
- t.uvs && n.setUVs(t.uvs),
- t.animations) {
- for (var r = 0; r < t.animations.length; r++) {
- var o = t.animations[r]
- , a = b("BABYLON.Animation");
- a && n.animations.push(a.Parse(o))
- }
- t.autoAnimate && i && i.beginAnimation(n, t.autoAnimateFrom, t.autoAnimateTo, t.autoAnimateLoop, t.autoAnimateSpeed || 1)
- }
- return n
- }
- ,
- e.FromMesh = function(t, i, n) {
- i || (i = t.name);
- var r = new e(i,n,t.getScene());
- return r.setPositions(t.getVerticesData(Bi.PositionKind)),
- t.isVerticesDataPresent(Bi.NormalKind) && r.setNormals(t.getVerticesData(Bi.NormalKind)),
- t.isVerticesDataPresent(Bi.TangentKind) && r.setTangents(t.getVerticesData(Bi.TangentKind)),
- t.isVerticesDataPresent(Bi.UVKind) && r.setUVs(t.getVerticesData(Bi.UVKind)),
- r
- }
- ,
- k([Ce()], e.prototype, "id", void 0),
- e
- }()
- , A_ = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h) {
- void 0 === l && (l = !0),
- void 0 === c && (c = !1),
- void 0 === u && (u = io.TRILINEAR_SAMPLINGMODE),
- void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
- var d = e.call(this, null, s, !l, c) || this;
- return d.format = o,
- d._texture = s.getEngine().createRawTexture2DArray(t, i, n, r, o, l, c, u, null, h),
- d._depth = r,
- d.is2DArray = !0,
- d
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "depth", {
- get: function() {
- return this._depth
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.update = function(e) {
- this._texture && this._getEngine().updateRawTexture2DArray(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
- }
- ,
- t.CreateRGBATexture = function(e, i, n, r, o, s, l, c, u) {
- return void 0 === s && (s = !0),
- void 0 === l && (l = !1),
- void 0 === c && (c = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- new t(e,i,n,r,a.TEXTUREFORMAT_RGBA,o,s,l,c,u)
- }
- ,
- t
- }(io)
- , x_ = function() {
- function e(e) {
- if (void 0 === e && (e = null),
- this._targets = new Array,
- this._targetInfluenceChangedObservers = new Array,
- this._targetDataLayoutChangedObservers = new Array,
- this._activeTargets = new bi(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 = E.LastCreatedScene),
- this._scene = e,
- this._scene) {
- this._scene.morphTargetManagers.push(this),
- this._uniqueId = this._scene.getUniqueId();
- var t = this._scene.getEngine().getCaps();
- this._canUseTextureForTargets = t.canUseGLVertexID && t.textureFloat && t.maxVertexTextureImageUnits > 0
- }
- }
- return Object.defineProperty(e.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(e.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vertexCount", {
- get: function() {
- return this._vertexCount
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportsNormals", {
- get: function() {
- return this._supportsNormals && this.enableNormalMorphing
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportsTangents", {
- get: function() {
- return this._supportsTangents && this.enableTangentMorphing
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportsUVs", {
- get: function() {
- return this._supportsUVs && this.enableUVMorphing
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "numTargets", {
- get: function() {
- return this._targets.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "numInfluencers", {
- get: function() {
- return this._activeTargets.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "influences", {
- get: function() {
- return this._influences
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useTextureToStoreTargets", {
- get: function() {
- return this._useTextureToStoreTargets
- },
- set: function(e) {
- this._useTextureToStoreTargets = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isUsingTextureForTargets", {
- get: function() {
- return e.EnableTextureStorage && this.useTextureToStoreTargets && this._canUseTextureForTargets
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveTarget = function(e) {
- return this._activeTargets.data[e]
- }
- ,
- e.prototype.getTarget = function(e) {
- return this._targets[e]
- }
- ,
- e.prototype.addTarget = function(e) {
- var t = this;
- this._targets.push(e),
- this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add((function(e) {
- t._syncActiveTargets(e)
- }
- ))),
- this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add((function() {
- t._syncActiveTargets(!0)
- }
- ))),
- this._syncActiveTargets(!0)
- }
- ,
- e.prototype.removeTarget = function(e) {
- var t = this._targets.indexOf(e);
- t >= 0 && (this._targets.splice(t, 1),
- e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t, 1)[0]),
- e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t, 1)[0]),
- this._syncActiveTargets(!0))
- }
- ,
- e.prototype._bind = function(e) {
- e.setFloat3("morphTargetTextureInfo", this._textureVertexStride, this._textureWidth, this._textureHeight),
- e.setFloatArray("morphTargetTextureIndices", this._morphTargetTextureIndices),
- e.setTexture("morphTargets", this._targetStoreTexture)
- }
- ,
- e.prototype.clone = function() {
- for (var t = new e(this._scene), i = 0, n = this._targets; i < n.length; i++) {
- var r = n[i];
- t.addTarget(r.clone())
- }
- return t.enableNormalMorphing = this.enableNormalMorphing,
- t.enableTangentMorphing = this.enableTangentMorphing,
- t.enableUVMorphing = this.enableUVMorphing,
- t
- }
- ,
- e.prototype.serialize = function() {
- var e = {};
- e.id = this.uniqueId,
- e.targets = [];
- for (var t = 0, i = this._targets; t < i.length; t++) {
- var n = i[t];
- e.targets.push(n.serialize())
- }
- return e
- }
- ,
- e.prototype._syncActiveTargets = function(e) {
- if (!this.areUpdatesFrozen) {
- var t = 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 i = -1, n = 0, r = this._targets; n < r.length; n++) {
- var o = r[n];
- if (i++,
- 0 !== o.influence || !this.optimizeInfluencers) {
- this._activeTargets.push(o),
- this._morphTargetTextureIndices[t] = i,
- this._tempInfluences[t++] = o.influence,
- this._supportsNormals = this._supportsNormals && o.hasNormals,
- this._supportsTangents = this._supportsTangents && o.hasTangents,
- this._supportsUVs = this._supportsUVs && o.hasUVs;
- var a = o.getPositions();
- if (a) {
- var s = a.length / 3;
- if (0 === this._vertexCount)
- this._vertexCount = s;
- else if (this._vertexCount !== s)
- return void K.Error("Incompatible target. Targets must all have the same vertices count.")
- }
- }
- }
- this._influences && this._influences.length === t || (this._influences = new Float32Array(t));
- for (var l = 0; l < t; l++)
- this._influences[l] = this._tempInfluences[l];
- e && this.synchronize()
- }
- }
- ,
- e.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 t = !0;
- if (this._targetStoreTexture) {
- var i = this._targetStoreTexture.getSize();
- i.width === this._textureWidth && i.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length && (t = !1)
- }
- if (t) {
- this._targetStoreTexture && this._targetStoreTexture.dispose();
- for (var n = this._targets.length, r = new Float32Array(n * this._textureWidth * this._textureHeight * 4), o = 0, s = 0; s < n; s++) {
- var l = this._targets[s]
- , c = l.getPositions()
- , u = l.getNormals()
- , h = l.getUVs()
- , d = l.getTangents();
- if (!c)
- return void (0 === s && K.Error("Invalid morph target. Target must have positions."));
- o = s * this._textureWidth * this._textureHeight * 4;
- for (var p = 0; p < this._vertexCount; p++)
- r[o] = c[3 * p],
- r[o + 1] = c[3 * p + 1],
- r[o + 2] = c[3 * p + 2],
- o += 4,
- u && (r[o] = u[3 * p],
- r[o + 1] = u[3 * p + 1],
- r[o + 2] = u[3 * p + 2],
- o += 4),
- h && (r[o] = h[2 * p],
- r[o + 1] = h[2 * p + 1],
- o += 4),
- d && (r[o] = d[3 * p],
- r[o + 1] = d[3 * p + 1],
- r[o + 2] = d[3 * p + 2],
- o += 4)
- }
- this._targetStoreTexture = A_.CreateRGBATexture(r, this._textureWidth, this._textureHeight, n, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE, a.TEXTURETYPE_FLOAT)
- }
- }
- for (var f = 0, _ = this._scene.meshes; f < _.length; f++) {
- var m = _[f];
- m.morphTargetManager === this && m._syncGeometryWithMorphTargetManager()
- }
- }
- }
- ,
- e.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
- }
- }
- ,
- e.Parse = function(t, i) {
- var n = new e(i);
- n._uniqueId = t.id;
- for (var r = 0, o = t.targets; r < o.length; r++) {
- var a = o[r];
- n.addTarget(S_.Parse(a, i))
- }
- return n
- }
- ,
- e.EnableTextureStorage = !0,
- e
- }()
- , R_ = function() {
- function e(t, i) {
- if (void 0 === i && (i = e.DefaultPluginFactory()),
- this._physicsPlugin = i,
- this._impostors = [],
- this._joints = [],
- this._subTimeStep = 0,
- this._uniqueIdCounter = 0,
- !this._physicsPlugin.isSupported())
- throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included.");
- t = t || new x(0,-9.807,0),
- this.setGravity(t),
- this.setTimeStep()
- }
- return e.DefaultPluginFactory = function() {
- throw be("CannonJSPlugin")
- }
- ,
- e.prototype.setGravity = function(e) {
- this.gravity = e,
- this._physicsPlugin.setGravity(this.gravity)
- }
- ,
- e.prototype.setTimeStep = function(e) {
- void 0 === e && (e = 1 / 60),
- this._physicsPlugin.setTimeStep(e)
- }
- ,
- e.prototype.getTimeStep = function() {
- return this._physicsPlugin.getTimeStep()
- }
- ,
- e.prototype.setSubTimeStep = function(e) {
- void 0 === e && (e = 0),
- this._subTimeStep = e
- }
- ,
- e.prototype.getSubTimeStep = function() {
- return this._subTimeStep
- }
- ,
- e.prototype.dispose = function() {
- this._impostors.forEach((function(e) {
- e.dispose()
- }
- )),
- this._physicsPlugin.dispose()
- }
- ,
- e.prototype.getPhysicsPluginName = function() {
- return this._physicsPlugin.name
- }
- ,
- e.prototype.addImpostor = function(e) {
- this._impostors.push(e),
- e.uniqueId = this._uniqueIdCounter++,
- e.parent || this._physicsPlugin.generatePhysicsBody(e)
- }
- ,
- e.prototype.removeImpostor = function(e) {
- var t = this._impostors.indexOf(e);
- t > -1 && this._impostors.splice(t, 1).length && this.getPhysicsPlugin().removePhysicsBody(e)
- }
- ,
- e.prototype.addJoint = function(e, t, i) {
- var n = {
- mainImpostor: e,
- connectedImpostor: t,
- joint: i
- };
- i.physicsPlugin = this._physicsPlugin,
- this._joints.push(n),
- this._physicsPlugin.generateJoint(n)
- }
- ,
- e.prototype.removeJoint = function(e, t, i) {
- var n = this._joints.filter((function(n) {
- return n.connectedImpostor === t && n.joint === i && n.mainImpostor === e
- }
- ));
- n.length && this._physicsPlugin.removeJoint(n[0])
- }
- ,
- e.prototype._step = function(e) {
- var t = this;
- this._impostors.forEach((function(e) {
- e.isBodyInitRequired() && t._physicsPlugin.generatePhysicsBody(e)
- }
- )),
- e > .1 ? e = .1 : e <= 0 && (e = 1 / 60),
- this._physicsPlugin.executeStep(e, this._impostors)
- }
- ,
- e.prototype.getPhysicsPlugin = function() {
- return this._physicsPlugin
- }
- ,
- e.prototype.getImpostors = function() {
- return this._impostors
- }
- ,
- e.prototype.getImpostorForPhysicsObject = function(e) {
- for (var t = 0; t < this._impostors.length; ++t)
- if (this._impostors[t].object === e)
- return this._impostors[t];
- return null
- }
- ,
- e.prototype.getImpostorWithPhysicsBody = function(e) {
- for (var t = 0; t < this._impostors.length; ++t)
- if (this._impostors[t].physicsBody === e)
- return this._impostors[t];
- return null
- }
- ,
- e.prototype.raycast = function(e, t) {
- return this._physicsPlugin.raycast(e, t)
- }
- ,
- e.Epsilon = .001,
- e
- }()
- , C_ = function() {
- function e() {
- this._hasHit = !1,
- this._hitDistance = 0,
- this._hitNormalWorld = x.Zero(),
- this._hitPointWorld = x.Zero(),
- this._rayFromWorld = x.Zero(),
- this._rayToWorld = x.Zero()
- }
- return Object.defineProperty(e.prototype, "hasHit", {
- get: function() {
- return this._hasHit
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hitDistance", {
- get: function() {
- return this._hitDistance
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hitNormalWorld", {
- get: function() {
- return this._hitNormalWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hitPointWorld", {
- get: function() {
- return this._hitPointWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rayFromWorld", {
- get: function() {
- return this._rayFromWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rayToWorld", {
- get: function() {
- return this._rayToWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setHitData = function(e, t) {
- this._hasHit = !0,
- this._hitNormalWorld = new x(e.x,e.y,e.z),
- this._hitPointWorld = new x(t.x,t.y,t.z)
- }
- ,
- e.prototype.setHitDistance = function(e) {
- this._hitDistance = e
- }
- ,
- e.prototype.calculateHitDistance = function() {
- this._hitDistance = x.Distance(this._rayFromWorld, this._hitPointWorld)
- }
- ,
- e.prototype.reset = function(e, t) {
- void 0 === e && (e = x.Zero()),
- void 0 === t && (t = x.Zero()),
- this._rayFromWorld = e,
- this._rayToWorld = t,
- this._hasHit = !1,
- this._hitDistance = 0,
- this._hitNormalWorld = x.Zero(),
- this._hitPointWorld = x.Zero()
- }
- ,
- e
- }()
- , P_ = function() {
- function e(e, t, i) {
- void 0 === e && (e = !0),
- void 0 === t && (t = 10),
- void 0 === i && (i = 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 C,
- this._minus90X = new C(-.7071067811865475,0,0,.7071067811865475),
- this._plus90X = new C(.7071067811865475,0,0,.7071067811865475),
- this._tmpPosition = x.Zero(),
- this._tmpDeltaPosition = x.Zero(),
- this._tmpUnityRotation = new C,
- this.BJSCANNON = i,
- this.isSupported() ? (this._extendNamespace(),
- this.world = new this.BJSCANNON.World,
- this.world.broadphase = new this.BJSCANNON.NaiveBroadphase,
- this.world.solver.iterations = t,
- this._cannonRaycastResult = new this.BJSCANNON.RaycastResult,
- this._raycastResult = new C_) : K.Error("CannonJS is not available. Please make sure you included the js file.")
- }
- return e.prototype.setGravity = function(e) {
- var t = e;
- this.world.gravity.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.setTimeStep = function(e) {
- this._fixedTimeStep = e
- }
- ,
- e.prototype.getTimeStep = function() {
- return this._fixedTimeStep
- }
- ,
- e.prototype.executeStep = function(e, t) {
- if (this._firstFrame) {
- this._firstFrame = !1;
- for (var i = 0, n = t; i < n.length; i++) {
- var r = n[i];
- r.type != Vl.HeightmapImpostor && r.type !== Vl.PlaneImpostor && r.beforeStep()
- }
- }
- this.world.step(this._useDeltaForWorldStep ? e : this._fixedTimeStep),
- this._removeMarkedPhysicsBodiesFromWorld()
- }
- ,
- e.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
- var e = this;
- this._physicsBodysToRemoveAfterStep.length > 0 && (this._physicsBodysToRemoveAfterStep.forEach((function(t) {
- "function" == typeof e.world.removeBody ? e.world.removeBody(t) : e.world.remove(t)
- }
- )),
- this._physicsBodysToRemoveAfterStep = [])
- }
- ,
- e.prototype.applyImpulse = function(e, t, i) {
- var n = new this.BJSCANNON.Vec3(i.x,i.y,i.z)
- , r = new this.BJSCANNON.Vec3(t.x,t.y,t.z);
- e.physicsBody.applyImpulse(r, n)
- }
- ,
- e.prototype.applyForce = function(e, t, i) {
- var n = new this.BJSCANNON.Vec3(i.x,i.y,i.z)
- , r = new this.BJSCANNON.Vec3(t.x,t.y,t.z);
- e.physicsBody.applyForce(r, n)
- }
- ,
- e.prototype.generatePhysicsBody = function(e) {
- if (this._removeMarkedPhysicsBodiesFromWorld(),
- e.parent)
- e.physicsBody && (this.removePhysicsBody(e),
- e.forceUpdate());
- else {
- if (e.isBodyInitRequired()) {
- var t = this._createShape(e);
- if (!t)
- return void K.Warn("It was not possible to create a physics body for this object.");
- var i = e.physicsBody;
- i && this.removePhysicsBody(e);
- var n = this._addMaterial("mat-" + e.uniqueId, e.getParam("friction"), e.getParam("restitution"))
- , r = {
- mass: e.getParam("mass"),
- material: n
- }
- , o = e.getParam("nativeOptions");
- for (var a in o)
- Object.prototype.hasOwnProperty.call(o, a) && (r[a] = o[a]);
- e.physicsBody = new this.BJSCANNON.Body(r),
- e.physicsBody.addEventListener("collide", e.onCollide),
- this.world.addEventListener("preStep", e.beforeStep),
- this.world.addEventListener("postStep", e.afterStep),
- e.physicsBody.addShape(t),
- "function" == typeof this.world.addBody ? this.world.addBody(e.physicsBody) : this.world.add(e.physicsBody),
- i && ["force", "torque", "velocity", "angularVelocity"].forEach((function(t) {
- var n = i[t];
- e.physicsBody[t].set(n.x, n.y, n.z)
- }
- )),
- this._processChildMeshes(e)
- }
- this._updatePhysicsBodyTransformation(e)
- }
- }
- ,
- e.prototype._processChildMeshes = function(e) {
- var t = this
- , i = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : []
- , n = e.object.rotationQuaternion;
- if (n ? n.conjugateToRef(this._tmpQuaternion) : this._tmpQuaternion.set(0, 0, 0, 1),
- i.length) {
- var r = function(i) {
- if (i.rotationQuaternion) {
- var n = i.getPhysicsImpostor();
- if (n && n.parent !== e && i.parent) {
- var o = i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition())
- , a = i.rotationQuaternion.multiply(t._tmpQuaternion);
- n.physicsBody && (t.removePhysicsBody(n),
- n.physicsBody = null),
- n.parent = e,
- n.resetUpdateFlags(),
- e.physicsBody.addShape(t._createShape(n), new t.BJSCANNON.Vec3(o.x,o.y,o.z), new t.BJSCANNON.Quaternion(a.x,a.y,a.z,a.w)),
- e.physicsBody.mass += n.getParam("mass")
- }
- i.getChildMeshes(!0).filter((function(e) {
- return !!e.physicsImpostor
- }
- )).forEach(r)
- }
- };
- i.filter((function(e) {
- return !!e.physicsImpostor
- }
- )).forEach(r)
- }
- }
- ,
- e.prototype.removePhysicsBody = function(e) {
- e.physicsBody.removeEventListener("collide", e.onCollide),
- this.world.removeEventListener("preStep", e.beforeStep),
- this.world.removeEventListener("postStep", e.afterStep),
- -1 === this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody) && this._physicsBodysToRemoveAfterStep.push(e.physicsBody)
- }
- ,
- e.prototype.generateJoint = function(e) {
- var t = e.mainImpostor.physicsBody
- , i = e.connectedImpostor.physicsBody;
- if (t && i) {
- var n, r = e.joint.jointData, o = {
- pivotA: r.mainPivot ? (new this.BJSCANNON.Vec3).set(r.mainPivot.x, r.mainPivot.y, r.mainPivot.z) : null,
- pivotB: r.connectedPivot ? (new this.BJSCANNON.Vec3).set(r.connectedPivot.x, r.connectedPivot.y, r.connectedPivot.z) : null,
- axisA: r.mainAxis ? (new this.BJSCANNON.Vec3).set(r.mainAxis.x, r.mainAxis.y, r.mainAxis.z) : null,
- axisB: r.connectedAxis ? (new this.BJSCANNON.Vec3).set(r.connectedAxis.x, r.connectedAxis.y, r.connectedAxis.z) : null,
- maxForce: r.nativeParams.maxForce,
- collideConnected: !!r.collision
- };
- switch (e.joint.type) {
- case Ll.HingeJoint:
- case Ll.Hinge2Joint:
- n = new this.BJSCANNON.HingeConstraint(t,i,o);
- break;
- case Ll.DistanceJoint:
- n = new this.BJSCANNON.DistanceConstraint(t,i,r.maxDistance || 2);
- break;
- case Ll.SpringJoint:
- var a = r;
- n = new this.BJSCANNON.Spring(t,i,{
- restLength: a.length,
- stiffness: a.stiffness,
- damping: a.damping,
- localAnchorA: o.pivotA,
- localAnchorB: o.pivotB
- });
- break;
- case Ll.LockJoint:
- n = new this.BJSCANNON.LockConstraint(t,i,o);
- break;
- case Ll.PointToPointJoint:
- case Ll.BallAndSocketJoint:
- default:
- n = new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)
- }
- n.collideConnected = !!r.collision,
- e.joint.physicsJoint = n,
- e.joint.type !== Ll.SpringJoint ? this.world.addConstraint(n) : (e.joint.jointData.forceApplicationCallback = e.joint.jointData.forceApplicationCallback || function() {
- n.applyForce()
- }
- ,
- e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))
- }
- }
- ,
- e.prototype.removeJoint = function(e) {
- e.joint.type !== Ll.SpringJoint ? this.world.removeConstraint(e.joint.physicsJoint) : e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)
- }
- ,
- e.prototype._addMaterial = function(e, t, i) {
- var n, r;
- for (n = 0; n < this._physicsMaterials.length; n++)
- if ((r = this._physicsMaterials[n]).friction === t && r.restitution === i)
- return r;
- var o = new this.BJSCANNON.Material(e);
- return o.friction = t,
- o.restitution = i,
- this._physicsMaterials.push(o),
- o
- }
- ,
- e.prototype._checkWithEpsilon = function(e) {
- return e < R_.Epsilon ? R_.Epsilon : e
- }
- ,
- e.prototype._createShape = function(e) {
- var t, i = e.object, n = e.getObjectExtendSize();
- switch (e.type) {
- case Vl.SphereImpostor:
- var r = n.x
- , o = n.y
- , a = n.z;
- t = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(r), this._checkWithEpsilon(o), this._checkWithEpsilon(a)) / 2);
- break;
- case Vl.CylinderImpostor:
- var s = e.getParam("nativeOptions");
- s || (s = {});
- var l = void 0 !== s.radiusTop ? s.radiusTop : this._checkWithEpsilon(n.x) / 2
- , c = void 0 !== s.radiusBottom ? s.radiusBottom : this._checkWithEpsilon(n.x) / 2
- , u = void 0 !== s.height ? s.height : this._checkWithEpsilon(n.y)
- , h = void 0 !== s.numSegments ? s.numSegments : 16;
- t = new this.BJSCANNON.Cylinder(l,c,u,h);
- var d = new this.BJSCANNON.Quaternion;
- d.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0), -Math.PI / 2);
- var p = new this.BJSCANNON.Vec3(0,0,0);
- t.transformAllPoints(p, d);
- break;
- case Vl.BoxImpostor:
- var f = n.scale(.5);
- t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(f.x),this._checkWithEpsilon(f.y),this._checkWithEpsilon(f.z)));
- break;
- case Vl.PlaneImpostor:
- K.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),
- t = new this.BJSCANNON.Plane;
- break;
- case Vl.MeshImpostor:
- var _ = i.getVerticesData ? i.getVerticesData(Bi.PositionKind) : []
- , m = i.getIndices ? i.getIndices() : [];
- if (!_)
- return void K.Warn("Tried to create a MeshImpostor for an object without vertices. This will fail.");
- var g = i.position.clone()
- , v = i.rotation && i.rotation.clone()
- , y = 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 b = i.computeWorldMatrix(!0)
- , T = new Array
- , E = void 0;
- for (E = 0; E < _.length; E += 3)
- x.TransformCoordinates(x.FromArray(_, E), b).toArray(T, E);
- K.Warn("MeshImpostor only collides against spheres."),
- t = new this.BJSCANNON.Trimesh(T,m),
- i.position.copyFrom(g),
- v && i.rotation && i.rotation.copyFrom(v),
- y && i.rotationQuaternion && i.rotationQuaternion.copyFrom(y);
- break;
- case Vl.HeightmapImpostor:
- var S = i.position.clone()
- , A = i.rotation && i.rotation.clone()
- , R = 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),
- t = this._createHeightmap(i),
- i.position.copyFrom(S),
- A && i.rotation && i.rotation.copyFrom(A),
- R && i.rotationQuaternion && i.rotationQuaternion.copyFrom(R),
- i.computeWorldMatrix(!0);
- break;
- case Vl.ParticleImpostor:
- t = new this.BJSCANNON.Particle;
- break;
- case Vl.NoImpostor:
- t = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))
- }
- return t
- }
- ,
- e.prototype._createHeightmap = function(e, t) {
- var i, n = e.getVerticesData(Bi.PositionKind), r = e.computeWorldMatrix(!0), o = new Array;
- for (i = 0; i < n.length; i += 3)
- x.TransformCoordinates(x.FromArray(n, i), r).toArray(o, i);
- n = o;
- for (var a = new Array, s = t || ~~(Math.sqrt(n.length / 3) - 1), l = e.getBoundingInfo(), c = Math.min(l.boundingBox.extendSizeWorld.x, l.boundingBox.extendSizeWorld.y), u = l.boundingBox.extendSizeWorld.z, h = 2 * c / s, d = 0; d < n.length; d += 3) {
- var p = Math.round(n[d + 0] / h + s / 2)
- , f = Math.round(-1 * (n[d + 1] / h - s / 2))
- , _ = -n[d + 2] + u;
- a[p] || (a[p] = []),
- a[p][f] || (a[p][f] = _),
- a[p][f] = Math.max(_, a[p][f])
- }
- for (p = 0; p <= s; ++p) {
- if (!a[p]) {
- for (var m = 1; !a[(p + m) % s]; )
- m++;
- a[p] = a[(p + m) % s].slice()
- }
- for (f = 0; f <= s; ++f)
- if (!a[p][f]) {
- m = 1;
- for (var g = void 0; void 0 === g; )
- g = a[p][(f + m++) % s];
- a[p][f] = g
- }
- }
- var v = new this.BJSCANNON.Heightfield(a,{
- elementSize: h
- });
- return v.minY = u,
- v
- }
- ,
- e.prototype._updatePhysicsBodyTransformation = function(e) {
- var t = e.object;
- if (t.computeWorldMatrix && t.computeWorldMatrix(!0),
- t.getBoundingInfo()) {
- var i = e.getObjectCenter();
- this._tmpDeltaPosition.copyFrom(t.getAbsolutePivotPoint().subtract(i)),
- this._tmpDeltaPosition.divideInPlace(e.object.scaling),
- this._tmpPosition.copyFrom(i);
- var n = t.rotationQuaternion;
- if (n) {
- if (e.type !== Vl.PlaneImpostor && e.type !== Vl.HeightmapImpostor || (n = n.multiply(this._minus90X),
- e.setDeltaRotation(this._plus90X)),
- e.type === Vl.HeightmapImpostor) {
- var r = t
- , o = r.getBoundingInfo()
- , a = r.rotationQuaternion;
- r.rotationQuaternion = this._tmpUnityRotation,
- r.computeWorldMatrix(!0);
- var s = i.clone()
- , l = r.getPivotMatrix();
- l = l ? l.clone() : P.Identity();
- var c = P.Translation(o.boundingBox.extendSizeWorld.x, 0, -o.boundingBox.extendSizeWorld.z);
- r.setPreTransformMatrix(c),
- r.computeWorldMatrix(!0);
- var u = (o = r.getBoundingInfo()).boundingBox.centerWorld.subtract(i).subtract(r.position).negate();
- this._tmpPosition.copyFromFloats(u.x, u.y - o.boundingBox.extendSizeWorld.y, u.z),
- this._tmpDeltaPosition.copyFrom(o.boundingBox.centerWorld.subtract(s)),
- this._tmpDeltaPosition.y += o.boundingBox.extendSizeWorld.y,
- r.rotationQuaternion = a,
- r.setPreTransformMatrix(l),
- r.computeWorldMatrix(!0)
- } else
- e.type === Vl.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(n.x, n.y, n.z, n.w)
- }
- }
- }
- ,
- e.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 t = e.physicsBody.quaternion;
- e.object.rotationQuaternion.set(t.x, t.y, t.z, t.w)
- }
- }
- ,
- e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
- e.physicsBody.position.set(t.x, t.y, t.z),
- e.physicsBody.quaternion.set(i.x, i.y, i.z, i.w)
- }
- ,
- e.prototype.isSupported = function() {
- return void 0 !== this.BJSCANNON
- }
- ,
- e.prototype.setLinearVelocity = function(e, t) {
- e.physicsBody.velocity.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.setAngularVelocity = function(e, t) {
- e.physicsBody.angularVelocity.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.getLinearVelocity = function(e) {
- var t = e.physicsBody.velocity;
- return t ? new x(t.x,t.y,t.z) : null
- }
- ,
- e.prototype.getAngularVelocity = function(e) {
- var t = e.physicsBody.angularVelocity;
- return t ? new x(t.x,t.y,t.z) : null
- }
- ,
- e.prototype.setBodyMass = function(e, t) {
- e.physicsBody.mass = t,
- e.physicsBody.updateMassProperties()
- }
- ,
- e.prototype.getBodyMass = function(e) {
- return e.physicsBody.mass
- }
- ,
- e.prototype.getBodyFriction = function(e) {
- return e.physicsBody.material.friction
- }
- ,
- e.prototype.setBodyFriction = function(e, t) {
- e.physicsBody.material.friction = t
- }
- ,
- e.prototype.getBodyRestitution = function(e) {
- return e.physicsBody.material.restitution
- }
- ,
- e.prototype.setBodyRestitution = function(e, t) {
- e.physicsBody.material.restitution = t
- }
- ,
- e.prototype.sleepBody = function(e) {
- e.physicsBody.sleep()
- }
- ,
- e.prototype.wakeUpBody = function(e) {
- e.physicsBody.wakeUp()
- }
- ,
- e.prototype.updateDistanceJoint = function(e, t) {
- e.physicsJoint.distance = t
- }
- ,
- e.prototype.setMotor = function(e, t, i, n) {
- n || (e.physicsJoint.enableMotor(),
- e.physicsJoint.setMotorSpeed(t),
- i && this.setLimit(e, i))
- }
- ,
- e.prototype.setLimit = function(e, t, i) {
- e.physicsJoint.motorEquation.maxForce = t,
- e.physicsJoint.motorEquation.minForce = void 0 === i ? -t : i
- }
- ,
- e.prototype.syncMeshWithImpostor = function(e, t) {
- var i = t.physicsBody;
- e.position.x = i.position.x,
- e.position.y = i.position.y,
- e.position.z = i.position.z,
- e.rotationQuaternion && (e.rotationQuaternion.x = i.quaternion.x,
- e.rotationQuaternion.y = i.quaternion.y,
- e.rotationQuaternion.z = i.quaternion.z,
- e.rotationQuaternion.w = i.quaternion.w)
- }
- ,
- e.prototype.getRadius = function(e) {
- return e.physicsBody.shapes[0].boundingSphereRadius
- }
- ,
- e.prototype.getBoxSizeToRef = function(e, t) {
- var i = e.physicsBody.shapes[0];
- t.x = 2 * i.halfExtents.x,
- t.y = 2 * i.halfExtents.y,
- t.z = 2 * i.halfExtents.z
- }
- ,
- e.prototype.dispose = function() {}
- ,
- e.prototype._extendNamespace = function() {
- var e = new this.BJSCANNON.Vec3
- , t = this.BJSCANNON;
- this.BJSCANNON.World.prototype.step = function(i, n, r) {
- if (r = r || 10,
- 0 === (n = n || 0))
- this.internalStep(i),
- this.time += i;
- else {
- var o = Math.floor((this.time + n) / i) - Math.floor(this.time / i);
- o = Math.min(o, r) || 1;
- for (var a = performance.now(), s = 0; s !== o && (this.internalStep(i),
- !(performance.now() - a > 1e3 * i)); s++)
- ;
- this.time += n;
- for (var l = this.time % i / i, c = e, u = this.bodies, h = 0; h !== u.length; h++) {
- var d = u[h];
- d.type !== t.Body.STATIC && d.sleepState !== t.Body.SLEEPING ? (d.position.vsub(d.previousPosition, c),
- c.scale(l, c),
- d.position.vadd(c, d.interpolatedPosition)) : (d.interpolatedPosition.set(d.position.x, d.position.y, d.position.z),
- d.interpolatedQuaternion.set(d.quaternion.x, d.quaternion.y, d.quaternion.z, d.quaternion.w))
- }
- }
- }
- }
- ,
- e.prototype.raycast = function(e, t) {
- return this._cannonRaycastResult.reset(),
- this.world.raycastClosest(e, t, {}, this._cannonRaycastResult),
- this._raycastResult.reset(e, t),
- 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
- }
- ,
- e
- }();
- R_.DefaultPluginFactory = function() {
- return new P_
- }
- ;
- var M_ = function() {
- function e(e, t, i) {
- void 0 === e && (e = !0),
- void 0 === i && (i = OIMO),
- this._useDeltaForWorldStep = e,
- this.name = "OimoJSPlugin",
- this._fixedTimeStep = 1 / 60,
- this._tmpImpostorsArray = [],
- this._tmpPositionVector = x.Zero(),
- this.BJSOIMO = i,
- this.world = new this.BJSOIMO.World({
- iterations: t
- }),
- this.world.clear(),
- this._raycastResult = new C_
- }
- return e.prototype.setGravity = function(e) {
- this.world.gravity.set(e.x, e.y, e.z)
- }
- ,
- e.prototype.setTimeStep = function(e) {
- this.world.timeStep = e
- }
- ,
- e.prototype.getTimeStep = function() {
- return this.world.timeStep
- }
- ,
- e.prototype.executeStep = function(e, t) {
- var i = this;
- t.forEach((function(e) {
- e.beforeStep()
- }
- )),
- this.world.timeStep = this._useDeltaForWorldStep ? e : this._fixedTimeStep,
- this.world.step(),
- t.forEach((function(e) {
- e.afterStep(),
- i._tmpImpostorsArray[e.uniqueId] = e
- }
- ));
- for (var n = this.world.contacts; null !== n; )
- if (!n.touching || n.body1.sleeping || n.body2.sleeping) {
- var r = this._tmpImpostorsArray[+n.body1.name]
- , o = this._tmpImpostorsArray[+n.body2.name];
- r && o ? (r.onCollide({
- body: o.physicsBody,
- point: null
- }),
- o.onCollide({
- body: r.physicsBody,
- point: null
- }),
- n = n.next) : n = n.next
- } else
- n = n.next
- }
- ,
- e.prototype.applyImpulse = function(e, t, i) {
- var n = e.physicsBody.mass;
- e.physicsBody.applyImpulse(i.scale(this.world.invScale), t.scale(this.world.invScale * n))
- }
- ,
- e.prototype.applyForce = function(e, t, i) {
- K.Warn("Oimo doesn't support applying force. Using impule instead."),
- this.applyImpulse(e, t, i)
- }
- ,
- e.prototype.generatePhysicsBody = function(e) {
- var t = this;
- if (e.parent)
- e.physicsBody && (this.removePhysicsBody(e),
- e.forceUpdate());
- else {
- if (e.isBodyInitRequired()) {
- var i = {
- name: e.uniqueId,
- config: [e.getParam("mass") || .001, e.getParam("friction"), e.getParam("restitution")],
- size: [],
- type: [],
- pos: [],
- posShape: [],
- rot: [],
- rotShape: [],
- move: 0 !== e.getParam("mass"),
- density: e.getParam("mass"),
- friction: e.getParam("friction"),
- restitution: e.getParam("restitution"),
- world: this.world
- }
- , n = [e];
- (a = e.object).getChildMeshes && a.getChildMeshes().forEach((function(e) {
- e.physicsImpostor && n.push(e.physicsImpostor)
- }
- ));
- var r = function(e) {
- return Math.max(e, R_.Epsilon)
- }
- , o = new C;
- n.forEach((function(n) {
- if (n.object.rotationQuaternion) {
- var a = n.object.rotationQuaternion;
- o.copyFrom(a),
- n.object.rotationQuaternion.set(0, 0, 0, 1),
- n.object.computeWorldMatrix(!0);
- var s = o.toEulerAngles()
- , l = n.getObjectExtendSize()
- , c = 57.29577951308232;
- if (n === e) {
- var u = e.getObjectCenter();
- e.object.getAbsolutePivotPoint().subtractToRef(u, t._tmpPositionVector),
- t._tmpPositionVector.divideInPlace(e.object.scaling),
- i.pos.push(u.x),
- i.pos.push(u.y),
- i.pos.push(u.z),
- i.posShape.push(0, 0, 0),
- i.rotShape.push(0, 0, 0)
- } else {
- var h = n.object.position.clone();
- i.posShape.push(h.x),
- i.posShape.push(h.y),
- i.posShape.push(h.z),
- i.rotShape.push(s.x * c, s.y * c, s.z * c)
- }
- switch (n.object.rotationQuaternion.copyFrom(o),
- n.type) {
- case Vl.ParticleImpostor:
- K.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
- case Vl.SphereImpostor:
- var d = l.x
- , p = l.y
- , f = l.z
- , _ = Math.max(r(d), r(p), r(f)) / 2;
- i.type.push("sphere"),
- i.size.push(_),
- i.size.push(_),
- i.size.push(_);
- break;
- case Vl.CylinderImpostor:
- var m = r(l.x) / 2
- , g = r(l.y);
- i.type.push("cylinder"),
- i.size.push(m),
- i.size.push(g),
- i.size.push(g);
- break;
- case Vl.PlaneImpostor:
- case Vl.BoxImpostor:
- default:
- m = r(l.x),
- g = r(l.y);
- var v = r(l.z);
- i.type.push("box"),
- i.size.push(m),
- i.size.push(g),
- i.size.push(v)
- }
- n.object.rotationQuaternion = a
- }
- }
- )),
- e.physicsBody = this.world.add(i),
- e.physicsBody.resetQuaternion(o),
- e.physicsBody.updatePosition(0)
- } else
- this._tmpPositionVector.copyFromFloats(0, 0, 0);
- var a;
- e.setDeltaPosition(this._tmpPositionVector)
- }
- }
- ,
- e.prototype.removePhysicsBody = function(e) {
- this.world.removeRigidBody(e.physicsBody)
- }
- ,
- e.prototype.generateJoint = function(e) {
- var t = e.mainImpostor.physicsBody
- , i = e.connectedImpostor.physicsBody;
- if (t && i) {
- var n, r = e.joint.jointData, o = r.nativeParams || {}, a = {
- body1: t,
- body2: i,
- axe1: o.axe1 || (r.mainAxis ? r.mainAxis.asArray() : null),
- axe2: o.axe2 || (r.connectedAxis ? r.connectedAxis.asArray() : null),
- pos1: o.pos1 || (r.mainPivot ? r.mainPivot.asArray() : null),
- pos2: o.pos2 || (r.connectedPivot ? r.connectedPivot.asArray() : null),
- min: o.min,
- max: o.max,
- collision: o.collision || r.collision,
- spring: o.spring,
- world: this.world
- };
- switch (e.joint.type) {
- case Ll.BallAndSocketJoint:
- n = "jointBall";
- break;
- case Ll.SpringJoint:
- K.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
- var s = r;
- a.min = s.length || a.min,
- a.max = Math.max(a.min, a.max);
- case Ll.DistanceJoint:
- n = "jointDistance",
- a.max = r.maxDistance;
- break;
- case Ll.PrismaticJoint:
- n = "jointPrisme";
- break;
- case Ll.SliderJoint:
- n = "jointSlide";
- break;
- case Ll.WheelJoint:
- n = "jointWheel";
- break;
- case Ll.HingeJoint:
- default:
- n = "jointHinge"
- }
- a.type = n,
- e.joint.physicsJoint = this.world.add(a)
- }
- }
- ,
- e.prototype.removeJoint = function(e) {
- try {
- this.world.removeJoint(e.joint.physicsJoint)
- } catch (e) {
- K.Warn(e)
- }
- }
- ,
- e.prototype.isSupported = function() {
- return void 0 !== this.BJSOIMO
- }
- ,
- e.prototype.setTransformationFromPhysicsBody = function(e) {
- if (!e.physicsBody.sleeping) {
- if (e.physicsBody.shapes.next) {
- for (var t = e.physicsBody.shapes; t.next; )
- t = t.next;
- e.object.position.set(t.position.x, t.position.y, t.position.z)
- } else {
- var i = e.physicsBody.getPosition();
- e.object.position.set(i.x, i.y, i.z)
- }
- if (e.object.rotationQuaternion) {
- var n = e.physicsBody.getQuaternion();
- e.object.rotationQuaternion.set(n.x, n.y, n.z, n.w)
- }
- }
- }
- ,
- e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
- var n = e.physicsBody;
- e.physicsBody.shapes.next || (n.position.set(t.x, t.y, t.z),
- n.orientation.set(i.x, i.y, i.z, i.w),
- n.syncShapes(),
- n.awake())
- }
- ,
- e.prototype.setLinearVelocity = function(e, t) {
- e.physicsBody.linearVelocity.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.setAngularVelocity = function(e, t) {
- e.physicsBody.angularVelocity.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.getLinearVelocity = function(e) {
- var t = e.physicsBody.linearVelocity;
- return t ? new x(t.x,t.y,t.z) : null
- }
- ,
- e.prototype.getAngularVelocity = function(e) {
- var t = e.physicsBody.angularVelocity;
- return t ? new x(t.x,t.y,t.z) : null
- }
- ,
- e.prototype.setBodyMass = function(e, t) {
- var i = 0 === t;
- e.physicsBody.shapes.density = i ? 1 : t,
- e.physicsBody.setupMass(i ? 2 : 1)
- }
- ,
- e.prototype.getBodyMass = function(e) {
- return e.physicsBody.shapes.density
- }
- ,
- e.prototype.getBodyFriction = function(e) {
- return e.physicsBody.shapes.friction
- }
- ,
- e.prototype.setBodyFriction = function(e, t) {
- e.physicsBody.shapes.friction = t
- }
- ,
- e.prototype.getBodyRestitution = function(e) {
- return e.physicsBody.shapes.restitution
- }
- ,
- e.prototype.setBodyRestitution = function(e, t) {
- e.physicsBody.shapes.restitution = t
- }
- ,
- e.prototype.sleepBody = function(e) {
- e.physicsBody.sleep()
- }
- ,
- e.prototype.wakeUpBody = function(e) {
- e.physicsBody.awake()
- }
- ,
- e.prototype.updateDistanceJoint = function(e, t, i) {
- e.physicsJoint.limitMotor.upperLimit = t,
- void 0 !== i && (e.physicsJoint.limitMotor.lowerLimit = i)
- }
- ,
- e.prototype.setMotor = function(e, t, i, n) {
- void 0 !== i ? K.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : i = 1e6,
- t *= -1;
- var r = n ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
- r && r.setMotor(t, i)
- }
- ,
- e.prototype.setLimit = function(e, t, i, n) {
- var r = n ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
- r && r.setLimit(t, void 0 === i ? -t : i)
- }
- ,
- e.prototype.syncMeshWithImpostor = function(e, t) {
- var i = t.physicsBody;
- e.position.x = i.position.x,
- e.position.y = i.position.y,
- e.position.z = i.position.z,
- e.rotationQuaternion && (e.rotationQuaternion.x = i.orientation.x,
- e.rotationQuaternion.y = i.orientation.y,
- e.rotationQuaternion.z = i.orientation.z,
- e.rotationQuaternion.w = i.orientation.s)
- }
- ,
- e.prototype.getRadius = function(e) {
- return e.physicsBody.shapes.radius
- }
- ,
- e.prototype.getBoxSizeToRef = function(e, t) {
- var i = e.physicsBody.shapes;
- t.x = 2 * i.halfWidth,
- t.y = 2 * i.halfHeight,
- t.z = 2 * i.halfDepth
- }
- ,
- e.prototype.dispose = function() {
- this.world.clear()
- }
- ,
- e.prototype.raycast = function(e, t) {
- return K.Warn("raycast is not currently supported by the Oimo physics plugin"),
- this._raycastResult.reset(e, t),
- this._raycastResult
- }
- ,
- e
- }()
- , I_ = function() {
- function e(e, t, i) {
- void 0 === e && (e = !0),
- void 0 === t && (t = Ammo),
- void 0 === i && (i = null);
- var n = this;
- this._useDeltaForWorldStep = e,
- this.bjsAMMO = {},
- this.name = "AmmoJSPlugin",
- this._timeStep = 1 / 60,
- this._fixedTimeStep = 1 / 60,
- this._maxSteps = 5,
- this._tmpQuaternion = new C,
- this._tmpContactCallbackResult = !1,
- this._tmpContactPoint = new x,
- this._tmpVec3 = new x,
- this._tmpMatrix = new P,
- "function" != typeof t ? (this.bjsAMMO = t,
- this.isSupported() ? (this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,
- this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),
- this._overlappingPairCache = i || 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(e) {
- var t = (e = n.bjsAMMO.wrapPointer(e, n.bjsAMMO.btManifoldPoint)).getPositionWorldOnA();
- n._tmpContactPoint.x = t.x(),
- n._tmpContactPoint.y = t.y(),
- n._tmpContactPoint.z = t.z(),
- n._tmpContactCallbackResult = !0
- }
- ,
- this._raycastResult = new C_,
- 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)) : K.Error("AmmoJS is not available. Please make sure you included the js file.")) : K.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.")
- }
- return e.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)
- }
- ,
- e.prototype.setTimeStep = function(e) {
- this._timeStep = e
- }
- ,
- e.prototype.setFixedTimeStep = function(e) {
- this._fixedTimeStep = e
- }
- ,
- e.prototype.setMaxSteps = function(e) {
- this._maxSteps = e
- }
- ,
- e.prototype.getTimeStep = function() {
- return this._timeStep
- }
- ,
- e.prototype._isImpostorInContact = function(e) {
- return this._tmpContactCallbackResult = !1,
- this.world.contactTest(e.physicsBody, this._tmpAmmoConcreteContactResultCallback),
- this._tmpContactCallbackResult
- }
- ,
- e.prototype._isImpostorPairInContact = function(e, t) {
- return this._tmpContactCallbackResult = !1,
- this.world.contactPairTest(e.physicsBody, t.physicsBody, this._tmpAmmoConcreteContactResultCallback),
- this._tmpContactCallbackResult
- }
- ,
- e.prototype._stepSimulation = function(e, t, i) {
- if (void 0 === e && (e = 1 / 60),
- void 0 === t && (t = 10),
- void 0 === i && (i = 1 / 60),
- 0 == t)
- this.world.stepSimulation(e, 0);
- else
- for (; t > 0 && e > 0; )
- e - i < i ? (this.world.stepSimulation(e, 0),
- e = 0) : (e -= i,
- this.world.stepSimulation(i, 0)),
- t--
- }
- ,
- e.prototype.executeStep = function(e, t) {
- for (var i = 0, n = t; i < n.length; i++) {
- var r = n[i];
- r.soft || r.beforeStep()
- }
- this._stepSimulation(this._useDeltaForWorldStep ? e : this._timeStep, this._maxSteps, this._fixedTimeStep);
- for (var o = 0, a = t; o < a.length; o++) {
- var s = a[o];
- if (s.soft ? this._afterSoftStep(s) : s.afterStep(),
- s._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(s))
- for (var l = 0, c = s._onPhysicsCollideCallbacks; l < c.length; l++)
- for (var u = 0, h = c[l].otherImpostors; u < h.length; u++) {
- var d = h[u];
- (s.physicsBody.isActive() || d.physicsBody.isActive()) && this._isImpostorPairInContact(s, d) && (s.onCollide({
- body: d.physicsBody,
- point: this._tmpContactPoint
- }),
- d.onCollide({
- body: s.physicsBody,
- point: this._tmpContactPoint
- }))
- }
- }
- }
- ,
- e.prototype._afterSoftStep = function(e) {
- e.type === Vl.RopeImpostor ? this._ropeStep(e) : this._softbodyOrClothStep(e)
- }
- ,
- e.prototype._ropeStep = function(e) {
- for (var t, i, n, r, o = e.physicsBody.get_m_nodes(), a = o.size(), s = new Array, l = 0; l < a; l++)
- i = (t = o.at(l).get_m_x()).x(),
- n = t.y(),
- r = t.z(),
- s.push(new x(i,n,r));
- var c = e.object
- , u = e.getParam("shape");
- e._isFromLine ? e.object = Jl("lines", {
- points: s,
- instance: c
- }) : e.object = oc("ext", {
- shape: u,
- path: s,
- instance: c
- })
- }
- ,
- e.prototype._softbodyOrClothStep = function(e) {
- var t = e.type === Vl.ClothImpostor ? 1 : -1
- , i = e.object
- , n = i.getVerticesData(Bi.PositionKind);
- n || (n = []);
- var r = i.getVerticesData(Bi.NormalKind);
- r || (r = []);
- for (var o, a, s, l, c, u, h, d, p = n.length / 3, f = e.physicsBody.get_m_nodes(), _ = 0; _ < p; _++) {
- s = (a = (o = f.at(_)).get_m_x()).x(),
- l = a.y(),
- c = a.z() * t;
- var m = o.get_m_n();
- u = m.x(),
- h = m.y(),
- d = m.z() * t,
- n[3 * _] = s,
- n[3 * _ + 1] = l,
- n[3 * _ + 2] = c,
- r[3 * _] = u,
- r[3 * _ + 1] = h,
- r[3 * _ + 2] = d
- }
- var g = new $n;
- g.positions = n,
- g.normals = r,
- g.uvs = i.getVerticesData(Bi.UVKind),
- g.colors = i.getVerticesData(Bi.ColorKind),
- i && i.getIndices && (g.indices = i.getIndices()),
- g.applyToMesh(i)
- }
- ,
- e.prototype.applyImpulse = function(e, t, i) {
- if (e.soft)
- K.Warn("Cannot be applied to a soft body");
- else {
- e.physicsBody.activate();
- var n = this._tmpAmmoVectorA
- , r = this._tmpAmmoVectorB;
- e.object && e.object.getWorldMatrix && i.subtractInPlace(e.object.getWorldMatrix().getTranslation()),
- n.setValue(i.x, i.y, i.z),
- r.setValue(t.x, t.y, t.z),
- e.physicsBody.applyImpulse(r, n)
- }
- }
- ,
- e.prototype.applyForce = function(e, t, i) {
- if (e.soft)
- K.Warn("Cannot be applied to a soft body");
- else {
- e.physicsBody.activate();
- var n = this._tmpAmmoVectorA
- , r = this._tmpAmmoVectorB;
- if (e.object && e.object.getWorldMatrix) {
- var o = e.object.getWorldMatrix().getTranslation();
- n.setValue(i.x - o.x, i.y - o.y, i.z - o.z)
- } else
- n.setValue(i.x, i.y, i.z);
- r.setValue(t.x, t.y, t.z),
- e.physicsBody.applyForce(r, n)
- }
- }
- ,
- e.prototype.generatePhysicsBody = function(t) {
- if (t._pluginData.toDispose = [],
- t.parent)
- t.physicsBody && (this.removePhysicsBody(t),
- t.forceUpdate());
- else if (t.isBodyInitRequired()) {
- var i = this._createShape(t)
- , n = t.getParam("mass");
- if (t._pluginData.mass = n,
- t.soft)
- i.get_m_cfg().set_collisions(17),
- i.get_m_cfg().set_kDP(t.getParam("damping")),
- this.bjsAMMO.castObject(i, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")),
- i.setActivationState(e._DISABLE_DEACTIVATION_FLAG),
- this.world.addSoftBody(i, 1, -1),
- t.physicsBody = i,
- t._pluginData.toDispose.push(i),
- this.setBodyPressure(t, 0),
- t.type === Vl.SoftbodyImpostor && this.setBodyPressure(t, t.getParam("pressure")),
- this.setBodyStiffness(t, t.getParam("stiffness")),
- this.setBodyVelocityIterations(t, t.getParam("velocityIterations")),
- this.setBodyPositionIterations(t, t.getParam("positionIterations"));
- else {
- var r = new this.bjsAMMO.btVector3(0,0,0)
- , o = new this.bjsAMMO.btTransform;
- t.object.computeWorldMatrix(!0),
- o.setIdentity(),
- 0 !== n && i.calculateLocalInertia(n, r),
- this._tmpAmmoVectorA.setValue(t.object.position.x, t.object.position.y, t.object.position.z),
- this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x, t.object.rotationQuaternion.y, t.object.rotationQuaternion.z, t.object.rotationQuaternion.w),
- o.setOrigin(this._tmpAmmoVectorA),
- o.setRotation(this._tmpAmmoQuaternion);
- var a = new this.bjsAMMO.btDefaultMotionState(o)
- , s = new this.bjsAMMO.btRigidBodyConstructionInfo(n,a,i,r)
- , l = new this.bjsAMMO.btRigidBody(s);
- if (0 === n && (l.setCollisionFlags(l.getCollisionFlags() | e._KINEMATIC_FLAG),
- l.setActivationState(e._DISABLE_DEACTIVATION_FLAG)),
- t.type != Vl.NoImpostor || i.getChildShape || l.setCollisionFlags(l.getCollisionFlags() | e._DISABLE_COLLISION_FLAG),
- t.type !== Vl.MeshImpostor && t.type !== Vl.NoImpostor) {
- var c = t.object.getBoundingInfo();
- this._tmpVec3.copyFrom(t.object.getAbsolutePosition()),
- this._tmpVec3.subtractInPlace(c.boundingBox.centerWorld),
- this._tmpVec3.x /= t.object.scaling.x,
- this._tmpVec3.y /= t.object.scaling.y,
- this._tmpVec3.z /= t.object.scaling.z,
- t.setDeltaPosition(this._tmpVec3)
- }
- var u = t.getParam("group")
- , h = t.getParam("mask");
- u && h ? this.world.addRigidBody(l, u, h) : this.world.addRigidBody(l),
- t.physicsBody = l,
- t._pluginData.toDispose = t._pluginData.toDispose.concat([l, s, a, o, r, i])
- }
- this.setBodyRestitution(t, t.getParam("restitution")),
- this.setBodyFriction(t, t.getParam("friction"))
- }
- }
- ,
- e.prototype.removePhysicsBody = function(e) {
- var t = this;
- this.world && (e.soft ? this.world.removeSoftBody(e.physicsBody) : this.world.removeRigidBody(e.physicsBody),
- e._pluginData && (e._pluginData.toDispose.forEach((function(e) {
- t.bjsAMMO.destroy(e)
- }
- )),
- e._pluginData.toDispose = []))
- }
- ,
- e.prototype.generateJoint = function(e) {
- var t = e.mainImpostor.physicsBody
- , i = e.connectedImpostor.physicsBody;
- if (t && i) {
- var n, r = e.joint.jointData;
- switch (r.mainPivot || (r.mainPivot = new x(0,0,0)),
- r.connectedPivot || (r.connectedPivot = new x(0,0,0)),
- e.joint.type) {
- case Ll.DistanceJoint:
- var o = r.maxDistance;
- o && (r.mainPivot = new x(0,-o / 2,0),
- r.connectedPivot = new x(0,o / 2,0)),
- n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));
- break;
- case Ll.HingeJoint:
- r.mainAxis || (r.mainAxis = new x(0,0,0)),
- r.connectedAxis || (r.connectedAxis = new x(0,0,0));
- var a = new this.bjsAMMO.btVector3(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z)
- , s = new this.bjsAMMO.btVector3(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z);
- n = new this.bjsAMMO.btHingeConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z),a,s);
- break;
- case Ll.BallAndSocketJoint:
- n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));
- break;
- default:
- K.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),
- n = new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z))
- }
- this.world.addConstraint(n, !e.joint.jointData.collision),
- e.joint.physicsJoint = n
- }
- }
- ,
- e.prototype.removeJoint = function(e) {
- this.world && this.world.removeConstraint(e.joint.physicsJoint)
- }
- ,
- e.prototype._addMeshVerts = function(e, t, i) {
- var n = this
- , r = 0;
- if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
- var o = i.getIndices();
- o || (o = []);
- var a = i.getVerticesData(Bi.PositionKind);
- a || (a = []);
- var s = void 0;
- if (t && t !== i) {
- var l;
- l = t.rotationQuaternion ? t.rotationQuaternion : t.rotation ? C.FromEulerAngles(t.rotation.x, t.rotation.y, t.rotation.z) : C.Identity(),
- P.Compose(x.One(), l, t.position).invertToRef(this._tmpMatrix),
- s = i.computeWorldMatrix(!1).multiply(this._tmpMatrix)
- } else
- P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix),
- s = this._tmpMatrix;
- for (var c = o.length / 3, u = 0; u < c; u++) {
- for (var h = [], d = 0; d < 3; d++) {
- var p = new x(a[3 * o[3 * u + d] + 0],a[3 * o[3 * u + d] + 1],a[3 * o[3 * u + d] + 2]);
- p = x.TransformCoordinates(p, s);
- var f = void 0;
- (f = 0 == d ? this._tmpAmmoVectorA : 1 == d ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(p.x, p.y, p.z),
- h.push(f)
- }
- e.addTriangle(h[0], h[1], h[2]),
- r++
- }
- i.getChildMeshes().forEach((function(i) {
- r += n._addMeshVerts(e, t, i)
- }
- ))
- }
- return r
- }
- ,
- e.prototype._softVertexData = function(e) {
- var t = e.object;
- if (t && t.getIndices && t.getWorldMatrix && t.getChildMeshes) {
- var i = t.getIndices();
- i || (i = []);
- var n = t.getVerticesData(Bi.PositionKind);
- n || (n = []);
- var r = t.getVerticesData(Bi.NormalKind);
- r || (r = []),
- t.computeWorldMatrix(!1);
- for (var o = [], a = [], s = 0; s < n.length; s += 3) {
- var l = new x(n[s],n[s + 1],n[s + 2])
- , c = new x(r[s],r[s + 1],r[s + 2]);
- l = x.TransformCoordinates(l, t.getWorldMatrix()),
- c = x.TransformNormal(c, t.getWorldMatrix()),
- o.push(l.x, l.y, l.z),
- a.push(c.x, c.y, c.z)
- }
- var u = new $n;
- return u.positions = o,
- u.normals = a,
- u.uvs = t.getVerticesData(Bi.UVKind),
- u.colors = t.getVerticesData(Bi.ColorKind),
- t && t.getIndices && (u.indices = t.getIndices()),
- u.applyToMesh(t),
- t.position = x.Zero(),
- t.rotationQuaternion = null,
- t.rotation = x.Zero(),
- t.computeWorldMatrix(!0),
- u
- }
- return $n.ExtractFromMesh(t)
- }
- ,
- e.prototype._createSoftbody = function(e) {
- var t = e.object;
- if (t && t.getIndices) {
- var i = t.getIndices();
- i || (i = []);
- var n = this._softVertexData(e)
- , r = n.positions
- , o = n.normals;
- if (null === r || null === o)
- return new this.bjsAMMO.btCompoundShape;
- for (var a = [], s = [], l = 0; l < r.length; l += 3) {
- var c = new x(r[l],r[l + 1],r[l + 2])
- , u = new x(o[l],o[l + 1],o[l + 2]);
- a.push(c.x, c.y, -c.z),
- s.push(u.x, u.y, -u.z)
- }
- var h = (new this.bjsAMMO.btSoftBodyHelpers).CreateFromTriMesh(this.world.getWorldInfo(), a, t.getIndices(), i.length / 3, !0)
- , d = r.length / 3
- , p = h.get_m_nodes()
- , f = void 0;
- for (l = 0; l < d; l++)
- (f = p.at(l).get_m_n()).setX(s[3 * l]),
- f.setY(s[3 * l + 1]),
- f.setZ(s[3 * l + 2]);
- return h
- }
- }
- ,
- e.prototype._createCloth = function(e) {
- var t = e.object;
- if (t && t.getIndices) {
- var i = t.getIndices();
- i || (i = []);
- var n = this._softVertexData(e)
- , r = n.positions
- , o = n.normals;
- if (null === r || null === o)
- return new this.bjsAMMO.btCompoundShape;
- var a = r.length
- , s = Math.sqrt(a / 3);
- e.segments = s;
- var l = s - 1;
- return this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]),
- this._tmpAmmoVectorB.setValue(r[3 * l], r[3 * l + 1], r[3 * l + 2]),
- this._tmpAmmoVectorD.setValue(r[a - 3], r[a - 2], r[a - 1]),
- this._tmpAmmoVectorC.setValue(r[a - 3 - 3 * l], r[a - 2 - 3 * l], r[a - 1 - 3 * l]),
- (new this.bjsAMMO.btSoftBodyHelpers).CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, s, s, e.getParam("fixedPoints"), !0)
- }
- }
- ,
- e.prototype._createRope = function(e) {
- var t, i, n = this._softVertexData(e), r = n.positions, o = n.normals;
- if (null === r || null === o)
- return new this.bjsAMMO.btCompoundShape;
- if (n.applyToMesh(e.object, !0),
- e._isFromLine = !0,
- 0 === o.map((function(e) {
- return e * e
- }
- )).reduce((function(e, t) {
- return e + t
- }
- )))
- i = (t = r.length) / 3 - 1,
- this._tmpAmmoVectorA.setValue(r[0], r[1], r[2]),
- this._tmpAmmoVectorB.setValue(r[t - 3], r[t - 2], r[t - 1]);
- else {
- e._isFromLine = !1;
- var a = e.getParam("path");
- if (null === e.getParam("shape"))
- return K.Warn("No shape available for extruded mesh"),
- new this.bjsAMMO.btCompoundShape;
- i = (t = a.length) - 1,
- this._tmpAmmoVectorA.setValue(a[0].x, a[0].y, a[0].z),
- this._tmpAmmoVectorB.setValue(a[t - 1].x, a[t - 1].y, a[t - 1].z)
- }
- e.segments = i;
- var s = e.getParam("fixedPoints");
- s = s > 3 ? 3 : s;
- var l = (new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, i - 1, s);
- return l.get_m_cfg().set_collisions(17),
- l
- }
- ,
- e.prototype._createCustom = function(e) {
- var t = null;
- return this.onCreateCustomShape && (t = this.onCreateCustomShape(e)),
- null == t && (t = new this.bjsAMMO.btCompoundShape),
- t
- }
- ,
- e.prototype._addHullVerts = function(e, t, i) {
- var n = this
- , r = 0;
- if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
- var o = i.getIndices();
- o || (o = []);
- var a = i.getVerticesData(Bi.PositionKind);
- a || (a = []),
- i.computeWorldMatrix(!1);
- for (var s = o.length / 3, l = 0; l < s; l++) {
- for (var c = [], u = 0; u < 3; u++) {
- var h = new x(a[3 * o[3 * l + u] + 0],a[3 * o[3 * l + u] + 1],a[3 * o[3 * l + u] + 2]);
- P.ScalingToRef(i.scaling.x, i.scaling.y, i.scaling.z, this._tmpMatrix),
- h = x.TransformCoordinates(h, this._tmpMatrix);
- var d = void 0;
- (d = 0 == u ? this._tmpAmmoVectorA : 1 == u ? this._tmpAmmoVectorB : this._tmpAmmoVectorC).setValue(h.x, h.y, h.z),
- c.push(d)
- }
- e.addPoint(c[0], !0),
- e.addPoint(c[1], !0),
- e.addPoint(c[2], !0),
- r++
- }
- i.getChildMeshes().forEach((function(i) {
- r += n._addHullVerts(e, t, i)
- }
- ))
- }
- return r
- }
- ,
- e.prototype._createShape = function(e, t) {
- var i = this;
- void 0 === t && (t = !1);
- var n, r = e.object, o = e.getObjectExtendSize();
- if (!t) {
- var a = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : [];
- n = new this.bjsAMMO.btCompoundShape;
- var s = 0;
- if (a.forEach((function(e) {
- var t = e.getPhysicsImpostor();
- if (t) {
- if (t.type == Vl.MeshImpostor)
- throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
- var r = i._createShape(t)
- , o = e.parent.getWorldMatrix().clone()
- , a = new x;
- o.decompose(a),
- i._tmpAmmoTransform.getOrigin().setValue(e.position.x * a.x, e.position.y * a.y, e.position.z * a.z),
- i._tmpAmmoQuaternion.setValue(e.rotationQuaternion.x, e.rotationQuaternion.y, e.rotationQuaternion.z, e.rotationQuaternion.w),
- i._tmpAmmoTransform.setRotation(i._tmpAmmoQuaternion),
- n.addChildShape(i._tmpAmmoTransform, r),
- t.dispose(),
- s++
- }
- }
- )),
- s > 0) {
- if (e.type != Vl.NoImpostor) {
- var l = this._createShape(e, !0);
- l && (this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0),
- this._tmpAmmoQuaternion.setValue(0, 0, 0, 1),
- this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),
- n.addChildShape(this._tmpAmmoTransform, l))
- }
- return n
- }
- this.bjsAMMO.destroy(n),
- n = null
- }
- switch (e.type) {
- case Vl.SphereImpostor:
- if (d.WithinEpsilon(o.x, o.y, 1e-4) && d.WithinEpsilon(o.x, o.z, 1e-4))
- n = new this.bjsAMMO.btSphereShape(o.x / 2);
- else {
- var c = [new this.bjsAMMO.btVector3(0,0,0)];
- (n = new this.bjsAMMO.btMultiSphereShape(c,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x / 2,o.y / 2,o.z / 2))
- }
- break;
- case Vl.CapsuleImpostor:
- var u = o.x / 2;
- n = new this.bjsAMMO.btCapsuleShape(u,o.y - 2 * u);
- break;
- case Vl.CylinderImpostor:
- this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2),
- n = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
- break;
- case Vl.PlaneImpostor:
- case Vl.BoxImpostor:
- this._tmpAmmoVectorA.setValue(o.x / 2, o.y / 2, o.z / 2),
- n = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
- break;
- case Vl.MeshImpostor:
- if (0 == e.getParam("mass")) {
- if (this.onCreateCustomMeshImpostor)
- n = this.onCreateCustomMeshImpostor(e);
- else {
- var h = new this.bjsAMMO.btTriangleMesh;
- e._pluginData.toDispose.push(h);
- var p = this._addMeshVerts(h, r, r);
- n = 0 == p ? new this.bjsAMMO.btCompoundShape : new this.bjsAMMO.btBvhTriangleMeshShape(h)
- }
- break
- }
- case Vl.ConvexHullImpostor:
- if (this.onCreateCustomConvexHullImpostor)
- n = this.onCreateCustomConvexHullImpostor(e);
- else {
- var f = new this.bjsAMMO.btConvexHullShape;
- 0 == (p = this._addHullVerts(f, r, r)) ? (e._pluginData.toDispose.push(f),
- n = new this.bjsAMMO.btCompoundShape) : n = f
- }
- break;
- case Vl.NoImpostor:
- n = new this.bjsAMMO.btSphereShape(o.x / 2);
- break;
- case Vl.CustomImpostor:
- n = this._createCustom(e);
- break;
- case Vl.SoftbodyImpostor:
- n = this._createSoftbody(e);
- break;
- case Vl.ClothImpostor:
- n = this._createCloth(e);
- break;
- case Vl.RopeImpostor:
- n = this._createRope(e);
- break;
- default:
- K.Warn("The impostor type is not currently supported by the ammo plugin.")
- }
- return n
- }
- ,
- e.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))
- }
- ,
- e.prototype.setPhysicsBodyTransformation = function(e, t, i) {
- var n = e.physicsBody.getWorldTransform();
- if (Math.abs(n.getOrigin().x() - t.x) > m || Math.abs(n.getOrigin().y() - t.y) > m || Math.abs(n.getOrigin().z() - t.z) > m || Math.abs(n.getRotation().x() - i.x) > m || Math.abs(n.getRotation().y() - i.y) > m || Math.abs(n.getRotation().z() - i.z) > m || Math.abs(n.getRotation().w() - i.w) > m)
- if (this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
- n.setOrigin(this._tmpAmmoVectorA),
- this._tmpAmmoQuaternion.setValue(i.x, i.y, i.z, i.w),
- n.setRotation(this._tmpAmmoQuaternion),
- e.physicsBody.setWorldTransform(n),
- 0 == e.mass) {
- var r = e.physicsBody.getMotionState();
- r && r.setWorldTransform(n)
- } else
- e.physicsBody.activate()
- }
- ,
- e.prototype.isSupported = function() {
- return void 0 !== this.bjsAMMO
- }
- ,
- e.prototype.setLinearVelocity = function(e, t) {
- this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
- e.soft ? e.physicsBody.linearVelocity(this._tmpAmmoVectorA) : e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)
- }
- ,
- e.prototype.setAngularVelocity = function(e, t) {
- this._tmpAmmoVectorA.setValue(t.x, t.y, t.z),
- e.soft ? e.physicsBody.angularVelocity(this._tmpAmmoVectorA) : e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)
- }
- ,
- e.prototype.getLinearVelocity = function(e) {
- var t;
- if (!(t = e.soft ? e.physicsBody.linearVelocity() : e.physicsBody.getLinearVelocity()))
- return null;
- var i = new x(t.x(),t.y(),t.z());
- return this.bjsAMMO.destroy(t),
- i
- }
- ,
- e.prototype.getAngularVelocity = function(e) {
- var t;
- if (!(t = e.soft ? e.physicsBody.angularVelocity() : e.physicsBody.getAngularVelocity()))
- return null;
- var i = new x(t.x(),t.y(),t.z());
- return this.bjsAMMO.destroy(t),
- i
- }
- ,
- e.prototype.setBodyMass = function(e, t) {
- e.soft ? e.physicsBody.setTotalMass(t, !1) : e.physicsBody.setMassProps(t),
- e._pluginData.mass = t
- }
- ,
- e.prototype.getBodyMass = function(e) {
- return e._pluginData.mass || 0
- }
- ,
- e.prototype.getBodyFriction = function(e) {
- return e._pluginData.friction || 0
- }
- ,
- e.prototype.setBodyFriction = function(e, t) {
- e.soft ? e.physicsBody.get_m_cfg().set_kDF(t) : e.physicsBody.setFriction(t),
- e._pluginData.friction = t
- }
- ,
- e.prototype.getBodyRestitution = function(e) {
- return e._pluginData.restitution || 0
- }
- ,
- e.prototype.setBodyRestitution = function(e, t) {
- e.physicsBody.setRestitution(t),
- e._pluginData.restitution = t
- }
- ,
- e.prototype.getBodyPressure = function(e) {
- return e.soft ? e._pluginData.pressure || 0 : (K.Warn("Pressure is not a property of a rigid body"),
- 0)
- }
- ,
- e.prototype.setBodyPressure = function(e, t) {
- e.soft ? e.type === Vl.SoftbodyImpostor ? (e.physicsBody.get_m_cfg().set_kPR(t),
- e._pluginData.pressure = t) : (e.physicsBody.get_m_cfg().set_kPR(0),
- e._pluginData.pressure = 0) : K.Warn("Pressure can only be applied to a softbody")
- }
- ,
- e.prototype.getBodyStiffness = function(e) {
- return e.soft ? e._pluginData.stiffness || 0 : (K.Warn("Stiffness is not a property of a rigid body"),
- 0)
- }
- ,
- e.prototype.setBodyStiffness = function(e, t) {
- e.soft ? (t = (t = t < 0 ? 0 : t) > 1 ? 1 : t,
- e.physicsBody.get_m_materials().at(0).set_m_kLST(t),
- e._pluginData.stiffness = t) : K.Warn("Stiffness cannot be applied to a rigid body")
- }
- ,
- e.prototype.getBodyVelocityIterations = function(e) {
- return e.soft ? e._pluginData.velocityIterations || 0 : (K.Warn("Velocity iterations is not a property of a rigid body"),
- 0)
- }
- ,
- e.prototype.setBodyVelocityIterations = function(e, t) {
- e.soft ? (t = t < 0 ? 0 : t,
- e.physicsBody.get_m_cfg().set_viterations(t),
- e._pluginData.velocityIterations = t) : K.Warn("Velocity iterations cannot be applied to a rigid body")
- }
- ,
- e.prototype.getBodyPositionIterations = function(e) {
- return e.soft ? e._pluginData.positionIterations || 0 : (K.Warn("Position iterations is not a property of a rigid body"),
- 0)
- }
- ,
- e.prototype.setBodyPositionIterations = function(e, t) {
- e.soft ? (t = t < 0 ? 0 : t,
- e.physicsBody.get_m_cfg().set_piterations(t),
- e._pluginData.positionIterations = t) : K.Warn("Position iterations cannot be applied to a rigid body")
- }
- ,
- e.prototype.appendAnchor = function(e, t, i, n, r, o) {
- void 0 === r && (r = 1),
- void 0 === o && (o = !1);
- var a = e.segments
- , s = Math.round((a - 1) * i) + a * (a - 1 - Math.round((a - 1) * n));
- e.physicsBody.appendAnchor(s, t.physicsBody, o, r)
- }
- ,
- e.prototype.appendHook = function(e, t, i, n, r) {
- void 0 === n && (n = 1),
- void 0 === r && (r = !1);
- var o = Math.round(e.segments * i);
- e.physicsBody.appendAnchor(o, t.physicsBody, r, n)
- }
- ,
- e.prototype.sleepBody = function(e) {
- e.physicsBody.forceActivationState(0)
- }
- ,
- e.prototype.wakeUpBody = function(e) {
- e.physicsBody.activate()
- }
- ,
- e.prototype.updateDistanceJoint = function() {
- K.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")
- }
- ,
- e.prototype.setMotor = function(e, t, i) {
- e.physicsJoint.enableAngularMotor(!0, t, i)
- }
- ,
- e.prototype.setLimit = function() {
- K.Warn("setLimit is not currently supported by the Ammo physics plugin")
- }
- ,
- e.prototype.syncMeshWithImpostor = function(e, t) {
- t.physicsBody.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())
- }
- ,
- e.prototype.getRadius = function(e) {
- return e.getObjectExtendSize().x / 2
- }
- ,
- e.prototype.getBoxSizeToRef = function(e, t) {
- var i = e.getObjectExtendSize();
- t.x = i.x,
- t.y = i.y,
- t.z = i.z
- }
- ,
- e.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
- }
- ,
- e.prototype.raycast = function(e, t) {
- this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(e.x,e.y,e.z),
- this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(t.x,t.y,t.z);
- var i = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);
- return this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, i),
- this._raycastResult.reset(e, t),
- i.hasHit() && (this._raycastResult.setHitData({
- x: i.get_m_hitNormalWorld().x(),
- y: i.get_m_hitNormalWorld().y(),
- z: i.get_m_hitNormalWorld().z()
- }, {
- x: i.get_m_hitPointWorld().x(),
- y: i.get_m_hitPointWorld().y(),
- z: i.get_m_hitPointWorld().z()
- }),
- this._raycastResult.calculateHitDistance()),
- this.bjsAMMO.destroy(i),
- this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),
- this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),
- this._raycastResult
- }
- ,
- e._DISABLE_COLLISION_FLAG = 4,
- e._KINEMATIC_FLAG = 2,
- e._DISABLE_DEACTIVATION_FLAG = 4,
- e
- }();
- o.prototype.removeReflectionProbe = function(e) {
- if (!this.reflectionProbes)
- return -1;
- var t = this.reflectionProbes.indexOf(e);
- return -1 !== t && this.reflectionProbes.splice(t, 1),
- t
- }
- ,
- o.prototype.addReflectionProbe = function(e) {
- this.reflectionProbes || (this.reflectionProbes = []),
- this.reflectionProbes.push(e)
- }
- ;
- var O_ = function() {
- function e(e, t, i, n, r, o) {
- void 0 === n && (n = !0),
- void 0 === r && (r = !1),
- void 0 === o && (o = !1);
- var s = this;
- if (this.name = e,
- this._viewMatrix = P.Identity(),
- this._target = x.Zero(),
- this._add = x.Zero(),
- this._invertYAxis = !1,
- this.position = x.Zero(),
- this._parentContainer = null,
- this._scene = i,
- i.getEngine().supportsUniformBuffers) {
- this._sceneUBOs = [];
- for (var l = 0; l < 6; ++l)
- this._sceneUBOs.push(i.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(e, '") face #').concat(l)))
- }
- this._scene.reflectionProbes || (this._scene.reflectionProbes = new Array),
- this._scene.reflectionProbes.push(this);
- var c = a.TEXTURETYPE_UNSIGNED_BYTE;
- if (r) {
- var u = this._scene.getEngine().getCaps();
- u.textureHalfFloatRender ? c = a.TEXTURETYPE_HALF_FLOAT : u.textureFloatRender && (c = a.TEXTURETYPE_FLOAT)
- }
- this._renderTargetTexture = new ns(e,t,i,n,!0,c,!0),
- this._renderTargetTexture.gammaSpace = !o;
- var h, d = i.getEngine().useReverseDepthBuffer;
- this._renderTargetTexture.onBeforeRenderObservable.add((function(e) {
- switch (s._sceneUBOs && (i.setSceneUniformBuffer(s._sceneUBOs[e]),
- i.getSceneUniformBuffer().unbindEffect()),
- e) {
- case 0:
- s._add.copyFromFloats(1, 0, 0);
- break;
- case 1:
- s._add.copyFromFloats(-1, 0, 0);
- break;
- case 2:
- s._add.copyFromFloats(0, s._invertYAxis ? 1 : -1, 0);
- break;
- case 3:
- s._add.copyFromFloats(0, s._invertYAxis ? -1 : 1, 0);
- break;
- case 4:
- s._add.copyFromFloats(0, 0, i.useRightHandedSystem ? -1 : 1);
- break;
- case 5:
- s._add.copyFromFloats(0, 0, i.useRightHandedSystem ? 1 : -1)
- }
- s._attachedMesh && s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),
- s.position.addToRef(s._add, s._target);
- var t = i.useRightHandedSystem ? P.LookAtRHToRef : P.LookAtLHToRef
- , n = i.useRightHandedSystem ? P.PerspectiveFovRH : P.PerspectiveFovLH;
- t(s.position, s._target, x.Up(), s._viewMatrix),
- i.activeCamera && (s._projectionMatrix = n(Math.PI / 2, 1, d ? i.activeCamera.maxZ : i.activeCamera.minZ, d ? i.activeCamera.minZ : i.activeCamera.maxZ, s._scene.getEngine().isNDCHalfZRange),
- i.setTransformMatrix(s._viewMatrix, s._projectionMatrix),
- i.activeCamera.isRigCamera && !s._renderTargetTexture.activeCamera && (s._renderTargetTexture.activeCamera = i.activeCamera.rigParent || null)),
- i._forcedViewPosition = s.position
- }
- )),
- this._renderTargetTexture.onBeforeBindObservable.add((function() {
- var t, n;
- s._currentSceneUBO = i.getSceneUniformBuffer(),
- null === (n = (t = i.getEngine())._debugPushGroup) || void 0 === n || n.call(t, "reflection probe generation for ".concat(e), 1),
- h = s._scene.imageProcessingConfiguration.applyByPostProcess,
- o && (i.imageProcessingConfiguration.applyByPostProcess = !0)
- }
- )),
- this._renderTargetTexture.onAfterUnbindObservable.add((function() {
- var e, t;
- i.imageProcessingConfiguration.applyByPostProcess = h,
- i._forcedViewPosition = null,
- s._sceneUBOs && i.setSceneUniformBuffer(s._currentSceneUBO),
- i.updateTransformMatrix(!0),
- null === (t = (e = i.getEngine())._debugPopGroup) || void 0 === t || t.call(e, 1)
- }
- ))
- }
- return Object.defineProperty(e.prototype, "samples", {
- get: function() {
- return this._renderTargetTexture.samples
- },
- set: function(e) {
- this._renderTargetTexture.samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "refreshRate", {
- get: function() {
- return this._renderTargetTexture.refreshRate
- },
- set: function(e) {
- this._renderTargetTexture.refreshRate = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- Object.defineProperty(e.prototype, "cubeTexture", {
- get: function() {
- return this._renderTargetTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderList", {
- get: function() {
- return this._renderTargetTexture.renderList
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attachToMesh = function(e) {
- this._attachedMesh = e
- }
- ,
- e.prototype.setRenderingAutoClearDepthStencil = function(e, t) {
- this._renderTargetTexture.setRenderingAutoClearDepthStencil(e, t)
- }
- ,
- e.prototype.dispose = function() {
- var e = this._scene.reflectionProbes.indexOf(this);
- if (-1 !== e && this._scene.reflectionProbes.splice(e, 1),
- this._parentContainer) {
- var t = this._parentContainer.reflectionProbes.indexOf(this);
- t > -1 && this._parentContainer.reflectionProbes.splice(t, 1),
- this._parentContainer = null
- }
- if (this._renderTargetTexture && (this._renderTargetTexture.dispose(),
- this._renderTargetTexture = null),
- this._sceneUBOs) {
- for (var i = 0, n = this._sceneUBOs; i < n.length; i++)
- n[i].dispose();
- this._sceneUBOs = []
- }
- }
- ,
- e.prototype.toString = function(e) {
- var t = "Name: " + this.name;
- return e && (t += ", position: " + this.position.toString(),
- this._attachedMesh && (t += ", attached mesh: " + this._attachedMesh.name)),
- t
- }
- ,
- e.prototype.getClassName = function() {
- return "ReflectionProbe"
- }
- ,
- e.prototype.serialize = function() {
- var e = Ge.Serialize(this, this._renderTargetTexture.serialize());
- return e.isReflectionProbe = !0,
- e
- }
- ,
- e.Parse = function(t, i, n) {
- var r = null;
- if (i.reflectionProbes)
- for (var o = 0; o < i.reflectionProbes.length; o++) {
- var a = i.reflectionProbes[o];
- if (a.name === t.name) {
- r = a;
- break
- }
- }
- return (r = Ge.Parse((function() {
- return r || new e(t.name,t.renderTargetSize,i,t._generateMipMaps)
- }
- ), t, i, n)).cubeTexture._waitingRenderList = t.renderList,
- t._attachedMesh && r.attachToMesh(i.getMeshById(t._attachedMesh)),
- r
- }
- ,
- k([Ne()], e.prototype, "_attachedMesh", void 0),
- k([De()], e.prototype, "position", void 0),
- e
- }()
- , D_ = !0
- , N_ = function() {
- function e() {}
- return e.LoaderInjectedPhysicsEngine = void 0,
- e
- }()
- , L_ = {}
- , F_ = {}
- , w_ = function(e, t, i, n) {
- if (!t.materials)
- return null;
- for (var r = 0, o = t.materials.length; r < o; r++) {
- var a = t.materials[r];
- if (e(a))
- return Or.Parse(a, i, n)
- }
- return null
- }
- , B_ = function(e, t) {
- return e + " of " + (t ? t.file + " from " + t.name + " version: " + t.version + ", exporter version: " + t.exporter_version : "unknown")
- }
- , U_ = function(e, t) {
- var i = t;
- if (t._waitingData.lods) {
- if (t._waitingData.lods.ids && t._waitingData.lods.ids.length > 0) {
- var n = t._waitingData.lods.ids
- , r = i.isEnabled(!1);
- if (t._waitingData.lods.distances) {
- var o = t._waitingData.lods.distances;
- if (o.length >= n.length) {
- var a = o.length > n.length ? o[o.length - 1] : 0;
- i.setEnabled(!1);
- for (var s = 0; s < n.length; s++) {
- var l = n[s]
- , c = e.getMeshById(l);
- null != c && i.addLODLevel(o[s], c)
- }
- a > 0 && i.addLODLevel(a, null),
- !0 === r && i.setEnabled(!0)
- } else
- gi.Warn("Invalid level of detail distances for " + t.name)
- }
- }
- t._waitingData.lods = null
- }
- }
- , V_ = function(e, t) {
- return "number" != typeof e ? t.getLastEntryById(e) : L_[e]
- }
- , k_ = function(e, t) {
- return "number" != typeof e ? t.getLastMaterialById(e, !0) : F_[e]
- }
- , G_ = function(e, t, i, n, r) {
- void 0 === r && (r = !1);
- var a = new zr(e)
- , s = "importScene has failed JSON parse";
- try {
- var l = JSON.parse(t);
- s = "";
- var c = od.loggingLevel === od.DETAILED_LOGGING
- , u = void 0
- , h = void 0;
- if (void 0 !== l.environmentTexture && null !== l.environmentTexture) {
- var d = void 0 === l.isPBR || l.isPBR;
- if (l.environmentTextureType && "BABYLON.HDRCubeTexture" === l.environmentTextureType) {
- var p = l.environmentTextureSize ? l.environmentTextureSize : 128
- , f = new E_((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture,e,p,!0,!d);
- l.environmentTextureRotationY && (f.rotationY = l.environmentTextureRotationY),
- e.environmentTexture = f
- } else if (oe(l.environmentTexture, ".env")) {
- var _ = new Bd((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture,e);
- l.environmentTextureRotationY && (_.rotationY = l.environmentTextureRotationY),
- e.environmentTexture = _
- } else {
- var m = Bd.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g) ? "" : i) + l.environmentTexture, e);
- l.environmentTextureRotationY && (m.rotationY = l.environmentTextureRotationY),
- e.environmentTexture = m
- }
- if (!0 === l.createDefaultSkybox) {
- var g = void 0 !== e.activeCamera && null !== e.activeCamera ? (e.activeCamera.maxZ - e.activeCamera.minZ) / 2 : 1e3
- , v = l.skyboxBlurLevel || 0;
- e.createDefaultSkybox(e.environmentTexture, d, g, v)
- }
- a.environmentTexture = e.environmentTexture
- }
- if (void 0 !== l.environmentIntensity && null !== l.environmentIntensity && (e.environmentIntensity = l.environmentIntensity),
- void 0 !== l.lights && null !== l.lights)
- for (u = 0,
- h = l.lights.length; u < h; u++) {
- var y = l.lights[u];
- (ie = Cr.Parse(y, e)) && (L_[y.uniqueId] = ie,
- a.lights.push(ie),
- ie._parentContainer = a,
- s += 0 === u ? "\n\tLights:" : "",
- s += "\n\t\t" + ie.toString(c))
- }
- if (void 0 !== l.reflectionProbes && null !== l.reflectionProbes)
- for (u = 0,
- h = l.reflectionProbes.length; u < h; u++) {
- var T = l.reflectionProbes[u]
- , E = O_.Parse(T, e, i);
- E && (a.reflectionProbes.push(E),
- E._parentContainer = a,
- s += 0 === u ? "\n\tReflection Probes:" : "",
- s += "\n\t\t" + E.toString(c))
- }
- if (void 0 !== l.animations && null !== l.animations)
- for (u = 0,
- h = l.animations.length; u < h; u++) {
- var S = l.animations[u]
- , A = b("BABYLON.Animation");
- if (A) {
- var x = A.Parse(S);
- e.animations.push(x),
- a.animations.push(x),
- s += 0 === u ? "\n\tAnimations:" : "",
- s += "\n\t\t" + x.toString(c)
- }
- }
- if (void 0 !== l.materials && null !== l.materials)
- for (u = 0,
- h = l.materials.length; u < h; u++) {
- var R = l.materials[u]
- , C = Or.Parse(R, e, i);
- C && (F_[R.uniqueId || R.id] = C,
- a.materials.push(C),
- C._parentContainer = a,
- s += 0 === u ? "\n\tMaterials:" : "",
- s += "\n\t\t" + C.toString(c),
- C.getActiveTextures().forEach((function(e) {
- -1 == a.textures.indexOf(e) && (a.textures.push(e),
- e._parentContainer = a)
- }
- )))
- }
- if (void 0 !== l.multiMaterials && null !== l.multiMaterials)
- for (u = 0,
- h = l.multiMaterials.length; u < h; u++) {
- var P = l.multiMaterials[u]
- , M = Dr.ParseMultiMaterial(P, e);
- F_[P.uniqueId || P.id] = M,
- a.multiMaterials.push(M),
- M._parentContainer = a,
- s += 0 === u ? "\n\tMultiMaterials:" : "",
- s += "\n\t\t" + M.toString(c),
- M.getActiveTextures().forEach((function(e) {
- -1 == a.textures.indexOf(e) && (a.textures.push(e),
- e._parentContainer = a)
- }
- ))
- }
- if (void 0 !== l.morphTargetManagers && null !== l.morphTargetManagers)
- for (var I = 0, O = l.morphTargetManagers; I < O.length; I++) {
- var D = O[I]
- , N = x_.Parse(D, e);
- a.morphTargetManagers.push(N),
- N._parentContainer = a
- }
- if (void 0 !== l.skeletons && null !== l.skeletons)
- for (u = 0,
- h = l.skeletons.length; u < h; u++) {
- var L = l.skeletons[u]
- , F = Fo.Parse(L, e);
- a.skeletons.push(F),
- F._parentContainer = a,
- s += 0 === u ? "\n\tSkeletons:" : "",
- s += "\n\t\t" + F.toString(c)
- }
- var w = l.geometries;
- if (null != w) {
- var B = new Array
- , U = w.vertexData;
- if (null != U)
- for (u = 0,
- h = U.length; u < h; u++) {
- var V = U[u];
- B.push(fr.Parse(V, e, i))
- }
- B.forEach((function(e) {
- e && (a.geometries.push(e),
- e._parentContainer = a)
- }
- ))
- }
- if (void 0 !== l.transformNodes && null !== l.transformNodes)
- for (u = 0,
- h = l.transformNodes.length; u < h; u++) {
- var k = l.transformNodes[u]
- , G = yr.Parse(k, e, i);
- L_[k.uniqueId] = G,
- a.transformNodes.push(G),
- G._parentContainer = a
- }
- if (void 0 !== l.meshes && null !== l.meshes)
- for (u = 0,
- h = l.meshes.length; u < h; u++) {
- var z = l.meshes[u]
- , W = Vr.Parse(z, e, i);
- if (L_[z.uniqueId] = W,
- a.meshes.push(W),
- W._parentContainer = a,
- W.hasInstances)
- for (var H = 0, X = W.instances; H < X.length; H++) {
- var j = X[H];
- a.meshes.push(j),
- j._parentContainer = a
- }
- s += 0 === u ? "\n\tMeshes:" : "",
- s += "\n\t\t" + W.toString(c)
- }
- if (void 0 !== l.cameras && null !== l.cameras)
- for (u = 0,
- h = l.cameras.length; u < h; u++) {
- var Y = l.cameras[u]
- , Q = Rr.Parse(Y, e);
- L_[Y.uniqueId] = Q,
- a.cameras.push(Q),
- Q._parentContainer = a,
- s += 0 === u ? "\n\tCameras:" : "",
- s += "\n\t\t" + Q.toString(c)
- }
- if (void 0 !== l.postProcesses && null !== l.postProcesses)
- for (u = 0,
- h = l.postProcesses.length; u < h; u++) {
- var q = l.postProcesses[u]
- , Z = Ba.Parse(q, e, i);
- Z && (a.postProcesses.push(Z),
- Z._parentContainer = a,
- s += 0 === u ? "\nPostprocesses:" : "",
- s += "\n\t\t" + Z.toString())
- }
- if (void 0 !== l.animationGroups && null !== l.animationGroups)
- for (u = 0,
- h = l.animationGroups.length; u < h; u++) {
- var J = l.animationGroups[u]
- , $ = Hn.Parse(J, e);
- a.animationGroups.push($),
- $._parentContainer = a,
- s += 0 === u ? "\n\tAnimationGroups:" : "",
- s += "\n\t\t" + $.toString(c)
- }
- for (u = 0,
- h = e.cameras.length; u < h; u++)
- null !== (Q = e.cameras[u])._waitingParentId && (Q.parent = V_(Q._waitingParentId, e),
- Q._waitingParentId = null);
- for (u = 0,
- h = e.lights.length; u < h; u++)
- (ie = e.lights[u]) && null !== ie._waitingParentId && (ie.parent = V_(ie._waitingParentId, e),
- ie._waitingParentId = null);
- for (u = 0,
- h = e.transformNodes.length; u < h; u++) {
- var ee = e.transformNodes[u];
- null !== ee._waitingParentId && (ee.parent = V_(ee._waitingParentId, e),
- ee._waitingParentId = null)
- }
- for (u = 0,
- h = e.meshes.length; u < h; u++)
- null !== (W = e.meshes[u])._waitingParentId && (W.parent = V_(W._waitingParentId, e),
- W._waitingParentId = null),
- W._waitingData.lods && U_(e, W);
- for (e.multiMaterials.forEach((function(t) {
- t._waitingSubMaterialsUniqueIds.forEach((function(i) {
- t.subMaterials.push(k_(i, e))
- }
- )),
- t._waitingSubMaterialsUniqueIds = []
- }
- )),
- e.meshes.forEach((function(t) {
- null !== t._waitingMaterialId && (t.material = k_(t._waitingMaterialId, e),
- t._waitingMaterialId = null)
- }
- )),
- u = 0,
- h = e.skeletons.length; u < h; u++)
- (F = e.skeletons[u])._hasWaitingData && (null != F.bones && F.bones.forEach((function(t) {
- if (t._waitingTransformNodeId) {
- var i = e.getLastEntryById(t._waitingTransformNodeId);
- i && t.linkTransformNode(i),
- t._waitingTransformNodeId = null
- }
- }
- )),
- F._hasWaitingData = null);
- for (u = 0,
- h = e.meshes.length; u < h; u++) {
- var te = e.meshes[u];
- te._waitingData.freezeWorldMatrix ? (te.freezeWorldMatrix(),
- te._waitingData.freezeWorldMatrix = null) : te.computeWorldMatrix(!0)
- }
- for (u = 0,
- h = e.lights.length; u < h; u++) {
- var ie;
- if ((ie = e.lights[u])._excludedMeshesIds.length > 0) {
- for (var ne = 0; ne < ie._excludedMeshesIds.length; ne++) {
- var re = e.getMeshById(ie._excludedMeshesIds[ne]);
- re && ie.excludedMeshes.push(re)
- }
- ie._excludedMeshesIds = []
- }
- if (ie._includedOnlyMeshesIds.length > 0) {
- for (var ae = 0; ae < ie._includedOnlyMeshesIds.length; ae++) {
- var se = e.getMeshById(ie._includedOnlyMeshesIds[ae]);
- se && ie.includedOnlyMeshes.push(se)
- }
- ie._includedOnlyMeshesIds = []
- }
- }
- for (o.Parse(l, e, a, i),
- u = 0,
- h = e.meshes.length; u < h; u++)
- (W = e.meshes[u])._waitingData.actions && (_e.Parse(W._waitingData.actions, W, e),
- W._waitingData.actions = null);
- void 0 !== l.actions && null !== l.actions && _e.Parse(l.actions, null, e)
- } catch (e) {
- var le = B_("loadAssets", l ? l.producer : "Unknown") + s;
- if (!n)
- throw K.Log(le),
- e;
- n(le, e)
- } finally {
- L_ = {},
- r || a.removeAllFromScene(),
- null !== s && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("loadAssets", l ? l.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? s : ""))
- }
- return a
- };
- od.RegisterPlugin({
- name: "babylon.js",
- extensions: ".babylon",
- canDirectLoad: function(e) {
- return -1 !== e.indexOf("babylon")
- },
- importMesh: function(e, t, i, n, r, a, s, l) {
- var c, u = "importMesh has failed JSON parse";
- try {
- var h = JSON.parse(i);
- u = "";
- var d = od.loggingLevel === od.DETAILED_LOGGING;
- e ? Array.isArray(e) || (e = [e]) : e = null;
- var p = new Array
- , f = [];
- if (void 0 !== h.transformNodes && null !== h.transformNodes)
- for (var _ = 0, m = h.transformNodes.length; _ < m; _++) {
- var g = h.transformNodes[_];
- f.push(yr.Parse(g, t, n))
- }
- if (void 0 !== h.meshes && null !== h.meshes) {
- var v = []
- , y = []
- , b = []
- , T = []
- , E = function(i, o) {
- var a = h.meshes[i];
- if (null === e || function(e, t, i) {
- for (var n in t)
- if (e.name === t[n])
- return i.push(e.id),
- !0;
- return void 0 !== e.parentId && -1 !== i.indexOf(e.parentId) && (i.push(e.id),
- !0)
- }(a, e, p)) {
- if (null !== e && delete e[e.indexOf(a.name)],
- void 0 !== a.geometryId && null !== a.geometryId && void 0 !== h.geometries && null !== h.geometries) {
- var l = !1;
- ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach((function(e) {
- !0 !== l && h.geometries[e] && Array.isArray(h.geometries[e]) && h.geometries[e].forEach((function(i) {
- i.id === a.geometryId && ("vertexData" === e && fr.Parse(i, t, n),
- l = !0)
- }
- ))
- }
- )),
- !1 === l && K.Warn("Geometry not found for mesh " + a.id)
- }
- if (a.materialUniqueId || a.materialId) {
- var c = a.materialUniqueId ? b : y
- , f = -1 !== c.indexOf(a.materialUniqueId || a.materialId);
- if (!1 === f && void 0 !== h.multiMaterials && null !== h.multiMaterials)
- for (var _ = function(e, i) {
- c.push(e);
- var r = w_(i, h, t, n);
- r && (u += "\n\tMaterial " + r.toString(d))
- }, m = 0, g = h.multiMaterials.length; m < g; m++) {
- var E = h.multiMaterials[m];
- if (a.materialUniqueId && E.uniqueId === a.materialUniqueId || E.id === a.materialId) {
- E.materialsUniqueIds ? E.materialsUniqueIds.forEach((function(e) {
- return _(e, (function(t) {
- return t.uniqueId === e
- }
- ))
- }
- )) : E.materials.forEach((function(e) {
- return _(e, (function(t) {
- return t.id === e
- }
- ))
- }
- )),
- c.push(E.uniqueId || E.id);
- var S = Dr.ParseMultiMaterial(E, t);
- F_[E.uniqueId || E.id] = S,
- S && (f = !0,
- u += "\n\tMulti-Material " + S.toString(d));
- break
- }
- }
- if (!1 === f) {
- c.push(a.materialUniqueId || a.materialId);
- var A = w_((function(e) {
- return a.MaterialUniqueId && e.uniqueId === a.materialUniqueId || e.id === a.materialId
- }
- ), h, t, n);
- A ? u += "\n\tMaterial " + A.toString(d) : K.Warn("Material not found for mesh " + a.id)
- }
- }
- if (a.skeletonId > -1 && void 0 !== h.skeletons && null !== h.skeletons && !(v.indexOf(a.skeletonId) > -1))
- for (var x = 0, R = h.skeletons.length; x < R; x++) {
- var C = h.skeletons[x];
- if (C.id === a.skeletonId) {
- var P = Fo.Parse(C, t);
- s.push(P),
- v.push(C.id),
- u += "\n\tSkeleton " + P.toString(d)
- }
- }
- if (a.morphTargetManagerId > -1 && void 0 !== h.morphTargetManagers && null !== h.morphTargetManagers && !(T.indexOf(a.morphTargetManagerId) > -1))
- for (var M = 0, I = h.morphTargetManagers.length; M < I; M++) {
- var O = h.morphTargetManagers[M];
- if (O.id === a.morphTargetManagerId) {
- var D = x_.Parse(O, t);
- T.push(D.uniqueId),
- u += "\nMorph target " + D.toString()
- }
- }
- var N = Vr.Parse(a, t, n);
- r.push(N),
- u += "\n\tMesh " + N.toString(d)
- }
- };
- for (_ = 0,
- m = h.meshes.length; _ < m; _++)
- E(_);
- for (t.multiMaterials.forEach((function(e) {
- e._waitingSubMaterialsUniqueIds.forEach((function(i) {
- e.subMaterials.push(k_(i, t))
- }
- )),
- e._waitingSubMaterialsUniqueIds = []
- }
- )),
- t.meshes.forEach((function(e) {
- null !== e._waitingMaterialId && (e.material = k_(e._waitingMaterialId, t),
- e._waitingMaterialId = null)
- }
- )),
- _ = 0,
- m = t.transformNodes.length; _ < m; _++)
- null !== (C = t.transformNodes[_])._waitingParentId && (C.parent = t.getLastEntryById(C._waitingParentId),
- C._waitingParentId = null);
- var S = void 0;
- for (_ = 0,
- m = t.meshes.length; _ < m; _++) {
- if ((S = t.meshes[_])._waitingParentId) {
- if (S.parent = t.getLastEntryById(S._waitingParentId),
- "TransformNode" === (null === (c = S.parent) || void 0 === c ? void 0 : c.getClassName())) {
- var A = f.indexOf(S.parent);
- A > -1 && f.splice(A, 1)
- }
- S._waitingParentId = null
- }
- S._waitingData.lods && U_(t, S)
- }
- for (var x = 0, R = f; x < R.length; x++) {
- var C;
- (C = R[x]).dispose()
- }
- for (_ = 0,
- m = t.skeletons.length; _ < m; _++) {
- var P = t.skeletons[_];
- P._hasWaitingData && (null != P.bones && P.bones.forEach((function(e) {
- if (e._waitingTransformNodeId) {
- var i = t.getLastEntryById(e._waitingTransformNodeId);
- i && e.linkTransformNode(i),
- e._waitingTransformNodeId = null
- }
- }
- )),
- P._hasWaitingData = null)
- }
- for (_ = 0,
- m = t.meshes.length; _ < m; _++)
- (S = t.meshes[_])._waitingData.freezeWorldMatrix ? (S.freezeWorldMatrix(),
- S._waitingData.freezeWorldMatrix = null) : S.computeWorldMatrix(!0)
- }
- if (void 0 !== h.particleSystems && null !== h.particleSystems) {
- var M = o.GetIndividualParser(Wi.NAME_PARTICLESYSTEM);
- if (M)
- for (_ = 0,
- m = h.particleSystems.length; _ < m; _++) {
- var I = h.particleSystems[_];
- -1 !== p.indexOf(I.emitterId) && a.push(M(I, t, n))
- }
- }
- return !0
- } catch (e) {
- var O = B_("importMesh", h ? h.producer : "Unknown") + u;
- if (!l)
- throw K.Log(O),
- e;
- l(O, e)
- } finally {
- null !== u && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("importMesh", h ? h.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? u : ""))
- }
- return !1
- },
- load: function(e, t, i, n) {
- var r = "importScene has failed JSON parse";
- try {
- var o = JSON.parse(t);
- if (r = "",
- void 0 !== o.useDelayedTextureLoading && null !== o.useDelayedTextureLoading && (e.useDelayedTextureLoading = o.useDelayedTextureLoading && !od.ForceFullSceneLoadingForIncremental),
- void 0 !== o.autoClear && null !== o.autoClear && (e.autoClear = o.autoClear),
- void 0 !== o.clearColor && null !== o.clearColor && (e.clearColor = N.FromArray(o.clearColor)),
- void 0 !== o.ambientColor && null !== o.ambientColor && (e.ambientColor = D.FromArray(o.ambientColor)),
- void 0 !== o.gravity && null !== o.gravity && (e.gravity = x.FromArray(o.gravity)),
- void 0 !== o.useRightHandedSystem && (e.useRightHandedSystem = !!o.useRightHandedSystem),
- o.fogMode && 0 !== o.fogMode)
- switch (e.fogMode = o.fogMode,
- e.fogColor = D.FromArray(o.fogColor),
- e.fogStart = o.fogStart,
- e.fogEnd = o.fogEnd,
- e.fogDensity = o.fogDensity,
- r += "\tFog mode for scene: ",
- e.fogMode) {
- case 1:
- r += "exp\n";
- break;
- case 2:
- r += "exp2\n";
- break;
- case 3:
- r += "linear\n"
- }
- if (o.physicsEnabled) {
- var a = void 0;
- "cannon" === o.physicsEngine ? a = new P_(void 0,void 0,N_.LoaderInjectedPhysicsEngine) : "oimo" === o.physicsEngine ? a = new M_(void 0,N_.LoaderInjectedPhysicsEngine) : "ammo" === o.physicsEngine && (a = new I_(void 0,N_.LoaderInjectedPhysicsEngine,void 0)),
- r = "\tPhysics engine " + (o.physicsEngine ? o.physicsEngine : "oimo") + " enabled\n";
- var s = o.physicsGravity ? x.FromArray(o.physicsGravity) : null;
- e.enablePhysics(s, a)
- }
- return void 0 !== o.metadata && null !== o.metadata && (e.metadata = o.metadata),
- void 0 !== o.collisionsEnabled && null !== o.collisionsEnabled && (e.collisionsEnabled = o.collisionsEnabled),
- !!G_(e, t, i, n, !0) && (o.autoAnimate && e.beginAnimation(e, o.autoAnimateFrom, o.autoAnimateTo, o.autoAnimateLoop, o.autoAnimateSpeed || 1),
- void 0 !== o.activeCameraID && null !== o.activeCameraID && e.setActiveCameraById(o.activeCameraID),
- !0)
- } catch (e) {
- var l = B_("importScene", o ? o.producer : "Unknown") + r;
- if (!n)
- throw K.Log(l),
- e;
- n(l, e)
- } finally {
- null !== r && od.loggingLevel !== od.NO_LOGGING && K.Log(B_("importScene", o ? o.producer : "Unknown") + (od.loggingLevel !== od.MINIMAL_LOGGING ? r : ""))
- }
- return !1
- },
- loadAssetContainer: function(e, t, i, n) {
- return G_(e, t, i, n)
- }
- });
- var z_ = function() {
- function e(e) {
- void 0 === e && (e = {}),
- this._isEnabled = !0,
- this.bias = void 0 === e.bias ? 0 : e.bias,
- this.power = void 0 === e.power ? 1 : e.power,
- this.leftColor = e.leftColor || D.White(),
- this.rightColor = e.rightColor || D.Black(),
- !1 === e.isEnabled && (this.isEnabled = !1)
- }
- return Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled !== e && (this._isEnabled = e,
- vr.MarkAllMaterialsAsDirty(a.MATERIAL_FresnelDirtyFlag | a.MATERIAL_MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.clone = function() {
- var t = new e;
- return fe.DeepCopy(this, t),
- t
- }
- ,
- e.prototype.equals = function(e) {
- return e && this.bias === e.bias && this.power === e.power && this.leftColor.equals(e.leftColor) && this.rightColor.equals(e.rightColor) && this.isEnabled === e.isEnabled
- }
- ,
- e.prototype.serialize = function() {
- return {
- isEnabled: this.isEnabled,
- leftColor: this.leftColor.asArray(),
- rightColor: this.rightColor.asArray(),
- bias: this.bias,
- power: this.power
- }
- }
- ,
- e.Parse = function(t) {
- return new e({
- isEnabled: t.isEnabled,
- leftColor: D.FromArray(t.leftColor),
- rightColor: D.FromArray(t.rightColor),
- bias: t.bias,
- power: t.power || 1
- })
- }
- ,
- e
- }();
- Ge._FresnelParametersParser = z_.Parse;
- var W_ = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i, "color", {
- attributes: ["position"],
- uniforms: ["world", "viewProjection", "color"]
- }) || this;
- return n.disableColorWrite = !0,
- n.forceDepthWrite = !0,
- n.setColor4("color", new N(0,0,0,1)),
- n
- }
- return U(t, e),
- t
- }(jl)
- , H_ = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n.maxSimultaneousLights = 4,
- n.disableLighting = !1,
- n.invertNormalMapX = !1,
- n.invertNormalMapY = !1,
- n.emissiveColor = new D(0,0,0),
- n.occlusionStrength = 1,
- n.useLightmapAsShadowmap = !1,
- n._useAlphaFromAlbedoTexture = !0,
- n._useAmbientInGrayScale = !0,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "doubleSided", {
- get: function() {
- return this._twoSidedLighting
- },
- set: function(e) {
- this._twoSidedLighting !== e && (this._twoSidedLighting = e,
- this.backFaceCulling = !e,
- this._markAllSubMeshesAsTexturesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "PBRBaseSimpleMaterial"
- }
- ,
- k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "maxSimultaneousLights", void 0),
- k([Ce(), Re("_markAllSubMeshesAsLightsDirty")], t.prototype, "disableLighting", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")], t.prototype, "environmentTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapX", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "invertNormalMapY", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")], t.prototype, "normalTexture", void 0),
- k([Me("emissive"), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveColor", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "emissiveTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")], t.prototype, "occlusionStrength", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")], t.prototype, "occlusionTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")], t.prototype, "alphaCutOff", void 0),
- k([Ce()], t.prototype, "doubleSided", null),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", null)], t.prototype, "lightmapTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "useLightmapAsShadowmap", void 0),
- t
- }(rp)
- , X_ = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n._useRoughnessFromMetallicTextureAlpha = !1,
- n._useRoughnessFromMetallicTextureGreen = !0,
- n._useMetallnessFromMetallicTextureBlue = !0,
- n.metallic = 1,
- n.roughness = 1,
- n
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "PBRMetallicRoughnessMaterial"
- }
- ,
- t.prototype.clone = function(e) {
- var i = this
- , n = Ge.Clone((function() {
- return new t(e,i.getScene())
- }
- ), this);
- return n.id = e,
- n.name = e,
- this.clearCoat.copyTo(n.clearCoat),
- this.anisotropy.copyTo(n.anisotropy),
- this.brdf.copyTo(n.brdf),
- this.sheen.copyTo(n.sheen),
- this.subSurface.copyTo(n.subSurface),
- n
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.customType = "BABYLON.PBRMetallicRoughnessMaterial",
- e.clearCoat = this.clearCoat.serialize(),
- e.anisotropy = this.anisotropy.serialize(),
- e.brdf = this.brdf.serialize(),
- e.sheen = this.sheen.serialize(),
- e.subSurface = this.subSurface.serialize(),
- e
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n);
- return e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
- e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
- e.brdf && r.brdf.parse(e.brdf, i, n),
- e.sheen && r.sheen.parse(e.sheen, i, n),
- e.subSurface && r.subSurface.parse(e.subSurface, i, n),
- r
- }
- ,
- k([Me(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "baseColor", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "baseTexture", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "metallic", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty")], t.prototype, "roughness", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")], t.prototype, "metallicRoughnessTexture", void 0),
- t
- }(H_);
- y("BABYLON.PBRMetallicRoughnessMaterial", X_);
- var j_ = function(e) {
- function t(t, i) {
- var n = e.call(this, t, i) || this;
- return n._useMicroSurfaceFromReflectivityMapAlpha = !0,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "useMicroSurfaceFromReflectivityMapAlpha", {
- get: function() {
- return this._useMicroSurfaceFromReflectivityMapAlpha
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "PBRSpecularGlossinessMaterial"
- }
- ,
- t.prototype.clone = function(e) {
- var i = this
- , n = Ge.Clone((function() {
- return new t(e,i.getScene())
- }
- ), this);
- return n.id = e,
- n.name = e,
- this.clearCoat.copyTo(n.clearCoat),
- this.anisotropy.copyTo(n.anisotropy),
- this.brdf.copyTo(n.brdf),
- this.sheen.copyTo(n.sheen),
- this.subSurface.copyTo(n.subSurface),
- n
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.customType = "BABYLON.PBRSpecularGlossinessMaterial",
- e.clearCoat = this.clearCoat.serialize(),
- e.anisotropy = this.anisotropy.serialize(),
- e.brdf = this.brdf.serialize(),
- e.sheen = this.sheen.serialize(),
- e.subSurface = this.subSurface.serialize(),
- e
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- return new t(e.name,i)
- }
- ), e, i, n);
- return e.clearCoat && r.clearCoat.parse(e.clearCoat, i, n),
- e.anisotropy && r.anisotropy.parse(e.anisotropy, i, n),
- e.brdf && r.brdf.parse(e.brdf, i, n),
- e.sheen && r.sheen.parse(e.sheen, i, n),
- e.subSurface && r.subSurface.parse(e.subSurface, i, n),
- r
- }
- ,
- k([Me("diffuse"), Re("_markAllSubMeshesAsTexturesDirty", "_albedoColor")], t.prototype, "diffuseColor", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")], t.prototype, "diffuseTexture", void 0),
- k([Me("specular"), Re("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")], t.prototype, "specularColor", void 0),
- k([Ce(), Re("_markAllSubMeshesAsTexturesDirty", "_microSurface")], t.prototype, "glossiness", void 0),
- k([Pe(), Re("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")], t.prototype, "specularGlossinessTexture", void 0),
- t
- }(H_);
- y("BABYLON.PBRSpecularGlossinessMaterial", j_);
- var Y_ = function(e) {
- function t(t, i, n) {
- void 0 === n && (n = null);
- var r = e.call(this, i) || this;
- if (!t)
- return r;
- if (r._textureMatrix = P.Identity(),
- r.name = t,
- r.url = t,
- r._onLoad = n,
- r._texture = r._getFromCache(t, !0),
- r._texture)
- r._triggerOnLoad();
- else {
- var o = r.getScene();
- o && o.useDelayedTextureLoading ? r.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : r._loadTexture()
- }
- return r
- }
- return U(t, e),
- t.prototype._triggerOnLoad = function() {
- this._onLoad && this._onLoad()
- }
- ,
- t.prototype.getTextureMatrix = function() {
- return this._textureMatrix
- }
- ,
- t.prototype._load3dlTexture = function() {
- var e, i = this, n = this._getEngine();
- e = n._features.support3DTextures ? n.createRawTexture3D(null, 1, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT) : n.createRawTexture(null, 1, 1, a.TEXTUREFORMAT_RGBA, !1, !1, a.TEXTURE_BILINEAR_SAMPLINGMODE, null, a.TEXTURETYPE_UNSIGNED_INT),
- this._texture = e,
- this._texture.isReady = !1,
- this.isCube = !1,
- this.is3D = n._features.support3DTextures,
- this.wrapU = a.TEXTURE_CLAMP_ADDRESSMODE,
- this.wrapV = a.TEXTURE_CLAMP_ADDRESSMODE,
- this.wrapR = a.TEXTURE_CLAMP_ADDRESSMODE,
- this.anisotropicFilteringLevel = 1;
- var r = function(r) {
- if ("string" == typeof r) {
- for (var o, s = null, l = null, c = r.split("\n"), u = 0, h = 0, d = 0, p = 0, f = 0, _ = 0; _ < c.length; _++)
- if (o = c[_],
- t._NoneEmptyLineRegex.test(o) && 0 !== o.indexOf("#")) {
- var m = o.split(" ");
- if (0 !== u) {
- if (0 != u) {
- var g = Math.max(parseInt(m[0]), 0)
- , v = Math.max(parseInt(m[1]), 0)
- , y = Math.max(parseInt(m[2]), 0);
- f = Math.max(g, f),
- f = Math.max(v, f),
- f = Math.max(y, f);
- var b = 4 * (h + p * u + d * u * u);
- l && (l[b + 0] = g,
- l[b + 1] = v,
- l[b + 2] = y),
- ++d % u == 0 && (d = 0,
- ++p % u == 0 && (h++,
- p = 0))
- }
- } else
- u = m.length,
- s = new Uint8Array(u * u * u * 4),
- l = new Float32Array(u * u * u * 4)
- }
- if (l && s)
- for (_ = 0; _ < l.length; _++)
- if (_ > 0 && (_ + 1) % 4 == 0)
- s[_] = 255;
- else {
- var T = l[_];
- s[_] = T / f * 255
- }
- e.is3D ? (e.updateSize(u, u, u),
- n.updateRawTexture3D(e, s, a.TEXTUREFORMAT_RGBA, !1)) : (e.updateSize(u * u, u),
- n.updateRawTexture(e, s, a.TEXTUREFORMAT_RGBA, !1)),
- e.isReady = !0,
- i._triggerOnLoad()
- }
- }
- , o = this.getScene();
- return o ? o._loadFile(this.url, r) : n._loadFile(this.url, r),
- this._texture
- }
- ,
- t.prototype._loadTexture = function() {
- this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == this.url.length - 4 && this._load3dlTexture()
- }
- ,
- t.prototype.clone = function() {
- var e = new t(this.url,this.getScene() || this._getEngine());
- return e.level = this.level,
- e
- }
- ,
- t.prototype.delayLoad = function() {
- this.delayLoadState === a.DELAYLOADSTATE_NOTLOADED && (this.delayLoadState = a.DELAYLOADSTATE_LOADED,
- this._texture = this._getFromCache(this.url, !0),
- this._texture || this._loadTexture())
- }
- ,
- t.Parse = function(e, i) {
- var n = null;
- return e.name && !e.isRenderTarget && ((n = new t(e.name,i)).name = e.name,
- n.level = e.level),
- n
- }
- ,
- t.prototype.serialize = function() {
- if (!this.name)
- return null;
- var e = {};
- return e.name = this.name,
- e.level = this.level,
- e.customType = "BABYLON.ColorGradingTexture",
- e
- }
- ,
- t._NoneEmptyLineRegex = /\S+/,
- t
- }(Zr);
- y("BABYLON.ColorGradingTexture", Y_);
- var K_ = function(e) {
- function t(t, i, n, r, o, s, l) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !0),
- void 0 === s && (s = null),
- void 0 === l && (l = null);
- var c = e.call(this, i) || this;
- if (c._onLoad = null,
- c._onError = null,
- !t)
- throw new Error("Image url is not set");
- return c._coordinatesMode = io.CUBIC_MODE,
- c.name = t,
- c.url = t,
- c._size = n,
- c._noMipmap = r,
- c.gammaSpace = o,
- c._onLoad = s,
- c._onError = l,
- c.hasAlpha = !1,
- c.isCube = !0,
- c._texture = c._getFromCache(t, c._noMipmap),
- c._texture ? s && (c._texture.isReady ? gi.SetImmediate((function() {
- return s()
- }
- )) : c._texture.onLoadedObservable.add(s)) : i.useDelayedTextureLoading ? c.delayLoadState = a.DELAYLOADSTATE_NOTLOADED : c._loadImage(c._loadTexture.bind(c), c._onError),
- c
- }
- return U(t, e),
- t.prototype._loadImage = function(e, t) {
- var i = this
- , n = document.createElement("canvas");
- $t(this.url, (function(t) {
- i._width = t.width,
- i._height = t.height,
- n.width = i._width,
- n.height = i._height;
- var r = n.getContext("2d");
- r.drawImage(t, 0, 0);
- var o = r.getImageData(0, 0, t.width, t.height);
- i._buffer = o.data.buffer,
- n.remove(),
- e()
- }
- ), (function(e, n) {
- t && t("".concat(i.getClassName(), " could not be loaded"), n)
- }
- ), null)
- }
- ,
- t.prototype._loadTexture = function() {
- var e = this
- , i = this.getScene();
- i && (this._texture = i.getEngine().createRawCubeTextureFromUrl(this.url, i, this._size, a.TEXTUREFORMAT_RGB, i.getEngine().getCaps().textureFloat ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, (function() {
- for (var i = e._getFloat32ArrayFromArrayBuffer(e._buffer), n = g_.ConvertPanoramaToCubemap(i, e._width, e._height, e._size), r = [], o = 0; o < 6; o++) {
- var a = n[t._FacesMapping[o]];
- r.push(a)
- }
- return r
- }
- ), null, this._onLoad, this._onError))
- }
- ,
- t.prototype._getFloat32ArrayFromArrayBuffer = function(e) {
- for (var t = new DataView(e), i = new Float32Array(3 * e.byteLength / 4), n = 0, r = 0; r < e.byteLength; r++)
- (r + 1) % 4 != 0 && (i[n++] = t.getUint8(r) / 255);
- return i
- }
- ,
- t.prototype.getClassName = function() {
- return "EquiRectangularCubeTexture"
- }
- ,
- t.prototype.clone = function() {
- var e = this.getScene();
- if (!e)
- return this;
- var i = new t(this.url,e,this._size,this._noMipmap,this.gammaSpace);
- return i.level = this.level,
- i.wrapU = this.wrapU,
- i.wrapV = this.wrapV,
- i.coordinatesIndex = this.coordinatesIndex,
- i.coordinatesMode = this.coordinatesMode,
- i
- }
- ,
- t._FacesMapping = ["right", "left", "up", "down", "front", "back"],
- t
- }(Zr)
- , Q_ = function(e) {
- function t(i, n, r) {
- var o = e.call(this, r.scene || r.engine) || this;
- return n && (r.engine || r.scene) ? (r = V(V({}, t._DefaultOptions), r),
- o._generateMipMaps = r.generateMipMaps,
- o._samplingMode = r.samplingMode,
- o._textureMatrix = P.Identity(),
- o.name = i,
- o.element = n,
- o._isVideo = n instanceof HTMLVideoElement,
- o.anisotropicFilteringLevel = 1,
- o._createInternalTexture(),
- o) : o
- }
- return U(t, e),
- t.prototype._createInternalTexture = function() {
- var e = 0
- , t = 0;
- this._isVideo ? (e = this.element.videoWidth,
- t = this.element.videoHeight) : (e = this.element.width,
- t = this.element.height);
- var i = this._getEngine();
- i && (this._texture = i.createDynamicTexture(e, t, this._generateMipMaps, this._samplingMode)),
- this.update()
- }
- ,
- t.prototype.getTextureMatrix = function() {
- return this._textureMatrix
- }
- ,
- t.prototype.update = function(e) {
- void 0 === e && (e = null);
- var t = this._getEngine();
- if (null != this._texture && null != t)
- if (this._isVideo) {
- var i = this.element;
- if (i.readyState < i.HAVE_CURRENT_DATA)
- return;
- t.updateVideoTexture(this._texture, i, null === e || e)
- } else {
- var n = this.element;
- t.updateDynamicTexture(this._texture, n, null === e || e, !1)
- }
- }
- ,
- t._DefaultOptions = {
- generateMipMaps: !1,
- samplingMode: a.TEXTURE_BILINEAR_SAMPLINGMODE,
- engine: null,
- scene: null
- },
- t
- }(Zr);
- function q_(e) {
- var t = 0;
- return {
- id_length: e[t++],
- colormap_type: e[t++],
- image_type: e[t++],
- colormap_index: e[t++] | e[t++] << 8,
- colormap_length: e[t++] | e[t++] << 8,
- colormap_size: e[t++],
- origin: [e[t++] | e[t++] << 8, e[t++] | e[t++] << 8],
- width: e[t++] | e[t++] << 8,
- height: e[t++] | e[t++] << 8,
- pixel_size: e[t++],
- flags: e[t++]
- }
- }
- function Z_(e, t) {
- if (t.length < 19)
- K.Error("Unable to load TGA file - Not enough data to contain header");
- else {
- var i = 18
- , n = q_(t);
- if (n.id_length + i > t.length)
- K.Error("Unable to load TGA file - Not enough data");
- else {
- i += n.id_length;
- var r, o = !1, a = !1, s = !1;
- switch (n.image_type) {
- case 9:
- o = !0;
- case 1:
- a = !0;
- break;
- case 10:
- o = !0;
- case 2:
- break;
- case 11:
- o = !0;
- case 3:
- s = !0
- }
- var l, c, u, h, d, p, f, _ = n.pixel_size >> 3, m = n.width * n.height * _;
- if (a && (l = t.subarray(i, i += n.colormap_length * (n.colormap_size >> 3))),
- o) {
- r = new Uint8Array(m);
- for (var g = void 0, v = void 0, y = void 0, b = 0, T = new Uint8Array(_); i < m && b < m; )
- if (v = 1 + (127 & (g = t[i++])),
- 128 & g) {
- for (y = 0; y < _; ++y)
- T[y] = t[i++];
- for (y = 0; y < v; ++y)
- r.set(T, b + y * _);
- b += _ * v
- } else {
- for (v *= _,
- y = 0; y < v; ++y)
- r[b + y] = t[i++];
- b += v
- }
- } else
- r = t.subarray(i, i += a ? n.width * n.height : m);
- switch ((48 & n.flags) >> 4) {
- default:
- case 2:
- c = 0,
- h = 1,
- f = n.width,
- u = 0,
- d = 1,
- p = n.height;
- break;
- case 0:
- c = 0,
- h = 1,
- f = n.width,
- u = n.height - 1,
- d = -1,
- p = -1;
- break;
- case 3:
- c = n.width - 1,
- h = -1,
- f = -1,
- u = 0,
- d = 1,
- p = n.height;
- break;
- case 1:
- c = n.width - 1,
- h = -1,
- f = -1,
- u = n.height - 1,
- d = -1,
- p = -1
- }
- var E = "_getImageData" + (s ? "Grey" : "") + n.pixel_size + "bits"
- , S = J_[E](n, l, r, u, d, p, c, h, f);
- e.getEngine()._uploadDataToTextureDirectly(e, S)
- }
- }
- }
- var J_ = {
- GetTGAHeader: q_,
- UploadContent: Z_,
- _getImageData8bits: function(e, t, i, n, r, o, a, s, l) {
- var c, u, h, d = i, p = t, f = e.width, _ = e.height, m = 0, g = new Uint8Array(f * _ * 4);
- for (h = n; h !== o; h += r)
- for (u = a; u !== l; u += s,
- m++)
- c = d[m],
- g[4 * (u + f * h) + 3] = 255,
- g[4 * (u + f * h) + 2] = p[3 * c + 0],
- g[4 * (u + f * h) + 1] = p[3 * c + 1],
- g[4 * (u + f * h) + 0] = p[3 * c + 2];
- return g
- },
- _getImageData16bits: function(e, t, i, n, r, o, a, s, l) {
- var c, u, h, d = i, p = e.width, f = e.height, _ = 0, m = new Uint8Array(p * f * 4);
- for (h = n; h !== o; h += r)
- for (u = a; u !== l; u += s,
- _ += 2) {
- var g = 255 * ((31744 & (c = d[_ + 0] + (d[_ + 1] << 8))) >> 10) / 31 | 0
- , v = 255 * ((992 & c) >> 5) / 31 | 0
- , y = 255 * (31 & c) / 31 | 0;
- m[4 * (u + p * h) + 0] = g,
- m[4 * (u + p * h) + 1] = v,
- m[4 * (u + p * h) + 2] = y,
- m[4 * (u + p * h) + 3] = 32768 & c ? 0 : 255
- }
- return m
- },
- _getImageData24bits: function(e, t, i, n, r, o, a, s, l) {
- var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
- for (u = n; u !== o; u += r)
- for (c = a; c !== l; c += s,
- f += 3)
- _[4 * (c + d * u) + 3] = 255,
- _[4 * (c + d * u) + 2] = h[f + 0],
- _[4 * (c + d * u) + 1] = h[f + 1],
- _[4 * (c + d * u) + 0] = h[f + 2];
- return _
- },
- _getImageData32bits: function(e, t, i, n, r, o, a, s, l) {
- var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
- for (u = n; u !== o; u += r)
- for (c = a; c !== l; c += s,
- f += 4)
- _[4 * (c + d * u) + 2] = h[f + 0],
- _[4 * (c + d * u) + 1] = h[f + 1],
- _[4 * (c + d * u) + 0] = h[f + 2],
- _[4 * (c + d * u) + 3] = h[f + 3];
- return _
- },
- _getImageDataGrey8bits: function(e, t, i, n, r, o, a, s, l) {
- var c, u, h, d = i, p = e.width, f = e.height, _ = 0, m = new Uint8Array(p * f * 4);
- for (h = n; h !== o; h += r)
- for (u = a; u !== l; u += s,
- _++)
- c = d[_],
- m[4 * (u + p * h) + 0] = c,
- m[4 * (u + p * h) + 1] = c,
- m[4 * (u + p * h) + 2] = c,
- m[4 * (u + p * h) + 3] = 255;
- return m
- },
- _getImageDataGrey16bits: function(e, t, i, n, r, o, a, s, l) {
- var c, u, h = i, d = e.width, p = e.height, f = 0, _ = new Uint8Array(d * p * 4);
- for (u = n; u !== o; u += r)
- for (c = a; c !== l; c += s,
- f += 2)
- _[4 * (c + d * u) + 0] = h[f + 0],
- _[4 * (c + d * u) + 1] = h[f + 0],
- _[4 * (c + d * u) + 2] = h[f + 0],
- _[4 * (c + d * u) + 3] = h[f + 1];
- return _
- }
- }
- , $_ = function() {
- function e() {
- this.supportCascades = !1
- }
- return e.prototype.canLoad = function(e) {
- return oe(e, ".tga")
- }
- ,
- e.prototype.loadCubeData = function() {
- throw ".env not supported in Cube."
- }
- ,
- e.prototype.loadData = function(e, t, i) {
- var n = new Uint8Array(e.buffer,e.byteOffset,e.byteLength)
- , r = q_(n);
- i(r.width, r.height, t.generateMipMaps, !1, (function() {
- Z_(t, n)
- }
- ))
- }
- ,
- e
- }();
- vr._TextureLoaders.push(new $_);
- var em = function() {
- function e() {
- this.supportCascades = !1
- }
- return e.prototype.canLoad = function(e) {
- return oe(e, ".hdr")
- }
- ,
- e.prototype.loadCubeData = function() {
- throw ".env not supported in Cube."
- }
- ,
- e.prototype.loadData = function(e, t, i) {
- for (var n = new Uint8Array(e.buffer,e.byteOffset,e.byteLength), r = v_.RGBE_ReadHeader(n), o = v_.RGBE_ReadPixels(n, r), s = r.width * r.height, l = new Float32Array(4 * s), c = 0; c < s; c += 1)
- l[4 * c] = o[3 * c],
- l[4 * c + 1] = o[3 * c + 1],
- l[4 * c + 2] = o[3 * c + 2],
- l[4 * c + 3] = 1;
- i(r.width, r.height, t.generateMipMaps, !1, (function() {
- var e = t.getEngine();
- t.type = a.TEXTURETYPE_FLOAT,
- t.format = a.TEXTUREFORMAT_RGBA,
- t._gammaSpace = !1,
- e._uploadDataToTextureDirectly(t, l)
- }
- ))
- }
- ,
- e
- }();
- vr._TextureLoaders.push(new em);
- var tm, im = function() {};
- !function(e) {
- e[e.cTFETC1 = 0] = "cTFETC1",
- e[e.cTFBC1 = 1] = "cTFBC1",
- e[e.cTFBC4 = 2] = "cTFBC4",
- e[e.cTFPVRTC1_4_OPAQUE_ONLY = 3] = "cTFPVRTC1_4_OPAQUE_ONLY",
- e[e.cTFBC7_M6_OPAQUE_ONLY = 4] = "cTFBC7_M6_OPAQUE_ONLY",
- e[e.cTFETC2 = 5] = "cTFETC2",
- e[e.cTFBC3 = 6] = "cTFBC3",
- e[e.cTFBC5 = 7] = "cTFBC5"
- }(tm || (tm = {}));
- var nm = {
- JSModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js",
- WasmModuleURL: "https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm"
- }
- , rm = function(e, t) {
- var i;
- switch (e) {
- case tm.cTFETC1:
- i = a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL;
- break;
- case tm.cTFBC1:
- i = a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1;
- break;
- case tm.cTFBC4:
- i = a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5
- }
- if (void 0 === i)
- throw "The chosen Basis transcoder format is not currently supported";
- return i
- }
- , om = null
- , am = null
- , sm = 0
- , lm = function(e, t) {
- var i = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
- return new Promise((function(e, n) {
- (om || (om = new Promise((function(e, t) {
- am ? e(am) : gi.LoadFileAsync(nm.WasmModuleURL).then((function(i) {
- var n = URL.createObjectURL(new Blob(["(".concat(hm, ")()")],{
- type: "application/javascript"
- }));
- am = new Worker(n);
- var r = function(i) {
- "init" === i.data.action ? (am.removeEventListener("message", r),
- e(am)) : "error" === i.data.action && t(i.data.error || "error initializing worker")
- };
- am.addEventListener("message", r),
- am.postMessage({
- action: "init",
- url: nm.JSModuleURL,
- wasmBinary: i
- })
- }
- )).catch(t)
- }
- ))),
- om).then((function() {
- var r = sm++
- , o = function(t) {
- "transcode" === t.data.action && t.data.id === r && (am.removeEventListener("message", o),
- t.data.success ? e(t.data) : n("Transcode is not supported on this device"))
- };
- am.addEventListener("message", o);
- var a = new Uint8Array(i.byteLength);
- a.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)),
- am.postMessage({
- action: "transcode",
- id: r,
- imageData: a,
- config: t,
- ignoreSupportedFormats: !1
- }, [a.buffer])
- }
- ), (function(e) {
- n(e)
- }
- ))
- }
- ))
- }
- , cm = function(e, t) {
- for (var i = e.getEngine(), n = function(n) {
- var r = t.fileInfo.images[n].levels[0];
- if (e._invertVScale = e.invertY,
- -1 === t.format)
- if (e.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
- e.format = a.TEXTUREFORMAT_RGB,
- !i._features.basisNeedsPOT || d.Log2(r.width) % 1 == 0 && d.Log2(r.height) % 1 == 0)
- e._invertVScale = !e.invertY,
- e.width = r.width + 3 & -4,
- e.height = r.height + 3 & -4,
- i._uploadDataToTextureDirectly(e, r.transcodedPixels, n, 0, a.TEXTUREFORMAT_RGB, !0);
- else {
- var o = new Lt(i,At.Temp);
- e._invertVScale = e.invertY,
- o.type = a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,
- o.format = a.TEXTUREFORMAT_RGB,
- o.width = r.width + 3 & -4,
- o.height = r.height + 3 & -4,
- i._bindTextureDirectly(i._gl.TEXTURE_2D, o, !0),
- i._uploadDataToTextureDirectly(o, r.transcodedPixels, n, 0, a.TEXTUREFORMAT_RGB, !0),
- i._rescaleTexture(o, e, i.scenes[0], i._getInternalFormat(a.TEXTUREFORMAT_RGB), (function() {
- i._releaseTexture(o),
- i._bindTextureDirectly(i._gl.TEXTURE_2D, e, !0)
- }
- ))
- }
- else
- e.width = r.width,
- e.height = r.height,
- e.generateMipMaps = t.fileInfo.images[n].levels.length > 1,
- t.fileInfo.images[n].levels.forEach((function(r, o) {
- i._uploadCompressedDataToTextureDirectly(e, um.GetInternalFormatFromBasisFormat(t.format, i), r.width, r.height, r.transcodedPixels, n, o)
- }
- )),
- !i._features.basisNeedsPOT || d.Log2(e.width) % 1 == 0 && d.Log2(e.height) % 1 == 0 || (gi.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),
- e._cachedWrapU = io.CLAMP_ADDRESSMODE,
- e._cachedWrapV = io.CLAMP_ADDRESSMODE)
- }, r = 0; r < t.fileInfo.images.length; r++)
- n(r)
- }
- , um = {
- JSModuleURL: nm.JSModuleURL,
- WasmModuleURL: nm.WasmModuleURL,
- GetInternalFormatFromBasisFormat: rm,
- TranscodeAsync: lm,
- LoadTextureFromTranscodeResult: cm
- };
- function hm() {
- var e = null;
- function t(e, t, i, n, r) {
- var o = e.getImageTranscodedSizeInBytes(t, i, n)
- , a = new Uint8Array(o);
- return e.transcodeImage(a, t, i, n, 1, 0) ? (r && (a = function(e, t, i, n) {
- for (var r = new Uint16Array(4), o = new Uint16Array(i * n), a = i / 4, s = n / 4, l = 0; l < s; l++)
- for (var c = 0; c < a; c++) {
- var u = 0 + 8 * (l * a + c);
- r[0] = e[u] | e[u + 1] << 8,
- r[1] = e[u + 2] | e[u + 3] << 8,
- r[2] = (2 * (31 & r[0]) + 1 * (31 & r[1])) / 3 | (2 * (2016 & r[0]) + 1 * (2016 & r[1])) / 3 & 2016 | (2 * (63488 & r[0]) + 1 * (63488 & r[1])) / 3 & 63488,
- r[3] = (2 * (31 & r[1]) + 1 * (31 & r[0])) / 3 | (2 * (2016 & r[1]) + 1 * (2016 & r[0])) / 3 & 2016 | (2 * (63488 & r[1]) + 1 * (63488 & r[0])) / 3 & 63488;
- for (var h = 0; h < 4; h++) {
- var d = e[u + 4 + h]
- , p = (4 * l + h) * i + 4 * c;
- o[p++] = r[3 & d],
- o[p++] = r[d >> 2 & 3],
- o[p++] = r[d >> 4 & 3],
- o[p++] = r[d >> 6 & 3]
- }
- }
- return o
- }(a, 0, e.getImageWidth(t, i) + 3 & -4, e.getImageHeight(t, i) + 3 & -4)),
- a) : null
- }
- onmessage = function(i) {
- if ("init" === i.data.action) {
- if (!e) {
- Module = {
- wasmBinary: i.data.wasmBinary
- };
- try {
- importScripts(i.data.url)
- } catch (e) {
- postMessage({
- action: "error",
- error: e
- })
- }
- e = new Promise((function(e) {
- Module.onRuntimeInitialized = function() {
- Module.initializeBasis(),
- e()
- }
- }
- ))
- }
- e.then((function() {
- postMessage({
- action: "init"
- })
- }
- ))
- } else if ("transcode" === i.data.action) {
- var n = i.data.config
- , r = i.data.imageData
- , o = new Module.BasisFile(r)
- , a = function(e) {
- for (var t = e.getHasAlpha(), i = e.getNumImages(), n = [], r = 0; r < i; r++) {
- for (var o = {
- levels: []
- }, a = e.getNumLevels(r), s = 0; s < a; s++) {
- var l = {
- width: e.getImageWidth(r, s),
- height: e.getImageHeight(r, s)
- };
- o.levels.push(l)
- }
- n.push(o)
- }
- return {
- hasAlpha: t,
- images: n
- }
- }(o)
- , s = i.data.ignoreSupportedFormats ? null : function(e, t) {
- var i = null;
- return e.supportedCompressionFormats && (e.supportedCompressionFormats.etc1 ? i = 0 : e.supportedCompressionFormats.s3tc ? i = t.hasAlpha ? 6 : 1 : e.supportedCompressionFormats.pvrtc || e.supportedCompressionFormats.etc2 && (i = 5)),
- i
- }(i.data.config, a)
- , l = !1;
- null === s && (l = !0,
- s = a.hasAlpha ? 6 : 1);
- var c = !0;
- o.startTranscoding() || (c = !1);
- for (var u = [], h = 0; h < a.images.length && c; h++) {
- var d = a.images[h];
- if (void 0 === n.loadSingleImage || n.loadSingleImage === h) {
- var p = d.levels.length;
- !1 === n.loadMipmapLevels && (p = 1);
- for (var f = 0; f < p; f++) {
- var _ = d.levels[f]
- , m = t(o, h, f, s, l);
- if (!m) {
- c = !1;
- break
- }
- _.transcodedPixels = m,
- u.push(_.transcodedPixels.buffer)
- }
- }
- }
- o.close(),
- o.delete(),
- l && (s = -1),
- c ? postMessage({
- action: "transcode",
- success: c,
- id: i.data.id,
- fileInfo: a,
- format: s
- }, u) : postMessage({
- action: "transcode",
- success: c,
- id: i.data.id
- })
- }
- }
- }
- Object.defineProperty(um, "JSModuleURL", {
- get: function() {
- return nm.JSModuleURL
- },
- set: function(e) {
- nm.JSModuleURL = e
- }
- }),
- Object.defineProperty(um, "WasmModuleURL", {
- get: function() {
- return nm.WasmModuleURL
- },
- set: function(e) {
- nm.WasmModuleURL = e
- }
- });
- var dm = function() {
- function e() {
- this.supportCascades = !1
- }
- return e.prototype.canLoad = function(e) {
- return oe(e, ".basis")
- }
- ,
- e.prototype.loadCubeData = function(e, t, i, n, r) {
- if (!Array.isArray(e)) {
- var o = t.getEngine().getCaps()
- , a = {
- supportedCompressionFormats: {
- etc1: !!o.etc1,
- s3tc: !!o.s3tc,
- pvrtc: !!o.pvrtc,
- etc2: !!o.etc2
- }
- };
- lm(e, a).then((function(e) {
- var i = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps;
- cm(t, e),
- t.getEngine()._setCubeMapTextureParams(t, i),
- t.isReady = !0,
- t.onLoadedObservable.notifyObservers(t),
- t.onLoadedObservable.clear(),
- n && n()
- }
- )).catch((function(e) {
- gi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),
- t.isReady = !0,
- r && r(e)
- }
- ))
- }
- }
- ,
- e.prototype.loadData = function(e, t, i) {
- var n = t.getEngine().getCaps()
- , r = {
- supportedCompressionFormats: {
- etc1: !!n.etc1,
- s3tc: !!n.s3tc,
- pvrtc: !!n.pvrtc,
- etc2: !!n.etc2
- }
- };
- lm(e, r).then((function(e) {
- var n = e.fileInfo.images[0].levels[0]
- , r = e.fileInfo.images[0].levels.length > 1 && t.generateMipMaps;
- i(n.width, n.height, r, -1 !== e.format, (function() {
- cm(t, e)
- }
- ))
- }
- )).catch((function() {
- gi.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),
- i(0, 0, !1, !1, (function() {}
- ), !0)
- }
- ))
- }
- ,
- e
- }();
- vr._TextureLoaders.push(new dm);
- var pm = function(e) {
- function t(t, i, n, r, o, s) {
- var l = this
- , c = !(!o || !o.generateMipMaps) && o.generateMipMaps
- , u = !(!o || !o.generateDepthTexture) && o.generateDepthTexture
- , h = o && o.depthTextureFormat ? o.depthTextureFormat : a.TEXTUREFORMAT_DEPTH16
- , d = !o || void 0 === o.doNotChangeAspectRatio || o.doNotChangeAspectRatio
- , p = !(!o || !o.drawOnlyOnFirstAttachmentByDefault) && o.drawOnlyOnFirstAttachmentByDefault;
- if (!(l = e.call(this, t, i, r, c, d, void 0, void 0, void 0, void 0, void 0, void 0, void 0, !0) || this).isSupported)
- return l.dispose(),
- l;
- var f = []
- , _ = [];
- l._initTypes(n, f, _, o);
- var m = !o || void 0 === o.generateDepthBuffer || o.generateDepthBuffer
- , g = !(!o || void 0 === o.generateStencilBuffer) && o.generateStencilBuffer;
- return l._size = i,
- l._multiRenderTargetOptions = {
- samplingModes: _,
- generateMipMaps: c,
- generateDepthBuffer: m,
- generateStencilBuffer: g,
- generateDepthTexture: u,
- depthTextureFormat: h,
- types: f,
- textureCount: n
- },
- l._count = n,
- l._drawOnlyOnFirstAttachmentByDefault = p,
- n > 0 && (l._createInternalTextures(),
- l._createTextures(s)),
- l
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "isSupported", {
- get: function() {
- var e, t;
- return null !== (t = null === (e = this._engine) || void 0 === e ? void 0 : e.getCaps().drawBuffersExtension) && void 0 !== t && t
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "textures", {
- get: function() {
- return this._textures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "count", {
- get: function() {
- return this._count
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthTexture", {
- get: function() {
- return this._textures[this._textures.length - 1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wrapU", {
- set: function(e) {
- if (this._textures)
- for (var t = 0; t < this._textures.length; t++)
- this._textures[t].wrapU = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "wrapV", {
- set: function(e) {
- if (this._textures)
- for (var t = 0; t < this._textures.length; t++)
- this._textures[t].wrapV = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._initTypes = function(e, t, i, n) {
- for (var r = 0; r < e; r++)
- n && n.types && void 0 !== n.types[r] ? t.push(n.types[r]) : t.push(n && n.defaultType ? n.defaultType : a.TEXTURETYPE_UNSIGNED_INT),
- n && n.samplingModes && void 0 !== n.samplingModes[r] ? i.push(n.samplingModes[r]) : i.push(io.BILINEAR_SAMPLINGMODE)
- }
- ,
- t.prototype._rebuild = function(e, t) {
- if (void 0 === e && (e = !1),
- !(this._count < 1)) {
- this.releaseInternalTextures(),
- this._createInternalTextures(),
- e && (this._releaseTextures(),
- this._createTextures(t));
- for (var i = this._renderTarget.textures, n = 0; n < i.length; n++)
- this._textures[n]._texture = i[n];
- 1 !== this.samples && this._renderTarget.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, !0)
- }
- }
- ,
- t.prototype._createInternalTextures = function() {
- this._renderTarget = this._getEngine().createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault),
- this._texture = this._renderTarget.texture
- }
- ,
- t.prototype._releaseTextures = function() {
- if (this._textures)
- for (var e = 0; e < this._textures.length; e++)
- this._textures[e]._texture = null,
- this._textures[e].dispose()
- }
- ,
- t.prototype._createTextures = function(e) {
- var t = this._renderTarget.textures;
- this._textures = [];
- for (var i = 0; i < t.length; i++) {
- var n = new io(null,this.getScene());
- (null == e ? void 0 : e[i]) && (n.name = e[i]),
- n._texture = t[i],
- this._textures.push(n)
- }
- }
- ,
- t.prototype.setInternalTexture = function(e, t, i) {
- void 0 === i && (i = !0),
- this.renderTarget && (0 === t && (this._texture = e),
- this.renderTarget.setTexture(e, t, i),
- this.textures[t] || (this.textures[t] = new io(null,this.getScene())),
- this.textures[t]._texture = e,
- this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0,
- this._multiRenderTargetOptions.types && (this._multiRenderTargetOptions.types[t] = e.type),
- this._multiRenderTargetOptions.samplingModes && (this._multiRenderTargetOptions.samplingModes[t] = e.samplingMode))
- }
- ,
- Object.defineProperty(t.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(e) {
- this._renderTarget ? this._samples = this._renderTarget.setSamples(e) : this._samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.resize = function(e) {
- this._size = e,
- this._rebuild()
- }
- ,
- t.prototype.updateCount = function(e, t, i) {
- this._multiRenderTargetOptions.textureCount = e,
- this._count = e;
- var n = []
- , r = [];
- this._initTypes(e, n, r, t),
- this._multiRenderTargetOptions.types = n,
- this._multiRenderTargetOptions.samplingModes = r,
- this._rebuild(!0, i)
- }
- ,
- t.prototype._unbindFrameBuffer = function(e, t) {
- var i = this;
- this._renderTarget && e.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, (function() {
- i.onAfterRenderObservable.notifyObservers(t)
- }
- ))
- }
- ,
- t.prototype.dispose = function(t) {
- void 0 === t && (t = !1),
- this._releaseTextures(),
- t ? this._texture = null : this.releaseInternalTextures(),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.releaseInternalTextures = function() {
- var e, t, i = null === (e = this._renderTarget) || void 0 === e ? void 0 : e.textures;
- if (i) {
- for (var n = i.length - 1; n >= 0; n--)
- this._textures[n]._texture = null;
- null === (t = this._renderTarget) || void 0 === t || t.dispose(),
- this._renderTarget = null
- }
- }
- ,
- t
- }(ns)
- , fm = function(e, t, i) {
- this.id = e,
- this.scale = t,
- this.offset = i
- }
- , _m = function() {
- function e(t, i, n, r) {
- var o, a, s, l, c, u, h, d, p, f, _, m, g;
- return this.name = t,
- this.meshes = i,
- this.scene = r,
- this.options = n,
- this.options.map = null !== (o = this.options.map) && void 0 !== o ? o : ["ambientTexture", "bumpTexture", "diffuseTexture", "emissiveTexture", "lightmapTexture", "opacityTexture", "reflectionTexture", "refractionTexture", "specularTexture"],
- this.options.uvsIn = null !== (a = this.options.uvsIn) && void 0 !== a ? a : Bi.UVKind,
- this.options.uvsOut = null !== (s = this.options.uvsOut) && void 0 !== s ? s : Bi.UVKind,
- this.options.layout = null !== (l = this.options.layout) && void 0 !== l ? l : e.LAYOUT_STRIP,
- this.options.layout === e.LAYOUT_COLNUM && (this.options.colnum = null !== (c = this.options.colnum) && void 0 !== c ? c : 8),
- this.options.updateInputMeshes = null === (u = this.options.updateInputMeshes) || void 0 === u || u,
- this.options.disposeSources = null === (h = this.options.disposeSources) || void 0 === h || h,
- this._expecting = 0,
- this.options.fillBlanks = null === (d = this.options.fillBlanks) || void 0 === d || d,
- !0 === this.options.fillBlanks && (this.options.customFillColor = null !== (p = this.options.customFillColor) && void 0 !== p ? p : "black"),
- this.options.frameSize = null !== (f = this.options.frameSize) && void 0 !== f ? f : 256,
- this.options.paddingRatio = null !== (_ = this.options.paddingRatio) && void 0 !== _ ? _ : .0115,
- this._paddingValue = Math.ceil(this.options.frameSize * this.options.paddingRatio),
- this._paddingValue % 2 != 0 && this._paddingValue++,
- this.options.paddingMode = null !== (m = this.options.paddingMode) && void 0 !== m ? m : e.SUBUV_WRAP,
- this.options.paddingMode === e.SUBUV_COLOR && (this.options.paddingColor = null !== (g = this.options.paddingColor) && void 0 !== g ? g : new N(0,0,0,1)),
- this.sets = {},
- this.frames = [],
- this
- }
- return e.prototype._createFrames = function(e) {
- for (var t = this, i = this._calculateSize(), n = new A(1,1).divide(i), r = 0, o = this._expecting, a = this.meshes.length, s = Object.keys(this.sets), l = 0; l < s.length; l++) {
- var c = s[l]
- , u = new Ds(this.name + ".TexturePack." + c + "Set",{
- width: i.x,
- height: i.y
- },this.scene,!0,io.TRILINEAR_SAMPLINGMODE,vr.TEXTUREFORMAT_RGBA)
- , h = u.getContext();
- h.fillStyle = "rgba(0,0,0,0)",
- h.fillRect(0, 0, i.x, i.y),
- u.update(!1),
- this.sets[c] = u
- }
- var d = this.options.frameSize || 256
- , p = this._paddingValue
- , f = d + 2 * p;
- for (l = 0; l < a; l++)
- for (var _ = this.meshes[l].material, m = function(a) {
- var c = new Ds("temp",f,g.scene,!0)
- , u = c.getContext()
- , h = g._getFrameOffset(l)
- , m = function() {
- r++,
- c.update(!1);
- var a = u.getImageData(0, 0, f, f)
- , s = t.sets[v];
- if (s.getContext().putImageData(a, i.x * h.x, i.y * h.y),
- c.dispose(),
- s.update(!1),
- r == o)
- return t._calculateMeshUVFrames(d, p, i, n, t.options.updateInputMeshes || !1),
- void e()
- }
- , v = s[a] || "_blank";
- if (_ && null !== _[v]) {
- var y = _[v]
- , b = new Image;
- b.src = y instanceof Ds ? y.getContext().canvas.toDataURL("image/png") : y.url,
- gi.SetCorsBehavior(b.src, b),
- b.onload = function() {
- u.fillStyle = "rgba(0,0,0,0)",
- u.fillRect(0, 0, f, f),
- c.update(!1),
- u.setTransform(1, 0, 0, -1, 0, 0);
- var e = [0, 0, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -2, 0, -1, 1, -1];
- switch (t.options.paddingMode) {
- case 0:
- for (var i = 0; i < 9; i++)
- u.drawImage(b, 0, 0, b.width, b.height, p + d * e[i], p + d * e[i + 1] - f, d, d);
- break;
- case 1:
- for (var n = 0; n < p; n++)
- u.drawImage(b, 0, 0, b.width, b.height, n + d * e[0], p - f, d, d),
- u.drawImage(b, 0, 0, b.width, b.height, 2 * p - n, p - f, d, d),
- u.drawImage(b, 0, 0, b.width, b.height, p, n - f, d, d),
- u.drawImage(b, 0, 0, b.width, b.height, p, 2 * p - n - f, d, d);
- u.drawImage(b, 0, 0, b.width, b.height, p + d * e[0], p + d * e[1] - f, d, d);
- break;
- case 2:
- u.fillStyle = (t.options.paddingColor || D.Black()).toHexString(),
- u.fillRect(0, 0, f, -f),
- u.clearRect(p, p, d, d),
- u.drawImage(b, 0, 0, b.width, b.height, p + d * e[0], p + d * e[1] - f, d, d)
- }
- u.setTransform(1, 0, 0, 1, 0, 0),
- m()
- }
- } else
- u.fillStyle = "rgba(0,0,0,0)",
- g.options.fillBlanks && (u.fillStyle = g.options.customFillColor),
- u.fillRect(0, 0, f, f),
- m()
- }, g = this, v = 0; v < s.length; v++)
- m(v)
- }
- ,
- e.prototype._calculateSize = function() {
- var e = this.meshes.length || 0
- , t = this.options.frameSize || 0
- , i = this._paddingValue || 0;
- switch (this.options.layout) {
- case 0:
- return new A(t * e + 2 * i * e,t + 2 * i);
- case 1:
- var n = Math.max(2, Math.ceil(Math.sqrt(e)))
- , r = t * n + 2 * i * n;
- return new A(r,r);
- case 2:
- var o = this.options.colnum || 1
- , a = Math.max(1, Math.ceil(e / o));
- return new A(t * o + 2 * i * o,t * a + 2 * i * a)
- }
- return A.Zero()
- }
- ,
- e.prototype._calculateMeshUVFrames = function(e, t, i, n, r) {
- for (var o = this.meshes.length, a = 0; a < o; a++) {
- var s = this.meshes[a]
- , l = new A(e / i.x,e / i.y)
- , c = n.clone().scale(t)
- , u = this._getFrameOffset(a).add(c)
- , h = new fm(a,l,u);
- this.frames.push(h),
- r && (this._updateMeshUV(s, a),
- this._updateTextureReferences(s))
- }
- }
- ,
- e.prototype._getFrameOffset = function(e) {
- var t, i, n, r = this.meshes.length;
- switch (this.options.layout) {
- case 0:
- return new A(e * (t = 1 / r),0);
- case 1:
- var o = Math.max(2, Math.ceil(Math.sqrt(r)));
- return i = Math.floor(e / o),
- new A((n = e - i * o) * (t = 1 / o),i * t);
- case 2:
- var a = this.options.colnum || 1
- , s = Math.max(1, Math.ceil(r / a));
- return i = e - (n = Math.floor(e / s)) * s,
- t = new A(1 / a,1 / s),
- new A(n * t.x,i * t.y)
- }
- return A.Zero()
- }
- ,
- e.prototype._updateMeshUV = function(e, t) {
- var i = this.frames[t]
- , n = e.getVerticesData(this.options.uvsIn || Bi.UVKind)
- , r = []
- , o = 0;
- n.length && (o = n.length || 0);
- for (var a = 0; a < o; a += 2)
- r.push(n[a] * i.scale.x + i.offset.x, n[a + 1] * i.scale.y + i.offset.y);
- e.setVerticesData(this.options.uvsOut || Bi.UVKind, r)
- }
- ,
- e.prototype._updateTextureReferences = function(e, t) {
- void 0 === t && (t = !1);
- for (var i = e.material, n = Object.keys(this.sets), r = function(e) {
- e.dispose && e.dispose()
- }, o = 0; o < n.length; o++) {
- var a = n[o];
- if (t)
- null !== i[a] && r(i[a]),
- i[a] = this.sets[a];
- else {
- if (!i)
- return;
- null !== i[a] && (r(i[a]),
- i[a] = this.sets[a])
- }
- }
- }
- ,
- e.prototype.setMeshToFrame = function(e, t, i) {
- void 0 === i && (i = !1),
- this._updateMeshUV(e, t),
- i && this._updateTextureReferences(e, !0)
- }
- ,
- e.prototype.processAsync = function() {
- var e = this;
- return new Promise((function(t, i) {
- try {
- if (0 === e.meshes.length)
- return void t();
- for (var n = 0, r = function(i) {
- var r = e.meshes[i]
- , o = r.material;
- if (!o)
- return ++n === e.meshes.length ? {
- value: e._createFrames(t)
- } : "continue";
- o.forceCompilationAsync(r).then((function() {
- !function(i) {
- if (n++,
- e.options.map) {
- for (var r = 0; r < e.options.map.length; r++)
- null !== i[e.options.map[r]] && (e.sets[e.options.map[r]] || (e.sets[e.options.map[r]] = !0),
- e._expecting++);
- n === e.meshes.length && e._createFrames(t)
- }
- }(o)
- }
- ))
- }, o = 0; o < e.meshes.length; o++) {
- var a = r(o);
- if ("object" == typeof a)
- return a.value
- }
- } catch (e) {
- return i(e)
- }
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- for (var e = Object.keys(this.sets), t = 0; t < e.length; t++) {
- var i = e[t];
- this.sets[i].dispose()
- }
- }
- ,
- e.prototype.download = function(e, t) {
- var i = this;
- void 0 === e && (e = "png"),
- void 0 === t && (t = 1),
- setTimeout((function() {
- var n = {
- name: i.name,
- sets: {},
- options: {},
- frames: []
- }
- , r = Object.keys(i.sets)
- , o = Object.keys(i.options);
- try {
- for (var a = 0; a < r.length; a++) {
- var s = r[a]
- , l = i.sets[s];
- n.sets[s] = l.getContext().canvas.toDataURL("image/" + e, t)
- }
- for (a = 0; a < o.length; a++) {
- var c = o[a];
- n.options[c] = i.options[c]
- }
- for (a = 0; a < i.frames.length; a++) {
- var u = i.frames[a];
- n.frames.push(u.scale.x, u.scale.y, u.offset.x, u.offset.y)
- }
- } catch (e) {
- return void K.Warn("Unable to download: " + e)
- }
- var h = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(n, null, 4))
- , d = document.createElement("a");
- d.setAttribute("href", h),
- d.setAttribute("download", i.name + "_texurePackage.json"),
- document.body.appendChild(d),
- d.click(),
- d.remove()
- }
- ), 0)
- }
- ,
- e.prototype.updateFromJSON = function(e) {
- try {
- var t = JSON.parse(e);
- this.name = t.name;
- for (var i = Object.keys(t.options), n = 0; n < i.length; n++)
- this.options[i[n]] = t.options[i[n]];
- for (n = 0; n < t.frames.length; n += 4) {
- var r = new fm(n / 4,new A(t.frames[n],t.frames[n + 1]),new A(t.frames[n + 2],t.frames[n + 3]));
- this.frames.push(r)
- }
- var o = Object.keys(t.sets);
- for (n = 0; n < o.length; n++) {
- var a = new io(t.sets[o[n]],this.scene,!1,!1);
- this.sets[o[n]] = a
- }
- } catch (e) {
- K.Warn("Unable to update from JSON: " + e)
- }
- }
- ,
- e.LAYOUT_STRIP = 0,
- e.LAYOUT_POWER2 = 1,
- e.LAYOUT_COLNUM = 2,
- e.SUBUV_WRAP = 0,
- e.SUBUV_EXTEND = 1,
- e.SUBUV_COLOR = 2,
- e
- }()
- , mm = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, n, null, r, o, a) || this;
- return s._animate = !0,
- s._time = 0,
- s._texturePath = i,
- s._loadJson(i),
- s.refreshRate = 1,
- s
- }
- return U(t, e),
- t.prototype._loadJson = function(e) {
- var t = this
- , i = function() {
- try {
- t.setFragment(t._texturePath)
- } catch (e) {
- K.Log("No json or ShaderStore or DOM element found for CustomProceduralTexture")
- }
- }
- , n = e + "/config.json"
- , r = new Ye;
- r.open("GET", n),
- r.addEventListener("load", (function() {
- if (200 === r.status || r.responseText && r.responseText.length > 0)
- try {
- t._config = JSON.parse(r.response),
- t.updateShaderUniforms(),
- t.updateTextures(),
- t.setFragment(t._texturePath + "/custom"),
- t._animate = t._config.animate,
- t.refreshRate = t._config.refreshrate
- } catch (e) {
- i()
- }
- else
- i()
- }
- ), !1),
- r.addEventListener("error", (function() {
- i()
- }
- ), !1);
- try {
- r.send()
- } catch (e) {
- K.Error("CustomProceduralTexture: Error on XHR send request.")
- }
- }
- ,
- t.prototype.isReady = function() {
- if (!e.prototype.isReady.call(this))
- return !1;
- for (var t in this._textures)
- if (!this._textures[t].isReady())
- return !1;
- return !0
- }
- ,
- t.prototype.render = function(t) {
- var i = this.getScene();
- this._animate && i && (this._time += .03 * i.getAnimationRatio(),
- this.updateShaderUniforms()),
- e.prototype.render.call(this, t)
- }
- ,
- t.prototype.updateTextures = function() {
- for (var e = 0; e < this._config.sampler2Ds.length; e++)
- this.setTexture(this._config.sampler2Ds[e].sample2Dname, new io(this._texturePath + "/" + this._config.sampler2Ds[e].textureRelativeUrl,this.getScene()))
- }
- ,
- t.prototype.updateShaderUniforms = function() {
- if (this._config)
- for (var e = 0; e < this._config.uniforms.length; e++) {
- var t = this._config.uniforms[e];
- switch (t.type) {
- case "float":
- this.setFloat(t.name, t.value);
- break;
- case "color3":
- this.setColor3(t.name, new D(t.r,t.g,t.b));
- break;
- case "color4":
- this.setColor4(t.name, new N(t.r,t.g,t.b,t.a));
- break;
- case "vector2":
- this.setVector2(t.name, new A(t.x,t.y));
- break;
- case "vector3":
- this.setVector3(t.name, new x(t.x,t.y,t.z))
- }
- }
- this.setFloat("time", this._time)
- }
- ,
- Object.defineProperty(t.prototype, "animate", {
- get: function() {
- return this._animate
- },
- set: function(e) {
- this._animate = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t
- }(xf);
- Pt.ShadersStore.noisePixelShader = "uniform float brightness;\nuniform float persistence;\nuniform float timeScale;\nvarying vec2 vUV;\nvec2 hash22(vec2 p)\n{\np=p*mat2(127.1,311.7,269.5,183.3);\np=-1.0+2.0*fract(sin(p)*43758.5453123);\nreturn sin(p*6.283+timeScale);\n}\nfloat interpolationNoise(vec2 p)\n{\nvec2 pi=floor(p);\nvec2 pf=p-pi;\nvec2 w=pf*pf*(3.-2.*pf);\nfloat f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));\nfloat f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));\nfloat f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));\nfloat f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));\nfloat xm1=mix(f00,f10,w.x);\nfloat xm2=mix(f01,f11,w.x);\nfloat ym=mix(xm1,xm2,w.y); \nreturn ym;\n}\nfloat perlinNoise2D(float x,float y)\n{\nfloat sum=0.0;\nfloat frequency=0.0;\nfloat amplitude=0.0;\nfor(int i=0; i<OCTAVES; i++)\n{\nfrequency=pow(2.0,float(i));\namplitude=pow(persistence,float(i));\nsum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;\n}\nreturn sum;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat x=abs(vUV.x);\nfloat y=abs(vUV.y);\nfloat noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);\ngl_FragColor=vec4(noise,noise,noise,1.0);\n}\n";
- var gm = function(e) {
- function t(t, i, n, r, o) {
- void 0 === i && (i = 256),
- void 0 === n && (n = E.LastCreatedScene);
- var a = e.call(this, t, i, "noise", n, r, o) || this;
- return a.time = 0,
- a.brightness = .2,
- a.octaves = 3,
- a.persistence = .8,
- a.animationSpeedFactor = 1,
- a.autoClear = !1,
- a._updateShaderUniforms(),
- a
- }
- return U(t, e),
- t.prototype._updateShaderUniforms = function() {
- var e = this.getScene();
- e && (this.time += e.getAnimationRatio() * this.animationSpeedFactor * .01,
- this.setFloat("brightness", this.brightness),
- this.setFloat("persistence", this.persistence),
- this.setFloat("timeScale", this.time))
- }
- ,
- t.prototype._getDefines = function() {
- return "#define OCTAVES " + (0 | this.octaves)
- }
- ,
- t.prototype.render = function(t) {
- this._updateShaderUniforms(),
- e.prototype.render.call(this, t)
- }
- ,
- t.prototype.serialize = function() {
- var e = {
- customType: "BABYLON.NoiseProceduralTexture"
- };
- return e.brightness = this.brightness,
- e.octaves = this.octaves,
- e.persistence = this.persistence,
- e.animationSpeedFactor = this.animationSpeedFactor,
- e.size = this.getSize().width,
- e.generateMipMaps = this._generateMipMaps,
- e.time = this.time,
- e
- }
- ,
- t.prototype.clone = function() {
- var e = this.getSize()
- , i = new t(this.name,e.width,this.getScene(),this._fallbackTexture ? this._fallbackTexture : void 0,this._generateMipMaps);
- return i.hasAlpha = this.hasAlpha,
- i.level = this.level,
- i.coordinatesMode = this.coordinatesMode,
- i.brightness = this.brightness,
- i.octaves = this.octaves,
- i.persistence = this.persistence,
- i.animationSpeedFactor = this.animationSpeedFactor,
- i.time = this.time,
- i
- }
- ,
- t.Parse = function(e, i) {
- var n, r = new t(e.name,e.size,i,void 0,e.generateMipMaps);
- return r.brightness = e.brightness,
- r.octaves = e.octaves,
- r.persistence = e.persistence,
- r.animationSpeedFactor = e.animationSpeedFactor,
- r.time = null !== (n = e.time) && void 0 !== n ? n : 0,
- r
- }
- ,
- t
- }(xf);
- y("BABYLON.NoiseProceduralTexture", gm);
- var vm = function(e) {
- function t(t, i, n, r, o, s, l, c, u) {
- void 0 === r && (r = a.TEXTUREFORMAT_RGBA),
- void 0 === o && (o = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === s && (s = !1),
- void 0 === l && (l = !1),
- void 0 === c && (c = a.TEXTURE_TRILINEAR_SAMPLINGMODE),
- void 0 === u && (u = null);
- var h = e.call(this, "", t) || this;
- return h._texture = t.getEngine().createRawCubeTexture(i, n, r, o, s, l, c, u),
- h
- }
- return U(t, e),
- t.prototype.update = function(e, t, i, n, r) {
- void 0 === r && (r = null),
- this._texture.getEngine().updateRawCubeTexture(this._texture, e, t, i, n, r)
- }
- ,
- t.prototype.updateRGBDAsync = function(e, t, i, n) {
- return void 0 === t && (t = null),
- void 0 === i && (i = .8),
- void 0 === n && (n = 0),
- Kc(this._texture, e, t, i, n).then((function() {}
- ))
- }
- ,
- t.prototype.clone = function() {
- var e = this;
- return Ge.Clone((function() {
- var i = e.getScene()
- , n = e._texture
- , r = new t(i,n._bufferViewArray,n.width,n.format,n.type,n.generateMipMaps,n.invertY,n.samplingMode,n._compression);
- return n.source === At.CubeRawRGBD && r.updateRGBDAsync(n._bufferViewArrayArray, n._sphericalPolynomial, n._lodGenerationScale, n._lodGenerationOffset),
- r
- }
- ), this)
- }
- ,
- t
- }(Bd)
- , ym = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h) {
- void 0 === l && (l = !0),
- void 0 === c && (c = !1),
- void 0 === u && (u = io.TRILINEAR_SAMPLINGMODE),
- void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT);
- var d = e.call(this, null, s, !l, c) || this;
- return d.format = o,
- d._texture = s.getEngine().createRawTexture3D(t, i, n, r, o, l, c, u, null, h),
- d.is3D = !0,
- d
- }
- return U(t, e),
- t.prototype.update = function(e) {
- this._texture && this._getEngine().updateRawTexture3D(this._texture, e, this._texture.format, this._texture.invertY, null, this._texture.type)
- }
- ,
- t
- }(io)
- , bm = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t, i, n, r, !0) || this;
- return o.refractionPlane = new hn(0,1,0,1),
- o.depth = 2,
- o.onBeforeRenderObservable.add((function() {
- o.getScene().clipPlane = o.refractionPlane
- }
- )),
- o.onAfterRenderObservable.add((function() {
- o.getScene().clipPlane = null
- }
- )),
- o
- }
- return U(t, e),
- t.prototype.clone = function() {
- var e = this.getScene();
- if (!e)
- return this;
- var i = this.getSize()
- , n = new t(this.name,i.width,e,this._generateMipMaps);
- return n.hasAlpha = this.hasAlpha,
- n.level = this.level,
- n.refractionPlane = this.refractionPlane.clone(),
- this.renderList && (n.renderList = this.renderList.slice(0)),
- n.depth = this.depth,
- n
- }
- ,
- t.prototype.serialize = function() {
- if (!this.name)
- return null;
- var t = e.prototype.serialize.call(this);
- return t.mirrorPlane = this.refractionPlane.asArray(),
- t.depth = this.depth,
- t
- }
- ,
- t
- }(ns)
- , Tm = function(e) {
- function t(t, i, n) {
- var r = e.call(this, null) || this;
- return r._renderTarget = null,
- r._engine = t,
- r._renderTargetOptions = n,
- r.resize(i),
- r
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "renderTarget", {
- get: function() {
- return this._renderTarget
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.resize = function(e) {
- var t;
- null === (t = this._renderTarget) || void 0 === t || t.dispose(),
- this._renderTarget = null,
- this._texture = null,
- this._size = e,
- this._engine && (this._renderTarget = this._engine.createRenderTargetTexture(this._size, this._renderTargetOptions)),
- this._texture = this.renderTarget.texture
- }
- ,
- t.prototype.getInternalTexture = function() {
- return this._texture
- }
- ,
- t.prototype.getClassName = function() {
- return "ThinRenderTargetTexture"
- }
- ,
- t.prototype.dispose = function(e) {
- var t;
- void 0 === e && (e = !1),
- null === (t = this._renderTarget) || void 0 === t || t.dispose(!0),
- this._renderTarget = null,
- e || this.dispose()
- }
- ,
- t
- }(qr)
- , Em = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Vertex) || this;
- return i.registerInput("matricesIndices", Op.Vector4),
- i.registerInput("matricesWeights", Op.Vector4),
- i.registerInput("matricesIndicesExtra", Op.Vector4, !0),
- i.registerInput("matricesWeightsExtra", Op.Vector4, !0),
- i.registerInput("world", Op.Matrix),
- i.registerOutput("output", Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("boneSampler"),
- e._excludeVariableName("boneTextureWidth"),
- e._excludeVariableName("mBones"),
- e._excludeVariableName("BonesPerMesh")
- }
- ,
- t.prototype.getClassName = function() {
- return "BonesBlock"
- }
- ,
- Object.defineProperty(t.prototype, "matricesIndices", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "matricesWeights", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "matricesIndicesExtra", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "matricesWeightsExtra", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.matricesIndices.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "matricesIndices" === e.name
- }
- ));
- t || (t = new tf("matricesIndices")).setAsAttribute("matricesIndices"),
- t.output.connectTo(this.matricesIndices)
- }
- if (!this.matricesWeights.isConnected) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "matricesWeights" === e.name
- }
- ));
- i || (i = new tf("matricesWeights")).setAsAttribute("matricesWeights"),
- i.output.connectTo(this.matricesWeights)
- }
- if (!this.world.isConnected) {
- var n = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.World
- }
- ));
- n || (n = new tf("world")).setAsSystemValue(Qp.World),
- n.output.connectTo(this.world)
- }
- }
- ,
- t.prototype.provideFallbacks = function(e, t) {
- e && e.useBones && e.computeBonesUsingShaders && e.skeleton && t.addCPUSkinningFallback(0, e)
- }
- ,
- t.prototype.bind = function(e, t, i) {
- Mr.BindBonesParameters(i, e)
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- i._areAttributesDirty && Mr.PrepareDefinesForBones(e, i)
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t),
- t.sharedData.blocksWithFallbacks.push(this),
- t.sharedData.forcedBindableBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this),
- t.uniforms.push("boneTextureWidth"),
- t.uniforms.push("mBones"),
- t.samplers.push("boneSampler");
- var i = "//".concat(this.name);
- t._emitFunctionFromInclude("bonesDeclaration", i, {
- removeAttributes: !0,
- removeUniforms: !1,
- removeVaryings: !0,
- removeIfDef: !1
- });
- var n = t._getFreeVariableName("influence");
- t.compilationString += t._emitCodeFromInclude("bonesVertex", i, {
- replaceStrings: [{
- search: /finalWorld=finalWorld\*influence;/,
- replace: ""
- }, {
- search: /influence/gm,
- replace: n
- }]
- });
- var r = this._outputs[0]
- , o = this.world;
- return t.compilationString += "#if NUM_BONE_INFLUENCERS>0\r\n",
- t.compilationString += this._declareOutput(r, t) + " = ".concat(o.associatedVariableName, " * ").concat(n, ";\r\n"),
- t.compilationString += "#else\r\n",
- t.compilationString += this._declareOutput(r, t) + " = ".concat(o.associatedVariableName, ";\r\n"),
- t.compilationString += "#endif\r\n",
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.BonesBlock", Em);
- var Sm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Vertex) || this;
- return i.registerInput("world0", Op.Vector4),
- i.registerInput("world1", Op.Vector4),
- i.registerInput("world2", Op.Vector4),
- i.registerInput("world3", Op.Vector4),
- i.registerInput("world", Op.Matrix, !0),
- i.registerOutput("output", Op.Matrix),
- i.registerOutput("instanceID", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "InstancesBlock"
- }
- ,
- Object.defineProperty(t.prototype, "world0", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world1", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world2", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world3", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "instanceID", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.world0.connectedPoint) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "world0" === e.name
- }
- ));
- t || (t = new tf("world0")).setAsAttribute("world0"),
- t.output.connectTo(this.world0)
- }
- if (!this.world1.connectedPoint) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "world1" === e.name
- }
- ));
- i || (i = new tf("world1")).setAsAttribute("world1"),
- i.output.connectTo(this.world1)
- }
- if (!this.world2.connectedPoint) {
- var n = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "world2" === e.name
- }
- ));
- n || (n = new tf("world2")).setAsAttribute("world2"),
- n.output.connectTo(this.world2)
- }
- if (!this.world3.connectedPoint) {
- var r = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "world3" === e.name
- }
- ));
- r || (r = new tf("world3")).setAsAttribute("world3"),
- r.output.connectTo(this.world3)
- }
- if (!this.world.connectedPoint) {
- var o = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "world" === e.name
- }
- ));
- o || (o = new tf("world")).setAsSystemValue(Qp.World),
- o.output.connectTo(this.world)
- }
- this.world.define = "!INSTANCES || THIN_INSTANCES"
- }
- ,
- t.prototype.prepareDefines = function(e, t, i, n, r) {
- void 0 === n && (n = !1);
- var o = !1;
- i.INSTANCES !== n && (i.setValue("INSTANCES", n),
- o = !0),
- r && i.THIN_INSTANCES !== !!(null == r ? void 0 : r.getRenderingMesh().hasThinInstances) && (i.setValue("THIN_INSTANCES", !!(null == r ? void 0 : r.getRenderingMesh().hasThinInstances)),
- o = !0),
- o && i.markAsUnprocessed()
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = t.sharedData.scene.getEngine();
- t.sharedData.blocksWithDefines.push(this);
- var n = this._outputs[0]
- , r = this._outputs[1]
- , o = this.world0
- , a = this.world1
- , s = this.world2
- , l = this.world3;
- return t.compilationString += "#ifdef INSTANCES\r\n",
- t.compilationString += this._declareOutput(n, t) + " = mat4(".concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ", ").concat(s.associatedVariableName, ", ").concat(l.associatedVariableName, ");\r\n"),
- t.compilationString += "#ifdef THIN_INSTANCES\r\n",
- t.compilationString += "".concat(n.associatedVariableName, " = ").concat(this.world.associatedVariableName, " * ").concat(n.associatedVariableName, ";\r\n"),
- t.compilationString += "#endif\r\n",
- i._caps.canUseGLInstanceID ? t.compilationString += this._declareOutput(r, t) + " = float(gl_InstanceID);\r\n" : t.compilationString += this._declareOutput(r, t) + " = 0.0;\r\n",
- t.compilationString += "#else\r\n",
- t.compilationString += this._declareOutput(n, t) + " = ".concat(this.world.associatedVariableName, ";\r\n"),
- t.compilationString += this._declareOutput(r, t) + " = 0.0;\r\n",
- t.compilationString += "#endif\r\n",
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.InstancesBlock", Sm);
- var Am = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Vertex) || this;
- return i.registerInput("position", Op.Vector3),
- i.registerInput("normal", Op.Vector3),
- i.registerInput("tangent", Op.Vector3),
- i.registerInput("uv", Op.Vector2),
- i.registerOutput("positionOutput", Op.Vector3),
- i.registerOutput("normalOutput", Op.Vector3),
- i.registerOutput("tangentOutput", Op.Vector3),
- i.registerOutput("uvOutput", Op.Vector2),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "MorphTargetsBlock"
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tangent", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "positionOutput", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normalOutput", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tangentOutput", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uvOutput", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("morphTargetInfluences")
- }
- ,
- t.prototype.autoConfigure = function(e) {
- if (!this.position.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "position" === e.name
- }
- ));
- t || (t = new tf("position")).setAsAttribute(),
- t.output.connectTo(this.position)
- }
- if (!this.normal.isConnected) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "normal" === e.name
- }
- ));
- i || (i = new tf("normal")).setAsAttribute("normal"),
- i.output.connectTo(this.normal)
- }
- if (!this.tangent.isConnected) {
- var n = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "tangent" === e.name
- }
- ));
- n || (n = new tf("tangent")).setAsAttribute("tangent"),
- n.output.connectTo(this.tangent)
- }
- if (!this.uv.isConnected) {
- var r = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "uv" === e.name
- }
- ));
- r || (r = new tf("uv")).setAsAttribute("uv"),
- r.output.connectTo(this.uv)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- if (e.morphTargetManager) {
- var n = e.morphTargetManager;
- (null == n ? void 0 : n.isUsingTextureForTargets) && n.numInfluencers !== i.NUM_MORPH_INFLUENCERS && i.markAsAttributesDirty()
- }
- i._areAttributesDirty && Mr.PrepareDefinesForMorphTargets(e, i)
- }
- ,
- t.prototype.bind = function(e, t, i) {
- i && i.morphTargetManager && i.morphTargetManager.numInfluencers > 0 && (Mr.BindMorphTargetParameters(i, e),
- i.morphTargetManager.isUsingTextureForTargets && i.morphTargetManager._bind(e))
- }
- ,
- t.prototype.replaceRepeatableContent = function(e, t, i, n) {
- var r = this.position
- , o = this.normal
- , a = this.tangent
- , s = this.uv
- , l = this.positionOutput
- , c = this.normalOutput
- , u = this.tangentOutput
- , h = this.uvOutput
- , d = e
- , p = n.NUM_MORPH_INFLUENCERS
- , f = i.morphTargetManager
- , _ = f && f.supportsNormals && n.NORMAL
- , m = f && f.supportsTangents && n.TANGENT
- , g = f && f.supportsUVs && n.UV1
- , v = "";
- (null == f ? void 0 : f.isUsingTextureForTargets) && p > 0 && (v += "float vertexID;\r\n");
- for (var y = 0; y < p; y++)
- v += "#ifdef MORPHTARGETS\r\n",
- (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\r\n",
- v += "".concat(l.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(r.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
- v += "vertexID += 1.0;\r\n") : v += "".concat(l.associatedVariableName, " += (position").concat(y, " - ").concat(r.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
- _ && (v += "#ifdef MORPHTARGETS_NORMAL\r\n",
- (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(c.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
- v += "vertexID += 1.0;\r\n") : v += "".concat(c.associatedVariableName, " += (normal").concat(y, " - ").concat(o.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
- v += "#endif\r\n"),
- g && (v += "#ifdef MORPHTARGETS_UV\r\n",
- (null == f ? void 0 : f.isUsingTextureForTargets) ? (v += "".concat(h.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID).xy - ").concat(s.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n"),
- v += "vertexID += 1.0;\r\n") : v += "".concat(h.associatedVariableName, ".xy += (uv_").concat(y, " - ").concat(s.associatedVariableName, ".xy) * morphTargetInfluences[").concat(y, "];\r\n"),
- v += "#endif\r\n"),
- m && (v += "#ifdef MORPHTARGETS_TANGENT\r\n",
- (null == f ? void 0 : f.isUsingTextureForTargets) ? v += "".concat(u.associatedVariableName, " += (readVector3FromRawSampler(").concat(y, ", vertexID) - ").concat(a.associatedVariableName, ") * morphTargetInfluences[").concat(y, "];\r\n") : v += "".concat(u.associatedVariableName, ".xyz += (tangent").concat(y, " - ").concat(a.associatedVariableName, ".xyz) * morphTargetInfluences[").concat(y, "];\r\n"),
- v += "#endif\r\n"),
- v += "#endif\r\n";
- if (d.compilationString = d.compilationString.replace(this._repeatableContentAnchor, v),
- p > 0)
- for (y = 0; y < p; y++)
- d.attributes.push(Bi.PositionKind + y),
- _ && d.attributes.push(Bi.NormalKind + y),
- m && d.attributes.push(Bi.TangentKind + y),
- g && d.attributes.push(Bi.UVKind + "_" + y)
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t),
- t.sharedData.blocksWithDefines.push(this),
- t.sharedData.bindableBlocks.push(this),
- t.sharedData.repeatableContentBlocks.push(this);
- var i = this.position
- , n = this.normal
- , r = this.tangent
- , o = this.uv
- , a = this.positionOutput
- , s = this.normalOutput
- , l = this.tangentOutput
- , c = this.uvOutput
- , u = "//".concat(this.name);
- return t.uniforms.push("morphTargetInfluences"),
- t.uniforms.push("morphTargetTextureInfo"),
- t.uniforms.push("morphTargetTextureIndices"),
- t.samplers.push("morphTargets"),
- t._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", u),
- t._emitFunctionFromInclude("morphTargetsVertexDeclaration", u, {
- repeatKey: "maxSimultaneousMorphTargets"
- }),
- t.compilationString += "".concat(this._declareOutput(a, t), " = ").concat(i.associatedVariableName, ";\r\n"),
- t.compilationString += "#ifdef NORMAL\r\n",
- t.compilationString += "".concat(this._declareOutput(s, t), " = ").concat(n.associatedVariableName, ";\r\n"),
- t.compilationString += "#else\r\n",
- t.compilationString += "".concat(this._declareOutput(s, t), " = vec3(0., 0., 0.);\r\n"),
- t.compilationString += "#endif\r\n",
- t.compilationString += "#ifdef TANGENT\r\n",
- t.compilationString += "".concat(this._declareOutput(l, t), " = ").concat(r.associatedVariableName, ";\r\n"),
- t.compilationString += "#else\r\n",
- t.compilationString += "".concat(this._declareOutput(l, t), " = vec3(0., 0., 0.);\r\n"),
- t.compilationString += "#endif\r\n",
- t.compilationString += "#ifdef UV1\r\n",
- t.compilationString += "".concat(this._declareOutput(c, t), " = ").concat(o.associatedVariableName, ";\r\n"),
- t.compilationString += "#else\r\n",
- t.compilationString += "".concat(this._declareOutput(c, t), " = vec2(0., 0.);\r\n"),
- t.compilationString += "#endif\r\n",
- this._repeatableContentAnchor = t._repeatableContentAnchor,
- t.compilationString += this._repeatableContentAnchor,
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.MorphTargetsBlock", Am);
- var xm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Vertex) || this;
- return i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
- i.registerOutput("direction", Op.Vector3),
- i.registerOutput("color", Op.Color3),
- i.registerOutput("intensity", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "LightInformationBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "direction", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "intensity", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.bind = function(e, t, i) {
- if (i) {
- this.light && this.light.isDisposed && (this.light = null);
- var n = this.light
- , r = t.getScene();
- if (!n && r.lights.length && (n = this.light = r.lights[0],
- this._forcePrepareDefines = !0),
- !n || !n.isEnabled)
- return e.setFloat3(this._lightDataUniformName, 0, 0, 0),
- void e.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
- n.transferToNodeMaterialEffect(e, this._lightDataUniformName),
- e.setColor4(this._lightColorUniformName, n.diffuse, n.intensity)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- if (i._areLightsDirty || this._forcePrepareDefines) {
- this._forcePrepareDefines = !1;
- var n = this.light;
- i.setValue(this._lightTypeDefineName, !!(n && n instanceof __), !0)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t),
- t.sharedData.bindableBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this);
- var i = this.direction
- , n = this.color
- , r = this.intensity;
- return this._lightDataUniformName = t._getFreeVariableName("lightData"),
- this._lightColorUniformName = t._getFreeVariableName("lightColor"),
- this._lightTypeDefineName = t._getFreeDefineName("LIGHTPOINTTYPE"),
- t._emitUniformFromString(this._lightDataUniformName, "vec3"),
- t._emitUniformFromString(this._lightColorUniformName, "vec4"),
- t.compilationString += "#ifdef ".concat(this._lightTypeDefineName, "\r\n"),
- t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.worldPosition.associatedVariableName, ".xyz - ").concat(this._lightDataUniformName, ");\r\n"),
- t.compilationString += "#else\r\n",
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this._lightDataUniformName, ";\r\n"),
- t.compilationString += "#endif\r\n",
- t.compilationString += this._declareOutput(n, t) + " = ".concat(this._lightColorUniformName, ".rgb;\r\n"),
- t.compilationString += this._declareOutput(r, t) + " = ".concat(this._lightColorUniformName, ".a;\r\n"),
- this
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return this.light && (t.lightId = this.light.id),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- t.lightId && (this.light = i.getLightById(t.lightId))
- }
- ,
- t
- }(Wp);
- y("BABYLON.LightInformationBlock", xm);
- var Rm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.convertInputToLinearSpace = !0,
- i.registerInput("color", Op.Color4),
- i.registerOutput("output", Op.Color4),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ImageProcessingBlock"
- }
- ,
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("exposureLinear"),
- e._excludeVariableName("contrast"),
- e._excludeVariableName("vInverseScreenSize"),
- e._excludeVariableName("vignetteSettings1"),
- e._excludeVariableName("vignetteSettings2"),
- e._excludeVariableName("vCameraColorCurveNegative"),
- e._excludeVariableName("vCameraColorCurveNeutral"),
- e._excludeVariableName("vCameraColorCurvePositive"),
- e._excludeVariableName("txColorTransform"),
- e._excludeVariableName("colorTransformSettings")
- }
- ,
- t.prototype.isReady = function(e, t, i) {
- return !(i._areImageProcessingDirty && t.imageProcessingConfiguration && !t.imageProcessingConfiguration.isReady())
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- i._areImageProcessingDirty && t.imageProcessingConfiguration && t.imageProcessingConfiguration.prepareDefines(i)
- }
- ,
- t.prototype.bind = function(e, t, i) {
- i && t.imageProcessingConfiguration && t.imageProcessingConfiguration.bind(e)
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t),
- t.sharedData.blocksWithDefines.push(this),
- t.sharedData.blockingBlocks.push(this),
- t.sharedData.bindableBlocks.push(this),
- t.uniforms.push("exposureLinear"),
- t.uniforms.push("contrast"),
- t.uniforms.push("vInverseScreenSize"),
- t.uniforms.push("vignetteSettings1"),
- t.uniforms.push("vignetteSettings2"),
- t.uniforms.push("vCameraColorCurveNegative"),
- t.uniforms.push("vCameraColorCurveNeutral"),
- t.uniforms.push("vCameraColorCurvePositive"),
- t.uniforms.push("txColorTransform"),
- t.uniforms.push("colorTransformSettings");
- var i = this.color
- , n = this._outputs[0]
- , r = "//".concat(this.name);
- return t._emitFunctionFromInclude("helperFunctions", r),
- t._emitFunctionFromInclude("imageProcessingDeclaration", r),
- t._emitFunctionFromInclude("imageProcessingFunctions", r),
- i.connectedPoint.type === Op.Color4 || i.connectedPoint.type === Op.Vector4 ? t.compilationString += "".concat(this._declareOutput(n, t), " = ").concat(i.associatedVariableName, ";\r\n") : t.compilationString += "".concat(this._declareOutput(n, t), " = vec4(").concat(i.associatedVariableName, ", 1.0);\r\n"),
- t.compilationString += "#ifdef IMAGEPROCESSINGPOSTPROCESS\r\n",
- this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(i.associatedVariableName, ".rgb);\r\n")),
- t.compilationString += "#else\r\n",
- t.compilationString += "#ifdef IMAGEPROCESSING\r\n",
- this.convertInputToLinearSpace && (t.compilationString += "".concat(n.associatedVariableName, ".rgb = toLinearSpace(").concat(i.associatedVariableName, ".rgb);\r\n")),
- t.compilationString += "".concat(n.associatedVariableName, " = applyImageProcessing(").concat(n.associatedVariableName, ");\r\n"),
- t.compilationString += "#endif\r\n",
- t.compilationString += "#endif\r\n",
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".convertInputToLinearSpace = ").concat(this.convertInputToLinearSpace, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.convertInputToLinearSpace = this.convertInputToLinearSpace,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- var r;
- e.prototype._deserialize.call(this, t, i, n),
- this.convertInputToLinearSpace = null === (r = t.convertInputToLinearSpace) || void 0 === r || r
- }
- ,
- k([Yp("Convert input to linear space", Xp.Boolean, "ADVANCED")], t.prototype, "convertInputToLinearSpace", void 0),
- t
- }(Wp);
- y("BABYLON.ImageProcessingBlock", Rm);
- var Cm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i._tangentSpaceParameterName = "",
- i.invertX = !1,
- i.invertY = !1,
- i.useParallaxOcclusion = !1,
- i._isUnique = !0,
- i.registerInput("worldPosition", Op.Vector4, !1),
- i.registerInput("worldNormal", Op.Vector4, !1),
- i.registerInput("worldTangent", Op.Vector4, !0),
- i.registerInput("uv", Op.Vector2, !1),
- i.registerInput("normalMapColor", Op.Color3, !1),
- i.registerInput("strength", Op.Float, !1),
- i.registerInput("viewDirection", Op.Vector3, !0),
- i.registerInput("parallaxScale", Op.Float, !0),
- i.registerInput("parallaxHeight", Op.Float, !0),
- i.registerOutput("output", Op.Vector4),
- i.registerOutput("uvOffset", Op.Vector2),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "PerturbNormalBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldNormal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldTangent", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normalMapColor", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "strength", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "viewDirection", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "parallaxScale", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "parallaxHeight", {
- get: function() {
- return this._inputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uvOffset", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.prepareDefines = function(e, t, i) {
- var n = this.normalMapColor.connectedPoint._ownerBlock.samplerName
- , r = this.viewDirection.isConnected && (this.useParallaxOcclusion && n || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
- i.setValue("BUMP", !0),
- i.setValue("PARALLAX", r, !0),
- i.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0)
- }
- ,
- t.prototype.bind = function(e, t) {
- t.getScene()._mirroredCameraPosition ? e.setFloat2(this._tangentSpaceParameterName, this.invertX ? 1 : -1, this.invertY ? 1 : -1) : e.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1)
- }
- ,
- t.prototype.autoConfigure = function(e) {
- if (!this.uv.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "uv" === e.name
- }
- ));
- t || (t = new tf("uv")).setAsAttribute(),
- t.output.connectTo(this.uv)
- }
- if (!this.strength.isConnected) {
- var i = new tf("strength");
- i.value = 1,
- i.output.connectTo(this.strength)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = "//".concat(this.name)
- , n = this.uv
- , r = this.worldPosition
- , o = this.worldNormal
- , a = this.worldTangent;
- t.sharedData.blocksWithDefines.push(this),
- t.sharedData.bindableBlocks.push(this),
- this._tangentSpaceParameterName = t._getFreeDefineName("tangentSpaceParameter"),
- t._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
- var s = this.normalMapColor.connectedPoint._ownerBlock.samplerName
- , l = this.viewDirection.isConnected && (this.useParallaxOcclusion && s || !this.useParallaxOcclusion && this.parallaxHeight.isConnected)
- , c = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? t._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05"
- , u = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? "\r\n#if !defined(NORMALXYSCALE)\r\n1.0/\r\n#endif\r\n".concat(t._emitFloat(this.strength.connectInputBlock.value)) : "\r\n#if !defined(NORMALXYSCALE)\r\n1.0/\r\n#endif\r\n".concat(this.strength.associatedVariableName);
- t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
- var h = {
- search: /defined\(TANGENT\)/g,
- replace: a.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
- };
- a.isConnected && (t.compilationString += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
- t.compilationString += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\r\n"),
- t.compilationString += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
- t.compilationString += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
- t._emitFunctionFromInclude("bumpFragmentMainFunctions", i, {
- replaceStrings: [h, {
- search: /varying mat3 vTBN/g,
- replace: ""
- }]
- }),
- t._emitFunctionFromInclude("bumpFragmentFunctions", i, {
- 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\nvec2 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 d = l && s ? "texture2D(".concat(s, ", ").concat(n.associatedVariableName, " + uvOffset).xyz") : this.normalMapColor.associatedVariableName;
- return t.compilationString += this._declareOutput(this.output, t) + " = vec4(0.);\r\n",
- t.compilationString += t._emitCodeFromInclude("bumpFragment", i, {
- replaceStrings: [{
- search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,
- replace: "perturbNormal(TBN, ".concat(d, ", vBumpInfos.y)")
- }, {
- search: /parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,
- replace: "parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, ".concat(l && this.useParallaxOcclusion ? s : "bumpSampler", ")")
- }, {
- search: /parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,
- replace: "parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, ".concat(l ? this.parallaxHeight.associatedVariableName : "0.", ")")
- }, {
- search: /vTangentSpaceParams/g,
- replace: this._tangentSpaceParameterName
- }, {
- search: /vBumpInfos.y/g,
- replace: u
- }, {
- search: /vBumpInfos.z/g,
- replace: c
- }, {
- search: /vBumpUV/g,
- replace: n.associatedVariableName
- }, {
- search: /vPositionW/g,
- replace: r.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: o.associatedVariableName + ".xyz"
- }, {
- search: /viewDirectionW/g,
- replace: l ? this.viewDirection.associatedVariableName : "vec3(0.)"
- }, h]
- }),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".invertX = ").concat(this.invertX, ";\r\n");
- return (t += "".concat(this._codeVariableName, ".invertY = ").concat(this.invertY, ";\r\n")) + "".concat(this._codeVariableName, ".useParallaxOcclusion = ").concat(this.useParallaxOcclusion, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.invertX = this.invertX,
- t.invertY = this.invertY,
- t.useParallaxOcclusion = this.useParallaxOcclusion,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.invertX = t.invertX,
- this.invertY = t.invertY,
- this.useParallaxOcclusion = !!t.useParallaxOcclusion
- }
- ,
- k([Yp("Invert X axis", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !1
- }
- })], t.prototype, "invertX", void 0),
- k([Yp("Invert Y axis", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !1
- }
- })], t.prototype, "invertY", void 0),
- k([Yp("Use parallax occlusion", Xp.Boolean)], t.prototype, "useParallaxOcclusion", void 0),
- t
- }(Wp);
- y("BABYLON.PerturbNormalBlock", Cm);
- var Pm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment, !0) || this;
- return i.registerInput("value", Op.Float, !0),
- i.registerInput("cutoff", Op.Float, !0),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DiscardBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cutoff", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.sharedData.hints.needAlphaTesting = !0,
- this.cutoff.isConnected && this.value.isConnected)
- return t.compilationString += "if (".concat(this.value.associatedVariableName, " < ").concat(this.cutoff.associatedVariableName, ") discard;\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.DiscardBlock", Pm);
- var Mm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.registerOutput("output", Op.Float, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FrontFacingBlock"
- }
- ,
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target === Dp.Vertex)
- throw "FrontFacingBlock must only be used in a fragment shader";
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = gl_FrontFacing ? 1.0 : 0.0;\r\n",
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.FrontFacingBlock", Mm);
- var Im = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.registerInput("input", Op.AutoDetect, !1),
- i.registerOutput("dx", Op.BasedOnInput),
- i.registerOutput("dy", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._outputs[1]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DerivativeBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dx", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dy", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this._outputs[1];
- return t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
- i.hasEndpoints && (t.compilationString += this._declareOutput(i, t) + " = dFdx(".concat(this.input.associatedVariableName, ");\r\n")),
- n.hasEndpoints && (t.compilationString += this._declareOutput(n, t) + " = dFdy(".concat(this.input.associatedVariableName, ");\r\n")),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.DerivativeBlock", Im);
- var Om = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.registerOutput("xy", Op.Vector2, Dp.Fragment),
- i.registerOutput("xyz", Op.Vector3, Dp.Fragment),
- i.registerOutput("xyzw", Op.Vector4, Dp.Fragment),
- i.registerOutput("x", Op.Float, Dp.Fragment),
- i.registerOutput("y", Op.Float, Dp.Fragment),
- i.registerOutput("z", Op.Float, Dp.Fragment),
- i.registerOutput("w", Op.Float, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FragCoordBlock"
- }
- ,
- Object.defineProperty(t.prototype, "xy", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyz", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyzw", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "z", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.writeOutputs = function(e) {
- for (var t = "", i = 0, n = this._outputs; i < n.length; i++) {
- var r = n[i];
- r.hasEndpoints && (t += "".concat(this._declareOutput(r, e), " = gl_FragCoord.").concat(r.name, ";\r\n"))
- }
- return t
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target === Dp.Vertex)
- throw "FragCoordBlock must only be used in a fragment shader";
- return t.compilationString += this.writeOutputs(t),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.FragCoordBlock", Om);
- var Dm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.registerOutput("xy", Op.Vector2, Dp.Fragment),
- i.registerOutput("x", Op.Float, Dp.Fragment),
- i.registerOutput("y", Op.Float, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ScreenSizeBlock"
- }
- ,
- Object.defineProperty(t.prototype, "xy", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.bind = function(e) {
- var t = this._scene.getEngine();
- e.setFloat2(this._varName, t.getRenderWidth(), t.getRenderHeight())
- }
- ,
- t.prototype.writeOutputs = function(e, t) {
- for (var i = "", n = 0, r = this._outputs; n < r.length; n++) {
- var o = r[n];
- o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\r\n"))
- }
- return i
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this._scene = t.sharedData.scene,
- t.target === Dp.Vertex)
- throw "ScreenSizeBlock must only be used in a fragment shader";
- return t.sharedData.bindableBlocks.push(this),
- this._varName = t._getFreeVariableName("screenSize"),
- t._emitUniformFromString(this._varName, "vec2"),
- t.compilationString += this.writeOutputs(t, this._varName),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ScreenSizeBlock", Dm);
- var Nm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.registerInput("vector", Op.Vector3),
- i.registerInput("worldViewProjection", Op.Matrix),
- i.registerOutput("output", Op.Vector2),
- i.registerOutput("x", Op.Float),
- i.registerOutput("y", Op.Float),
- i.inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ScreenSpaceBlock"
- }
- ,
- Object.defineProperty(t.prototype, "vector", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldViewProjection", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.worldViewProjection.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.WorldViewProjection
- }
- ));
- t || (t = new tf("worldViewProjection")).setAsSystemValue(Qp.WorldViewProjection),
- t.output.connectTo(this.worldViewProjection)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.vector
- , n = this.worldViewProjection;
- if (i.connectedPoint) {
- var r = n.associatedVariableName
- , o = t._getFreeVariableName("screenSpaceTemp");
- switch (i.connectedPoint.type) {
- case Op.Vector3:
- t.compilationString += "vec4 ".concat(o, " = ").concat(r, " * vec4(").concat(i.associatedVariableName, ", 1.0);\r\n");
- break;
- case Op.Vector4:
- t.compilationString += "vec4 ".concat(o, " = ").concat(r, " * ").concat(i.associatedVariableName, ";\r\n")
- }
- return t.compilationString += "".concat(o, ".xy /= ").concat(o, ".w;"),
- t.compilationString += "".concat(o, ".xy = ").concat(o, ".xy * 0.5 + vec2(0.5, 0.5);"),
- this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(o, ".xy;\r\n")),
- this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(o, ".x;\r\n")),
- this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(o, ".y;\r\n")),
- this
- }
- }
- ,
- t
- }(Wp);
- y("BABYLON.ScreenSpaceBlock", Nm);
- var Lm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Fragment) || this;
- return i.registerInput("input", Op.Vector2),
- i.registerInput("strength", Op.Float),
- i.registerInput("center", Op.Vector2),
- i.registerInput("offset", Op.Vector2),
- i.registerOutput("output", Op.Vector2),
- i.registerOutput("x", Op.Float),
- i.registerOutput("y", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "TwirlBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "strength", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "center", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "offset", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function() {
- if (!this.center.isConnected) {
- var e = new tf("center");
- e.value = new A(.5,.5),
- e.output.connectTo(this.center)
- }
- if (!this.strength.isConnected) {
- var t = new tf("strength");
- t.value = 1,
- t.output.connectTo(this.strength)
- }
- if (!this.offset.isConnected) {
- var i = new tf("offset");
- i.value = new A(0,0),
- i.output.connectTo(this.offset)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = t._getFreeVariableName("delta")
- , n = t._getFreeVariableName("angle")
- , r = t._getFreeVariableName("x")
- , o = t._getFreeVariableName("y")
- , a = t._getFreeVariableName("result");
- return t.compilationString += "\n vec2 ".concat(i, " = ").concat(this.input.associatedVariableName, " - ").concat(this.center.associatedVariableName, ";\n float ").concat(n, " = ").concat(this.strength.associatedVariableName, " * length(").concat(i, ");\n float ").concat(r, " = cos(").concat(n, ") * ").concat(i, ".x - sin(").concat(n, ") * ").concat(i, ".y;\n float ").concat(o, " = sin(").concat(n, ") * ").concat(i, ".x + cos(").concat(n, ") * ").concat(i, ".y;\n vec2 ").concat(a, " = vec2(").concat(r, " + ").concat(this.center.associatedVariableName, ".x + ").concat(this.offset.associatedVariableName, ".x, ").concat(o, " + ").concat(this.center.associatedVariableName, ".y + ").concat(this.offset.associatedVariableName, ".y);\n "),
- this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(a, ";\r\n")),
- this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(a, ".x;\r\n")),
- this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(a, ".y;\r\n")),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.TwirlBlock", Lm);
- var Fm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.VertexAndFragment, !1) || this;
- return i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
- i.registerInput("view", Op.Matrix, !1, Dp.Vertex),
- i.registerInput("input", Op.Color3, !1, Dp.Fragment),
- i.registerInput("fogColor", Op.Color3, !1, Dp.Fragment),
- i.registerOutput("output", Op.Color3, Dp.Fragment),
- i.input.acceptedConnectionPointTypes.push(Op.Color4),
- i.fogColor.acceptedConnectionPointTypes.push(Op.Color4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FogBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "view", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fogColor", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.view.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.View
- }
- ));
- t || (t = new tf("view")).setAsSystemValue(Qp.View),
- t.output.connectTo(this.view)
- }
- if (!this.fogColor.isConnected) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.FogColor
- }
- ));
- i || (i = new tf("fogColor",void 0,Op.Color3)).setAsSystemValue(Qp.FogColor),
- i.output.connectTo(this.fogColor)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- var n = e.getScene();
- i.setValue("FOG", t.fogEnabled && Mr.GetFogState(e, n))
- }
- ,
- t.prototype.bind = function(e, t, i) {
- if (i) {
- var n = i.getScene();
- e.setFloat4(this._fogParameters, n.fogMode, n.fogStart, n.fogEnd, n.fogDensity)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target === Dp.Fragment) {
- t.sharedData.blocksWithDefines.push(this),
- t.sharedData.bindableBlocks.push(this),
- t._emitFunctionFromInclude("fogFragmentDeclaration", "//".concat(this.name), {
- removeUniforms: !0,
- removeVaryings: !0,
- removeIfDef: !1,
- replaceStrings: [{
- search: /float CalcFogFactor\(\)/,
- replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"
- }]
- });
- var i = t._getFreeVariableName("fog")
- , n = this.input
- , r = this.fogColor;
- this._fogParameters = t._getFreeVariableName("fogParameters");
- var o = this._outputs[0];
- t._emitUniformFromString(this._fogParameters, "vec4"),
- t.compilationString += "#ifdef FOG\r\n",
- t.compilationString += "float ".concat(i, " = CalcFogFactor(").concat(this._fogDistanceName, ", ").concat(this._fogParameters, ");\r\n"),
- t.compilationString += this._declareOutput(o, t) + " = ".concat(i, " * ").concat(n.associatedVariableName, ".rgb + (1.0 - ").concat(i, ") * ").concat(r.associatedVariableName, ".rgb;\r\n"),
- t.compilationString += "#else\r\n".concat(this._declareOutput(o, t), " = ").concat(n.associatedVariableName, ".rgb;\r\n"),
- t.compilationString += "#endif\r\n"
- } else {
- var a = this.worldPosition
- , s = this.view;
- this._fogDistanceName = t._getFreeVariableName("vFogDistance"),
- t._emitVaryingFromString(this._fogDistanceName, "vec3"),
- t.compilationString += "".concat(this._fogDistanceName, " = (").concat(s.associatedVariableName, " * ").concat(a.associatedVariableName, ").xyz;\r\n")
- }
- return this
- }
- ,
- t
- }(Wp);
- y("BABYLON.FogBlock", Fm);
- var wm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.VertexAndFragment) || this;
- return i._isUnique = !0,
- i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
- i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
- i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
- i.registerInput("glossiness", Op.Float, !0, Dp.Fragment),
- i.registerInput("glossPower", Op.Float, !0, Dp.Fragment),
- i.registerInput("diffuseColor", Op.Color3, !0, Dp.Fragment),
- i.registerInput("specularColor", Op.Color3, !0, Dp.Fragment),
- i.registerInput("view", Op.Matrix, !0),
- i.registerOutput("diffuseOutput", Op.Color3, Dp.Fragment),
- i.registerOutput("specularOutput", Op.Color3, Dp.Fragment),
- i.registerOutput("shadow", Op.Float, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "LightBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldNormal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "glossiness", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "glossPower", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "diffuseColor", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "specularColor", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "view", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "diffuseOutput", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "specularOutput", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadow", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.cameraPosition.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.CameraPosition
- }
- ));
- t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
- t.output.connectTo(this.cameraPosition)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- if (i._areLightsDirty) {
- var n = e.getScene();
- if (this.light) {
- var r = {
- needNormals: !1,
- needRebuild: !1,
- lightmapMode: !1,
- shadowEnabled: !1,
- specularEnabled: !1
- };
- Mr.PrepareDefinesForLight(n, e, this.light, this._lightId, i, !0, r),
- r.needRebuild && i.rebuild()
- } else
- Mr.PrepareDefinesForLights(n, e, i, !0, t.maxSimultaneousLights)
- }
- }
- ,
- t.prototype.updateUniformsAndSamples = function(e, t, i, n) {
- for (var r = 0; r < t.maxSimultaneousLights && i["LIGHT" + r]; r++) {
- var o = e.uniforms.indexOf("vLightData" + r) >= 0;
- Mr.PrepareUniformsAndSamplersForLight(r, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + r], n, o)
- }
- }
- ,
- t.prototype.bind = function(e, t, i) {
- if (i) {
- var n = i.getScene();
- this.light ? Mr.BindLight(this.light, this._lightId, n, e, !0) : Mr.BindLights(n, i, e, !0, t.maxSimultaneousLights)
- }
- }
- ,
- t.prototype._injectVertexCode = function(e) {
- var t = this.worldPosition
- , i = "//".concat(this.name);
- this.light ? (this._lightId = (void 0 !== e.counters.lightCounter ? e.counters.lightCounter : -1) + 1,
- e.counters.lightCounter = this._lightId,
- e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", i, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", i, {
- repeatKey: "maxSimultaneousLights"
- }),
- this._lightId = 0,
- e.sharedData.dynamicUniformBlocks.push(this));
- var n = "v_" + t.associatedVariableName;
- e._emitVaryingFromString(n, "vec4") && (e.compilationString += "".concat(n, " = ").concat(t.associatedVariableName, ";\r\n")),
- this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }, {
- search: /worldPos/g,
- replace: t.associatedVariableName
- }]
- }) : (e.compilationString += "vec4 worldPos = ".concat(t.associatedVariableName, ";\r\n"),
- this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, ";\r\n")),
- e.compilationString += e._emitCodeFromInclude("shadowsVertex", i, {
- repeatKey: "maxSimultaneousLights"
- }))
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- t.target === Dp.Fragment) {
- t.sharedData.forcedBindableBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this);
- var i = "//".concat(this.name)
- , n = this.worldPosition;
- t._emitFunctionFromInclude("helperFunctions", i),
- t._emitFunctionFromInclude("lightsFragmentFunctions", i, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: "v_" + n.associatedVariableName + ".xyz"
- }]
- }),
- t._emitFunctionFromInclude("shadowsFragmentFunctions", i, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: "v_" + n.associatedVariableName + ".xyz"
- }]
- }),
- this.light ? t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString()) : t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", i, {
- repeatKey: "maxSimultaneousLights"
- }),
- 0 === this._lightId && (t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat("v_" + n.associatedVariableName, ".xyz);\r\n")),
- t.compilationString += "lightingInfo info;\r\n",
- t.compilationString += "float shadow = 1.;\r\n",
- t.compilationString += "float glossiness = ".concat(this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0", " * ").concat(this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0", ";\r\n"),
- t.compilationString += "vec3 diffuseBase = vec3(0., 0., 0.);\r\n",
- t.compilationString += "vec3 specularBase = vec3(0., 0., 0.);\r\n",
- t.compilationString += "vec3 normalW = ".concat(this.worldNormal.associatedVariableName, ".xyz;\r\n")),
- this.light ? t.compilationString += t._emitCodeFromInclude("lightFragment", i, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }) : t.compilationString += t._emitCodeFromInclude("lightFragment", i, {
- repeatKey: "maxSimultaneousLights"
- });
- var r = this.diffuseOutput
- , o = this.specularOutput;
- return t.compilationString += this._declareOutput(r, t) + " = diffuseBase".concat(this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "", ";\r\n"),
- o.hasEndpoints && (t.compilationString += this._declareOutput(o, t) + " = specularBase".concat(this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "", ";\r\n")),
- this.shadow.hasEndpoints && (t.compilationString += this._declareOutput(this.shadow, t) + " = shadow;\r\n"),
- this
- }
- this._injectVertexCode(t)
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return this.light && (t.lightId = this.light.id),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- t.lightId && (this.light = i.getLightById(t.lightId))
- }
- ,
- t
- }(Wp);
- y("BABYLON.LightBlock", wm);
- var Bm = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, i, n) || this;
- return s._blockType = r,
- s._blockName = o,
- s._nameForCheking = a,
- s._nameForCheking || (s._nameForCheking = t),
- s.needDualDirectionValidation = !0,
- s
- }
- return U(t, e),
- t.prototype.checkCompatibilityState = function(e) {
- return e instanceof t && e.name === this._nameForCheking ? Up.Compatible : Up.TypeIncompatible
- }
- ,
- t.prototype.createCustomInputBlock = function() {
- return [new this._blockType(this._blockName), this.name]
- }
- ,
- t
- }(zp)
- , Um = function(e) {
- function t(i) {
- var n = e.call(this, i, Dp.VertexAndFragment) || this;
- return n.registerOutput("source", Op.Object, Dp.VertexAndFragment, new Bm("source",n,Vp.Output,t,"ImageSourceBlock")),
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "texture", {
- get: function() {
- return this._texture
- },
- set: function(e) {
- var t, i = this;
- if (this._texture !== e) {
- var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
- !e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(i._texture)
- }
- )),
- this._texture = e,
- e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
- return t.hasTexture(e)
- }
- ))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "samplerName", {
- get: function() {
- return this._samplerName
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.bind = function(e) {
- this.texture && e.setTexture(this._samplerName, this.texture)
- }
- ,
- t.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- t.prototype.getClassName = function() {
- return "ImageSourceBlock"
- }
- ,
- Object.defineProperty(t.prototype, "source", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- return e.prototype._buildBlock.call(this, t),
- t.target === Dp.Vertex && (this._samplerName = t._getFreeVariableName(this.name + "Sampler"),
- t.sharedData.blockingBlocks.push(this),
- t.sharedData.textureBlocks.push(this),
- t.sharedData.bindableBlocks.push(this)),
- t._emit2DSampler(this._samplerName),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return this.texture ? (t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, ");\r\n"),
- t += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")) : t
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return this.texture && !this.texture.isRenderTarget && "VideoTexture" !== this.texture.getClassName() && (t.texture = this.texture.serialize()),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- t.texture && !Of.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
- this.texture = io.Parse(t.texture, i, n))
- }
- ,
- t
- }(Wp);
- y("BABYLON.ImageSourceBlock", Um);
- var Vm = function(e) {
- function t(t, i) {
- void 0 === i && (i = !1);
- var n = e.call(this, t, i ? Dp.Fragment : Dp.VertexAndFragment) || this;
- return n._convertToGammaSpace = !1,
- n._convertToLinearSpace = !1,
- n.disableLevelMultiplication = !1,
- n._fragmentOnly = i,
- n.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
- n.registerInput("source", Op.Object, !0, Dp.VertexAndFragment, new Bm("source",n,Vp.Input,Um,"ImageSourceBlock")),
- n.registerOutput("rgba", Op.Color4, Dp.Neutral),
- n.registerOutput("rgb", Op.Color3, Dp.Neutral),
- n.registerOutput("r", Op.Float, Dp.Neutral),
- n.registerOutput("g", Op.Float, Dp.Neutral),
- n.registerOutput("b", Op.Float, Dp.Neutral),
- n.registerOutput("a", Op.Float, Dp.Neutral),
- n.registerOutput("level", Op.Float, Dp.Neutral),
- n._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- n._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- n._inputs[0]._prioritizeVertex = !i,
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "texture", {
- get: function() {
- var e;
- return this.source.isConnected ? (null === (e = this.source.connectedPoint) || void 0 === e ? void 0 : e.ownerBlock).texture : this._texture
- },
- set: function(e) {
- var t, i = this;
- if (this._texture !== e) {
- var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
- !e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(i._texture)
- }
- )),
- this._texture = e,
- e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
- return t.hasTexture(e)
- }
- ))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "samplerName", {
- get: function() {
- return this._imageSource ? this._imageSource.samplerName : this._samplerName
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasImageSource", {
- get: function() {
- return !!this._imageSource
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "convertToGammaSpace", {
- get: function() {
- return this._convertToGammaSpace
- },
- set: function(e) {
- var t, i = this;
- if (e !== this._convertToGammaSpace && (this._convertToGammaSpace = e,
- this.texture)) {
- var n = null !== (t = this.texture.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
- null == n || n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(i.texture)
- }
- ))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "convertToLinearSpace", {
- get: function() {
- return this._convertToLinearSpace
- },
- set: function(e) {
- var t, i = this;
- if (e !== this._convertToLinearSpace && (this._convertToLinearSpace = e,
- this.texture)) {
- var n = null !== (t = this.texture.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
- null == n || n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(i.texture)
- }
- ))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "TextureBlock"
- }
- ,
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "source", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgb", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "level", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- if (this._fragmentOnly)
- return Dp.Fragment;
- if (!this.uv.isConnected)
- return Dp.VertexAndFragment;
- if (this.uv.sourceBlock.isInput)
- return Dp.VertexAndFragment;
- for (var e = this.uv.connectedPoint; e; ) {
- if (e.target === Dp.Fragment)
- return Dp.Fragment;
- if (e.target === Dp.Vertex)
- return Dp.VertexAndFragment;
- if (e.target === Dp.Neutral || e.target === Dp.VertexAndFragment) {
- var t = e.ownerBlock;
- if (t.target === Dp.Fragment)
- return Dp.Fragment;
- e = null;
- for (var i = 0, n = t.inputs; i < n.length; i++) {
- var r = n[i];
- if (r.connectedPoint) {
- e = r.connectedPoint;
- break
- }
- }
- }
- }
- return Dp.VertexAndFragment
- },
- set: function(e) {},
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.uv.isConnected)
- if (e.mode === cf.PostProcess)
- (t = e.getBlockByPredicate((function(e) {
- return "uv" === e.name
- }
- ))) && t.connectTo(this);
- else {
- var t, i = e.mode === cf.Particle ? "particle_uv" : "uv";
- (t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && e.name === i
- }
- ))) || (t = new tf("uv")).setAsAttribute(i),
- t.output.connectTo(this.uv)
- }
- }
- ,
- t.prototype.initializeDefines = function(e, t, i) {
- i._areTexturesDirty && void 0 !== this._mainUVDefineName && i.setValue(this._mainUVDefineName, !1, !0)
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- if (i._areTexturesDirty)
- if (this.texture && this.texture.getTextureMatrix) {
- var n = this.convertToGammaSpace && this.texture && !this.texture.gammaSpace
- , r = this.convertToLinearSpace && this.texture && this.texture.gammaSpace;
- i.setValue(this._linearDefineName, n, !0),
- i.setValue(this._gammaDefineName, r, !0),
- this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (i.setValue(this._defineName, !1, !0),
- i.setValue(this._mainUVDefineName, !0, !0)) : (i.setValue(this._defineName, !0),
- null == i[this._mainUVDefineName] && i.setValue(this._mainUVDefineName, !1, !0)))
- } else
- this._isMixed && (i.setValue(this._defineName, !1, !0),
- i.setValue(this._mainUVDefineName, !0, !0))
- }
- ,
- t.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- t.prototype.bind = function(e) {
- this.texture && (this._isMixed && (e.setFloat(this._textureInfoName, this.texture.level),
- e.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())),
- this._imageSource || e.setTexture(this._samplerName, this.texture))
- }
- ,
- Object.defineProperty(t.prototype, "_isMixed", {
- get: function() {
- return this.target !== Dp.Fragment
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._injectVertexCode = function(e) {
- var t = this.uv;
- if (this._defineName = e._getFreeDefineName("UVTRANSFORM"),
- this._mainUVDefineName = "VMAIN" + t.associatedVariableName.toUpperCase(),
- this._mainUVName = "vMain" + t.associatedVariableName,
- this._transformedUVName = e._getFreeVariableName("transformedUV"),
- this._textureTransformName = e._getFreeVariableName("textureTransform"),
- this._textureInfoName = e._getFreeVariableName("textureInfoName"),
- this.level.associatedVariableName = this._textureInfoName,
- e._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName),
- e._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName),
- e._emitUniformFromString(this._textureTransformName, "mat4", this._defineName),
- e.compilationString += "#ifdef ".concat(this._defineName, "\r\n"),
- e.compilationString += "".concat(this._transformedUVName, " = vec2(").concat(this._textureTransformName, " * vec4(").concat(t.associatedVariableName, ".xy, 1.0, 0.0));\r\n"),
- e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\r\n"),
- e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
- e.compilationString += "#endif\r\n",
- this._outputs.some((function(e) {
- return e.isConnectedInVertexShader
- }
- ))) {
- this._writeTextureRead(e, !0);
- for (var i = 0, n = this._outputs; i < n.length; i++) {
- var r = n[i];
- r.hasEndpoints && "level" !== r.name && this._writeOutput(e, r, r.name, !0)
- }
- }
- }
- ,
- t.prototype._generateTextureLookup = function(e) {
- var t = this.samplerName;
- e.compilationString += "#ifdef ".concat(this._defineName, "\r\n"),
- e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(t, ", ").concat(this._transformedUVName, ");\r\n"),
- e.compilationString += "#elif defined(".concat(this._mainUVDefineName, ")\r\n"),
- e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(t, ", ").concat(this._mainUVName ? this._mainUVName : this.uv.associatedVariableName, ");\r\n"),
- e.compilationString += "#endif\r\n"
- }
- ,
- t.prototype._writeTextureRead = function(e, t) {
- void 0 === t && (t = !1);
- var i = this.uv;
- if (t) {
- if (e.target === Dp.Fragment)
- return;
- this._generateTextureLookup(e)
- } else
- this.uv.ownerBlock.target !== Dp.Fragment ? this._generateTextureLookup(e) : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this.samplerName, ", ").concat(i.associatedVariableName, ");\r\n")
- }
- ,
- t.prototype._generateConversionCode = function(e, t, i) {
- "a" !== i && (this.texture && this.texture.gammaSpace || (e.compilationString += "#ifdef ".concat(this._linearDefineName, "\n ").concat(t.associatedVariableName, " = toGammaSpace(").concat(t.associatedVariableName, ");\n #endif\n ")),
- e.compilationString += "#ifdef ".concat(this._gammaDefineName, "\n ").concat(t.associatedVariableName, " = toLinearSpace(").concat(t.associatedVariableName, ");\n #endif\n "))
- }
- ,
- t.prototype._writeOutput = function(e, t, i, n) {
- if (void 0 === n && (n = !1),
- n) {
- if (e.target === Dp.Fragment)
- return;
- return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
- void this._generateConversionCode(e, t, i)
- }
- if (this.uv.ownerBlock.target === Dp.Fragment)
- return e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n"),
- void this._generateConversionCode(e, t, i);
- var r = "";
- this.disableLevelMultiplication || (r = " * ".concat(this._textureInfoName)),
- e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i).concat(r, ";\r\n"),
- this._generateConversionCode(e, t, i)
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null,
- (t.target === Dp.Vertex || this._fragmentOnly || t.target === Dp.Fragment && void 0 === this._tempTextureRead) && (this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
- this._linearDefineName = t._getFreeDefineName("ISLINEAR"),
- this._gammaDefineName = t._getFreeDefineName("ISGAMMA")),
- (!this._isMixed && t.target === Dp.Fragment || this._isMixed && t.target === Dp.Vertex) && (this._imageSource || (this._samplerName = t._getFreeVariableName(this.name + "Sampler"),
- t._emit2DSampler(this._samplerName)),
- t.sharedData.blockingBlocks.push(this),
- t.sharedData.textureBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this),
- t.sharedData.bindableBlocks.push(this)),
- t.target === Dp.Fragment) {
- if (this._outputs.some((function(e) {
- return e.isConnectedInFragmentShader
- }
- ))) {
- this._isMixed && !this._imageSource && t._emit2DSampler(this._samplerName);
- var i = "//".concat(this.name);
- t._emitFunctionFromInclude("helperFunctions", i),
- this._isMixed && t._emitUniformFromString(this._textureInfoName, "float"),
- this._writeTextureRead(t);
- for (var n = 0, r = this._outputs; n < r.length; n++) {
- var o = r[n];
- o.hasEndpoints && "level" !== o.name && this._writeOutput(t, o, o.name)
- }
- return this
- }
- } else
- this._injectVertexCode(t)
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return t += "".concat(this._codeVariableName, ".convertToGammaSpace = ").concat(this.convertToGammaSpace, ";\r\n"),
- t += "".concat(this._codeVariableName, ".convertToLinearSpace = ").concat(this.convertToLinearSpace, ";\r\n"),
- t += "".concat(this._codeVariableName, ".disableLevelMultiplication = ").concat(this.disableLevelMultiplication, ";\r\n"),
- this.texture ? (t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null, ').concat(this.texture.noMipmap, ", ").concat(this.texture.invertY, ", ").concat(this.texture.samplingMode, ");\r\n"),
- t += "".concat(this._codeVariableName, ".texture.wrapU = ").concat(this.texture.wrapU, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.wrapV = ").concat(this.texture.wrapV, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.uAng = ").concat(this.texture.uAng, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.vAng = ").concat(this.texture.vAng, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.wAng = ").concat(this.texture.wAng, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.uOffset = ").concat(this.texture.uOffset, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.vOffset = ").concat(this.texture.vOffset, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.uScale = ").concat(this.texture.uScale, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.vScale = ").concat(this.texture.vScale, ";\r\n"),
- t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")) : t
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.convertToGammaSpace = this.convertToGammaSpace,
- t.convertToLinearSpace = this.convertToLinearSpace,
- t.fragmentOnly = this._fragmentOnly,
- t.disableLevelMultiplication = this.disableLevelMultiplication,
- this.hasImageSource || !this.texture || this.texture.isRenderTarget || "VideoTexture" === this.texture.getClassName() || (t.texture = this.texture.serialize()),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.convertToGammaSpace = t.convertToGammaSpace,
- this.convertToLinearSpace = !!t.convertToLinearSpace,
- this._fragmentOnly = !!t.fragmentOnly,
- this.disableLevelMultiplication = !!t.disableLevelMultiplication,
- t.texture && !Of.IgnoreTexturesAtLoadTime && void 0 !== t.texture.url && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
- this.texture = io.Parse(t.texture, i, n))
- }
- ,
- t
- }(Wp);
- y("BABYLON.TextureBlock", Vm);
- var km = function(e) {
- function t(t) {
- return e.call(this, t, Dp.VertexAndFragment) || this
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "texture", {
- get: function() {
- return this._texture
- },
- set: function(e) {
- var t, i = this;
- if (this._texture !== e) {
- var n = null !== (t = null == e ? void 0 : e.getScene()) && void 0 !== t ? t : E.LastCreatedScene;
- !e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(e) {
- return e.hasTexture(i._texture)
- }
- )),
- this._texture = e,
- e && n && n.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag, (function(t) {
- return t.hasTexture(e)
- }
- ))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "ReflectionTextureBaseBlock"
- }
- ,
- t.prototype._getTexture = function() {
- return this.texture
- }
- ,
- t.prototype.autoConfigure = function(e) {
- if (!this.position.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.isAttribute && "position" === e.name
- }
- ));
- t || (t = new tf("position")).setAsAttribute(),
- t.output.connectTo(this.position)
- }
- if (!this.world.isConnected) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.World
- }
- ));
- i || (i = new tf("world")).setAsSystemValue(Qp.World),
- i.output.connectTo(this.world)
- }
- if (this.view && !this.view.isConnected) {
- var n = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.View
- }
- ));
- n || (n = new tf("view")).setAsSystemValue(Qp.View),
- n.output.connectTo(this.view)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- if (i._areTexturesDirty) {
- var n = this._getTexture();
- n && n.getTextureMatrix && (i.setValue(this._define3DName, n.isCube, !0),
- i.setValue(this._defineLocalCubicName, !!n.boundingBoxSize, !0),
- i.setValue(this._defineExplicitName, n.coordinatesMode === a.TEXTURE_EXPLICIT_MODE, !0),
- i.setValue(this._defineSkyboxName, n.coordinatesMode === a.TEXTURE_SKYBOX_MODE, !0),
- i.setValue(this._defineCubicName, n.coordinatesMode === a.TEXTURE_CUBIC_MODE || n.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0),
- i.setValue("INVERTCUBICMAP", n.coordinatesMode === a.TEXTURE_INVCUBIC_MODE, !0),
- i.setValue(this._defineSphericalName, n.coordinatesMode === a.TEXTURE_SPHERICAL_MODE, !0),
- i.setValue(this._definePlanarName, n.coordinatesMode === a.TEXTURE_PLANAR_MODE, !0),
- i.setValue(this._defineProjectionName, n.coordinatesMode === a.TEXTURE_PROJECTION_MODE, !0),
- i.setValue(this._defineEquirectangularName, n.coordinatesMode === a.TEXTURE_EQUIRECTANGULAR_MODE, !0),
- i.setValue(this._defineEquirectangularFixedName, n.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE, !0),
- i.setValue(this._defineMirroredEquirectangularFixedName, n.coordinatesMode === a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE, !0))
- }
- }
- ,
- t.prototype.isReady = function() {
- var e = this._getTexture();
- return !(e && !e.isReadyOrNotBlocking())
- }
- ,
- t.prototype.bind = function(e, t, i) {
- var n = this._getTexture();
- if (i && n && (e.setMatrix(this._reflectionMatrixName, n.getReflectionTextureMatrix()),
- n.isCube ? e.setTexture(this._cubeSamplerName, n) : e.setTexture(this._2DSamplerName, n),
- n.boundingBoxSize)) {
- var r = n;
- e.setVector3(this._reflectionPositionName, r.boundingBoxPosition),
- e.setVector3(this._reflectionSizeName, r.boundingBoxSize)
- }
- }
- ,
- t.prototype.handleVertexSide = function(e) {
- this._define3DName = e._getFreeDefineName("REFLECTIONMAP_3D"),
- this._defineCubicName = e._getFreeDefineName("REFLECTIONMAP_CUBIC"),
- this._defineSphericalName = e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),
- this._definePlanarName = e._getFreeDefineName("REFLECTIONMAP_PLANAR"),
- this._defineProjectionName = e._getFreeDefineName("REFLECTIONMAP_PROJECTION"),
- this._defineExplicitName = e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),
- this._defineEquirectangularName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),
- this._defineLocalCubicName = e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),
- this._defineMirroredEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),
- this._defineEquirectangularFixedName = e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),
- this._defineSkyboxName = e._getFreeDefineName("REFLECTIONMAP_SKYBOX"),
- this._defineOppositeZ = e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),
- this._reflectionMatrixName = e._getFreeVariableName("reflectionMatrix"),
- e._emitUniformFromString(this._reflectionMatrixName, "mat4");
- var t = ""
- , i = "v_" + this.worldPosition.associatedVariableName;
- return e._emitVaryingFromString(i, "vec4") && (t += "".concat(i, " = ").concat(this.worldPosition.associatedVariableName, ";\r\n")),
- this._positionUVWName = e._getFreeVariableName("positionUVW"),
- this._directionWName = e._getFreeVariableName("directionW"),
- e._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (t += "#ifdef ".concat(this._defineSkyboxName, "\r\n"),
- t += "".concat(this._positionUVWName, " = ").concat(this.position.associatedVariableName, ".xyz;\r\n"),
- t += "#endif\r\n"),
- e._emitVaryingFromString(this._directionWName, "vec3", "defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")")) && (t += "#if defined(".concat(this._defineEquirectangularFixedName, ") || defined(").concat(this._defineMirroredEquirectangularFixedName, ")\r\n"),
- t += "".concat(this._directionWName, " = normalize(vec3(").concat(this.world.associatedVariableName, " * vec4(").concat(this.position.associatedVariableName, ".xyz, 0.0)));\r\n"),
- t += "#endif\r\n"),
- t
- }
- ,
- t.prototype.handleFragmentSideInits = function(e) {
- e.sharedData.blockingBlocks.push(this),
- e.sharedData.textureBlocks.push(this),
- this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"),
- e.samplers.push(this._cubeSamplerName),
- this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"),
- e.samplers.push(this._2DSamplerName),
- e._samplerDeclaration += "#ifdef ".concat(this._define3DName, "\r\n"),
- e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\r\n"),
- e._samplerDeclaration += "#else\r\n",
- e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\r\n"),
- e._samplerDeclaration += "#endif\r\n",
- e.sharedData.blocksWithDefines.push(this),
- e.sharedData.bindableBlocks.push(this);
- var t = "//".concat(this.name);
- e._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""),
- e._emitFunctionFromInclude("helperFunctions", t),
- e._emitFunctionFromInclude("reflectionFunction", t, {
- replaceStrings: [{
- search: /vec3 computeReflectionCoords/g,
- replace: "void DUMMYFUNC"
- }]
- }),
- this._reflectionColorName = e._getFreeVariableName("reflectionColor"),
- this._reflectionVectorName = e._getFreeVariableName("reflectionUVW"),
- this._reflectionCoordsName = e._getFreeVariableName("reflectionCoords"),
- this._reflectionPositionName = e._getFreeVariableName("vReflectionPosition"),
- e._emitUniformFromString(this._reflectionPositionName, "vec3"),
- this._reflectionSizeName = e._getFreeVariableName("vReflectionPosition"),
- e._emitUniformFromString(this._reflectionSizeName, "vec3")
- }
- ,
- t.prototype.handleFragmentSideCodeReflectionCoords = function(e, t, i) {
- void 0 === i && (i = !1),
- t || (t = "v_".concat(this.worldPosition.associatedVariableName));
- var n = this._reflectionMatrixName
- , r = "normalize(".concat(this._directionWName, ")")
- , o = "".concat(this._positionUVWName)
- , a = "".concat(this.cameraPosition.associatedVariableName)
- , s = "".concat(this.view.associatedVariableName);
- e += ".xyz";
- var l = "\n #ifdef ".concat(this._defineMirroredEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeMirroredFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(r, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularFixedName, "\n vec3 ").concat(this._reflectionVectorName, " = computeFixedEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(r, ");\n #endif\n\n #ifdef ").concat(this._defineEquirectangularName, "\n vec3 ").concat(this._reflectionVectorName, " = computeEquirectangularCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSphericalName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSphericalCoords(").concat(t, ", ").concat(e, ", ").concat(s, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._definePlanarName, "\n vec3 ").concat(this._reflectionVectorName, " = computePlanarCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineCubicName, "\n #ifdef ").concat(this._defineLocalCubicName, "\n vec3 ").concat(this._reflectionVectorName, " = computeCubicLocalCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ", ").concat(this._reflectionSizeName, ", ").concat(this._reflectionPositionName, ");\n #else\n vec3 ").concat(this._reflectionVectorName, " = computeCubicCoords(").concat(t, ", ").concat(e, ", ").concat(a, ".xyz, ").concat(n, ");\n #endif\n #endif\n\n #ifdef ").concat(this._defineProjectionName, "\n vec3 ").concat(this._reflectionVectorName, " = computeProjectionCoords(").concat(t, ", ").concat(s, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineSkyboxName, "\n vec3 ").concat(this._reflectionVectorName, " = computeSkyBoxCoords(").concat(o, ", ").concat(n, ");\n #endif\n\n #ifdef ").concat(this._defineExplicitName, "\n vec3 ").concat(this._reflectionVectorName, " = vec3(0, 0, 0);\n #endif\n\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(this._reflectionVectorName, ".z *= -1.0;\n #endif\r\n");
- return i || (l += "\n #ifdef ".concat(this._define3DName, "\n vec3 ").concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, ";\n #else\n vec2 ").concat(this._reflectionCoordsName, " = ").concat(this._reflectionVectorName, ".xy;\n #ifdef ").concat(this._defineProjectionName, "\n ").concat(this._reflectionCoordsName, " /= ").concat(this._reflectionVectorName, ".z;\n #endif\n ").concat(this._reflectionCoordsName, ".y = 1.0 - ").concat(this._reflectionCoordsName, ".y;\n #endif\r\n")),
- l
- }
- ,
- t.prototype.handleFragmentSideCodeReflectionColor = function(e, t) {
- void 0 === t && (t = ".rgb");
- var i = "vec" + (0 === t.length ? "4" : t.length - 1)
- , n = "".concat(i, " ").concat(this._reflectionColorName, ";\n #ifdef ").concat(this._define3DName, "\r\n");
- return n += e ? "".concat(this._reflectionColorName, " = textureCubeLodEXT(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ", ").concat(e, ")").concat(t, ";\r\n") : "".concat(this._reflectionColorName, " = textureCube(").concat(this._cubeSamplerName, ", ").concat(this._reflectionVectorName, ")").concat(t, ";\r\n"),
- n += "\n #else\r\n",
- (n += e ? "".concat(this._reflectionColorName, " = texture2DLodEXT(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ", ").concat(e, ")").concat(t, ";\r\n") : "".concat(this._reflectionColorName, " = texture2D(").concat(this._2DSamplerName, ", ").concat(this._reflectionCoordsName, ")").concat(t, ";\r\n")) + "#endif\r\n"
- }
- ,
- t.prototype.writeOutputs = function(e, t) {
- var i = "";
- if (e.target === Dp.Fragment)
- for (var n = 0, r = this._outputs; n < r.length; n++) {
- var o = r[n];
- o.hasEndpoints && (i += "".concat(this._declareOutput(o, e), " = ").concat(t, ".").concat(o.name, ";\r\n"))
- }
- return i
- }
- ,
- t.prototype._buildBlock = function(t) {
- return e.prototype._buildBlock.call(this, t),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- if (!this.texture)
- return t;
- if (this.texture.isCube) {
- var i = this.texture.forcedExtension;
- t += "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '", undefined, undefined, ').concat(this.texture.noMipmap, ", null, undefined, undefined, undefined, ").concat(this.texture._prefiltered, ", ").concat(i ? '"' + i + '"' : "null", ");\r\n")
- } else
- t += "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '", null);\r\n');
- return t + "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
- t.texture.isCube ? this.texture = Bd.Parse(t.texture, i, n) : this.texture = io.Parse(t.texture, i, n))
- }
- ,
- t
- }(Wp);
- y("BABYLON.ReflectionTextureBaseBlock", km);
- var Gm = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i.registerInput("position", Op.Vector3, !1, Dp.Vertex),
- i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
- i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
- i.registerInput("world", Op.Matrix, !1, Dp.Vertex),
- i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
- i.registerInput("view", Op.Matrix, !1, Dp.Fragment),
- i.registerOutput("rgb", Op.Color3, Dp.Fragment),
- i.registerOutput("rgba", Op.Color4, Dp.Fragment),
- i.registerOutput("r", Op.Float, Dp.Fragment),
- i.registerOutput("g", Op.Float, Dp.Fragment),
- i.registerOutput("b", Op.Float, Dp.Fragment),
- i.registerOutput("a", Op.Float, Dp.Fragment),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ReflectionTextureBlock"
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldNormal", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "view", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgb", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(t) {
- if (e.prototype.autoConfigure.call(this, t),
- !this.cameraPosition.isConnected) {
- var i = t.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.CameraPosition
- }
- ));
- i || (i = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
- i.output.connectTo(this.cameraPosition)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- !this.texture)
- return t.compilationString += this.writeOutputs(t, "vec3(0.)"),
- this;
- if (t.target !== Dp.Fragment)
- return t.compilationString += this.handleVertexSide(t),
- this;
- this.handleFragmentSideInits(t);
- var i = t._getFreeVariableName("normalWUnit");
- return t.compilationString += "vec4 ".concat(i, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\r\n"),
- t.compilationString += this.handleFragmentSideCodeReflectionCoords(i),
- t.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""),
- t.compilationString += this.writeOutputs(t, this._reflectionColorName),
- this
- }
- ,
- t
- }(km);
- y("BABYLON.ReflectionTextureBlock", Gm);
- var zm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.VertexAndFragment) || this;
- return i._samplerName = "textureSampler",
- i.useNonLinearDepth = !1,
- i.force32itsFloat = !1,
- i._isUnique = !0,
- i.registerInput("uv", Op.Vector2, !1, Dp.VertexAndFragment),
- i.registerOutput("depth", Op.Float, Dp.Neutral),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[0]._prioritizeVertex = !1,
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "SceneDepthBlock"
- }
- ,
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depth", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("textureSampler")
- }
- ,
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- return this.uv.isConnected ? this.uv.sourceBlock.isInput ? Dp.VertexAndFragment : Dp.Fragment : Dp.VertexAndFragment
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._getTexture = function(e) {
- return e.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat).getDepthMap()
- }
- ,
- t.prototype.bind = function(e, t) {
- var i = this._getTexture(t.getScene());
- e.setTexture(this._samplerName, i)
- }
- ,
- t.prototype._injectVertexCode = function(e) {
- var t = this.uv;
- if (t.connectedPoint.ownerBlock.isInput && (t.connectedPoint.ownerBlock.isAttribute || e._emitUniformFromString(t.associatedVariableName, "vec" + (t.type === Op.Vector3 ? "3" : t.type === Op.Vector4 ? "4" : "2"))),
- this._mainUVName = "vMain" + t.associatedVariableName,
- e._emitVaryingFromString(this._mainUVName, "vec2"),
- e.compilationString += "".concat(this._mainUVName, " = ").concat(t.associatedVariableName, ".xy;\r\n"),
- this._outputs.some((function(e) {
- return e.isConnectedInVertexShader
- }
- ))) {
- this._writeTextureRead(e, !0);
- for (var i = 0, n = this._outputs; i < n.length; i++) {
- var r = n[i];
- r.hasEndpoints && this._writeOutput(e, r, "r", !0)
- }
- }
- }
- ,
- t.prototype._writeTextureRead = function(e, t) {
- void 0 === t && (t = !1);
- var i = this.uv;
- if (t) {
- if (e.target === Dp.Fragment)
- return;
- e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\r\n")
- } else
- this.uv.ownerBlock.target !== Dp.Fragment ? e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(this._mainUVName, ");\r\n") : e.compilationString += "vec4 ".concat(this._tempTextureRead, " = texture2D(").concat(this._samplerName, ", ").concat(i.associatedVariableName, ".xy);\r\n")
- }
- ,
- t.prototype._writeOutput = function(e, t, i, n) {
- if (void 0 === n && (n = !1),
- n) {
- if (e.target === Dp.Fragment)
- return;
- e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
- } else
- this.uv.ownerBlock.target,
- Dp.Fragment,
- e.compilationString += "".concat(this._declareOutput(t, e), " = ").concat(this._tempTextureRead, ".").concat(i, ";\r\n")
- }
- ,
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this._tempTextureRead = t._getFreeVariableName("tempTextureRead"),
- t.sharedData.bindableBlocks.indexOf(this) < 0 && t.sharedData.bindableBlocks.push(this),
- t.target !== Dp.Fragment)
- return t._emit2DSampler(this._samplerName),
- void this._injectVertexCode(t);
- if (this._outputs.some((function(e) {
- return e.isConnectedInFragmentShader
- }
- ))) {
- t._emit2DSampler(this._samplerName),
- this._writeTextureRead(t);
- for (var i = 0, n = this._outputs; i < n.length; i++) {
- var r = n[i];
- r.hasEndpoints && this._writeOutput(t, r, "r")
- }
- return this
- }
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.useNonLinearDepth = this.useNonLinearDepth,
- t.force32itsFloat = this.force32itsFloat,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.useNonLinearDepth = t.useNonLinearDepth,
- this.force32itsFloat = t.force32itsFloat
- }
- ,
- k([Yp("Use non linear depth", Xp.Boolean, "ADVANCED", {
- notifiers: {
- activatePreviewCommand: !0,
- callback: function(e) {
- return e.disableDepthRenderer()
- }
- }
- })], t.prototype, "useNonLinearDepth", void 0),
- k([Yp("Force 32 bits float", Xp.Boolean, "ADVANCED", {
- notifiers: {
- activatePreviewCommand: !0,
- callback: function(e) {
- return e.disableDepthRenderer()
- }
- }
- })], t.prototype, "force32itsFloat", void 0),
- t
- }(Wp);
- y("BABYLON.SceneDepthBlock", zm);
- var Wm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.VertexAndFragment, !0) || this;
- return i.registerInput("worldPosition", Op.Vector4, !1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ClipPlanesBlock"
- }
- ,
- t.prototype.initialize = function(e) {
- e._excludeVariableName("vClipPlane"),
- e._excludeVariableName("fClipDistance"),
- e._excludeVariableName("vClipPlane2"),
- e._excludeVariableName("fClipDistance2"),
- e._excludeVariableName("vClipPlane3"),
- e._excludeVariableName("fClipDistance3"),
- e._excludeVariableName("vClipPlane4"),
- e._excludeVariableName("fClipDistance4"),
- e._excludeVariableName("vClipPlane5"),
- e._excludeVariableName("fClipDistance5"),
- e._excludeVariableName("vClipPlane6"),
- e._excludeVariableName("fClipDistance6")
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- return Dp.VertexAndFragment
- },
- set: function(e) {},
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.prepareDefines = function(e, t, i) {
- var n = e.getScene()
- , r = void 0 !== n.clipPlane && null !== n.clipPlane
- , o = void 0 !== n.clipPlane2 && null !== n.clipPlane2
- , a = void 0 !== n.clipPlane3 && null !== n.clipPlane3
- , s = void 0 !== n.clipPlane4 && null !== n.clipPlane4
- , l = void 0 !== n.clipPlane5 && null !== n.clipPlane5
- , c = void 0 !== n.clipPlane6 && null !== n.clipPlane6;
- i.setValue("CLIPPLANE", r, !0),
- i.setValue("CLIPPLANE2", o, !0),
- i.setValue("CLIPPLANE3", a, !0),
- i.setValue("CLIPPLANE4", s, !0),
- i.setValue("CLIPPLANE5", l, !0),
- i.setValue("CLIPPLANE6", c, !0)
- }
- ,
- t.prototype.bind = function(e, t, i) {
- if (i) {
- var n = i.getScene();
- Mr.BindClipPlane(e, n)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = "//".concat(this.name);
- if (t.target !== Dp.Fragment) {
- var n = this.worldPosition;
- return t._emitFunctionFromInclude("clipPlaneVertexDeclaration", i, {
- replaceStrings: [{
- search: /uniform vec4 vClipPlane\d*;/g,
- replace: ""
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("clipPlaneVertex", i, {
- replaceStrings: [{
- search: /worldPos/g,
- replace: n.associatedVariableName
- }]
- }),
- t._emitUniformFromString("vClipPlane", "vec4"),
- t._emitUniformFromString("vClipPlane2", "vec4"),
- t._emitUniformFromString("vClipPlane3", "vec4"),
- t._emitUniformFromString("vClipPlane4", "vec4"),
- t._emitUniformFromString("vClipPlane5", "vec4"),
- void t._emitUniformFromString("vClipPlane6", "vec4")
- }
- return t.sharedData.bindableBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this),
- t._emitFunctionFromInclude("clipPlaneFragmentDeclaration", i),
- t.compilationString += t._emitCodeFromInclude("clipPlaneFragment", i),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ClipPlanesBlock", Wm);
- var Hm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "AddBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " + ").concat(this.right.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.AddBlock", Hm);
- var Xm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("input", Op.AutoDetect),
- i.registerInput("factor", Op.Float),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ScaleBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "factor", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.input.associatedVariableName, " * ").concat(this.factor.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ScaleBlock", Xm);
- var jm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.minimum = 0,
- i.maximum = 1,
- i.registerInput("value", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ClampBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = clamp(".concat(this.value.associatedVariableName, ", ").concat(this._writeFloat(this.minimum), ", ").concat(this._writeFloat(this.maximum), ");\r\n"),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".minimum = ").concat(this.minimum, ";\r\n") + "".concat(this._codeVariableName, ".maximum = ").concat(this.maximum, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.minimum = this.minimum,
- t.maximum = this.maximum,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.minimum = t.minimum,
- this.maximum = t.maximum
- }
- ,
- k([Yp("Minimum", Xp.Float)], t.prototype, "minimum", void 0),
- k([Yp("Maximum", Xp.Float)], t.prototype, "maximum", void 0),
- t
- }(Wp);
- y("BABYLON.ClampBlock", jm);
- var Ym = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.Vector3),
- i._linkConnectionTypes(0, 1),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Vector2),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Vector2),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "CrossBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = cross(".concat(this.left.associatedVariableName, ".xyz, ").concat(this.right.associatedVariableName, ".xyz);\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.CrossBlock", Ym);
- var Km = function(e) {
- function t(t) {
- return e.call(this, t) || this
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "options", {
- get: function() {
- return this._options
- },
- set: function(e) {
- this._deserializeOptions(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "CustomBlock"
- }
- ,
- t.prototype._buildBlock = function(t) {
- var i = this;
- e.prototype._buildBlock.call(this, t);
- var n = this._code
- , r = this._options.functionName;
- this._inputs.forEach((function(e) {
- var i = new RegExp("\\{TYPE_" + e.name + "\\}","gm")
- , o = t._getGLType(e.type);
- n = n.replace(i, o),
- r = r.replace(i, o)
- }
- )),
- this._outputs.forEach((function(e) {
- var i = new RegExp("\\{TYPE_" + e.name + "\\}","gm")
- , o = t._getGLType(e.type);
- n = n.replace(i, o),
- r = r.replace(i, o)
- }
- )),
- t._emitFunction(r, n, ""),
- this._outputs.forEach((function(e) {
- t.compilationString += i._declareOutput(e, t) + ";\r\n"
- }
- )),
- t.compilationString += r + "(";
- var o = !1;
- return this._inputs.forEach((function(e, i) {
- i > 0 && (t.compilationString += ", "),
- t.compilationString += e.associatedVariableName,
- o = !0
- }
- )),
- this._outputs.forEach((function(e, i) {
- (i > 0 || o) && (t.compilationString += ", "),
- t.compilationString += e.associatedVariableName
- }
- )),
- t.compilationString += ");\r\n",
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".options = ").concat(JSON.stringify(this._options), ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.options = this._options,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- this._deserializeOptions(t.options),
- e.prototype._deserialize.call(this, t, i, n)
- }
- ,
- t.prototype._deserializeOptions = function(e) {
- var t, i, n, r = this;
- this._options = e,
- this._code = e.code.join("\r\n") + "\r\n",
- this.name = this.name || e.name,
- this.target = Dp[e.target],
- null === (t = e.inParameters) || void 0 === t || t.forEach((function(e, t) {
- var i = Op[e.type];
- r.registerInput(e.name, i),
- Object.defineProperty(r, e.name, {
- get: function() {
- return this._inputs[t]
- },
- enumerable: !0,
- configurable: !0
- })
- }
- )),
- null === (i = e.outParameters) || void 0 === i || i.forEach((function(e, t) {
- r.registerOutput(e.name, Op[e.type]),
- Object.defineProperty(r, e.name, {
- get: function() {
- return this._outputs[t]
- },
- enumerable: !0,
- configurable: !0
- }),
- "BasedOnInput" === e.type && (r._outputs[t]._typeConnectionSource = r._findInputByName(e.typeFromInput)[0])
- }
- )),
- null === (n = e.inLinkedConnectionTypes) || void 0 === n || n.forEach((function(e) {
- r._linkConnectionTypes(r._findInputByName(e.input1)[1], r._findInputByName(e.input2)[1])
- }
- ))
- }
- ,
- t.prototype._findInputByName = function(e) {
- if (!e)
- return null;
- for (var t = 0; t < this._inputs.length; t++)
- if (this._inputs[t].name === e)
- return [this._inputs[t], t];
- return null
- }
- ,
- t
- }(Wp);
- y("BABYLON.CustomBlock", Km);
- var Qm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.Float),
- i._linkConnectionTypes(0, 1),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DotBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = dot(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.DotBlock", Qm);
- var qm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("input", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "NormalizeBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this._inputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(n.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.NormalizeBlock", qm);
- var Zm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.rSwizzle = "r",
- i.gSwizzle = "g",
- i.bSwizzle = "b",
- i.aSwizzle = "a",
- i.registerInput("rgb ", Op.Color3, !0),
- i.registerInput("r", Op.Float, !0),
- i.registerInput("g", Op.Float, !0),
- i.registerInput("b", Op.Float, !0),
- i.registerInput("a", Op.Float, !0),
- i.registerOutput("rgba", Op.Color4),
- i.registerOutput("rgb", Op.Color3),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ColorMergerBlock"
- }
- ,
- Object.defineProperty(t.prototype, "rgbIn", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "r", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "g", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgbOut", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rgb", {
- get: function() {
- return this.rgbOut
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._inputRename = function(e) {
- return "rgb " === e ? "rgbIn" : e
- }
- ,
- t.prototype._buildSwizzle = function(e) {
- return "." + (this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle).substr(0, e)
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.r
- , n = this.g
- , r = this.b
- , o = this.a
- , a = this.rgbIn
- , s = this._outputs[0]
- , l = this._outputs[1];
- return a.isConnected ? (s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec4(".concat(a.associatedVariableName, ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
- l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(a.associatedVariableName).concat(this._buildSwizzle(3), ";\r\n"))) : (s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = vec4(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ", ").concat(o.isConnected ? this._writeVariable(o) : "0.0", ")").concat(this._buildSwizzle(4), ";\r\n")),
- l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = vec3(".concat(i.isConnected ? this._writeVariable(i) : "0.0", ", ").concat(n.isConnected ? this._writeVariable(n) : "0.0", ", ").concat(r.isConnected ? this._writeVariable(r) : "0.0", ")").concat(this._buildSwizzle(3), ";\r\n"))),
- this
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.rSwizzle = this.rSwizzle,
- t.gSwizzle = this.gSwizzle,
- t.bSwizzle = this.bSwizzle,
- t.aSwizzle = this.aSwizzle,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- var r, o, a, s;
- e.prototype._deserialize.call(this, t, i, n),
- this.rSwizzle = null !== (r = t.rSwizzle) && void 0 !== r ? r : "r",
- this.gSwizzle = null !== (o = t.gSwizzle) && void 0 !== o ? o : "g",
- this.bSwizzle = null !== (a = t.bSwizzle) && void 0 !== a ? a : "b",
- this.aSwizzle = null !== (s = t.aSwizzle) && void 0 !== s ? s : "a"
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return t += "".concat(this._codeVariableName, ".rSwizzle = ").concat(this.rSwizzle, "};\r\n"),
- t += "".concat(this._codeVariableName, ".gSwizzle = ").concat(this.gSwizzle, "};\r\n"),
- (t += "".concat(this._codeVariableName, ".bSwizzle = ").concat(this.bSwizzle, "};\r\n")) + "".concat(this._codeVariableName, ".aSwizzle = ").concat(this.aSwizzle, "};\r\n")
- }
- ,
- t
- }(Wp);
- y("BABYLON.ColorMergerBlock", Zm);
- var Jm = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("xyzw", Op.Vector4, !0),
- i.registerInput("xyz ", Op.Vector3, !0),
- i.registerInput("xy ", Op.Vector2, !0),
- i.registerOutput("xyz", Op.Vector3),
- i.registerOutput("xy", Op.Vector2),
- i.registerOutput("zw", Op.Vector2),
- i.registerOutput("x", Op.Float),
- i.registerOutput("y", Op.Float),
- i.registerOutput("z", Op.Float),
- i.registerOutput("w", Op.Float),
- i.inputsAreExclusive = !0,
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VectorSplitterBlock"
- }
- ,
- Object.defineProperty(t.prototype, "xyzw", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyzIn", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyIn", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyzOut", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xyOut", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "zw", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "z", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "w", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._inputRename = function(e) {
- switch (e) {
- case "xy ":
- return "xyIn";
- case "xyz ":
- return "xyzIn";
- default:
- return e
- }
- }
- ,
- t.prototype._outputRename = function(e) {
- switch (e) {
- case "xy":
- return "xyOut";
- case "xyz":
- return "xyzOut";
- default:
- return e
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn
- , n = this._outputs[0]
- , r = this._outputs[1]
- , o = this._outputs[2]
- , a = this._outputs[3]
- , s = this._outputs[4]
- , l = this._outputs[5]
- , c = this._outputs[6];
- return n.hasEndpoints && (i === this.xyIn ? t.compilationString += this._declareOutput(n, t) + " = vec3(".concat(i.associatedVariableName, ", 0.0);\r\n") : t.compilationString += this._declareOutput(n, t) + " = ".concat(i.associatedVariableName, ".xyz;\r\n")),
- o.hasEndpoints && this.xyzw.isConnected && (t.compilationString += this._declareOutput(o, t) + " = ".concat(this.xyzw.associatedVariableName, ".zw;\r\n")),
- r.hasEndpoints && (t.compilationString += this._declareOutput(r, t) + " = ".concat(i.associatedVariableName, ".xy;\r\n")),
- a.hasEndpoints && (t.compilationString += this._declareOutput(a, t) + " = ".concat(i.associatedVariableName, ".x;\r\n")),
- s.hasEndpoints && (t.compilationString += this._declareOutput(s, t) + " = ".concat(i.associatedVariableName, ".y;\r\n")),
- l.hasEndpoints && (t.compilationString += this._declareOutput(l, t) + " = ".concat(i.associatedVariableName, ".z;\r\n")),
- c.hasEndpoints && (t.compilationString += this._declareOutput(c, t) + " = ".concat(i.associatedVariableName, ".w;\r\n")),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.VectorSplitterBlock", Jm);
- var $m = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerInput("gradient", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i._linkConnectionTypes(1, 2, !0),
- i._inputs[2].acceptedConnectionPointTypes.push(Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "LerpBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "gradient", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.LerpBlock", $m);
- var eg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DivideBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " / ").concat(this.right.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.DivideBlock", eg);
- var tg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "SubtractBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.SubtractBlock", tg);
- var ig = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.Float),
- i.registerInput("edge", Op.Float),
- i.registerOutput("output", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "StepBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "edge", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = step(".concat(this.edge.associatedVariableName, ", ").concat(this.value.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.StepBlock", ig);
- var ng = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("input", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._outputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "OneMinusBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = 1. - ".concat(this.input.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.OneMinusBlock", ng),
- y("BABYLON.OppositeBlock", ng);
- var rg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("worldPosition", Op.Vector4),
- i.registerInput("cameraPosition", Op.Vector3),
- i.registerOutput("output", Op.Vector3),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ViewDirectionBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.cameraPosition.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.CameraPosition
- }
- ));
- t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
- t.output.connectTo(this.cameraPosition)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(this.worldPosition.associatedVariableName, ".xyz);\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ViewDirectionBlock", rg);
- var og = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("worldNormal", Op.Vector4),
- i.registerInput("viewDirection", Op.Vector3),
- i.registerInput("bias", Op.Float),
- i.registerInput("power", Op.Float),
- i.registerOutput("fresnel", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FresnelBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldNormal", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "viewDirection", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bias", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "power", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fresnel", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.viewDirection.isConnected) {
- var t = new rg("View direction");
- t.output.connectTo(this.viewDirection),
- t.autoConfigure(e)
- }
- if (!this.bias.isConnected) {
- var i = new tf("bias");
- i.value = 0,
- i.output.connectTo(this.bias)
- }
- if (!this.power.isConnected) {
- var n = new tf("power");
- n.value = 1,
- n.output.connectTo(this.power)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = "//".concat(this.name);
- return t._emitFunctionFromInclude("fresnelFunction", i, {
- removeIfDef: !0
- }),
- t.compilationString += this._declareOutput(this.fresnel, t) + " = computeFresnelTerm(".concat(this.viewDirection.associatedVariableName, ".xyz, ").concat(this.worldNormal.associatedVariableName, ".xyz, ").concat(this.bias.associatedVariableName, ", ").concat(this.power.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.FresnelBlock", og);
- var ag = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "MaxBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = max(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.MaxBlock", ag);
- var sg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "MinBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = min(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.MinBlock", sg);
- var lg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.Float),
- i._linkConnectionTypes(0, 1),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DistanceBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = length(".concat(this.left.associatedVariableName, " - ").concat(this.right.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.DistanceBlock", lg);
- var cg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.AutoDetect),
- i.registerOutput("output", Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "LengthBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = length(".concat(this.value.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.LengthBlock", cg);
- var ug = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "NegateBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = -1.0 * ".concat(this.value.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.NegateBlock", ug);
- var hg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.AutoDetect),
- i.registerInput("power", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "PowBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "power", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = pow(".concat(this.value.associatedVariableName, ", ").concat(this.power.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.PowBlock", hg);
- var dg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("seed", Op.Vector2),
- i.registerOutput("output", Op.Float),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "RandomNumberBlock"
- }
- ,
- Object.defineProperty(t.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = "//".concat(this.name);
- return t._emitFunctionFromInclude("helperFunctions", n),
- t.compilationString += this._declareOutput(i, t) + " = getRand(".concat(this.seed.associatedVariableName, ".xy);\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.RandomNumberBlock", dg);
- var pg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("x", Op.Float),
- i.registerInput("y", Op.Float),
- i.registerOutput("output", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ArcTan2Block"
- }
- ,
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = atan(".concat(this.x.associatedVariableName, ", ").concat(this.y.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ArcTan2Block", pg);
- var fg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.AutoDetect),
- i.registerInput("edge0", Op.Float),
- i.registerInput("edge1", Op.Float),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "SmoothStepBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "edge0", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "edge1", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = smoothstep(".concat(this.edge0.associatedVariableName, ", ").concat(this.edge1.associatedVariableName, ", ").concat(this.value.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.SmoothStepBlock", fg);
- var _g = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("input", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._outputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ReciprocalBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = 1. / ".concat(this.input.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ReciprocalBlock", _g);
- var mg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.AutoDetect),
- i.registerInput("reference", Op.AutoDetect),
- i.registerInput("distance", Op.Float),
- i.registerInput("replacement", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i._linkConnectionTypes(0, 3),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[3].excludedConnectionPointTypes.push(Op.Float),
- i._inputs[3].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ReplaceColorBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "reference", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "distance", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "replacement", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + ";\r\n",
- t.compilationString += "if (length(".concat(this.value.associatedVariableName, " - ").concat(this.reference.associatedVariableName, ") < ").concat(this.distance.associatedVariableName, ") {\r\n"),
- t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.replacement.associatedVariableName, ";\r\n"),
- t.compilationString += "} else {\r\n",
- t.compilationString += "".concat(i.associatedVariableName, " = ").concat(this.value.associatedVariableName, ";\r\n"),
- t.compilationString += "}\r\n",
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ReplaceColorBlock", mg);
- var gg, vg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("value", Op.AutoDetect),
- i.registerInput("steps", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i._inputs[1].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "PosterizeBlock"
- }
- ,
- Object.defineProperty(t.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "steps", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = floor(".concat(this.value.associatedVariableName, " / (1.0 / ").concat(this.steps.associatedVariableName, ")) * (1.0 / ").concat(this.steps.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.PosterizeBlock", vg),
- function(e) {
- e[e.SawTooth = 0] = "SawTooth",
- e[e.Square = 1] = "Square",
- e[e.Triangle = 2] = "Triangle"
- }(gg || (gg = {}));
- var yg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.kind = gg.SawTooth,
- i.registerInput("input", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._inputs[0].excludedConnectionPointTypes.push(Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "WaveBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- switch (this.kind) {
- case gg.SawTooth:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, ");\r\n");
- break;
- case gg.Square:
- t.compilationString += this._declareOutput(i, t) + " = 1.0 - 2.0 * round(fract(".concat(this.input.associatedVariableName, "));\r\n");
- break;
- case gg.Triangle:
- t.compilationString += this._declareOutput(i, t) + " = 2.0 * abs(2.0 * (".concat(this.input.associatedVariableName, " - floor(0.5 + ").concat(this.input.associatedVariableName, "))) - 1.0;\r\n")
- }
- return this
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.kind = this.kind,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.kind = t.kind
- }
- ,
- t
- }(Wp);
- y("BABYLON.WaveBlock", yg);
- var bg = function() {
- function e(e, t) {
- this.step = e,
- this.color = t
- }
- return Object.defineProperty(e.prototype, "step", {
- get: function() {
- return this._step
- },
- set: function(e) {
- this._step = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._color
- },
- set: function(e) {
- this._color = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }()
- , Tg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.colorSteps = [new bg(0,D.Black()), new bg(1,D.White())],
- i.onValueChangedObservable = new h,
- i.registerInput("gradient", Op.Float),
- i.registerOutput("output", Op.Color3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector2),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
- i
- }
- return U(t, e),
- t.prototype.colorStepsUpdated = function() {
- this.onValueChangedObservable.notifyObservers(this)
- }
- ,
- t.prototype.getClassName = function() {
- return "GradientBlock"
- }
- ,
- Object.defineProperty(t.prototype, "gradient", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._writeColorConstant = function(e) {
- var t = this.colorSteps[e];
- return "vec3(".concat(t.color.r, ", ").concat(t.color.g, ", ").concat(t.color.b, ")")
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- if (this.colorSteps.length && this.gradient.connectedPoint) {
- var n = t._getFreeVariableName("gradientTempColor")
- , r = t._getFreeVariableName("gradientTempPosition");
- t.compilationString += "vec3 ".concat(n, " = ").concat(this._writeColorConstant(0), ";\r\n"),
- t.compilationString += "float ".concat(r, ";\r\n");
- var o = this.gradient.associatedVariableName;
- this.gradient.connectedPoint.type !== Op.Float && (o += ".x");
- for (var a = 1; a < this.colorSteps.length; a++) {
- var s = this.colorSteps[a]
- , l = this.colorSteps[a - 1];
- t.compilationString += "".concat(r, " = clamp((").concat(o, " - ").concat(t._emitFloat(l.step), ") / (").concat(t._emitFloat(s.step), " - ").concat(t._emitFloat(l.step), "), 0.0, 1.0) * step(").concat(t._emitFloat(a), ", ").concat(t._emitFloat(this.colorSteps.length - 1), ");\r\n"),
- t.compilationString += "".concat(n, " = mix(").concat(n, ", ").concat(this._writeColorConstant(a), ", ").concat(r, ");\r\n")
- }
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(n, ";\r\n"),
- this
- }
- t.compilationString += this._declareOutput(i, t) + " = vec3(0., 0., 0.);\r\n"
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- t.colorSteps = [];
- for (var i = 0, n = this.colorSteps; i < n.length; i++) {
- var r = n[i];
- t.colorSteps.push({
- step: r.step,
- color: {
- r: r.color.r,
- g: r.color.g,
- b: r.color.b
- }
- })
- }
- return t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.colorSteps = [];
- for (var r = 0, o = t.colorSteps; r < o.length; r++) {
- var a = o[r];
- this.colorSteps.push(new bg(a.step,new D(a.color.r,a.color.g,a.color.b)))
- }
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- t += "".concat(this._codeVariableName, ".colorSteps = [];\r\n");
- for (var i = 0, n = this.colorSteps; i < n.length; i++) {
- var r = n[i];
- t += "".concat(this._codeVariableName, ".colorSteps.push(new BABYLON.GradientBlockColorStep(").concat(r.step, ", new BABYLON.Color3(").concat(r.color.r, ", ").concat(r.color.g, ", ").concat(r.color.b, ")));\r\n")
- }
- return t
- }
- ,
- t
- }(Wp);
- y("BABYLON.GradientBlock", Tg);
- var Eg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerInput("gradient", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i._linkConnectionTypes(1, 2, !0),
- i._inputs[2].acceptedConnectionPointTypes.push(Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "NLerpBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "gradient", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = normalize(mix(".concat(this.left.associatedVariableName, " , ").concat(this.right.associatedVariableName, ", ").concat(this.gradient.associatedVariableName, "));\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.NLerpBlock", Eg);
- var Sg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.manhattanDistance = !1,
- i.registerInput("seed", Op.Vector3),
- i.registerInput("jitter", Op.Float),
- i.registerOutput("output", Op.Vector2),
- i.registerOutput("x", Op.Float),
- i.registerOutput("y", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "WorleyNoise3DBlock"
- }
- ,
- Object.defineProperty(t.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "jitter", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this.seed.isConnected && (this.output.hasEndpoints || this.x.hasEndpoints || this.y.hasEndpoints)) {
- t._emitFunction("worley3D", "vec3 permute(vec3 x){\r\n return mod((34.0 * x + 1.0) * x, 289.0);\r\n}\r\n\r\nvec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r\n return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r\n}\r\n\r\nvec2 worley(vec3 P, float jitter, bool manhattanDistance){\r\n float K = 0.142857142857; // 1/7\r\n float Ko = 0.428571428571; // 1/2-K/2\r\n float K2 = 0.020408163265306; // 1/(7*7)\r\n float Kz = 0.166666666667; // 1/6\r\n float Kzo = 0.416666666667; // 1/2-1/6*2\r\n\r\n vec3 Pi = mod(floor(P), 289.0);\r\n vec3 Pf = fract(P) - 0.5;\r\n\r\n vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r\n\r\n vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r\n vec3 p1 = permute(p + Pi.y - 1.0);\r\n vec3 p2 = permute(p + Pi.y);\r\n vec3 p3 = permute(p + Pi.y + 1.0);\r\n\r\n vec3 p11 = permute(p1 + Pi.z - 1.0);\r\n vec3 p12 = permute(p1 + Pi.z);\r\n vec3 p13 = permute(p1 + Pi.z + 1.0);\r\n\r\n vec3 p21 = permute(p2 + Pi.z - 1.0);\r\n vec3 p22 = permute(p2 + Pi.z);\r\n vec3 p23 = permute(p2 + Pi.z + 1.0);\r\n\r\n vec3 p31 = permute(p3 + Pi.z - 1.0);\r\n vec3 p32 = permute(p3 + Pi.z);\r\n vec3 p33 = permute(p3 + Pi.z + 1.0);\r\n\r\n vec3 ox11 = fract(p11*K) - Ko;\r\n vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r\n vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r\n\r\n vec3 ox12 = fract(p12*K) - Ko;\r\n vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r\n vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r\n\r\n vec3 ox13 = fract(p13*K) - Ko;\r\n vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r\n vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r\n\r\n vec3 ox21 = fract(p21*K) - Ko;\r\n vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r\n vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r\n\r\n vec3 ox22 = fract(p22*K) - Ko;\r\n vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r\n vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r\n\r\n vec3 ox23 = fract(p23*K) - Ko;\r\n vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r\n vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r\n\r\n vec3 ox31 = fract(p31*K) - Ko;\r\n vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r\n vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r\n\r\n vec3 ox32 = fract(p32*K) - Ko;\r\n vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r\n vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r\n\r\n vec3 ox33 = fract(p33*K) - Ko;\r\n vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r\n vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r\n\r\n vec3 dx11 = Pfx + jitter*ox11;\r\n vec3 dy11 = Pfy.x + jitter*oy11;\r\n vec3 dz11 = Pfz.x + jitter*oz11;\r\n\r\n vec3 dx12 = Pfx + jitter*ox12;\r\n vec3 dy12 = Pfy.x + jitter*oy12;\r\n vec3 dz12 = Pfz.y + jitter*oz12;\r\n\r\n vec3 dx13 = Pfx + jitter*ox13;\r\n vec3 dy13 = Pfy.x + jitter*oy13;\r\n vec3 dz13 = Pfz.z + jitter*oz13;\r\n\r\n vec3 dx21 = Pfx + jitter*ox21;\r\n vec3 dy21 = Pfy.y + jitter*oy21;\r\n vec3 dz21 = Pfz.x + jitter*oz21;\r\n\r\n vec3 dx22 = Pfx + jitter*ox22;\r\n vec3 dy22 = Pfy.y + jitter*oy22;\r\n vec3 dz22 = Pfz.y + jitter*oz22;\r\n\r\n vec3 dx23 = Pfx + jitter*ox23;\r\n vec3 dy23 = Pfy.y + jitter*oy23;\r\n vec3 dz23 = Pfz.z + jitter*oz23;\r\n\r\n vec3 dx31 = Pfx + jitter*ox31;\r\n vec3 dy31 = Pfy.z + jitter*oy31;\r\n vec3 dz31 = Pfz.x + jitter*oz31;\r\n\r\n vec3 dx32 = Pfx + jitter*ox32;\r\n vec3 dy32 = Pfy.z + jitter*oy32;\r\n vec3 dz32 = Pfz.y + jitter*oz32;\r\n\r\n vec3 dx33 = Pfx + jitter*ox33;\r\n vec3 dy33 = Pfy.z + jitter*oy33;\r\n vec3 dz33 = Pfz.z + jitter*oz33;\r\n\r\n vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r\n vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r\n vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r\n vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r\n vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r\n vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r\n vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r\n vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r\n vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r\n\r\n vec3 d1a = min(d11, d12);\r\n d12 = max(d11, d12);\r\n d11 = min(d1a, d13); // Smallest now not in d12 or d13\r\n d13 = max(d1a, d13);\r\n d12 = min(d12, d13); // 2nd smallest now not in d13\r\n vec3 d2a = min(d21, d22);\r\n d22 = max(d21, d22);\r\n d21 = min(d2a, d23); // Smallest now not in d22 or d23\r\n d23 = max(d2a, d23);\r\n d22 = min(d22, d23); // 2nd smallest now not in d23\r\n vec3 d3a = min(d31, d32);\r\n d32 = max(d31, d32);\r\n d31 = min(d3a, d33); // Smallest now not in d32 or d33\r\n d33 = max(d3a, d33);\r\n d32 = min(d32, d33); // 2nd smallest now not in d33\r\n vec3 da = min(d11, d21);\r\n d21 = max(d11, d21);\r\n d11 = min(da, d31); // Smallest now in d11\r\n d31 = max(da, d31); // 2nd smallest now not in d31\r\n d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r\n d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r\n d12 = min(d12, d21); // 2nd smallest now not in d21\r\n d12 = min(d12, d22); // nor in d22\r\n d12 = min(d12, d31); // nor in d31\r\n d12 = min(d12, d32); // nor in d32\r\n d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r\n d11.y = min(d11.y,d12.z); // Only two more to go\r\n d11.y = min(d11.y,d11.z); // Done! (Phew!)\r\n return sqrt(d11.xy); // F1, F2\r\n}\r\n\r\n", "// Worley3D");
- var i = t._getFreeVariableName("worleyTemp");
- return t.compilationString += "vec2 ".concat(i, " = worley(").concat(this.seed.associatedVariableName, ", ").concat(this.jitter.associatedVariableName, ", ").concat(this.manhattanDistance, ");\r\n"),
- this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(i, ";\r\n")),
- this.x.hasEndpoints && (t.compilationString += this._declareOutput(this.x, t) + " = ".concat(i, ".x;\r\n")),
- this.y.hasEndpoints && (t.compilationString += this._declareOutput(this.y, t) + " = ".concat(i, ".y;\r\n")),
- this
- }
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".manhattanDistance = ").concat(this.manhattanDistance, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.manhattanDistance = this.manhattanDistance,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.manhattanDistance = t.manhattanDistance
- }
- ,
- k([Yp("Use Manhattan Distance", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !1
- }
- })], t.prototype, "manhattanDistance", void 0),
- t
- }(Wp);
- y("BABYLON.WorleyNoise3DBlock", Sg);
- var Ag = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("seed", Op.Vector3),
- i.registerOutput("output", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "SimplexPerlin3DBlock"
- }
- ,
- Object.defineProperty(t.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this.seed.isConnected && this._outputs[0].hasEndpoints)
- return t._emitFunction("SimplexPerlin3D", "const float SKEWFACTOR = 1.0/3.0;\r\nconst float UNSKEWFACTOR = 1.0/6.0;\r\nconst float SIMPLEX_CORNER_POS = 0.5;\r\nconst float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r\nfloat SimplexPerlin3D( vec3 P ){\r\n P.x = P == vec3(0., 0., 0.) ? 0.00001 : P.x;\r\n P *= SIMPLEX_TETRAHADRON_HEIGHT;\r\n vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) ); vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r\n vec3 g = step(x0.yzx, x0.xyz);\r\n vec3 l = 1.0 - g;\r\n vec3 Pi_1 = min( g.xyz, l.zxy );\r\n vec3 Pi_2 = max( g.xyz, l.zxy );\r\n vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r\n vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r\n vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r\n vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r\n vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r\n vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r\n Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r\n vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r\n vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r\n Pt *= Pt;\r\n vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r\n Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r\n const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r\n const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r\n vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r\n vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r\n Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r\n Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r\n vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r\n vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r\n vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r\n 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\n const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r\n vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r\n kernel_weights = max(0.5 - kernel_weights, 0.0);\r\n kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r\n return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r\n}\r\n", "// SimplexPerlin3D"),
- t.compilationString += this._declareOutput(this._outputs[0], t) + " = SimplexPerlin3D(".concat(this.seed.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.SimplexPerlin3DBlock", Ag);
- var xg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("normalMap0", Op.Vector3),
- i.registerInput("normalMap1", Op.Vector3),
- i.registerOutput("output", Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "NormalBlendBlock"
- }
- ,
- Object.defineProperty(t.prototype, "normalMap0", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normalMap1", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this._inputs[0]
- , r = this._inputs[1]
- , o = t._getFreeVariableName("stepR")
- , a = t._getFreeVariableName("stepG");
- return t.compilationString += "float ".concat(o, " = step(0.5, ").concat(n.associatedVariableName, ".r);\r\n"),
- t.compilationString += "float ".concat(a, " = step(0.5, ").concat(n.associatedVariableName, ".g);\r\n"),
- t.compilationString += this._declareOutput(i, t) + ";\r\n",
- t.compilationString += "".concat(i.associatedVariableName, ".r = (1.0 - ").concat(o, ") * ").concat(n.associatedVariableName, ".r * ").concat(r.associatedVariableName, ".r * 2.0 + ").concat(o, " * (1.0 - (1.0 - ").concat(n.associatedVariableName, ".r) * (1.0 - ").concat(r.associatedVariableName, ".r) * 2.0);\r\n"),
- t.compilationString += "".concat(i.associatedVariableName, ".g = (1.0 - ").concat(a, ") * ").concat(n.associatedVariableName, ".g * ").concat(r.associatedVariableName, ".g * 2.0 + ").concat(a, " * (1.0 - (1.0 - ").concat(n.associatedVariableName, ".g) * (1.0 - ").concat(r.associatedVariableName, ".g) * 2.0);\r\n"),
- t.compilationString += "".concat(i.associatedVariableName, ".b = ").concat(n.associatedVariableName, ".b * ").concat(r.associatedVariableName, ".b;\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.NormalBlendBlock", xg);
- var Rg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("input", Op.Vector2),
- i.registerInput("angle", Op.Float),
- i.registerOutput("output", Op.Vector2),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "Rotate2dBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "angle", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function() {
- if (!this.angle.isConnected) {
- var e = new tf("angle");
- e.value = 0,
- e.output.connectTo(this.angle)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this.angle
- , r = this.input;
- return t.compilationString += this._declareOutput(i, t) + " = vec2(cos(".concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".x - sin(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".y, sin(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".x + cos(").concat(n.associatedVariableName, ") * ").concat(r.associatedVariableName, ".y);\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.Rotate2dBlock", Rg);
- var Cg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("incident", Op.Vector3),
- i.registerInput("normal", Op.Vector3),
- i.registerOutput("output", Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ReflectBlock"
- }
- ,
- Object.defineProperty(t.prototype, "incident", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = reflect(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz);\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ReflectBlock", Cg);
- var Pg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("incident", Op.Vector3),
- i.registerInput("normal", Op.Vector3),
- i.registerInput("ior", Op.Float),
- i.registerOutput("output", Op.Vector3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Color4),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Vector4),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Color3),
- i._inputs[1].acceptedConnectionPointTypes.push(Op.Color4),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "RefractBlock"
- }
- ,
- Object.defineProperty(t.prototype, "incident", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "ior", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = refract(".concat(this.incident.associatedVariableName, ".xyz, ").concat(this.normal.associatedVariableName, ".xyz, ").concat(this.ior.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.RefractBlock", Pg);
- var Mg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("color", Op.Color3),
- i.registerInput("level", Op.Float),
- i.registerOutput("output", Op.Color3),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DesaturateBlock"
- }
- ,
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "level", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this.color.associatedVariableName
- , r = t._getFreeVariableName("colorMin")
- , o = t._getFreeVariableName("colorMax")
- , a = t._getFreeVariableName("colorMerge");
- return t.compilationString += "float ".concat(r, " = min(min(").concat(n, ".x, ").concat(n, ".y), ").concat(n, ".z);\r\n"),
- t.compilationString += "float ".concat(o, " = max(max(").concat(n, ".x, ").concat(n, ".y), ").concat(n, ".z);\r\n"),
- t.compilationString += "float ".concat(a, " = 0.5 * (").concat(r, " + ").concat(o, ");\r\n"),
- t.compilationString += this._declareOutput(i, t) + " = mix(".concat(n, ", vec3(").concat(a, ", ").concat(a, ", ").concat(a, "), ").concat(this.level.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.DesaturateBlock", Mg);
- var Ig = function(e) {
- function t(i) {
- var n = e.call(this, i, Dp.Fragment) || this;
- return n.albedoScaling = !1,
- n.linkSheenWithAlbedo = !1,
- n._isUnique = !0,
- n.registerInput("intensity", Op.Float, !0, Dp.Fragment),
- n.registerInput("color", Op.Color3, !0, Dp.Fragment),
- n.registerInput("roughness", Op.Float, !0, Dp.Fragment),
- n.registerOutput("sheen", Op.Object, Dp.Fragment, new Bm("sheen",n,Vp.Output,t,"SheenBlock")),
- n
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("sheenOut"),
- e._excludeVariableName("sheenMapData"),
- e._excludeVariableName("vSheenColor"),
- e._excludeVariableName("vSheenRoughness")
- }
- ,
- t.prototype.getClassName = function() {
- return "SheenBlock"
- }
- ,
- Object.defineProperty(t.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "roughness", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sheen", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.prepareDefines = function(t, i, n) {
- e.prototype.prepareDefines.call(this, t, i, n),
- n.setValue("SHEEN", !0),
- n.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
- n.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0),
- n.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0),
- n.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0)
- }
- ,
- t.prototype.getCode = function(e) {
- var t = this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)"
- , i = this.intensity.isConnected ? this.intensity.associatedVariableName : "1."
- , n = this.roughness.isConnected ? this.roughness.associatedVariableName : "0.";
- return "#ifdef SHEEN\n sheenOutParams sheenOut;\n\n vec4 vSheenColor = vec4(".concat(t, ", ").concat(i, ");\n\n sheenBlock(\n vSheenColor,\n #ifdef SHEEN_ROUGHNESS\n ").concat(n, ",\n #endif\n roughness,\n #ifdef SHEEN_TEXTURE\n ").concat("vec4(0.)", ",\n 1.0,\n #endif\n reflectance,\n #ifdef SHEEN_LINKWITHALBEDO\n baseColor,\n surfaceAlbedo,\n #endif\n #ifdef ENVIRONMENTBRDF\n NdotV,\n environmentBrdf,\n #endif\n #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\n AARoughnessFactors,\n ").concat(null == e ? void 0 : e._vReflectionMicrosurfaceInfosName, ",\n ").concat(null == e ? void 0 : e._vReflectionInfosName, ",\n ").concat(null == e ? void 0 : e.reflectionColor, ",\n vLightingIntensity,\n #ifdef ").concat(null == e ? void 0 : e._define3DName, "\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n #else\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n #endif\n reflectionOut.reflectionCoords,\n NdotVUnclamped,\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null == e ? void 0 : e._define3DName, "\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n ").concat(null == e ? void 0 : e._cubeSamplerName, ",\n #else\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n ").concat(null == e ? void 0 : e._2DSamplerName, ",\n #endif\n #endif\n #if !defined(").concat(null == e ? void 0 : e._defineSkyboxName, ") && defined(RADIANCEOCCLUSION)\n seo,\n #endif\n #if !defined(").concat(null == e ? void 0 : e._defineSkyboxName, ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(").concat(null == e ? void 0 : e._define3DName, ")\n eho,\n #endif\n #endif\n sheenOut\n );\n\n #ifdef SHEEN_LINKWITHALBEDO\n surfaceAlbedo = sheenOut.surfaceAlbedo;\n #endif\n #endif\r\n")
- }
- ,
- t.prototype._buildBlock = function(e) {
- return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return (t += "".concat(this._codeVariableName, ".albedoScaling = ").concat(this.albedoScaling, ";\r\n")) + "".concat(this._codeVariableName, ".linkSheenWithAlbedo = ").concat(this.linkSheenWithAlbedo, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.albedoScaling = this.albedoScaling,
- t.linkSheenWithAlbedo = this.linkSheenWithAlbedo,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.albedoScaling = t.albedoScaling,
- this.linkSheenWithAlbedo = t.linkSheenWithAlbedo
- }
- ,
- k([Yp("Albedo scaling", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "albedoScaling", void 0),
- k([Yp("Link sheen with albedo", Xp.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "linkSheenWithAlbedo", void 0),
- t
- }(Wp);
- y("BABYLON.SheenBlock", Ig);
- var Og = function(e) {
- function t(i) {
- var n = e.call(this, i, Dp.Fragment) || this;
- return n._isUnique = !0,
- n.registerInput("intensity", Op.Float, !0, Dp.Fragment),
- n.registerInput("direction", Op.Vector2, !0, Dp.Fragment),
- n.registerInput("uv", Op.Vector2, !0),
- n.registerInput("worldTangent", Op.Vector4, !0),
- n.registerOutput("anisotropy", Op.Object, Dp.Fragment, new Bm("anisotropy",n,Vp.Output,t,"AnisotropyBlock")),
- n
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("anisotropicOut"),
- e._excludeVariableName("TBN")
- }
- ,
- t.prototype.getClassName = function() {
- return "AnisotropyBlock"
- }
- ,
- Object.defineProperty(t.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "direction", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldTangent", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "anisotropy", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._generateTBNSpace = function(e) {
- var t = ""
- , i = "//".concat(this.name)
- , n = this.uv
- , r = this.worldPositionConnectionPoint
- , o = this.worldNormalConnectionPoint
- , a = this.worldTangent;
- n.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"),
- e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
- var s = {
- search: /defined\(TANGENT\)/g,
- replace: a.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
- };
- return a.isConnected && (t += "vec3 tbnNormal = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
- t += "vec3 tbnTangent = normalize(".concat(a.associatedVariableName, ".xyz);\r\n"),
- t += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
- t += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
- t += "\n #if defined(".concat(a.isConnected ? "TANGENT" : "IGNORE", ") && defined(NORMAL)\n mat3 TBN = vTBN;\n #else\n mat3 TBN = cotangent_frame(").concat(o.associatedVariableName + ".xyz", ", ").concat("v_" + r.associatedVariableName + ".xyz", ", ").concat(n.isConnected ? n.associatedVariableName : "vec2(0.)", ", vec2(1., 1.));\n #endif\r\n"),
- e._emitFunctionFromInclude("bumpFragmentMainFunctions", i, {
- replaceStrings: [s]
- }),
- t
- }
- ,
- t.prototype.getCode = function(e, t) {
- void 0 === t && (t = !1);
- var i = "";
- t && (i += this._generateTBNSpace(e));
- var n = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0"
- , r = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)";
- return i + "anisotropicOutParams anisotropicOut;\n anisotropicBlock(\n vec3(".concat(r, ", ").concat(n, "),\n #ifdef ANISOTROPIC_TEXTURE\n vec3(0.),\n #endif\n TBN,\n normalW,\n viewDirectionW,\n anisotropicOut\n );\r\n")
- }
- ,
- t.prototype.prepareDefines = function(t, i, n) {
- e.prototype.prepareDefines.call(this, t, i, n),
- n.setValue("ANISOTROPIC", !0),
- n.setValue("ANISOTROPIC_TEXTURE", !1, !0)
- }
- ,
- t.prototype._buildBlock = function(e) {
- return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.AnisotropyBlock", Og);
- var Dg = function(e) {
- function t(i) {
- var n = e.call(this, i) || this;
- return n.useSphericalHarmonics = !0,
- n.forceIrradianceInFragment = !1,
- n._isUnique = !0,
- n.registerInput("position", Op.Vector3, !1, Dp.Vertex),
- n.registerInput("world", Op.Matrix, !1, Dp.Vertex),
- n.registerInput("color", Op.Color3, !0, Dp.Fragment),
- n.registerOutput("reflection", Op.Object, Dp.Fragment, new Bm("reflection",n,Vp.Output,t,"ReflectionBlock")),
- n
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ReflectionBlock"
- }
- ,
- Object.defineProperty(t.prototype, "position", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this.worldPositionConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldNormal", {
- get: function() {
- return this.worldNormalConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "world", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraPosition", {
- get: function() {
- return this.cameraPositionConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "view", {
- get: function() {
- return this.viewConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "color", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "reflection", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasTexture", {
- get: function() {
- return !!this._getTexture()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "reflectionColor", {
- get: function() {
- return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)"
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._getTexture = function() {
- return this.texture ? this.texture : this._scene.environmentTexture
- }
- ,
- t.prototype.prepareDefines = function(t, i, n) {
- e.prototype.prepareDefines.call(this, t, i, n);
- var r = this._getTexture()
- , o = r && r.getTextureMatrix;
- n.setValue("REFLECTION", o, !0),
- o && (n.setValue(this._defineLODReflectionAlpha, r.lodLevelInAlpha, !0),
- n.setValue(this._defineLinearSpecularReflection, r.linearSpecularLOD, !0),
- n.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !r.invertZ : r.invertZ, !0),
- n.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0),
- n.setValue("GAMMAREFLECTION", r.gammaSpace, !0),
- n.setValue("RGBDREFLECTION", r.isRGBD, !0),
- r && r.coordinatesMode !== io.SKYBOX_MODE && r.isCube && (n.setValue("USESPHERICALFROMREFLECTIONMAP", !0),
- n.setValue("USEIRRADIANCEMAP", !1),
- this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? n.setValue("USESPHERICALINVERTEX", !1) : n.setValue("USESPHERICALINVERTEX", !0)))
- }
- ,
- t.prototype.bind = function(t, i, n, r) {
- e.prototype.bind.call(this, t, i, n);
- var o = this._getTexture();
- if (o && r) {
- o.isCube ? t.setTexture(this._cubeSamplerName, o) : t.setTexture(this._2DSamplerName, o);
- var a = o.getSize().width;
- t.setFloat3(this._vReflectionMicrosurfaceInfosName, a, o.lodGenerationScale, o.lodGenerationOffset),
- t.setFloat2(this._vReflectionFilteringInfoName, a, d.Log2(a));
- var s = r.materialDefines
- , l = o.sphericalPolynomial;
- if (s.USESPHERICALFROMREFLECTIONMAP && l)
- if (s.SPHERICAL_HARMONICS) {
- var c = l.preScaledHarmonics;
- t.setVector3("vSphericalL00", c.l00),
- t.setVector3("vSphericalL1_1", c.l1_1),
- t.setVector3("vSphericalL10", c.l10),
- t.setVector3("vSphericalL11", c.l11),
- t.setVector3("vSphericalL2_2", c.l2_2),
- t.setVector3("vSphericalL2_1", c.l2_1),
- t.setVector3("vSphericalL20", c.l20),
- t.setVector3("vSphericalL21", c.l21),
- t.setVector3("vSphericalL22", c.l22)
- } else
- t.setFloat3("vSphericalX", l.x.x, l.x.y, l.x.z),
- t.setFloat3("vSphericalY", l.y.x, l.y.y, l.y.z),
- t.setFloat3("vSphericalZ", l.z.x, l.z.y, l.z.z),
- t.setFloat3("vSphericalXX_ZZ", l.xx.x - l.zz.x, l.xx.y - l.zz.y, l.xx.z - l.zz.z),
- t.setFloat3("vSphericalYY_ZZ", l.yy.x - l.zz.x, l.yy.y - l.zz.y, l.yy.z - l.zz.z),
- t.setFloat3("vSphericalZZ", l.zz.x, l.zz.y, l.zz.z),
- t.setFloat3("vSphericalXY", l.xy.x, l.xy.y, l.xy.z),
- t.setFloat3("vSphericalYZ", l.yz.x, l.yz.y, l.yz.z),
- t.setFloat3("vSphericalZX", l.zx.x, l.zx.y, l.zx.z)
- }
- }
- ,
- t.prototype.handleVertexSide = function(t) {
- var i = e.prototype.handleVertexSide.call(this, t);
- t._emitFunctionFromInclude("harmonicsFunctions", "//".concat(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 n = t._getFreeVariableName("reflectionVector");
- return this._vEnvironmentIrradianceName = t._getFreeVariableName("vEnvironmentIrradiance"),
- t._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),
- t._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"),
- t._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0),
- t._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0),
- i + "#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\n vec3 ".concat(n, " = vec3(").concat(this._reflectionMatrixName, " * vec4(normalize(").concat(this.worldNormal.associatedVariableName, ").xyz, 0)).xyz;\n #ifdef ").concat(this._defineOppositeZ, "\n ").concat(n, ".z *= -1.0;\n #endif\n ").concat(this._vEnvironmentIrradianceName, " = computeEnvironmentIrradiance(").concat(n, ");\n #endif\r\n")
- }
- ,
- t.prototype.getCode = function(e, t) {
- var i = "";
- this.handleFragmentSideInits(e),
- e._emitFunctionFromInclude("harmonicsFunctions", "//".concat(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: ""
- }]
- }),
- e._emitFunction("sampleReflection", "\n #ifdef ".concat(this._define3DName, "\n #define sampleReflection(s, c) textureCube(s, c)\n #else\n #define sampleReflection(s, c) texture2D(s, c)\n #endif\r\n"), "//".concat(this.name)),
- e._emitFunction("sampleReflectionLod", "\n #ifdef ".concat(this._define3DName, "\n #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\r\n"), "//".concat(this.name));
- var n = "\n vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {\n ".concat(this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0), "\n return ").concat(this._reflectionVectorName, ";\n }\r\n");
- return e._emitFunction("computeReflectionCoordsPBR", n, "//".concat(this.name)),
- this._vReflectionMicrosurfaceInfosName = e._getFreeVariableName("vReflectionMicrosurfaceInfos"),
- e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"),
- this._vReflectionInfosName = e._getFreeVariableName("vReflectionInfos"),
- this._vReflectionFilteringInfoName = e._getFreeVariableName("vReflectionFilteringInfo"),
- e._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"),
- i + "#ifdef REFLECTION\n vec2 ".concat(this._vReflectionInfosName, " = vec2(1., 0.);\n\n reflectionOutParams reflectionOut;\n\n reflectionBlock(\n ").concat("v_" + this.worldPosition.associatedVariableName + ".xyz", ",\n ").concat(t, ",\n alphaG,\n ").concat(this._vReflectionMicrosurfaceInfosName, ",\n ").concat(this._vReflectionInfosName, ",\n ").concat(this.reflectionColor, ",\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #if defined(").concat(this._defineLODReflectionAlpha, ") && !defined(").concat(this._defineSkyboxName, ")\n NdotVUnclamped,\n #endif\n #ifdef ").concat(this._defineLinearSpecularReflection, "\n roughness,\n #endif\n #ifdef ").concat(this._define3DName, "\n ").concat(this._cubeSamplerName, ",\n #else\n ").concat(this._2DSamplerName, ",\n #endif\n #if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n ").concat(this._vEnvironmentIrradianceName, ",\n #endif\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n ").concat(this._reflectionMatrixName, ",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler, // ** not handled **\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(this._define3DName, "\n ").concat(this._cubeSamplerName, ",\n ").concat(this._cubeSamplerName, ",\n #else\n ").concat(this._2DSamplerName, ",\n ").concat(this._2DSamplerName, ",\n #endif\n #endif\n #ifdef REALTIME_FILTERING\n ").concat(this._vReflectionFilteringInfoName, ",\n #endif\n reflectionOut\n );\n #endif\r\n")
- }
- ,
- t.prototype._buildBlock = function(e) {
- return this._scene = e.sharedData.scene,
- e.target !== Dp.Fragment && (this._defineLODReflectionAlpha = e._getFreeDefineName("LODINREFLECTIONALPHA"),
- this._defineLinearSpecularReflection = e._getFreeDefineName("LINEARSPECULARREFLECTION")),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return this.texture && (t += "".concat(this._codeVariableName, ".texture.gammaSpace = ").concat(this.texture.gammaSpace, ";\r\n")),
- (t += "".concat(this._codeVariableName, ".useSphericalHarmonics = ").concat(this.useSphericalHarmonics, ";\r\n")) + "".concat(this._codeVariableName, ".forceIrradianceInFragment = ").concat(this.forceIrradianceInFragment, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t, i, n = e.prototype.serialize.call(this);
- return n.useSphericalHarmonics = this.useSphericalHarmonics,
- n.forceIrradianceInFragment = this.forceIrradianceInFragment,
- n.gammaSpace = null === (i = null === (t = this.texture) || void 0 === t ? void 0 : t.gammaSpace) || void 0 === i || i,
- n
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.useSphericalHarmonics = t.useSphericalHarmonics,
- this.forceIrradianceInFragment = t.forceIrradianceInFragment,
- this.texture && (this.texture.gammaSpace = t.gammaSpace)
- }
- ,
- k([Yp("Spherical Harmonics", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useSphericalHarmonics", void 0),
- k([Yp("Force irradiance in fragment", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "forceIrradianceInFragment", void 0),
- t
- }(km);
- y("BABYLON.ReflectionBlock", Dg);
- var Ng = function(e) {
- function t(i) {
- var n = e.call(this, i, Dp.Fragment) || this;
- return n.remapF0OnInterfaceChange = !0,
- n._isUnique = !0,
- n.registerInput("intensity", Op.Float, !1, Dp.Fragment),
- n.registerInput("roughness", Op.Float, !0, Dp.Fragment),
- n.registerInput("indexOfRefraction", Op.Float, !0, Dp.Fragment),
- n.registerInput("normalMapColor", Op.Color3, !0, Dp.Fragment),
- n.registerInput("uv", Op.Vector2, !0, Dp.Fragment),
- n.registerInput("tintColor", Op.Color3, !0, Dp.Fragment),
- n.registerInput("tintAtDistance", Op.Float, !0, Dp.Fragment),
- n.registerInput("tintThickness", Op.Float, !0, Dp.Fragment),
- n.registerInput("worldTangent", Op.Vector4, !0),
- n.registerOutput("clearcoat", Op.Object, Dp.Fragment, new Bm("clearcoat",n,Vp.Output,t,"ClearCoatBlock")),
- n
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("clearcoatOut"),
- e._excludeVariableName("vClearCoatParams"),
- e._excludeVariableName("vClearCoatTintParams"),
- e._excludeVariableName("vClearCoatRefractionParams"),
- e._excludeVariableName("vClearCoatTangentSpaceParams")
- }
- ,
- t.prototype.getClassName = function() {
- return "ClearCoatBlock"
- }
- ,
- Object.defineProperty(t.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "roughness", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "indexOfRefraction", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "normalMapColor", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "uv", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tintColor", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tintAtDistance", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tintThickness", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldTangent", {
- get: function() {
- return this._inputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "clearcoat", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function() {
- if (!this.intensity.isConnected) {
- var e = new tf("ClearCoat intensity",Dp.Fragment,Op.Float);
- e.value = 1,
- e.output.connectTo(this.intensity)
- }
- }
- ,
- t.prototype.prepareDefines = function(t, i, n) {
- e.prototype.prepareDefines.call(this, t, i, n),
- n.setValue("CLEARCOAT", !0),
- n.setValue("CLEARCOAT_TEXTURE", !1, !0),
- n.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
- n.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0),
- n.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0),
- n.setValue("CLEARCOAT_DEFAULTIOR", !this.indexOfRefraction.isConnected || this.indexOfRefraction.connectInputBlock.value === Qd._DefaultIndexOfRefraction, !0),
- n.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0)
- }
- ,
- t.prototype.bind = function(t, i, n) {
- var r, o;
- e.prototype.bind.call(this, t, i, n);
- var a = null !== (o = null === (r = this.indexOfRefraction.connectInputBlock) || void 0 === r ? void 0 : r.value) && void 0 !== o ? o : Qd._DefaultIndexOfRefraction
- , s = 1 - a
- , l = 1 + a
- , c = Math.pow(-s / l, 2)
- , u = 1 / a;
- t.setFloat4("vClearCoatRefractionParams", c, u, s, l);
- var h = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null
- , d = (null == h ? void 0 : h.perturbedNormal.isConnected) ? h.perturbedNormal.connectedPoint.ownerBlock : null;
- this._scene._mirroredCameraPosition ? t.setFloat2("vClearCoatTangentSpaceParams", (null == d ? void 0 : d.invertX) ? 1 : -1, (null == d ? void 0 : d.invertY) ? 1 : -1) : t.setFloat2("vClearCoatTangentSpaceParams", (null == d ? void 0 : d.invertX) ? -1 : 1, (null == d ? void 0 : d.invertY) ? -1 : 1)
- }
- ,
- t.prototype._generateTBNSpace = function(e, t, i) {
- var n = ""
- , r = "//".concat(this.name)
- , o = this.worldTangent;
- e._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
- var a = {
- search: /defined\(TANGENT\)/g,
- replace: o.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
- };
- return o.isConnected && (n += "vec3 tbnNormal = normalize(".concat(i, ".xyz);\r\n"),
- n += "vec3 tbnTangent = normalize(".concat(o.associatedVariableName, ".xyz);\r\n"),
- n += "vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",
- n += "mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),
- e._emitFunctionFromInclude("bumpFragmentMainFunctions", r, {
- replaceStrings: [a]
- }),
- n
- }
- ,
- t.GetCode = function(e, t, i, n, r, o, a) {
- var s = ""
- , l = (null == t ? void 0 : t.intensity.isConnected) ? t.intensity.associatedVariableName : "1."
- , c = (null == t ? void 0 : t.roughness.isConnected) ? t.roughness.associatedVariableName : "0."
- , u = (null == t ? void 0 : t.normalMapColor.isConnected) ? t.normalMapColor.associatedVariableName : "vec3(0.)"
- , h = (null == t ? void 0 : t.uv.isConnected) ? t.uv.associatedVariableName : "vec2(0.)"
- , d = (null == t ? void 0 : t.tintColor.isConnected) ? t.tintColor.associatedVariableName : "vec3(1.)"
- , p = (null == t ? void 0 : t.tintThickness.isConnected) ? t.tintThickness.associatedVariableName : "1."
- , f = (null == t ? void 0 : t.tintAtDistance.isConnected) ? t.tintAtDistance.associatedVariableName : "1.";
- return t && (e._emitUniformFromString("vClearCoatRefractionParams", "vec4"),
- e._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2")),
- r && t && (s += t._generateTBNSpace(e, n, a),
- o = t.worldTangent.isConnected),
- s + "clearcoatOutParams clearcoatOut;\n\n #ifdef CLEARCOAT\n vec2 vClearCoatParams = vec2(".concat(l, ", ").concat(c, ");\n vec4 vClearCoatTintParams = vec4(").concat(d, ", ").concat(p, ");\n\n clearcoatBlock(\n ").concat(n, ".xyz,\n geometricNormalW,\n viewDirectionW,\n vClearCoatParams,\n specularEnvironmentR0,\n #ifdef CLEARCOAT_TEXTURE\n vec2(0.),\n #endif\n #ifdef CLEARCOAT_TINT\n vClearCoatTintParams,\n ").concat(f, ",\n vClearCoatRefractionParams,\n #ifdef CLEARCOAT_TINT_TEXTURE\n ").concat("vec4(0.)", ",\n #endif\n #endif\n #ifdef CLEARCOAT_BUMP\n vec2(0., 1.),\n vec4(").concat(u, ", 0.),\n ").concat(h, ",\n #if defined(").concat(o ? "TANGENT" : "IGNORE", ") && defined(NORMAL)\n vTBN,\n #else\n vClearCoatTangentSpaceParams,\n #endif\n #ifdef OBJECTSPACE_NORMALMAP\n normalMatrix,\n #endif\n #endif\n #if defined(FORCENORMALFORWARD) && defined(NORMAL)\n faceNormal,\n #endif\n #ifdef REFLECTION\n ").concat(null == i ? void 0 : i._vReflectionMicrosurfaceInfosName, ",\n ").concat(null == i ? void 0 : i._vReflectionInfosName, ",\n ").concat(null == i ? void 0 : i.reflectionColor, ",\n vLightingIntensity,\n #ifdef ").concat(null == i ? void 0 : i._define3DName, "\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n #else\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null == i ? void 0 : i._define3DName, "\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n #else\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n ").concat(null == i ? void 0 : i._2DSamplerName, ",\n #endif\n #endif\n #endif\n #if defined(ENVIRONMENTBRDF) && !defined(").concat(null == i ? void 0 : i._defineSkyboxName, ")\n #ifdef RADIANCEOCCLUSION\n ambientMonochrome,\n #endif\n #endif\n #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)\n (gl_FrontFacing ? 1. : -1.),\n #endif\n clearcoatOut\n );\n #else\n clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;\n #endif\r\n")
- }
- ,
- t.prototype._buildBlock = function(e) {
- return this._scene = e.sharedData.scene,
- e.target === Dp.Fragment && (e.sharedData.bindableBlocks.push(this),
- e.sharedData.blocksWithDefines.push(this)),
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".remapF0OnInterfaceChange = ").concat(this.remapF0OnInterfaceChange, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- var r;
- e.prototype._deserialize.call(this, t, i, n),
- this.remapF0OnInterfaceChange = null === (r = t.remapF0OnInterfaceChange) || void 0 === r || r
- }
- ,
- k([Yp("Remap F0 on interface change", Xp.Boolean, "ADVANCED")], t.prototype, "remapF0OnInterfaceChange", void 0),
- t
- }(Wp);
- y("BABYLON.ClearCoatBlock", Ng);
- var Lg = function(e) {
- function t(i) {
- var n = e.call(this, i, Dp.Fragment) || this;
- return n.linkRefractionWithTransparency = !1,
- n.invertRefractionY = !1,
- n.useThicknessAsDepth = !1,
- n._isUnique = !0,
- n.registerInput("intensity", Op.Float, !1, Dp.Fragment),
- n.registerInput("tintAtDistance", Op.Float, !0, Dp.Fragment),
- n.registerInput("volumeIndexOfRefraction", Op.Float, !0, Dp.Fragment),
- n.registerOutput("refraction", Op.Object, Dp.Fragment, new Bm("refraction",n,Vp.Output,t,"RefractionBlock")),
- n
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("vRefractionPosition"),
- e._excludeVariableName("vRefractionSize")
- }
- ,
- t.prototype.getClassName = function() {
- return "RefractionBlock"
- }
- ,
- Object.defineProperty(t.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tintAtDistance", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "volumeIndexOfRefraction", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "view", {
- get: function() {
- return this.viewConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "refraction", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hasTexture", {
- get: function() {
- return !!this._getTexture()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._getTexture = function() {
- return this.texture ? this.texture : this._scene.environmentTexture
- }
- ,
- t.prototype.autoConfigure = function(e) {
- if (!this.intensity.isConnected) {
- var t = new tf("Refraction intensity",Dp.Fragment,Op.Float);
- t.value = 1,
- t.output.connectTo(this.intensity)
- }
- if (this.view && !this.view.isConnected) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.View
- }
- ));
- i || (i = new tf("view")).setAsSystemValue(Qp.View),
- i.output.connectTo(this.view)
- }
- }
- ,
- t.prototype.prepareDefines = function(t, i, n) {
- e.prototype.prepareDefines.call(this, t, i, n);
- var r = this._getTexture()
- , o = r && r.getTextureMatrix;
- n.setValue("SS_REFRACTION", o, !0),
- o && (n.setValue(this._define3DName, r.isCube, !0),
- n.setValue(this._defineLODRefractionAlpha, r.lodLevelInAlpha, !0),
- n.setValue(this._defineLinearSpecularRefraction, r.linearSpecularLOD, !0),
- n.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !r.invertZ : r.invertZ, !0),
- n.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0),
- n.setValue("SS_GAMMAREFRACTION", r.gammaSpace, !0),
- n.setValue("SS_RGBDREFRACTION", r.isRGBD, !0),
- n.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!r.boundingBoxSize, !0),
- n.setValue("SS_USE_THICKNESS_AS_DEPTH", this.useThicknessAsDepth, !0))
- }
- ,
- t.prototype.isReady = function() {
- var e = this._getTexture();
- return !(e && !e.isReadyOrNotBlocking())
- }
- ,
- t.prototype.bind = function(t, i, n) {
- var r, o, a, s;
- e.prototype.bind.call(this, t, i, n);
- var l = this._getTexture();
- if (l) {
- l.isCube ? t.setTexture(this._cubeSamplerName, l) : t.setTexture(this._2DSamplerName, l),
- t.setMatrix(this._refractionMatrixName, l.getReflectionTextureMatrix());
- var c = 1;
- l.isCube || l.depth && (c = l.depth);
- var u = null !== (s = null !== (o = null === (r = this.volumeIndexOfRefraction.connectInputBlock) || void 0 === r ? void 0 : r.value) && void 0 !== o ? o : null === (a = this.indexOfRefractionConnectionPoint.connectInputBlock) || void 0 === a ? void 0 : a.value) && void 0 !== s ? s : 1.5;
- t.setFloat4(this._vRefractionInfosName, l.level, 1 / u, c, this.invertRefractionY ? -1 : 1),
- t.setFloat4(this._vRefractionMicrosurfaceInfosName, l.getSize().width, l.lodGenerationScale, l.lodGenerationOffset, 1 / u);
- var h = l.getSize().width;
- if (t.setFloat2(this._vRefractionFilteringInfoName, h, d.Log2(h)),
- l.boundingBoxSize) {
- var p = l;
- t.setVector3("vRefractionPosition", p.boundingBoxPosition),
- t.setVector3("vRefractionSize", p.boundingBoxSize)
- }
- }
- }
- ,
- t.prototype.getCode = function(e) {
- return e.sharedData.blockingBlocks.push(this),
- e.sharedData.textureBlocks.push(this),
- this._cubeSamplerName = e._getFreeVariableName(this.name + "CubeSampler"),
- e.samplers.push(this._cubeSamplerName),
- this._2DSamplerName = e._getFreeVariableName(this.name + "2DSampler"),
- e.samplers.push(this._2DSamplerName),
- this._define3DName = e._getFreeDefineName("SS_REFRACTIONMAP_3D"),
- e._samplerDeclaration += "#ifdef ".concat(this._define3DName, "\r\n"),
- e._samplerDeclaration += "uniform samplerCube ".concat(this._cubeSamplerName, ";\r\n"),
- e._samplerDeclaration += "#else\r\n",
- e._samplerDeclaration += "uniform sampler2D ".concat(this._2DSamplerName, ";\r\n"),
- e._samplerDeclaration += "#endif\r\n",
- e.sharedData.blocksWithDefines.push(this),
- e.sharedData.bindableBlocks.push(this),
- this._defineLODRefractionAlpha = e._getFreeDefineName("SS_LODINREFRACTIONALPHA"),
- this._defineLinearSpecularRefraction = e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"),
- this._defineOppositeZ = e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"),
- this._refractionMatrixName = e._getFreeVariableName("refractionMatrix"),
- e._emitUniformFromString(this._refractionMatrixName, "mat4"),
- e._emitFunction("sampleRefraction", "\n #ifdef ".concat(this._define3DName, "\n #define sampleRefraction(s, c) textureCube(s, c)\n #else\n #define sampleRefraction(s, c) texture2D(s, c)\n #endif\r\n"), "//".concat(this.name)),
- e._emitFunction("sampleRefractionLod", "\n #ifdef ".concat(this._define3DName, "\n #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\r\n"), "//".concat(this.name)),
- this._vRefractionMicrosurfaceInfosName = e._getFreeVariableName("vRefractionMicrosurfaceInfos"),
- e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec4"),
- this._vRefractionInfosName = e._getFreeVariableName("vRefractionInfos"),
- e._emitUniformFromString(this._vRefractionInfosName, "vec4"),
- this._vRefractionFilteringInfoName = e._getFreeVariableName("vRefractionFilteringInfo"),
- e._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"),
- e._emitUniformFromString("vRefractionPosition", "vec3"),
- e._emitUniformFromString("vRefractionSize", "vec3"),
- ""
- }
- ,
- t.prototype._buildBlock = function(e) {
- return this._scene = e.sharedData.scene,
- this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return this.texture && (t = this.texture.isCube ? "".concat(this._codeVariableName, '.texture = new BABYLON.CubeTexture("').concat(this.texture.name, '");\r\n') : "".concat(this._codeVariableName, '.texture = new BABYLON.Texture("').concat(this.texture.name, '");\r\n'),
- t += "".concat(this._codeVariableName, ".texture.coordinatesMode = ").concat(this.texture.coordinatesMode, ";\r\n")),
- t += "".concat(this._codeVariableName, ".linkRefractionWithTransparency = ").concat(this.linkRefractionWithTransparency, ";\r\n"),
- (t += "".concat(this._codeVariableName, ".invertRefractionY = ").concat(this.invertRefractionY, ";\r\n")) + "".concat(this._codeVariableName, ".useThicknessAsDepth = ").concat(this.useThicknessAsDepth, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return this.texture && !this.texture.isRenderTarget && (t.texture = this.texture.serialize()),
- t.linkRefractionWithTransparency = this.linkRefractionWithTransparency,
- t.invertRefractionY = this.invertRefractionY,
- t.useThicknessAsDepth = this.useThicknessAsDepth,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- t.texture && (n = 0 === t.texture.url.indexOf("data:") ? "" : n,
- t.texture.isCube ? this.texture = Bd.Parse(t.texture, i, n) : this.texture = io.Parse(t.texture, i, n)),
- this.linkRefractionWithTransparency = t.linkRefractionWithTransparency,
- this.invertRefractionY = t.invertRefractionY,
- this.useThicknessAsDepth = !!t.useThicknessAsDepth
- }
- ,
- k([Yp("Link refraction to transparency", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "linkRefractionWithTransparency", void 0),
- k([Yp("Invert refraction Y", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "invertRefractionY", void 0),
- k([Yp("Use thickness as depth", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useThicknessAsDepth", void 0),
- t
- }(Wp);
- y("BABYLON.RefractionBlock", Lg);
- var Fg = function(e) {
- function t(i) {
- var n = e.call(this, i, Dp.Fragment) || this;
- return n._isUnique = !0,
- n.registerInput("thickness", Op.Float, !1, Dp.Fragment),
- n.registerInput("tintColor", Op.Color3, !0, Dp.Fragment),
- n.registerInput("translucencyIntensity", Op.Float, !0, Dp.Fragment),
- n.registerInput("translucencyDiffusionDist", Op.Color3, !0, Dp.Fragment),
- n.registerInput("refraction", Op.Object, !0, Dp.Fragment, new Bm("refraction",n,Vp.Input,Lg,"RefractionBlock")),
- n.registerOutput("subsurface", Op.Object, Dp.Fragment, new Bm("subsurface",n,Vp.Output,t,"SubSurfaceBlock")),
- n
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("subSurfaceOut"),
- e._excludeVariableName("vThicknessParam"),
- e._excludeVariableName("vTintColor"),
- e._excludeVariableName("vSubSurfaceIntensity")
- }
- ,
- t.prototype.getClassName = function() {
- return "SubSurfaceBlock"
- }
- ,
- Object.defineProperty(t.prototype, "thickness", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "tintColor", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "translucencyIntensity", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "translucencyDiffusionDist", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "refraction", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "subsurface", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function() {
- if (!this.thickness.isConnected) {
- var e = new tf("SubSurface thickness",Dp.Fragment,Op.Float);
- e.value = 0,
- e.output.connectTo(this.thickness)
- }
- }
- ,
- t.prototype.prepareDefines = function(t, i, n) {
- e.prototype.prepareDefines.call(this, t, i, n);
- var r = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
- n.setValue("SUBSURFACE", r || this.refraction.isConnected, !0),
- n.setValue("SS_TRANSLUCENCY", r, !0),
- n.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0),
- n.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0),
- n.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0),
- n.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0),
- n.setValue("SS_USE_GLTF_TEXTURES", !1, !0)
- }
- ,
- t.GetCode = function(e, t, i, n) {
- var r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b = "", T = (null == t ? void 0 : t.thickness.isConnected) ? t.thickness.associatedVariableName : "0.", E = (null == t ? void 0 : t.tintColor.isConnected) ? t.tintColor.associatedVariableName : "vec3(1.)", S = (null == t ? void 0 : t.translucencyIntensity.isConnected) ? null == t ? void 0 : t.translucencyIntensity.associatedVariableName : "1.", A = (null == t ? void 0 : t.translucencyDiffusionDist.isConnected) ? null == t ? void 0 : t.translucencyDiffusionDist.associatedVariableName : "vec3(1.)", x = (null == t ? void 0 : t.refraction.isConnected) ? null === (r = null == t ? void 0 : t.refraction.connectedPoint) || void 0 === r ? void 0 : r.ownerBlock : null, R = (null == x ? void 0 : x.tintAtDistance.isConnected) ? x.tintAtDistance.associatedVariableName : "1.", C = (null == x ? void 0 : x.intensity.isConnected) ? x.intensity.associatedVariableName : "1.", P = (null == x ? void 0 : x.view.isConnected) ? x.view.associatedVariableName : "";
- return (b += null !== (o = null == x ? void 0 : x.getCode(e)) && void 0 !== o ? o : "") + "subSurfaceOutParams subSurfaceOut;\n\n #ifdef SUBSURFACE\n vec2 vThicknessParam = vec2(0., ".concat(T, ");\n vec4 vTintColor = vec4(").concat(E, ", ").concat(R, ");\n vec3 vSubSurfaceIntensity = vec3(").concat(C, ", ").concat(S, ", 0.);\n\n subSurfaceBlock(\n vSubSurfaceIntensity,\n vThicknessParam,\n vTintColor,\n normalW,\n specularEnvironmentReflectance,\n #ifdef SS_THICKNESSANDMASK_TEXTURE\n vec4(0.),\n #endif\n #ifdef REFLECTION\n #ifdef SS_TRANSLUCENCY\n ").concat(null == i ? void 0 : i._reflectionMatrixName, ",\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n reflectionOut.irradianceVector,\n #endif\n #if defined(REALTIME_FILTERING)\n ").concat(null == i ? void 0 : i._cubeSamplerName, ",\n ").concat(null == i ? void 0 : i._vReflectionFilteringInfoName, ",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler,\n #endif\n #endif\n #endif\n #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\n surfaceAlbedo,\n #endif\n #ifdef SS_REFRACTION\n ").concat(n, ".xyz,\n viewDirectionW,\n ").concat(P, ",\n ").concat(null !== (a = null == x ? void 0 : x._vRefractionInfosName) && void 0 !== a ? a : "", ",\n ").concat(null !== (s = null == x ? void 0 : x._refractionMatrixName) && void 0 !== s ? s : "", ",\n ").concat(null !== (l = null == x ? void 0 : x._vRefractionMicrosurfaceInfosName) && void 0 !== l ? l : "", ",\n vLightingIntensity,\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha,\n #endif\n #ifdef ").concat(null !== (c = null == x ? void 0 : x._defineLODRefractionAlpha) && void 0 !== c ? c : "IGNORE", "\n NdotVUnclamped,\n #endif\n #ifdef ").concat(null !== (u = null == x ? void 0 : x._defineLinearSpecularRefraction) && void 0 !== u ? u : "IGNORE", "\n roughness,\n #endif\n alphaG,\n #ifdef ").concat(null !== (h = null == x ? void 0 : x._define3DName) && void 0 !== h ? h : "IGNORE", "\n ").concat(null !== (d = null == x ? void 0 : x._cubeSamplerName) && void 0 !== d ? d : "", ",\n #else\n ").concat(null !== (p = null == x ? void 0 : x._2DSamplerName) && void 0 !== p ? p : "", ",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef ").concat(null !== (f = null == x ? void 0 : x._define3DName) && void 0 !== f ? f : "IGNORE", "\n ").concat(null !== (_ = null == x ? void 0 : x._cubeSamplerName) && void 0 !== _ ? _ : "", ",\n ").concat(null !== (m = null == x ? void 0 : x._cubeSamplerName) && void 0 !== m ? m : "", ",\n #else\n ").concat(null !== (g = null == x ? void 0 : x._2DSamplerName) && void 0 !== g ? g : "", ",\n ").concat(null !== (v = null == x ? void 0 : x._2DSamplerName) && void 0 !== v ? v : "", ",\n #endif\n #endif\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #ifdef REALTIME_FILTERING\n ").concat(null !== (y = null == x ? void 0 : x._vRefractionFilteringInfoName) && void 0 !== y ? y : "", ",\n #endif\n #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\n vRefractionPosition,\n vRefractionSize,\n #endif\n #endif\n #ifdef SS_TRANSLUCENCY\n ").concat(A, ",\n #endif\n subSurfaceOut\n );\n\n #ifdef SS_REFRACTION\n surfaceAlbedo = subSurfaceOut.surfaceAlbedo;\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha = subSurfaceOut.alpha;\n #endif\n #endif\n #else\n subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;\n #endif\r\n")
- }
- ,
- t.prototype._buildBlock = function(e) {
- return e.target === Dp.Fragment && e.sharedData.blocksWithDefines.push(this),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.SubSurfaceBlock", Fg);
- var wg = {
- 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", ""]
- }
- , Bg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.VertexAndFragment) || this;
- return i._environmentBRDFTexture = null,
- i._metallicReflectanceColor = D.White(),
- i._metallicF0Factor = 1,
- i.directIntensity = 1,
- i.environmentIntensity = 1,
- i.specularIntensity = 1,
- i.lightFalloff = 0,
- i.useAlphaTest = !1,
- i.alphaTestCutoff = .5,
- i.useAlphaBlending = !1,
- i.useRadianceOverAlpha = !0,
- i.useSpecularOverAlpha = !0,
- i.enableSpecularAntiAliasing = !1,
- i.realTimeFiltering = !1,
- i.realTimeFilteringQuality = a.TEXTURE_FILTERING_QUALITY_LOW,
- i.useEnergyConservation = !0,
- i.useRadianceOcclusion = !0,
- i.useHorizonOcclusion = !0,
- i.unlit = !1,
- i.forceNormalForward = !1,
- i.debugMode = 0,
- i.debugLimit = 0,
- i.debugFactor = 1,
- i._isUnique = !0,
- i.registerInput("worldPosition", Op.Vector4, !1, Dp.Vertex),
- i.registerInput("worldNormal", Op.Vector4, !1, Dp.Fragment),
- i.registerInput("view", Op.Matrix, !1),
- i.registerInput("cameraPosition", Op.Vector3, !1, Dp.Fragment),
- i.registerInput("perturbedNormal", Op.Vector4, !0, Dp.Fragment),
- i.registerInput("baseColor", Op.Color3, !0, Dp.Fragment),
- i.registerInput("metallic", Op.Float, !1, Dp.Fragment),
- i.registerInput("roughness", Op.Float, !1, Dp.Fragment),
- i.registerInput("ambientOcc", Op.Float, !0, Dp.Fragment),
- i.registerInput("opacity", Op.Float, !0, Dp.Fragment),
- i.registerInput("indexOfRefraction", Op.Float, !0, Dp.Fragment),
- i.registerInput("ambientColor", Op.Color3, !0, Dp.Fragment),
- i.registerInput("reflection", Op.Object, !0, Dp.Fragment, new Bm("reflection",i,Vp.Input,Dg,"ReflectionBlock")),
- i.registerInput("clearcoat", Op.Object, !0, Dp.Fragment, new Bm("clearcoat",i,Vp.Input,Ng,"ClearCoatBlock")),
- i.registerInput("sheen", Op.Object, !0, Dp.Fragment, new Bm("sheen",i,Vp.Input,Ig,"SheenBlock")),
- i.registerInput("subsurface", Op.Object, !0, Dp.Fragment, new Bm("subsurface",i,Vp.Input,Fg,"SubSurfaceBlock")),
- i.registerInput("anisotropy", Op.Object, !0, Dp.Fragment, new Bm("anisotropy",i,Vp.Input,Og,"AnisotropyBlock")),
- i.registerOutput("ambientClr", Op.Color3, Dp.Fragment),
- i.registerOutput("diffuseDir", Op.Color3, Dp.Fragment),
- i.registerOutput("specularDir", Op.Color3, Dp.Fragment),
- i.registerOutput("clearcoatDir", Op.Color3, Dp.Fragment),
- i.registerOutput("sheenDir", Op.Color3, Dp.Fragment),
- i.registerOutput("diffuseInd", Op.Color3, Dp.Fragment),
- i.registerOutput("specularInd", Op.Color3, Dp.Fragment),
- i.registerOutput("clearcoatInd", Op.Color3, Dp.Fragment),
- i.registerOutput("sheenInd", Op.Color3, Dp.Fragment),
- i.registerOutput("refraction", Op.Color3, Dp.Fragment),
- i.registerOutput("lighting", Op.Color3, Dp.Fragment),
- i.registerOutput("shadow", Op.Float, Dp.Fragment),
- i.registerOutput("alpha", Op.Float, Dp.Fragment),
- i
- }
- return U(t, e),
- t.prototype.initialize = function(e) {
- e._excludeVariableName("vLightingIntensity"),
- e._excludeVariableName("geometricNormalW"),
- e._excludeVariableName("normalW"),
- e._excludeVariableName("faceNormal"),
- e._excludeVariableName("albedoOpacityOut"),
- e._excludeVariableName("surfaceAlbedo"),
- e._excludeVariableName("alpha"),
- e._excludeVariableName("aoOut"),
- e._excludeVariableName("baseColor"),
- e._excludeVariableName("reflectivityOut"),
- e._excludeVariableName("microSurface"),
- e._excludeVariableName("roughness"),
- e._excludeVariableName("NdotVUnclamped"),
- e._excludeVariableName("NdotV"),
- e._excludeVariableName("alphaG"),
- e._excludeVariableName("AARoughnessFactors"),
- e._excludeVariableName("environmentBrdf"),
- e._excludeVariableName("ambientMonochrome"),
- e._excludeVariableName("seo"),
- e._excludeVariableName("eho"),
- e._excludeVariableName("environmentRadiance"),
- e._excludeVariableName("irradianceVector"),
- e._excludeVariableName("environmentIrradiance"),
- e._excludeVariableName("diffuseBase"),
- e._excludeVariableName("specularBase"),
- e._excludeVariableName("preInfo"),
- e._excludeVariableName("info"),
- e._excludeVariableName("shadow"),
- e._excludeVariableName("finalDiffuse"),
- e._excludeVariableName("finalAmbient"),
- e._excludeVariableName("ambientOcclusionForDirectDiffuse"),
- e._excludeVariableName("finalColor"),
- e._excludeVariableName("vClipSpacePosition"),
- e._excludeVariableName("vDebugMode")
- }
- ,
- t.prototype.getClassName = function() {
- return "PBRMetallicRoughnessBlock"
- }
- ,
- Object.defineProperty(t.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "worldNormal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "view", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "perturbedNormal", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "baseColor", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "metallic", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "roughness", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "ambientOcc", {
- get: function() {
- return this._inputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "opacity", {
- get: function() {
- return this._inputs[9]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "indexOfRefraction", {
- get: function() {
- return this._inputs[10]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "ambientColor", {
- get: function() {
- return this._inputs[11]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "reflection", {
- get: function() {
- return this._inputs[12]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "clearcoat", {
- get: function() {
- return this._inputs[13]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sheen", {
- get: function() {
- return this._inputs[14]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "subsurface", {
- get: function() {
- return this._inputs[15]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "anisotropy", {
- get: function() {
- return this._inputs[16]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "ambientClr", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "diffuseDir", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "specularDir", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "clearcoatDir", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sheenDir", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "diffuseInd", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "specularInd", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "clearcoatInd", {
- get: function() {
- return this._outputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sheenInd", {
- get: function() {
- return this._outputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "refraction", {
- get: function() {
- return this._outputs[9]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lighting", {
- get: function() {
- return this._outputs[10]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "shadow", {
- get: function() {
- return this._outputs[11]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "alpha", {
- get: function() {
- return this._outputs[12]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function(e) {
- if (!this.cameraPosition.isConnected) {
- var t = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.CameraPosition
- }
- ));
- t || (t = new tf("cameraPosition")).setAsSystemValue(Qp.CameraPosition),
- t.output.connectTo(this.cameraPosition)
- }
- if (!this.view.isConnected) {
- var i = e.getInputBlockByPredicate((function(e) {
- return e.systemValue === Qp.View
- }
- ));
- i || (i = new tf("view")).setAsSystemValue(Qp.View),
- i.output.connectTo(this.view)
- }
- }
- ,
- t.prototype.prepareDefines = function(e, t, i) {
- i.setValue("PBR", !0),
- i.setValue("METALLICWORKFLOW", !0),
- i.setValue("DEBUGMODE", this.debugMode, !0),
- i.setValue("NORMALXYSCALE", !0),
- i.setValue("BUMP", this.perturbedNormal.isConnected, !0),
- i.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD),
- i.setValue("ALBEDO", !1, !0),
- i.setValue("OPACITY", this.opacity.isConnected, !0),
- i.setValue("AMBIENT", !0, !0),
- i.setValue("AMBIENTINGRAYSCALE", !1, !0),
- i.setValue("REFLECTIVITY", !1, !0),
- i.setValue("AOSTOREINMETALMAPRED", !1, !0),
- i.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0),
- i.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0),
- i.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0),
- this.lightFalloff === rp.LIGHTFALLOFF_STANDARD ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1),
- i.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === rp.LIGHTFALLOFF_GLTF ? (i.setValue("USEPHYSICALLIGHTFALLOFF", !1),
- i.setValue("USEGLTFLIGHTFALLOFF", !0)) : (i.setValue("USEPHYSICALLIGHTFALLOFF", !0),
- i.setValue("USEGLTFLIGHTFALLOFF", !1));
- var n = this.alphaTestCutoff.toString();
- i.setValue("ALPHABLEND", this.useAlphaBlending, !0),
- i.setValue("ALPHAFROMALBEDO", !1, !0),
- i.setValue("ALPHATEST", this.useAlphaTest, !0),
- i.setValue("ALPHATESTVALUE", n.indexOf(".") < 0 ? n + "." : n, !0),
- i.setValue("OPACITYRGB", !1, !0),
- i.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0),
- i.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0),
- i.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0),
- i.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0);
- var r = e.getScene();
- if (r.getEngine()._features.needTypeSuffixInShaderConstants ? i.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : i.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0),
- i.setValue("BRDF_V_HEIGHT_CORRELATED", !0),
- i.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0),
- i.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0),
- i.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0),
- i.setValue("UNLIT", this.unlit, !0),
- i.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0),
- this._environmentBRDFTexture && vs.ReflectionTextureEnabled ? (i.setValue("ENVIRONMENTBRDF", !0),
- i.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (i.setValue("ENVIRONMENTBRDF", !1),
- i.setValue("ENVIRONMENTBRDF_RGBD", !1)),
- i._areImageProcessingDirty && t.imageProcessingConfiguration && t.imageProcessingConfiguration.prepareDefines(i),
- i._areLightsDirty)
- if (this.light) {
- var o = {
- needNormals: !1,
- needRebuild: !1,
- lightmapMode: !1,
- shadowEnabled: !1,
- specularEnabled: !1
- };
- Mr.PrepareDefinesForLight(r, e, this.light, this._lightId, i, !0, o),
- o.needRebuild && i.rebuild()
- } else
- Mr.PrepareDefinesForLights(r, e, i, !0, t.maxSimultaneousLights),
- i._needNormals = !0,
- Mr.PrepareDefinesForMultiview(r, i)
- }
- ,
- t.prototype.updateUniformsAndSamples = function(e, t, i, n) {
- for (var r = 0; r < t.maxSimultaneousLights && i["LIGHT" + r]; r++) {
- var o = e.uniforms.indexOf("vLightData" + r) >= 0;
- Mr.PrepareUniformsAndSamplersForLight(r, e.uniforms, e.samplers, i["PROJECTEDLIGHTTEXTURE" + r], n, o)
- }
- }
- ,
- t.prototype.isReady = function(e, t, i) {
- return !(this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady() || i._areImageProcessingDirty && t.imageProcessingConfiguration && !t.imageProcessingConfiguration.isReady())
- }
- ,
- t.prototype.bind = function(e, t, i) {
- var n, r;
- if (i) {
- var o = i.getScene();
- this.light ? Mr.BindLight(this.light, this._lightId, o, e, !0) : Mr.BindLights(o, i, e, !0, t.maxSimultaneousLights),
- e.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture),
- e.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
- var a = this._scene.ambientColor;
- a && e.setColor3("ambientFromScene", a);
- var s = o.useRightHandedSystem === (null != o._mirroredCameraPosition);
- e.setFloat(this._invertNormalName, s ? -1 : 1),
- e.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
- var l = null !== (r = null === (n = this.indexOfRefraction.connectInputBlock) || void 0 === n ? void 0 : n.value) && void 0 !== r ? r : 1.5
- , c = Math.pow((l - 1) / (l + 1), 2);
- this._metallicReflectanceColor.scaleToRef(c * this._metallicF0Factor, L.Color3[0]);
- var u = this._metallicF0Factor;
- e.setColor4(this._vMetallicReflectanceFactorsName, L.Color3[0], u),
- t.imageProcessingConfiguration && t.imageProcessingConfiguration.bind(e)
- }
- }
- ,
- t.prototype._injectVertexCode = function(e) {
- var t, i, n = this.worldPosition, r = "//".concat(this.name);
- this.light ? (this._lightId = (void 0 !== e.counters.lightCounter ? e.counters.lightCounter : -1) + 1,
- e.counters.lightCounter = this._lightId,
- e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString())) : (e._emitFunctionFromInclude(e.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", r, {
- repeatKey: "maxSimultaneousLights"
- }),
- this._lightId = 0,
- e.sharedData.dynamicUniformBlocks.push(this));
- var o = "v_" + n.associatedVariableName;
- e._emitVaryingFromString(o, "vec4") && (e.compilationString += "".concat(o, " = ").concat(n.associatedVariableName, ";\r\n"));
- var a = this.reflection.isConnected ? null === (t = this.reflection.connectedPoint) || void 0 === t ? void 0 : t.ownerBlock : null;
- a && (a.viewConnectionPoint = this.view),
- e.compilationString += null !== (i = null == a ? void 0 : a.handleVertexSide(e)) && void 0 !== i ? i : "",
- e._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"),
- e._emitUniformFromString("ambientFromScene", "vec3"),
- e._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (e._injectAtEnd += "#if DEBUGMODE > 0\r\n",
- e._injectAtEnd += "vClipSpacePosition = gl_Position;\r\n",
- e._injectAtEnd += "#endif\r\n"),
- this.light ? e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }, {
- search: /worldPos/g,
- replace: n.associatedVariableName
- }]
- }) : (e.compilationString += "vec4 worldPos = ".concat(n.associatedVariableName, ";\r\n"),
- this.view.isConnected && (e.compilationString += "mat4 view = ".concat(this.view.associatedVariableName, ";\r\n")),
- e.compilationString += e._emitCodeFromInclude("shadowsVertex", r, {
- repeatKey: "maxSimultaneousLights"
- }))
- }
- ,
- t.prototype._getAlbedoOpacityCode = function() {
- var e = "albedoOpacityOutParams albedoOpacityOut;\r\n"
- , t = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)"
- , i = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
- return e + "albedoOpacityBlock(\n vec4(".concat(t, ", 1.),\n #ifdef ALBEDO\n vec4(1.),\n vec2(1., 1.),\n #endif\n #ifdef OPACITY\n vec4(").concat(i, "),\n vec2(1., 1.),\n #endif\n albedoOpacityOut\n );\n\n vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;\n float alpha = albedoOpacityOut.alpha;\r\n")
- }
- ,
- t.prototype._getAmbientOcclusionCode = function() {
- var e = "ambientOcclusionOutParams aoOut;\r\n"
- , t = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
- return e + "ambientOcclusionBlock(\n #ifdef AMBIENT\n vec3(".concat(t, "),\n vec4(0., 1.0, 1.0, 0.),\n #endif\n aoOut\n );\r\n")
- }
- ,
- t.prototype._getReflectivityCode = function(e) {
- var t = "reflectivityOutParams reflectivityOut;\r\n";
- return this._vMetallicReflectanceFactorsName = e._getFreeVariableName("vMetallicReflectanceFactors"),
- e._emitUniformFromString(this._vMetallicReflectanceFactorsName, "vec4"),
- t + "vec3 baseColor = surfaceAlbedo;\n\n reflectivityBlock(\n vec4(".concat(this.metallic.associatedVariableName, ", ").concat(this.roughness.associatedVariableName, ", 0., 0.),\n #ifdef METALLICWORKFLOW\n surfaceAlbedo,\n ").concat(this._vMetallicReflectanceFactorsName, ",\n #endif\n #ifdef REFLECTIVITY\n vec3(0., 0., ").concat("1.", "),\n vec4(1.),\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor,\n #endif\n #ifdef MICROSURFACEMAP\n microSurfaceTexel, <== not handled!\n #endif\n reflectivityOut\n );\n\n float microSurface = reflectivityOut.microSurface;\n float roughness = reflectivityOut.roughness;\n\n #ifdef METALLICWORKFLOW\n surfaceAlbedo = reflectivityOut.surfaceAlbedo;\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;\n #endif\r\n")
- }
- ,
- t.prototype._buildBlock = function(t) {
- var i, n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b, T, E, S, A, x, R, C, P, M, I, O, D, N, L, F, w, B, U, V, k, G;
- e.prototype._buildBlock.call(this, t),
- this._scene = t.sharedData.scene,
- this._environmentBRDFTexture || (this._environmentBRDFTexture = Hd(this._scene));
- var z = this.reflection.isConnected ? null === (i = this.reflection.connectedPoint) || void 0 === i ? void 0 : i.ownerBlock : null;
- if (z && (z.worldPositionConnectionPoint = this.worldPosition,
- z.cameraPositionConnectionPoint = this.cameraPosition,
- z.worldNormalConnectionPoint = this.worldNormal),
- t.target !== Dp.Fragment)
- return this._injectVertexCode(t),
- this;
- t.sharedData.forcedBindableBlocks.push(this),
- t.sharedData.blocksWithDefines.push(this),
- t.sharedData.blockingBlocks.push(this);
- var W = "//".concat(this.name)
- , H = "v_" + this.worldPosition.associatedVariableName
- , X = this.perturbedNormal;
- this._environmentBrdfSamplerName = t._getFreeVariableName("environmentBrdfSampler"),
- t._emit2DSampler(this._environmentBrdfSamplerName),
- t.sharedData.hints.needAlphaBlending = t.sharedData.hints.needAlphaBlending || this.useAlphaBlending,
- t.sharedData.hints.needAlphaTesting = t.sharedData.hints.needAlphaTesting || this.useAlphaTest,
- t._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)"),
- t._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
- t.uniforms.push("exposureLinear"),
- t.uniforms.push("contrast"),
- t.uniforms.push("vInverseScreenSize"),
- t.uniforms.push("vignetteSettings1"),
- t.uniforms.push("vignetteSettings2"),
- t.uniforms.push("vCameraColorCurveNegative"),
- t.uniforms.push("vCameraColorCurveNeutral"),
- t.uniforms.push("vCameraColorCurvePositive"),
- t.uniforms.push("txColorTransform"),
- t.uniforms.push("colorTransformSettings"),
- this.light ? t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", W, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString()) : t._emitFunctionFromInclude(t.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", W, {
- repeatKey: "maxSimultaneousLights"
- }),
- t._emitFunctionFromInclude("helperFunctions", W),
- t._emitFunctionFromInclude("importanceSampling", W),
- t._emitFunctionFromInclude("pbrHelperFunctions", W),
- t._emitFunctionFromInclude("imageProcessingDeclaration", W),
- t._emitFunctionFromInclude("imageProcessingFunctions", W),
- t._emitFunctionFromInclude("shadowsFragmentFunctions", W, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: H + ".xyz"
- }]
- }),
- t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", W, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: H + ".xyz"
- }]
- }),
- t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", W),
- t._emitFunctionFromInclude("pbrBRDFFunctions", W, {
- replaceStrings: [{
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: null !== (n = null == z ? void 0 : z._defineSkyboxName) && void 0 !== n ? n : "REFLECTIONMAP_SKYBOX"
- }]
- }),
- t._emitFunctionFromInclude("hdrFilteringFunctions", W),
- t._emitFunctionFromInclude("pbrDirectLightingFunctions", W, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: H + ".xyz"
- }]
- }),
- t._emitFunctionFromInclude("pbrIBLFunctions", W),
- t._emitFunctionFromInclude("pbrBlockAlbedoOpacity", W),
- t._emitFunctionFromInclude("pbrBlockReflectivity", W),
- t._emitFunctionFromInclude("pbrBlockAmbientOcclusion", W),
- t._emitFunctionFromInclude("pbrBlockAlphaFresnel", W),
- t._emitFunctionFromInclude("pbrBlockAnisotropic", W),
- t._emitUniformFromString("vLightingIntensity", "vec4"),
- this._vNormalWName = t._getFreeVariableName("vNormalW"),
- t.compilationString += "vec4 ".concat(this._vNormalWName, " = normalize(").concat(this.worldNormal.associatedVariableName, ");\r\n"),
- t._registerTempVariable("viewDirectionW") && (t.compilationString += "vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName, " - ").concat(H, ".xyz);\r\n")),
- t.compilationString += "vec3 geometricNormalW = ".concat(this._vNormalWName, ".xyz;\r\n"),
- t.compilationString += "vec3 normalW = ".concat(X.isConnected ? "normalize(" + X.associatedVariableName + ".xyz)" : "geometricNormalW", ";\r\n"),
- this._invertNormalName = t._getFreeVariableName("invertNormal"),
- t._emitUniformFromString(this._invertNormalName, "float"),
- t.compilationString += t._emitCodeFromInclude("pbrBlockNormalFinal", W, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: H + ".xyz"
- }, {
- search: /vEyePosition.w/g,
- replace: this._invertNormalName
- }]
- }),
- t.compilationString += this._getAlbedoOpacityCode(),
- t.compilationString += t._emitCodeFromInclude("depthPrePass", W),
- t.compilationString += this._getAmbientOcclusionCode(),
- t.compilationString += t._emitCodeFromInclude("pbrBlockLightmapInit", W),
- t.compilationString += "#ifdef UNLIT\n vec3 diffuseBase = vec3(1., 1., 1.);\n #else\r\n",
- t.compilationString += this._getReflectivityCode(t),
- t.compilationString += t._emitCodeFromInclude("pbrBlockGeometryInfo", W, {
- replaceStrings: [{
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: null !== (r = null == z ? void 0 : z._defineSkyboxName) && void 0 !== r ? r : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: null !== (o = null == z ? void 0 : z._define3DName) && void 0 !== o ? o : "REFLECTIONMAP_3D"
- }]
- });
- var j = this.anisotropy.isConnected ? null === (a = this.anisotropy.connectedPoint) || void 0 === a ? void 0 : a.ownerBlock : null;
- j && (j.worldPositionConnectionPoint = this.worldPosition,
- j.worldNormalConnectionPoint = this.worldNormal,
- t.compilationString += j.getCode(t, !this.perturbedNormal.isConnected)),
- z && z.hasTexture && (t.compilationString += z.getCode(t, j ? "anisotropicOut.anisotropicNormal" : "normalW")),
- t._emitFunctionFromInclude("pbrBlockReflection", W, {
- replaceStrings: [{
- search: /computeReflectionCoords/g,
- replace: "computeReflectionCoordsPBR"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: null !== (s = null == z ? void 0 : z._define3DName) && void 0 !== s ? s : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_OPPOSITEZ/g,
- replace: null !== (l = null == z ? void 0 : z._defineOppositeZ) && void 0 !== l ? l : "REFLECTIONMAP_OPPOSITEZ"
- }, {
- search: /REFLECTIONMAP_PROJECTION/g,
- replace: null !== (c = null == z ? void 0 : z._defineProjectionName) && void 0 !== c ? c : "REFLECTIONMAP_PROJECTION"
- }, {
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: null !== (u = null == z ? void 0 : z._defineSkyboxName) && void 0 !== u ? u : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /LODINREFLECTIONALPHA/g,
- replace: null !== (h = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== h ? h : "LODINREFLECTIONALPHA"
- }, {
- search: /LINEARSPECULARREFLECTION/g,
- replace: null !== (d = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== d ? d : "LINEARSPECULARREFLECTION"
- }, {
- search: /vReflectionFilteringInfo/g,
- replace: null !== (p = null == z ? void 0 : z._vReflectionFilteringInfoName) && void 0 !== p ? p : "vReflectionFilteringInfo"
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("pbrBlockReflectance0", W, {
- replaceStrings: [{
- search: /metallicReflectanceFactors/g,
- replace: this._vMetallicReflectanceFactorsName
- }]
- });
- var Y = this.sheen.isConnected ? null === (f = this.sheen.connectedPoint) || void 0 === f ? void 0 : f.ownerBlock : null;
- Y && (t.compilationString += Y.getCode(z)),
- t._emitFunctionFromInclude("pbrBlockSheen", W, {
- replaceStrings: [{
- search: /REFLECTIONMAP_3D/g,
- replace: null !== (_ = null == z ? void 0 : z._define3DName) && void 0 !== _ ? _ : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: null !== (m = null == z ? void 0 : z._defineSkyboxName) && void 0 !== m ? m : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /LODINREFLECTIONALPHA/g,
- replace: null !== (g = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== g ? g : "LODINREFLECTIONALPHA"
- }, {
- search: /LINEARSPECULARREFLECTION/g,
- replace: null !== (v = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== v ? v : "LINEARSPECULARREFLECTION"
- }]
- });
- var K = this.clearcoat.isConnected ? null === (y = this.clearcoat.connectedPoint) || void 0 === y ? void 0 : y.ownerBlock : null
- , Q = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected
- , q = this.perturbedNormal.isConnected && (null === (T = (null === (b = this.perturbedNormal.connectedPoint) || void 0 === b ? void 0 : b.ownerBlock).worldTangent) || void 0 === T ? void 0 : T.isConnected)
- , Z = this.anisotropy.isConnected && (null === (E = this.anisotropy.connectedPoint) || void 0 === E ? void 0 : E.ownerBlock).worldTangent.isConnected
- , J = q || !this.perturbedNormal.isConnected && Z;
- t.compilationString += Ng.GetCode(t, K, z, H, Q, J, this.worldNormal.associatedVariableName),
- Q && (J = null !== (S = null == K ? void 0 : K.worldTangent.isConnected) && void 0 !== S && S),
- t._emitFunctionFromInclude("pbrBlockClearcoat", W, {
- replaceStrings: [{
- search: /computeReflectionCoords/g,
- replace: "computeReflectionCoordsPBR"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: null !== (A = null == z ? void 0 : z._define3DName) && void 0 !== A ? A : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_OPPOSITEZ/g,
- replace: null !== (x = null == z ? void 0 : z._defineOppositeZ) && void 0 !== x ? x : "REFLECTIONMAP_OPPOSITEZ"
- }, {
- search: /REFLECTIONMAP_PROJECTION/g,
- replace: null !== (R = null == z ? void 0 : z._defineProjectionName) && void 0 !== R ? R : "REFLECTIONMAP_PROJECTION"
- }, {
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: null !== (C = null == z ? void 0 : z._defineSkyboxName) && void 0 !== C ? C : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /LODINREFLECTIONALPHA/g,
- replace: null !== (P = null == z ? void 0 : z._defineLODReflectionAlpha) && void 0 !== P ? P : "LODINREFLECTIONALPHA"
- }, {
- search: /LINEARSPECULARREFLECTION/g,
- replace: null !== (M = null == z ? void 0 : z._defineLinearSpecularReflection) && void 0 !== M ? M : "LINEARSPECULARREFLECTION"
- }, {
- search: /defined\(TANGENT\)/g,
- replace: J ? "defined(TANGENT)" : "defined(IGNORE)"
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("pbrBlockReflectance", W, {
- replaceStrings: [{
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: null !== (I = null == z ? void 0 : z._defineSkyboxName) && void 0 !== I ? I : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: null !== (O = null == z ? void 0 : z._define3DName) && void 0 !== O ? O : "REFLECTIONMAP_3D"
- }]
- });
- var $ = this.subsurface.isConnected ? null === (D = this.subsurface.connectedPoint) || void 0 === D ? void 0 : D.ownerBlock : null
- , ee = this.subsurface.isConnected ? null === (L = (null === (N = this.subsurface.connectedPoint) || void 0 === N ? void 0 : N.ownerBlock).refraction.connectedPoint) || void 0 === L ? void 0 : L.ownerBlock : null;
- ee && (ee.viewConnectionPoint = this.view,
- ee.indexOfRefractionConnectionPoint = this.indexOfRefraction),
- t.compilationString += Fg.GetCode(t, $, z, H),
- t._emitFunctionFromInclude("pbrBlockSubSurface", W, {
- replaceStrings: [{
- search: /REFLECTIONMAP_3D/g,
- replace: null !== (F = null == z ? void 0 : z._define3DName) && void 0 !== F ? F : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_OPPOSITEZ/g,
- replace: null !== (w = null == z ? void 0 : z._defineOppositeZ) && void 0 !== w ? w : "REFLECTIONMAP_OPPOSITEZ"
- }, {
- search: /REFLECTIONMAP_PROJECTION/g,
- replace: null !== (B = null == z ? void 0 : z._defineProjectionName) && void 0 !== B ? B : "REFLECTIONMAP_PROJECTION"
- }, {
- search: /SS_REFRACTIONMAP_3D/g,
- replace: null !== (U = null == ee ? void 0 : ee._define3DName) && void 0 !== U ? U : "SS_REFRACTIONMAP_3D"
- }, {
- search: /SS_LODINREFRACTIONALPHA/g,
- replace: null !== (V = null == ee ? void 0 : ee._defineLODRefractionAlpha) && void 0 !== V ? V : "SS_LODINREFRACTIONALPHA"
- }, {
- search: /SS_LINEARSPECULARREFRACTION/g,
- replace: null !== (k = null == ee ? void 0 : ee._defineLinearSpecularRefraction) && void 0 !== k ? k : "SS_LINEARSPECULARREFRACTION"
- }, {
- search: /SS_REFRACTIONMAP_OPPOSITEZ/g,
- replace: null !== (G = null == ee ? void 0 : ee._defineOppositeZ) && void 0 !== G ? G : "SS_REFRACTIONMAP_OPPOSITEZ"
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("pbrBlockDirectLighting", W),
- this.light ? t.compilationString += t._emitCodeFromInclude("lightFragment", W, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }) : t.compilationString += t._emitCodeFromInclude("lightFragment", W, {
- repeatKey: "maxSimultaneousLights"
- }),
- t.compilationString += t._emitCodeFromInclude("pbrBlockFinalLitComponents", W),
- t.compilationString += "#endif\r\n";
- var te = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)"
- , ie = rp.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
- -1 === ie.indexOf(".") && (ie += "."),
- t.compilationString += t._emitCodeFromInclude("pbrBlockFinalUnlitComponents", W, {
- replaceStrings: [{
- search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,
- replace: ""
- }, {
- search: /vAmbientColor/g,
- replace: te + " * ambientFromScene"
- }, {
- search: /vAmbientInfos\.w/g,
- replace: ie
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("pbrBlockFinalColorComposition", W, {
- replaceStrings: [{
- search: /finalEmissive/g,
- replace: "vec3(0.)"
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("pbrBlockImageProcessing", W, {
- replaceStrings: [{
- search: /visibility/g,
- replace: "1."
- }]
- }),
- t.compilationString += t._emitCodeFromInclude("pbrDebug", W, {
- replaceStrings: [{
- search: /vNormalW/g,
- replace: this._vNormalWName
- }, {
- search: /vPositionW/g,
- replace: H
- }, {
- search: /albedoTexture\.rgb;/g,
- replace: "vec3(1.);\r\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r\n"
- }]
- });
- for (var ne = 0, re = this._outputs; ne < re.length; ne++) {
- var oe = re[ne];
- if (oe.hasEndpoints) {
- var ae = wg[oe.name];
- if (ae) {
- var se = ae[0]
- , le = ae[1];
- le && (t.compilationString += "#if ".concat(le, "\r\n")),
- t.compilationString += "".concat(this._declareOutput(oe, t), " = ").concat(se, ";\r\n"),
- le && (t.compilationString += "#else\r\n",
- t.compilationString += "".concat(this._declareOutput(oe, t), " = vec3(0.);\r\n"),
- t.compilationString += "#endif\r\n")
- } else
- console.error("There's no remapping for the ".concat(oe.name, " end point! No code generated"))
- }
- }
- return this
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- var t = e.prototype._dumpPropertiesCode.call(this);
- return t += "".concat(this._codeVariableName, ".lightFalloff = ").concat(this.lightFalloff, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useAlphaTest = ").concat(this.useAlphaTest, ";\r\n"),
- t += "".concat(this._codeVariableName, ".alphaTestCutoff = ").concat(this.alphaTestCutoff, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useAlphaBlending = ").concat(this.useAlphaBlending, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useRadianceOverAlpha = ").concat(this.useRadianceOverAlpha, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useSpecularOverAlpha = ").concat(this.useSpecularOverAlpha, ";\r\n"),
- t += "".concat(this._codeVariableName, ".enableSpecularAntiAliasing = ").concat(this.enableSpecularAntiAliasing, ";\r\n"),
- t += "".concat(this._codeVariableName, ".realTimeFiltering = ").concat(this.realTimeFiltering, ";\r\n"),
- t += "".concat(this._codeVariableName, ".realTimeFilteringQuality = ").concat(this.realTimeFilteringQuality, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useEnergyConservation = ").concat(this.useEnergyConservation, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useRadianceOcclusion = ").concat(this.useRadianceOcclusion, ";\r\n"),
- t += "".concat(this._codeVariableName, ".useHorizonOcclusion = ").concat(this.useHorizonOcclusion, ";\r\n"),
- t += "".concat(this._codeVariableName, ".unlit = ").concat(this.unlit, ";\r\n"),
- t += "".concat(this._codeVariableName, ".forceNormalForward = ").concat(this.forceNormalForward, ";\r\n"),
- t += "".concat(this._codeVariableName, ".debugMode = ").concat(this.debugMode, ";\r\n"),
- (t += "".concat(this._codeVariableName, ".debugLimit = ").concat(this.debugLimit, ";\r\n")) + "".concat(this._codeVariableName, ".debugFactor = ").concat(this.debugFactor, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return this.light && (t.lightId = this.light.id),
- t.lightFalloff = this.lightFalloff,
- t.useAlphaTest = this.useAlphaTest,
- t.alphaTestCutoff = this.alphaTestCutoff,
- t.useAlphaBlending = this.useAlphaBlending,
- t.useRadianceOverAlpha = this.useRadianceOverAlpha,
- t.useSpecularOverAlpha = this.useSpecularOverAlpha,
- t.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing,
- t.realTimeFiltering = this.realTimeFiltering,
- t.realTimeFilteringQuality = this.realTimeFilteringQuality,
- t.useEnergyConservation = this.useEnergyConservation,
- t.useRadianceOcclusion = this.useRadianceOcclusion,
- t.useHorizonOcclusion = this.useHorizonOcclusion,
- t.unlit = this.unlit,
- t.forceNormalForward = this.forceNormalForward,
- t.debugMode = this.debugMode,
- t.debugLimit = this.debugLimit,
- t.debugFactor = this.debugFactor,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- var r, o;
- e.prototype._deserialize.call(this, t, i, n),
- t.lightId && (this.light = i.getLightById(t.lightId)),
- this.lightFalloff = null !== (r = t.lightFalloff) && void 0 !== r ? r : 0,
- this.useAlphaTest = t.useAlphaTest,
- this.alphaTestCutoff = t.alphaTestCutoff,
- this.useAlphaBlending = t.useAlphaBlending,
- this.useRadianceOverAlpha = t.useRadianceOverAlpha,
- this.useSpecularOverAlpha = t.useSpecularOverAlpha,
- this.enableSpecularAntiAliasing = t.enableSpecularAntiAliasing,
- this.realTimeFiltering = !!t.realTimeFiltering,
- this.realTimeFilteringQuality = null !== (o = t.realTimeFilteringQuality) && void 0 !== o ? o : a.TEXTURE_FILTERING_QUALITY_LOW,
- this.useEnergyConservation = t.useEnergyConservation,
- this.useRadianceOcclusion = t.useRadianceOcclusion,
- this.useHorizonOcclusion = t.useHorizonOcclusion,
- this.unlit = t.unlit,
- this.forceNormalForward = !!t.forceNormalForward,
- this.debugMode = t.debugMode,
- this.debugLimit = t.debugLimit,
- this.debugFactor = t.debugFactor
- }
- ,
- k([Yp("Direct lights", Xp.Float, "INTENSITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], t.prototype, "directIntensity", void 0),
- k([Yp("Environment lights", Xp.Float, "INTENSITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], t.prototype, "environmentIntensity", void 0),
- k([Yp("Specular highlights", Xp.Float, "INTENSITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], t.prototype, "specularIntensity", void 0),
- k([Yp("Light falloff", Xp.List, "LIGHTING & COLORS", {
- notifiers: {
- update: !0
- },
- options: [{
- label: "Physical",
- value: rp.LIGHTFALLOFF_PHYSICAL
- }, {
- label: "GLTF",
- value: rp.LIGHTFALLOFF_GLTF
- }, {
- label: "Standard",
- value: rp.LIGHTFALLOFF_STANDARD
- }]
- })], t.prototype, "lightFalloff", void 0),
- k([Yp("Alpha Testing", Xp.Boolean, "OPACITY")], t.prototype, "useAlphaTest", void 0),
- k([Yp("Alpha CutOff", Xp.Float, "OPACITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], t.prototype, "alphaTestCutoff", void 0),
- k([Yp("Alpha blending", Xp.Boolean, "OPACITY")], t.prototype, "useAlphaBlending", void 0),
- k([Yp("Radiance over alpha", Xp.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useRadianceOverAlpha", void 0),
- k([Yp("Specular over alpha", Xp.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useSpecularOverAlpha", void 0),
- k([Yp("Specular anti-aliasing", Xp.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "enableSpecularAntiAliasing", void 0),
- k([Yp("Realtime filtering", Xp.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "realTimeFiltering", void 0),
- k([Yp("Realtime filtering quality", Xp.List, "RENDERING", {
- notifiers: {
- update: !0
- },
- options: [{
- label: "Low",
- value: a.TEXTURE_FILTERING_QUALITY_LOW
- }, {
- label: "Medium",
- value: a.TEXTURE_FILTERING_QUALITY_MEDIUM
- }, {
- label: "High",
- value: a.TEXTURE_FILTERING_QUALITY_HIGH
- }]
- })], t.prototype, "realTimeFilteringQuality", void 0),
- k([Yp("Energy Conservation", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useEnergyConservation", void 0),
- k([Yp("Radiance occlusion", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useRadianceOcclusion", void 0),
- k([Yp("Horizon occlusion", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "useHorizonOcclusion", void 0),
- k([Yp("Unlit", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "unlit", void 0),
- k([Yp("Force normal forward", Xp.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], t.prototype, "forceNormalForward", void 0),
- k([Yp("Debug mode", Xp.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
- }]
- })], t.prototype, "debugMode", void 0),
- k([Yp("Split position", Xp.Float, "DEBUG", {
- min: -1,
- max: 1,
- notifiers: {
- update: !0
- }
- })], t.prototype, "debugLimit", void 0),
- k([Yp("Output factor", Xp.Float, "DEBUG", {
- min: 0,
- max: 5,
- notifiers: {
- update: !0
- }
- })], t.prototype, "debugFactor", void 0),
- t
- }(Wp);
- y("BABYLON.PBRMetallicRoughnessBlock", Bg);
- var Ug = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("left", Op.AutoDetect),
- i.registerInput("right", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ModBlock"
- }
- ,
- Object.defineProperty(t.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = mod(".concat(this.left.associatedVariableName, ", ").concat(this.right.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ModBlock", Ug);
- var Vg, kg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("row0", Op.Vector4),
- i.registerInput("row1", Op.Vector4),
- i.registerInput("row2", Op.Vector4),
- i.registerInput("row3", Op.Vector4),
- i.registerOutput("output", Op.Matrix),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "MatrixBuilder"
- }
- ,
- Object.defineProperty(t.prototype, "row0", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "row1", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "row2", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "row3", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.autoConfigure = function() {
- if (!this.row0.isConnected) {
- var e = new tf("row0");
- e.value = new R(1,0,0,0),
- e.output.connectTo(this.row0)
- }
- if (!this.row1.isConnected) {
- var t = new tf("row1");
- t.value = new R(0,1,0,0),
- t.output.connectTo(this.row1)
- }
- if (!this.row2.isConnected) {
- var i = new tf("row2");
- i.value = new R(0,0,1,0),
- i.output.connectTo(this.row2)
- }
- if (!this.row3.isConnected) {
- var n = new tf("row3");
- n.value = new R(0,0,0,1),
- n.output.connectTo(this.row3)
- }
- }
- ,
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this.row0
- , r = this.row1
- , o = this.row2
- , a = this.row3;
- return t.compilationString += this._declareOutput(i, t) + " = mat4(".concat(n.associatedVariableName, ", ").concat(r.associatedVariableName, ", ").concat(o.associatedVariableName, ", ").concat(a.associatedVariableName, ");\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.MatrixBuilder", kg),
- function(e) {
- e[e.Equal = 0] = "Equal",
- e[e.NotEqual = 1] = "NotEqual",
- e[e.LessThan = 2] = "LessThan",
- e[e.GreaterThan = 3] = "GreaterThan",
- e[e.LessOrEqual = 4] = "LessOrEqual",
- e[e.GreaterOrEqual = 5] = "GreaterOrEqual",
- e[e.Xor = 6] = "Xor",
- e[e.Or = 7] = "Or",
- e[e.And = 8] = "And"
- }(Vg || (Vg = {}));
- var Gg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.condition = Vg.LessThan,
- i.registerInput("a", Op.Float),
- i.registerInput("b", Op.Float),
- i.registerInput("true", Op.AutoDetect, !0),
- i.registerInput("false", Op.AutoDetect, !0),
- i.registerOutput("output", Op.BasedOnInput),
- i._linkConnectionTypes(2, 3),
- i._outputs[0]._typeConnectionSource = i._inputs[2],
- i._outputs[0]._defaultConnectionPointType = Op.Float,
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ConditionalBlock"
- }
- ,
- Object.defineProperty(t.prototype, "a", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "b", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "true", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "false", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this.true.isConnected ? this.true.associatedVariableName : "1.0"
- , r = this.false.isConnected ? this.false.associatedVariableName : "0.0";
- switch (this.condition) {
- case Vg.Equal:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " == ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.NotEqual:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " != ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.LessThan:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " < ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.LessOrEqual:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " <= ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.GreaterThan:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " > ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.GreaterOrEqual:
- t.compilationString += this._declareOutput(i, t) + " = ".concat(this.a.associatedVariableName, " >= ").concat(this.b.associatedVariableName, " ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.Xor:
- t.compilationString += this._declareOutput(i, t) + " = (mod(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 2.0) > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.Or:
- t.compilationString += this._declareOutput(i, t) + " = (min(".concat(this.a.associatedVariableName, " + ").concat(this.b.associatedVariableName, ", 1.0) > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n");
- break;
- case Vg.And:
- t.compilationString += this._declareOutput(i, t) + " = (".concat(this.a.associatedVariableName, " * ").concat(this.b.associatedVariableName, " > 0.0) ? ").concat(n, " : ").concat(r, ";\r\n")
- }
- return this
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.condition = this.condition,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.condition = t.condition
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".condition = BABYLON.ConditionalBlockConditions.").concat(Vg[this.condition], ";\r\n")
- }
- ,
- t
- }(Wp);
- y("BABYLON.ConditionalBlock", Gg);
- var zg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.octaves = 6,
- i.registerInput("seed", Op.AutoDetect),
- i.registerInput("chaos", Op.AutoDetect, !0),
- i.registerInput("offsetX", Op.Float, !0),
- i.registerInput("offsetY", Op.Float, !0),
- i.registerInput("offsetZ", Op.Float, !0),
- i.registerOutput("output", Op.Float),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector2),
- i._inputs[0].acceptedConnectionPointTypes.push(Op.Vector3),
- i._linkConnectionTypes(0, 1),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "CloudBlock"
- }
- ,
- Object.defineProperty(t.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "chaos", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "offsetX", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "offsetY", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "offsetZ", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- var i, n;
- if (e.prototype._buildBlock.call(this, t),
- this.seed.isConnected && this._outputs[0].hasEndpoints) {
- var r = "fbm".concat(this.octaves);
- t._emitFunction("CloudBlockCode", "\n\n float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }\n\n // Based on Morgan McGuire @morgan3d\n // https://www.shadertoy.com/view/4dS3Wd\n float cloudNoise(in vec2 x, in vec2 chaos) {\n vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);\n\n vec2 i = floor(x);\n vec2 f = fract(x);\n\n float n = dot(i, step);\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),\n mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),\n u.y\n );\n }\n\n float cloudNoise(in vec3 x, in vec3 chaos) {\n vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);\n\n vec3 i = floor(x);\n vec3 f = fract(x);\n\n float n = dot(i, step);\n\n vec3 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n }", "// CloudBlockCode"),
- t._emitFunction("CloudBlockCodeFBM" + this.octaves, "\n float fbm(in vec2 st, in vec2 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = .5;\n float frequency = 0.;\n\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitude * cloudNoise(st, chaos);\n st *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n }\n\n float fbm(in vec3 x, in vec3 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < OCTAVES; ++i) {\n value += amplitude * cloudNoise(x, chaos);\n x = x * 2.0;\n amplitude *= 0.5;\n }\n return value;\n }".replace(/fbm/gi, r).replace(/OCTAVES/gi, (0 | this.octaves).toString()), "// CloudBlockCode FBM");
- var o = t._getFreeVariableName("st")
- , a = (null === (i = this.seed.connectedPoint) || void 0 === i ? void 0 : i.type) === Op.Vector2 ? "vec2" : "vec3";
- t.compilationString += "".concat(a, " ").concat(o, " = ").concat(this.seed.associatedVariableName, ";\r\n"),
- this.offsetX.isConnected && (t.compilationString += "".concat(o, ".x += 0.1 * ").concat(this.offsetX.associatedVariableName, ";\r\n")),
- this.offsetY.isConnected && (t.compilationString += "".concat(o, ".y += 0.1 * ").concat(this.offsetY.associatedVariableName, ";\r\n")),
- this.offsetZ.isConnected && "vec3" === a && (t.compilationString += "".concat(o, ".z += 0.1 * ").concat(this.offsetZ.associatedVariableName, ";\r\n"));
- var s;
- return s = this.chaos.isConnected ? this.chaos.associatedVariableName : (null === (n = this.seed.connectedPoint) || void 0 === n ? void 0 : n.type) === Op.Vector2 ? "vec2(0., 0.)" : "vec3(0., 0., 0.)",
- t.compilationString += this._declareOutput(this._outputs[0], t) + " = ".concat(r, "(").concat(o, ", ").concat(s, ");\r\n"),
- this
- }
- }
- ,
- t.prototype._dumpPropertiesCode = function() {
- return e.prototype._dumpPropertiesCode.call(this) + "".concat(this._codeVariableName, ".octaves = ").concat(this.octaves, ";\r\n")
- }
- ,
- t.prototype.serialize = function() {
- var t = e.prototype.serialize.call(this);
- return t.octaves = this.octaves,
- t
- }
- ,
- t.prototype._deserialize = function(t, i, n) {
- e.prototype._deserialize.call(this, t, i, n),
- this.octaves = t.octaves
- }
- ,
- k([Yp("Octaves", Xp.Int)], t.prototype, "octaves", void 0),
- t
- }(Wp);
- y("BABYLON.CloudBlock", zg);
- var Wg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("seed", Op.Vector2),
- i.registerInput("offset", Op.Float),
- i.registerInput("density", Op.Float),
- i.registerOutput("output", Op.Float),
- i.registerOutput("cells", Op.Float),
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "VoronoiNoiseBlock"
- }
- ,
- Object.defineProperty(t.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "offset", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "density", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "cells", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- if (e.prototype._buildBlock.call(this, t),
- this.seed.isConnected) {
- var i = "vec2 voronoiRandom(vec2 seed, float offset){\n mat2 m = mat2(15.27, 47.63, 99.41, 89.98);\n vec2 uv = fract(sin(m * seed) * 46839.32);\n return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);\n }\n ";
- t._emitFunction("voronoiRandom", i, "// Voronoi random generator"),
- i = "void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){\n vec2 g = floor(seed * density);\n vec2 f = fract(seed * density);\n float t = 8.0;\n vec3 res = vec3(8.0, 0.0, 0.0);\n\n for(int y=-1; y<=1; y++)\n {\n for(int x=-1; x<=1; x++)\n {\n vec2 lattice = vec2(x,y);\n vec2 randomOffset = voronoiRandom(lattice + g, offset);\n float d = distance(lattice + randomOffset, f);\n if(d < res.x)\n {\n res = vec3(d, randomOffset.x, randomOffset.y);\n outValue = res.x;\n cells = res.y;\n }\n }\n }\n }\n ",
- t._emitFunction("voronoi", i, "// Voronoi");
- var n = t._getFreeVariableName("tempOutput")
- , r = t._getFreeVariableName("tempCells");
- return t.compilationString += "float ".concat(n, " = 0.0;\r\n"),
- t.compilationString += "float ".concat(r, " = 0.0;\r\n"),
- t.compilationString += "voronoi(".concat(this.seed.associatedVariableName, ", ").concat(this.offset.associatedVariableName, ", ").concat(this.density.associatedVariableName, ", ").concat(n, ", ").concat(r, ");\r\n"),
- this.output.hasEndpoints && (t.compilationString += this._declareOutput(this.output, t) + " = ".concat(n, ";\r\n")),
- this.cells.hasEndpoints && (t.compilationString += this._declareOutput(this.cells, t) + " = ".concat(r, ";\r\n")),
- this
- }
- }
- ,
- t
- }(Wp);
- y("BABYLON.VoronoiNoiseBlock", Wg);
- var Hg = function(e) {
- function t(t) {
- var i = e.call(this, t, Dp.Neutral) || this;
- return i.registerInput("input", Op.AutoDetect),
- i.registerOutput("output", Op.BasedOnInput),
- i._outputs[0]._typeConnectionSource = i._inputs[0],
- i
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ElbowBlock"
- }
- ,
- Object.defineProperty(t.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "target", {
- get: function() {
- var e = this._inputs[0];
- return e.isConnected && e.connectedPoint.ownerBlock.isInput ? Dp.Vertex : this._target
- },
- set: function(e) {
- 0 == (this._target & e) && (this._target = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildBlock = function(t) {
- e.prototype._buildBlock.call(this, t);
- var i = this._outputs[0]
- , n = this._inputs[0];
- return t.compilationString += this._declareOutput(i, t) + " = ".concat(n.associatedVariableName, ";\r\n"),
- this
- }
- ,
- t
- }(Wp);
- y("BABYLON.ElbowBlock", Hg);
- var Xg = function() {
- function e() {}
- return e.prototype.optimize = function(e, t) {}
- ,
- e
- }()
- , jg = function() {
- function e() {
- this.mm = new Map
- }
- return e.prototype.get = function(e, t) {
- var i = this.mm.get(e);
- if (void 0 !== i)
- return i.get(t)
- }
- ,
- e.prototype.set = function(e, t, i) {
- var n = this.mm.get(e);
- void 0 === n && this.mm.set(e, n = new Map),
- n.set(t, i)
- }
- ,
- e
- }()
- , Yg = function() {
- function e(e, t, i) {
- var n = this;
- this._baseMaterial = e,
- this._scene = null != t ? t : E.LastCreatedScene,
- this._options = i,
- this._subMeshToEffect = new Map,
- this._subMeshToDepthWrapper = new jg,
- this._meshes = new Map,
- this._onEffectCreatedObserver = this._baseMaterial.onEffectCreatedObservable.add((function(e) {
- var t, i = null === (t = e.subMesh) || void 0 === t ? void 0 : t.getMesh();
- i && !n._meshes.has(i) && n._meshes.set(i, i.onDisposeObservable.add((function(e) {
- for (var t = n._subMeshToEffect.keys(), i = t.next(); !0 !== i.done; i = t.next()) {
- var r = i.value;
- (null == r ? void 0 : r.getMesh()) === e && (n._subMeshToEffect.delete(r),
- n._subMeshToDepthWrapper.mm.delete(r))
- }
- }
- ))),
- n._subMeshToEffect.set(e.subMesh, [e.effect, n._scene.getEngine().currentRenderPassId]),
- n._subMeshToDepthWrapper.mm.delete(e.subMesh)
- }
- ))
- }
- return Object.defineProperty(e.prototype, "standalone", {
- get: function() {
- var e, t;
- return null !== (t = null === (e = this._options) || void 0 === e ? void 0 : e.standalone) && void 0 !== t && t
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "baseMaterial", {
- get: function() {
- return this._baseMaterial
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getEffect = function(e, t, i) {
- var n, r = null === (n = this._subMeshToDepthWrapper.mm.get(e)) || void 0 === n ? void 0 : n.get(t);
- if (!r)
- return null;
- var o = r.drawWrapper[i];
- return o || (o = r.drawWrapper[i] = new Gt(this._scene.getEngine())).setEffect(r.mainDrawWrapper.effect, r.mainDrawWrapper.defines),
- o
- }
- ,
- e.prototype.isReadyForSubMesh = function(e, t, i, n, r) {
- var o, a;
- return !(this.standalone && !this._baseMaterial.isReadyForSubMesh(e.getMesh(), e, n)) && null !== (a = null === (o = this._makeEffect(e, t, i, r)) || void 0 === o ? void 0 : o.isReady()) && void 0 !== a && a
- }
- ,
- e.prototype.dispose = function() {
- this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver),
- this._onEffectCreatedObserver = null;
- for (var e = this._meshes.entries(), t = e.next(); !0 !== t.done; t = e.next()) {
- var i = t.value
- , n = i[0]
- , r = i[1];
- n.onDisposeObservable.remove(r)
- }
- }
- ,
- e.prototype._makeEffect = function(e, t, i, n) {
- var r, o, a, s = this._scene.getEngine(), l = this._subMeshToEffect.get(e);
- if (!l)
- return null;
- var c = l[0]
- , u = l[1]
- , h = this._subMeshToDepthWrapper.get(e, i);
- if (!h) {
- var d = new Gt(s);
- d.defines = null !== (o = null === (r = e._getDrawWrapper(u)) || void 0 === r ? void 0 : r.defines) && void 0 !== o ? o : null,
- (h = {
- drawWrapper: [],
- mainDrawWrapper: d,
- depthDefines: "",
- token: fi()
- }).drawWrapper[n] = d,
- this._subMeshToDepthWrapper.set(e, i, h)
- }
- var p = t.join("\n");
- if (h.mainDrawWrapper.effect && p === h.depthDefines)
- return h.mainDrawWrapper.effect;
- h.depthDefines = p;
- var f = c.rawVertexSourceCode
- , _ = c.rawFragmentSourceCode
- , m = this._options && this._options.remappedVariables ? "#include<shadowMapVertexNormalBias>(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapVertexNormalBias
- , g = this._options && this._options.remappedVariables ? "#include<shadowMapVertexMetric>(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapVertexMetric
- , v = this._options && this._options.remappedVariables ? "#include<shadowMapFragmentSoftTransparentShadow>(".concat(this._options.remappedVariables.join(","), ")") : Mt.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow
- , y = Mt.IncludesShadersStore.shadowMapFragment;
- f = (f = -1 !== (f = (f = f.replace(/void\s+?main/g, Mt.IncludesShadersStore.shadowMapVertexExtraDeclaration + "\r\nvoid main")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g, m)).indexOf("#define SHADOWDEPTH_METRIC") ? f.replace(/#define SHADOWDEPTH_METRIC/g, g) : f.replace(/}\s*$/g, g + "\r\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
- var b = _.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW") >= 0 || _.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG") >= 0
- , T = -1 !== _.indexOf("#define SHADOWDEPTH_FRAGMENT")
- , E = "";
- b ? _ = _.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g, v) : E = v + "\r\n",
- _ = _.replace(/void\s+?main/g, Mt.IncludesShadersStore.shadowMapFragmentExtraDeclaration + "\r\nvoid main"),
- T ? _ = _.replace(/#define SHADOWDEPTH_FRAGMENT/g, y) : E += y + "\r\n",
- E && (_ = _.replace(/}\s*$/g, E + "}")),
- _ = _.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g, "");
- var S = c.getUniformNames().slice();
- S.push("biasAndScaleSM", "depthValuesSM", "lightDataSM", "softTransparentShadowSM"),
- h.mainDrawWrapper.effect = s.createEffect({
- vertexSource: f,
- fragmentSource: _,
- vertexToken: h.token,
- fragmentToken: h.token
- }, {
- attributes: c.getAttributesNames(),
- uniformsNames: S,
- uniformBuffersNames: c.getUniformBuffersNames(),
- samplers: c.getSamplers(),
- defines: p + "\n" + c.defines.replace("#define SHADOWS", "").replace(/#define SHADOW\d/g, ""),
- indexParameters: c.getIndexParameters()
- }, s);
- for (var A = 0; A < h.drawWrapper.length; ++A)
- A !== n && (null === (a = h.drawWrapper[A]) || void 0 === a || a.setEffect(h.mainDrawWrapper.effect, h.mainDrawWrapper.defines));
- return h.mainDrawWrapper.effect
- }
- ,
- e
- }();
- function Kg(e) {
- return e instanceof rp ? new Zd(e) : null
- }
- function Qg(e) {
- return e instanceof rp ? new Yd(e) : null
- }
- function qg(e) {
- return e instanceof rp ? new Qd(e) : null
- }
- function Zg(e) {
- return e instanceof rp ? new $d(e) : null
- }
- function Jg(e) {
- return e instanceof rp ? new tp(e) : null
- }
- function $g(e) {
- return e instanceof rp || e instanceof Os ? new Ps(e) : null
- }
- function ev(e, t, i, n, r, o) {
- var a = new e.DecoderBuffer;
- a.Init(t, t.byteLength);
- var s, l, c = new e.Decoder;
- try {
- var u = c.GetEncodedGeometryType(a);
- switch (u) {
- case e.TRIANGULAR_MESH:
- s = new e.Mesh,
- l = c.DecodeBufferToMesh(a, s);
- break;
- case e.POINT_CLOUD:
- s = new e.PointCloud,
- l = c.DecodeBufferToPointCloud(a, s);
- break;
- default:
- throw new Error("Invalid geometry type ".concat(u))
- }
- if (!l.ok() || !s.ptr)
- throw new Error(l.error_msg());
- if (u === e.TRIANGULAR_MESH) {
- var h = 3 * s.num_faces()
- , d = 4 * h
- , p = e._malloc(d);
- try {
- c.GetTrianglesUInt32Array(s, d, p);
- var f = new Uint32Array(h);
- f.set(new Uint32Array(e.HEAPF32.buffer,p,h)),
- n(f)
- } finally {
- e._free(p)
- }
- }
- var _ = function(t, i, n) {
- void 0 === n && (n = 1);
- var o = i.num_components()
- , a = s.num_points()
- , l = a * o
- , u = l * Float32Array.BYTES_PER_ELEMENT
- , h = e._malloc(u);
- try {
- c.GetAttributeDataArrayForAllPoints(s, i, e.DT_FLOAT32, u, h);
- var d = new Float32Array(e.HEAPF32.buffer,h,l);
- if ("color" === t && 3 === o) {
- for (var p = new Float32Array(4 * a), f = 0, _ = 0; f < p.length; f += 4,
- _ += o)
- p[f + 0] = d[_ + 0],
- p[f + 1] = d[_ + 1],
- p[f + 2] = d[_ + 2],
- p[f + 3] = 1;
- r(t, p)
- } else {
- if ((p = new Float32Array(l)).set(new Float32Array(e.HEAPF32.buffer,h,l)),
- 1 !== n)
- for (f = 0; f < p.length; f++)
- p[f] = p[f] / n;
- r(t, p)
- }
- } finally {
- e._free(h)
- }
- };
- if (i)
- for (var m in i) {
- var g = i[m];
- _(m, c.GetAttributeByUniqueId(s, g), o && o[m] || 1)
- }
- else {
- var v = {
- position: "POSITION",
- normal: "NORMAL",
- color: "COLOR",
- uv: "TEX_COORD"
- };
- for (var m in v)
- -1 !== (g = c.GetAttributeId(s, e[v[m]])) && _(m, c.GetAttribute(s, g))
- }
- } finally {
- s && e.destroy(s),
- e.destroy(c),
- e.destroy(a)
- }
- }
- function tv() {
- var e;
- onmessage = function(t) {
- var i = t.data;
- switch (i.id) {
- case "init":
- var n = i.decoder;
- n.url && (importScripts(n.url),
- e = DracoDecoderModule({
- wasmBinary: n.wasmBinary
- })),
- postMessage("done");
- break;
- case "decodeMesh":
- if (!e)
- throw new Error("Draco decoder module is not available");
- e.then((function(e) {
- ev(e, i.dataView, i.attributes, (function(e) {
- postMessage({
- id: "indices",
- value: e
- }, [e.buffer])
- }
- ), (function(e, t) {
- postMessage({
- id: e,
- value: t
- }, [t.buffer])
- }
- )),
- postMessage("done")
- }
- ))
- }
- }
- }
- var iv = function() {
- function e(t) {
- void 0 === t && (t = e.DefaultNumWorkers);
- var i = e.Configuration.decoder
- , n = i.wasmUrl && i.wasmBinaryUrl && "object" == typeof WebAssembly ? {
- url: gi.GetAbsoluteUrl(i.wasmUrl),
- wasmBinaryPromise: gi.LoadFileAsync(gi.GetAbsoluteUrl(i.wasmBinaryUrl))
- } : {
- url: gi.GetAbsoluteUrl(i.fallbackUrl),
- wasmBinaryPromise: Promise.resolve(void 0)
- };
- t && "function" == typeof Worker ? this._workerPoolPromise = n.wasmBinaryPromise.then((function(e) {
- var i = "".concat(ev, "(").concat(tv, ")()")
- , r = URL.createObjectURL(new Blob([i],{
- type: "application/javascript"
- }));
- return new vp(t,(function() {
- return new Promise((function(t, i) {
- var o = new Worker(r)
- , a = function(e) {
- o.removeEventListener("error", a),
- o.removeEventListener("message", s),
- i(e)
- }
- , s = function(e) {
- "done" === e.data && (o.removeEventListener("error", a),
- o.removeEventListener("message", s),
- t(o))
- };
- o.addEventListener("error", a),
- o.addEventListener("message", s),
- o.postMessage({
- id: "init",
- decoder: {
- url: n.url,
- wasmBinary: e
- }
- })
- }
- ))
- }
- ))
- }
- )) : this._decoderModulePromise = n.wasmBinaryPromise.then((function(e) {
- if (!n.url)
- throw new Error("Draco decoder module is not available");
- return gi.LoadScriptAsync(n.url).then((function() {
- return t = e,
- new Promise((function(e) {
- DracoDecoderModule({
- wasmBinary: t
- }).then((function(t) {
- e({
- module: t
- })
- }
- ))
- }
- ));
- var t
- }
- ))
- }
- ))
- }
- return Object.defineProperty(e, "DecoderAvailable", {
- get: function() {
- var t = e.Configuration.decoder;
- return !!(t.wasmUrl && t.wasmBinaryUrl && "object" == typeof WebAssembly || t.fallbackUrl)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.GetDefaultNumWorkers = function() {
- return "object" == typeof navigator && navigator.hardwareConcurrency ? Math.min(Math.floor(.5 * navigator.hardwareConcurrency), 4) : 1
- }
- ,
- Object.defineProperty(e, "Default", {
- get: function() {
- return e._Default || (e._Default = new e),
- e._Default
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this._workerPoolPromise && this._workerPoolPromise.then((function(e) {
- e.dispose()
- }
- )),
- delete this._workerPoolPromise,
- delete this._decoderModulePromise
- }
- ,
- e.prototype.whenReadyAsync = function() {
- return this._workerPoolPromise ? this._workerPoolPromise.then((function() {}
- )) : this._decoderModulePromise ? this._decoderModulePromise.then((function() {}
- )) : Promise.resolve()
- }
- ,
- e.prototype.decodeMeshAsync = function(e, t, i) {
- var n = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
- if (this._workerPoolPromise)
- return this._workerPoolPromise.then((function(e) {
- return new Promise((function(r, o) {
- e.push((function(e, a) {
- var s = new $n
- , l = function(t) {
- e.removeEventListener("error", l),
- e.removeEventListener("message", c),
- o(t),
- a()
- }
- , c = function(t) {
- if ("done" === t.data)
- e.removeEventListener("error", l),
- e.removeEventListener("message", c),
- r(s),
- a();
- else if ("indices" === t.data.id)
- s.indices = t.data.value;
- else {
- var n = i && i[t.data.id] ? i[t.data.id] : 1;
- if (1 !== n)
- for (var o = 0; o < t.data.value.length; o++)
- t.data.value[o] = t.data.value[o] / n;
- s.set(t.data.value, t.data.id)
- }
- };
- e.addEventListener("error", l),
- e.addEventListener("message", c);
- var u = new Uint8Array(n.byteLength);
- u.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),
- e.postMessage({
- id: "decodeMesh",
- dataView: u,
- attributes: t
- }, [u.buffer])
- }
- ))
- }
- ))
- }
- ));
- if (this._decoderModulePromise)
- return this._decoderModulePromise.then((function(e) {
- var r = new $n;
- return ev(e.module, n, t, (function(e) {
- r.indices = e
- }
- ), (function(e, t) {
- r.set(t, e)
- }
- ), i),
- r
- }
- ));
- throw new Error("Draco decoder module is not available")
- }
- ,
- e.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"
- }
- },
- e.DefaultNumWorkers = e.GetDefaultNumWorkers(),
- e._Default = null,
- e
- }()
- , nv = function() {
- function e() {
- var t = e.Configuration.decoder;
- this._decoderModulePromise = gi.LoadScriptAsync(gi.GetAbsoluteUrl(t.url)).then((function() {
- return MeshoptDecoder.ready
- }
- ))
- }
- return Object.defineProperty(e, "Default", {
- get: function() {
- return e._Default || (e._Default = new e),
- e._Default
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- delete this._decoderModulePromise
- }
- ,
- e.prototype.decodeGltfBufferAsync = function(e, t, i, n, r) {
- return this._decoderModulePromise.then((function() {
- var o = new Uint8Array(t * i);
- return MeshoptDecoder.decodeGltfBuffer(o, t, i, e, n, r),
- o
- }
- ))
- }
- ,
- e.Configuration = {
- decoder: {
- url: "https://preview.babylonjs.com/meshopt_decoder.js"
- }
- },
- e._Default = null,
- e
- }()
- , rv = 0
- , ov = function() {
- function e(e, t, i, n) {
- this.pos = e,
- this.normal = t,
- this.uv = i,
- this.vertColor = n
- }
- return e.prototype.clone = function() {
- var t, i;
- return new e(this.pos.clone(),this.normal.clone(),null === (t = this.uv) || void 0 === t ? void 0 : t.clone(),null === (i = this.vertColor) || void 0 === i ? void 0 : i.clone())
- }
- ,
- e.prototype.flip = function() {
- this.normal = this.normal.scale(-1)
- }
- ,
- e.prototype.interpolate = function(t, i) {
- return new e(x.Lerp(this.pos, t.pos, i),x.Lerp(this.normal, t.normal, i),this.uv && t.uv ? A.Lerp(this.uv, t.uv, i) : void 0,this.vertColor && t.vertColor ? N.Lerp(this.vertColor, t.vertColor, i) : void 0)
- }
- ,
- e
- }()
- , av = function() {
- function e(e, t) {
- this.normal = e,
- this.w = t
- }
- return e.FromPoints = function(t, i, n) {
- var r = n.subtract(t)
- , o = i.subtract(t);
- if (0 === r.lengthSquared() || 0 === o.lengthSquared())
- return null;
- var a = x.Normalize(x.Cross(r, o));
- return new e(a,x.Dot(a, t))
- }
- ,
- e.prototype.clone = function() {
- return new e(this.normal.clone(),this.w)
- }
- ,
- e.prototype.flip = function() {
- this.normal.scaleInPlace(-1),
- this.w = -this.w
- }
- ,
- e.prototype.splitPolygon = function(t, i, n, r, o) {
- var a, s, l = 0, c = [];
- for (a = 0; a < t.vertices.length; a++) {
- var u = (s = x.Dot(this.normal, t.vertices[a].pos) - this.w) < -e.EPSILON ? 2 : s > e.EPSILON ? 1 : 0;
- l |= u,
- c.push(u)
- }
- switch (l) {
- case 0:
- (x.Dot(this.normal, t.plane.normal) > 0 ? i : n).push(t);
- break;
- case 1:
- r.push(t);
- break;
- case 2:
- o.push(t);
- break;
- case 3:
- var h = []
- , d = [];
- for (a = 0; a < t.vertices.length; a++) {
- var p = (a + 1) % t.vertices.length
- , f = c[a]
- , _ = c[p]
- , m = t.vertices[a]
- , g = t.vertices[p];
- if (2 !== f && h.push(m),
- 1 !== f && d.push(2 !== f ? m.clone() : m),
- 3 == (f | _)) {
- s = (this.w - x.Dot(this.normal, m.pos)) / x.Dot(this.normal, g.pos.subtract(m.pos));
- var v = m.interpolate(g, s);
- h.push(v),
- d.push(v.clone())
- }
- }
- var y = void 0;
- h.length >= 3 && (y = new sv(h,t.shared)).plane && r.push(y),
- d.length >= 3 && (y = new sv(d,t.shared)).plane && o.push(y)
- }
- }
- ,
- e.EPSILON = 1e-5,
- e
- }()
- , sv = function() {
- function e(e, t) {
- this.vertices = e,
- this.shared = t,
- this.plane = av.FromPoints(e[0].pos, e[1].pos, e[2].pos)
- }
- return e.prototype.clone = function() {
- return new e(this.vertices.map((function(e) {
- return e.clone()
- }
- )),this.shared)
- }
- ,
- e.prototype.flip = function() {
- this.vertices.reverse().map((function(e) {
- e.flip()
- }
- )),
- this.plane.flip()
- }
- ,
- e
- }()
- , lv = function() {
- function e(e) {
- this._plane = null,
- this._front = null,
- this._back = null,
- this._polygons = new Array,
- e && this.build(e)
- }
- return e.prototype.clone = function() {
- var t = new e;
- return t._plane = this._plane && this._plane.clone(),
- t._front = this._front && this._front.clone(),
- t._back = this._back && this._back.clone(),
- t._polygons = this._polygons.map((function(e) {
- return e.clone()
- }
- )),
- t
- }
- ,
- e.prototype.invert = function() {
- for (var e = 0; e < this._polygons.length; e++)
- this._polygons[e].flip();
- this._plane && this._plane.flip(),
- this._front && this._front.invert(),
- this._back && this._back.invert();
- var t = this._front;
- this._front = this._back,
- this._back = t
- }
- ,
- e.prototype.clipPolygons = function(e) {
- if (!this._plane)
- return e.slice();
- for (var t = new Array, i = new Array, n = 0; n < e.length; n++)
- this._plane.splitPolygon(e[n], t, i, t, i);
- return this._front && (t = this._front.clipPolygons(t)),
- i = this._back ? this._back.clipPolygons(i) : [],
- t.concat(i)
- }
- ,
- e.prototype.clipTo = function(e) {
- this._polygons = e.clipPolygons(this._polygons),
- this._front && this._front.clipTo(e),
- this._back && this._back.clipTo(e)
- }
- ,
- e.prototype.allPolygons = function() {
- var e = this._polygons.slice();
- return this._front && (e = e.concat(this._front.allPolygons())),
- this._back && (e = e.concat(this._back.allPolygons())),
- e
- }
- ,
- e.prototype.build = function(t) {
- if (t.length) {
- this._plane || (this._plane = t[0].plane.clone());
- for (var i = new Array, n = new Array, r = 0; r < t.length; r++)
- this._plane.splitPolygon(t[r], this._polygons, this._polygons, i, n);
- i.length && (this._front || (this._front = new e),
- this._front.build(i)),
- n.length && (this._back || (this._back = new e),
- this._back.build(n))
- }
- }
- ,
- e
- }()
- , cv = function() {
- function e() {
- this._polygons = new Array
- }
- return e.FromMesh = function(t, i) {
- void 0 === i && (i = !1);
- var n, r, o, s, l, c, u, h, d, p = void 0, f = void 0, _ = new Array, m = null, g = !1;
- if (!(t instanceof Vr))
- throw "BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";
- t.computeWorldMatrix(!0),
- c = t.getWorldMatrix(),
- u = t.position.clone(),
- h = t.rotation.clone(),
- t.rotationQuaternion && (m = t.rotationQuaternion.clone()),
- d = t.scaling.clone(),
- t.material && i && (g = t.material.sideOrientation === a.MATERIAL_ClockWiseSideOrientation);
- for (var v = t.getIndices(), y = t.getVerticesData(Bi.PositionKind), b = t.getVerticesData(Bi.NormalKind), T = t.getVerticesData(Bi.UVKind), E = t.getVerticesData(Bi.ColorKind), S = t.subMeshes, R = 0, M = S.length; R < M; R++)
- for (var I = S[R].indexStart, O = S[R].indexCount + S[R].indexStart; I < O; I += 3) {
- l = [];
- for (var D = 0; D < 3; D++) {
- var L = 0 === D ? I + D : g ? I + 3 - D : I + D
- , F = new x(b[3 * v[L]],b[3 * v[L] + 1],b[3 * v[L] + 2]);
- T && (p = new A(T[2 * v[L]],T[2 * v[L] + 1])),
- E && (f = new N(E[4 * v[L]],E[4 * v[L] + 1],E[4 * v[L] + 2],E[4 * v[L] + 3]));
- var w = new x(y[3 * v[L]],y[3 * v[L] + 1],y[3 * v[L] + 2]);
- o = x.TransformCoordinates(w, c),
- r = x.TransformNormal(F, c),
- n = new ov(o,r,p,f),
- l.push(n)
- }
- (s = new sv(l,{
- subMeshId: R,
- meshId: rv,
- materialIndex: S[R].materialIndex
- })).plane && _.push(s)
- }
- var B = e._FromPolygons(_);
- return B.matrix = i ? P.Identity() : c,
- B.position = i ? x.Zero() : u,
- B.rotation = i ? x.Zero() : h,
- B.scaling = i ? x.One() : d,
- B.rotationQuaternion = i && m ? C.Identity() : m,
- rv++,
- B
- }
- ,
- e._FromPolygons = function(t) {
- var i = new e;
- return i._polygons = t,
- i
- }
- ,
- e.prototype.clone = function() {
- var t = new e;
- return t._polygons = this._polygons.map((function(e) {
- return e.clone()
- }
- )),
- t.copyTransformAttributes(this),
- t
- }
- ,
- e.prototype.union = function(t) {
- var i = new lv(this.clone()._polygons)
- , n = new lv(t.clone()._polygons);
- return i.clipTo(n),
- n.clipTo(i),
- n.invert(),
- n.clipTo(i),
- n.invert(),
- i.build(n.allPolygons()),
- e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
- }
- ,
- e.prototype.unionInPlace = function(e) {
- var t = new lv(this._polygons)
- , i = new lv(e._polygons);
- t.clipTo(i),
- i.clipTo(t),
- i.invert(),
- i.clipTo(t),
- i.invert(),
- t.build(i.allPolygons()),
- this._polygons = t.allPolygons()
- }
- ,
- e.prototype.subtract = function(t) {
- var i = new lv(this.clone()._polygons)
- , n = new lv(t.clone()._polygons);
- return i.invert(),
- i.clipTo(n),
- n.clipTo(i),
- n.invert(),
- n.clipTo(i),
- n.invert(),
- i.build(n.allPolygons()),
- i.invert(),
- e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
- }
- ,
- e.prototype.subtractInPlace = function(e) {
- var t = new lv(this._polygons)
- , i = new lv(e._polygons);
- t.invert(),
- t.clipTo(i),
- i.clipTo(t),
- i.invert(),
- i.clipTo(t),
- i.invert(),
- t.build(i.allPolygons()),
- t.invert(),
- this._polygons = t.allPolygons()
- }
- ,
- e.prototype.intersect = function(t) {
- var i = new lv(this.clone()._polygons)
- , n = new lv(t.clone()._polygons);
- return i.invert(),
- n.clipTo(i),
- n.invert(),
- i.clipTo(n),
- n.clipTo(i),
- i.build(n.allPolygons()),
- i.invert(),
- e._FromPolygons(i.allPolygons()).copyTransformAttributes(this)
- }
- ,
- e.prototype.intersectInPlace = function(e) {
- var t = new lv(this._polygons)
- , i = new lv(e._polygons);
- t.invert(),
- i.clipTo(t),
- i.invert(),
- t.clipTo(i),
- i.clipTo(t),
- t.build(i.allPolygons()),
- t.invert(),
- this._polygons = t.allPolygons()
- }
- ,
- e.prototype.inverse = function() {
- var e = this.clone();
- return e.inverseInPlace(),
- e
- }
- ,
- e.prototype.inverseInPlace = function() {
- this._polygons.map((function(e) {
- e.flip()
- }
- ))
- }
- ,
- e.prototype.copyTransformAttributes = function(e) {
- return this.matrix = e.matrix,
- this.position = e.position,
- this.rotation = e.rotation,
- this.scaling = e.scaling,
- this.rotationQuaternion = e.rotationQuaternion,
- this
- }
- ,
- e.prototype.buildMeshGeometry = function(e, t, i) {
- var n = this.matrix.clone();
- n.invert();
- var r, o, a, s = new Vr(e,t), l = [], c = [], u = [], h = null, d = null, p = x.Zero(), f = x.Zero(), _ = A.Zero(), m = new N(0,0,0,0), g = this._polygons, v = [0, 0, 0], y = {}, b = 0, T = {};
- i && g.sort((function(e, t) {
- return e.shared.meshId === t.shared.meshId ? e.shared.subMeshId - t.shared.subMeshId : e.shared.meshId - t.shared.meshId
- }
- ));
- for (var E = 0, S = g.length; E < S; E++) {
- T[(r = g[E]).shared.meshId] || (T[r.shared.meshId] = {}),
- T[r.shared.meshId][r.shared.subMeshId] || (T[r.shared.meshId][r.shared.subMeshId] = {
- indexStart: 1 / 0,
- indexEnd: -1 / 0,
- materialIndex: r.shared.materialIndex
- }),
- a = T[r.shared.meshId][r.shared.subMeshId];
- for (var R = 2, C = r.vertices.length; R < C; R++) {
- v[0] = 0,
- v[1] = R - 1,
- v[2] = R;
- for (var P = 0; P < 3; P++) {
- p.copyFrom(r.vertices[v[P]].pos),
- f.copyFrom(r.vertices[v[P]].normal),
- r.vertices[v[P]].uv && (h || (h = []),
- _.copyFrom(r.vertices[v[P]].uv)),
- r.vertices[v[P]].vertColor && (d || (d = []),
- m.copyFrom(r.vertices[v[P]].vertColor));
- var M = x.TransformCoordinates(p, n)
- , I = x.TransformNormal(f, n);
- o = y[M.x + "," + M.y + "," + M.z];
- var O = !1;
- h && h[2 * o] !== _.x && h[2 * o + 1] !== _.y && (O = !0);
- var D = !1;
- d && d[4 * o] !== m.r && d[4 * o + 1] !== m.g && d[4 * o + 2] !== m.b && d[4 * o + 3] !== m.a && (D = !0),
- (void 0 === o || u[3 * o] !== I.x || u[3 * o + 1] !== I.y || u[3 * o + 2] !== I.z || O || D) && (l.push(M.x, M.y, M.z),
- h && h.push(_.x, _.y),
- u.push(f.x, f.y, f.z),
- d && d.push(m.r, m.g, m.b, m.a),
- o = y[M.x + "," + M.y + "," + M.z] = l.length / 3 - 1),
- c.push(o),
- a.indexStart = Math.min(b, a.indexStart),
- a.indexEnd = Math.max(b, a.indexEnd),
- b++
- }
- }
- }
- if (s.setVerticesData(Bi.PositionKind, l),
- s.setVerticesData(Bi.NormalKind, u),
- h && s.setVerticesData(Bi.UVKind, h),
- d && s.setVerticesData(Bi.ColorKind, d),
- s.setIndices(c, null),
- i) {
- var L = 0
- , F = void 0;
- for (var w in s.subMeshes = new Array,
- T) {
- for (var B in F = -1,
- T[w])
- a = T[w][B],
- hr.CreateFromIndices(a.materialIndex + L, a.indexStart, a.indexEnd - a.indexStart + 1, s),
- F = Math.max(a.materialIndex, F);
- L += ++F
- }
- }
- return s
- }
- ,
- e.prototype.toMesh = function(e, t, i, n) {
- void 0 === t && (t = null);
- var r = this.buildMeshGeometry(e, i, n);
- return r.material = t,
- r.position.copyFrom(this.position),
- r.rotation.copyFrom(this.rotation),
- this.rotationQuaternion && (r.rotationQuaternion = this.rotationQuaternion.clone()),
- r.scaling.copyFrom(this.scaling),
- r.computeWorldMatrix(!0),
- r
- }
- ,
- e
- }();
- Vr._GoldbergMeshParser = function(e, t) {
- return uv.Parse(e, t)
- }
- ;
- var uv = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t.goldbergData = {
- faceColors: [],
- faceCenters: [],
- faceZaxis: [],
- faceXaxis: [],
- faceYaxis: [],
- nbSharedFaces: 0,
- nbUnsharedFaces: 0,
- nbFaces: 0,
- nbFacesAtPole: 0,
- adjacentFaces: []
- },
- t
- }
- return U(t, e),
- t.prototype.relatedGoldbergFace = function(e, t) {
- return void 0 === t ? (e > this.goldbergData.nbUnsharedFaces - 1 && (K.Warn("Maximum number of unshared faces used"),
- e = this.goldbergData.nbUnsharedFaces - 1),
- this.goldbergData.nbUnsharedFaces + e) : (e > 11 && (K.Warn("Last pole used"),
- e = 11),
- t > this.goldbergData.nbFacesAtPole - 1 && (K.Warn("Maximum number of faces at a pole used"),
- t = this.goldbergData.nbFacesAtPole - 1),
- 12 + e * this.goldbergData.nbFacesAtPole + t)
- }
- ,
- t.prototype._changeGoldbergFaceColors = function(e) {
- for (var t = 0; t < e.length; t++)
- for (var i = e[t][0], n = e[t][1], r = e[t][2], o = i; o < n + 1; o++)
- this.goldbergData.faceColors[o] = r;
- var a = [];
- for (o = 0; o < 12; o++)
- for (t = 0; t < 5; t++)
- a.push(this.goldbergData.faceColors[o].r, this.goldbergData.faceColors[o].g, this.goldbergData.faceColors[o].b, this.goldbergData.faceColors[o].a);
- for (o = 12; o < this.goldbergData.faceColors.length; o++)
- for (t = 0; t < 6; t++)
- a.push(this.goldbergData.faceColors[o].r, this.goldbergData.faceColors[o].g, this.goldbergData.faceColors[o].b, this.goldbergData.faceColors[o].a);
- return a
- }
- ,
- t.prototype.setGoldbergFaceColors = function(e) {
- var t = this._changeGoldbergFaceColors(e);
- this.setVerticesData(Bi.ColorKind, t)
- }
- ,
- t.prototype.updateGoldbergFaceColors = function(e) {
- var t = this._changeGoldbergFaceColors(e);
- this.updateVerticesData(Bi.ColorKind, t)
- }
- ,
- t.prototype._changeGoldbergFaceUVs = function(e) {
- for (var t = this.getVerticesData(Bi.UVKind), i = 0; i < e.length; i++) {
- for (var n = e[i][0], r = e[i][1], o = e[i][2], a = e[i][3], s = e[i][4], l = [], c = [], u = void 0, h = void 0, d = 0; d < 5; d++)
- u = o.x + a * Math.cos(s + d * Math.PI / 2.5),
- h = o.y + a * Math.sin(s + d * Math.PI / 2.5),
- u < 0 && (u = 0),
- u > 1 && (u = 1),
- l.push(u, h);
- for (d = 0; d < 6; d++)
- u = o.x + a * Math.cos(s + d * Math.PI / 3),
- h = o.y + a * Math.sin(s + d * Math.PI / 3),
- u < 0 && (u = 0),
- u > 1 && (u = 1),
- c.push(u, h);
- for (var p = n; p < Math.min(12, r + 1); p++)
- for (d = 0; d < 5; d++)
- t[10 * p + 2 * d] = l[2 * d],
- t[10 * p + 2 * d + 1] = l[2 * d + 1];
- for (p = Math.max(12, n); p < r + 1; p++)
- for (d = 0; d < 6; d++)
- t[12 * p - 24 + 2 * d] = c[2 * d],
- t[12 * p - 23 + 2 * d] = c[2 * d + 1]
- }
- return t
- }
- ,
- t.prototype.setGoldbergFaceUVs = function(e) {
- var t = this._changeGoldbergFaceUVs(e);
- this.setVerticesData(Bi.UVKind, t)
- }
- ,
- t.prototype.updateGoldbergFaceUVs = function(e) {
- var t = this._changeGoldbergFaceUVs(e);
- this.updateVerticesData(Bi.UVKind, t)
- }
- ,
- t.prototype.placeOnGoldbergFaceAt = function(e, t, i) {
- var n = x.RotationFromAxis(this.goldbergData.faceXaxis[t], this.goldbergData.faceYaxis[t], this.goldbergData.faceZaxis[t]);
- e.rotation = n,
- e.position = this.goldbergData.faceCenters[t].add(this.goldbergData.faceXaxis[t].scale(i.x)).add(this.goldbergData.faceYaxis[t].scale(i.y)).add(this.goldbergData.faceZaxis[t].scale(i.z))
- }
- ,
- t.prototype.serialize = function(t) {
- e.prototype.serialize.call(this, t),
- t.type = "GoldbergMesh";
- var i = {};
- if (i.adjacentFaces = this.goldbergData.adjacentFaces,
- i.nbSharedFaces = this.goldbergData.nbSharedFaces,
- i.nbUnsharedFaces = this.goldbergData.nbUnsharedFaces,
- i.nbFaces = this.goldbergData.nbFaces,
- i.nbFacesAtPole = this.goldbergData.nbFacesAtPole,
- this.goldbergData.faceColors) {
- i.faceColors = [];
- for (var n = 0, r = this.goldbergData.faceColors; n < r.length; n++) {
- var o = r[n];
- i.faceColors.push(o.asArray())
- }
- }
- if (this.goldbergData.faceCenters) {
- i.faceCenters = [];
- for (var a = 0, s = this.goldbergData.faceCenters; a < s.length; a++) {
- var l = s[a];
- i.faceCenters.push(l.asArray())
- }
- }
- if (this.goldbergData.faceZaxis) {
- i.faceZaxis = [];
- for (var c = 0, u = this.goldbergData.faceZaxis; c < u.length; c++)
- l = u[c],
- i.faceZaxis.push(l.asArray())
- }
- if (this.goldbergData.faceYaxis) {
- i.faceYaxis = [];
- for (var h = 0, d = this.goldbergData.faceYaxis; h < d.length; h++)
- l = d[h],
- i.faceYaxis.push(l.asArray())
- }
- if (this.goldbergData.faceXaxis) {
- i.faceXaxis = [];
- for (var p = 0, f = this.goldbergData.faceXaxis; p < f.length; p++)
- l = f[p],
- i.faceXaxis.push(l.asArray())
- }
- t.goldbergData = i
- }
- ,
- t.Parse = function(e, i) {
- var n = e.goldbergData;
- n.faceColors = n.faceColors.map((function(e) {
- return N.FromArray(e)
- }
- )),
- n.faceCenters = n.faceCenters.map((function(e) {
- return x.FromArray(e)
- }
- )),
- n.faceZaxis = n.faceZaxis.map((function(e) {
- return x.FromArray(e)
- }
- )),
- n.faceXaxis = n.faceXaxis.map((function(e) {
- return x.FromArray(e)
- }
- )),
- n.faceYaxis = n.faceYaxis.map((function(e) {
- return x.FromArray(e)
- }
- ));
- var r = new t(e.name,i);
- return r.goldbergData = n,
- r
- }
- ,
- t
- }(Vr)
- , hv = function(e) {
- function t(t, i, n, r, o, a) {
- void 0 === r && (r = 1),
- void 0 === o && (o = 60),
- void 0 === a && (a = !0);
- var s = e.call(this, t, n) || this;
- s._sectionPolygonPointsCount = 4,
- s._running = !1,
- s._autoStart = a,
- s._generator = i,
- s._diameter = r,
- s._length = o,
- s._sectionVectors = [],
- s._sectionNormalVectors = [];
- for (var l = 0; l < s._sectionPolygonPointsCount; l++)
- s._sectionVectors[l] = x.Zero(),
- s._sectionNormalVectors[l] = x.Zero();
- return s._createMesh(),
- s
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "TrailMesh"
- }
- ,
- t.prototype._createMesh = function() {
- var e = new $n
- , t = []
- , i = []
- , n = []
- , r = x.Zero();
- r = this._generator instanceof Sr && this._generator.hasBoundingInfo ? this._generator.getBoundingInfo().boundingBox.centerWorld : this._generator.position;
- for (var o = 2 * Math.PI / this._sectionPolygonPointsCount, a = 0; a < this._sectionPolygonPointsCount; a++)
- t.push(r.x + Math.cos(a * o) * this._diameter, r.y + Math.sin(a * o) * this._diameter, r.z);
- for (a = 1; a <= this._length; a++) {
- for (var s = 0; s < this._sectionPolygonPointsCount; s++)
- t.push(r.x + Math.cos(s * o) * this._diameter, r.y + Math.sin(s * o) * this._diameter, r.z);
- var l = t.length / 3 - 2 * this._sectionPolygonPointsCount;
- for (s = 0; s < this._sectionPolygonPointsCount - 1; s++)
- n.push(l + s, l + s + this._sectionPolygonPointsCount, l + s + this._sectionPolygonPointsCount + 1),
- n.push(l + s, l + s + this._sectionPolygonPointsCount + 1, l + s + 1);
- n.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount),
- n.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l)
- }
- $n.ComputeNormals(t, n, i),
- e.positions = t,
- e.normals = i,
- e.indices = n,
- e.applyToMesh(this, !0),
- this._autoStart && this.start()
- }
- ,
- t.prototype.start = function() {
- var e = this;
- this._running || (this._running = !0,
- this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add((function() {
- e.update()
- }
- )))
- }
- ,
- t.prototype.stop = function() {
- this._beforeRenderObserver && this._running && (this._running = !1,
- this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver))
- }
- ,
- t.prototype.update = function() {
- var e = this.getVerticesData(Bi.PositionKind)
- , t = this.getVerticesData(Bi.NormalKind)
- , i = this._generator.getWorldMatrix();
- if (e && t) {
- for (var n = 3 * this._sectionPolygonPointsCount; n < e.length; n++)
- e[n - 3 * this._sectionPolygonPointsCount] = e[n] - t[n] / this._length * this._diameter;
- for (n = 3 * this._sectionPolygonPointsCount; n < t.length; n++)
- t[n - 3 * this._sectionPolygonPointsCount] = t[n];
- var r = e.length - 3 * this._sectionPolygonPointsCount
- , o = 2 * Math.PI / this._sectionPolygonPointsCount;
- for (n = 0; n < this._sectionPolygonPointsCount; n++)
- this._sectionVectors[n].copyFromFloats(Math.cos(n * o) * this._diameter, Math.sin(n * o) * this._diameter, 0),
- this._sectionNormalVectors[n].copyFromFloats(Math.cos(n * o), Math.sin(n * o), 0),
- x.TransformCoordinatesToRef(this._sectionVectors[n], i, this._sectionVectors[n]),
- x.TransformNormalToRef(this._sectionNormalVectors[n], i, this._sectionNormalVectors[n]);
- for (n = 0; n < this._sectionPolygonPointsCount; n++)
- e[r + 3 * n] = this._sectionVectors[n].x,
- e[r + 3 * n + 1] = this._sectionVectors[n].y,
- e[r + 3 * n + 2] = this._sectionVectors[n].z,
- t[r + 3 * n] = this._sectionNormalVectors[n].x,
- t[r + 3 * n + 1] = this._sectionNormalVectors[n].y,
- t[r + 3 * n + 2] = this._sectionNormalVectors[n].z;
- this.updateVerticesData(Bi.PositionKind, e, !0, !1),
- this.updateVerticesData(Bi.NormalKind, t, !0, !1)
- }
- }
- ,
- t.prototype.clone = function(e, i) {
- return void 0 === e && (e = ""),
- new t(e,void 0 === i ? this._generator : i,this.getScene(),this._diameter,this._length,this._autoStart)
- }
- ,
- t.prototype.serialize = function(t) {
- e.prototype.serialize.call(this, t)
- }
- ,
- t.Parse = function(e, i) {
- return new t(e.name,e._generator,i,e._diameter,e._length,e._autoStart)
- }
- ,
- t
- }(Vr);
- function dv(e) {
- var t = e.pattern || Vr.NO_FLIP
- , i = e.tileWidth || e.tileSize || 1
- , n = e.tileHeight || e.tileSize || 1
- , r = e.alignHorizontal || 0
- , o = e.alignVertical || 0
- , a = e.width || e.size || 1
- , s = Math.floor(a / i)
- , l = a - s * i
- , c = e.height || e.size || 1
- , u = Math.floor(c / n)
- , h = c - u * n
- , d = i * s / 2
- , p = n * u / 2
- , f = 0
- , _ = 0
- , m = 0
- , g = 0
- , v = 0
- , y = 0;
- if (l > 0 || h > 0) {
- switch (m = -d,
- g = -p,
- v = d,
- y = p,
- r) {
- case Vr.CENTER:
- m -= l /= 2,
- v += l;
- break;
- case Vr.LEFT:
- v += l,
- f = -l / 2;
- break;
- case Vr.RIGHT:
- m -= l,
- f = l / 2
- }
- switch (o) {
- case Vr.CENTER:
- g -= h /= 2,
- y += h;
- break;
- case Vr.BOTTOM:
- y += h,
- _ = -h / 2;
- break;
- case Vr.TOP:
- g -= h,
- _ = h / 2
- }
- }
- var b = []
- , T = []
- , E = [];
- E[0] = [0, 0, 1, 0, 1, 1, 0, 1],
- E[1] = [0, 0, 1, 0, 1, 1, 0, 1],
- t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (E[1] = [1, 1, 0, 1, 0, 0, 1, 0]),
- t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (E[1] = [1, 0, 0, 0, 0, 1, 1, 1]),
- t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (E[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
- for (var S = [], A = [], x = [], R = 0, C = 0; C < u; C++)
- for (var P = 0; P < s; P++)
- b.push(P * i - d + f, C * n - p + _, 0),
- b.push((P + 1) * i - d + f, C * n - p + _, 0),
- b.push((P + 1) * i - d + f, (C + 1) * n - p + _, 0),
- b.push(P * i - d + f, (C + 1) * n - p + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(E[(P % 2 + C % 2) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(E[C % 2]) : S.concat(E[0]),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1),
- R += 4;
- if (l > 0 || h > 0) {
- var M = h > 0 && (o === Vr.CENTER || o === Vr.TOP)
- , I = h > 0 && (o === Vr.CENTER || o === Vr.BOTTOM)
- , O = l > 0 && (r === Vr.CENTER || r === Vr.RIGHT)
- , D = l > 0 && (r === Vr.CENTER || r === Vr.LEFT)
- , N = []
- , L = void 0
- , F = void 0
- , w = void 0
- , B = void 0;
- if (M && O && (b.push(m + f, g + _, 0),
- b.push(-d + f, g + _, 0),
- b.push(-d + f, g + h + _, 0),
- b.push(m + f, g + h + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- N = [L = 1 - l / i, F = 1 - h / n, w = 1, F, w, B = 1, L, B],
- t === Vr.ROTATE_ROW && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- t === Vr.FLIP_ROW && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- t === Vr.FLIP_N_ROTATE_ROW && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- S = S.concat(N),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- M && D && (b.push(d + f, g + _, 0),
- b.push(v + f, g + _, 0),
- b.push(v + f, g + h + _, 0),
- b.push(d + f, g + h + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- N = [L = 0, F = 1 - h / n, w = l / i, F, w, B = 1, L, B],
- (t === Vr.ROTATE_ROW || t === Vr.ROTATE_TILE && s % 2 == 0) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- (t === Vr.FLIP_ROW || t === Vr.FLIP_TILE && s % 2 == 0) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- (t === Vr.FLIP_N_ROTATE_ROW || t === Vr.FLIP_N_ROTATE_TILE && s % 2 == 0) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- S = S.concat(N),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- I && O && (b.push(m + f, p + _, 0),
- b.push(-d + f, p + _, 0),
- b.push(-d + f, y + _, 0),
- b.push(m + f, y + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- N = [L = 1 - l / i, F = 0, w = 1, F, w, B = h / n, L, B],
- (t === Vr.ROTATE_ROW && u % 2 == 1 || t === Vr.ROTATE_TILE && u % 1 == 0) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- (t === Vr.FLIP_ROW && u % 2 == 1 || t === Vr.FLIP_TILE && u % 2 == 0) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- (t === Vr.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Vr.FLIP_N_ROTATE_TILE && u % 2 == 0) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- S = S.concat(N),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- I && D && (b.push(d + f, p + _, 0),
- b.push(v + f, p + _, 0),
- b.push(v + f, y + _, 0),
- b.push(d + f, y + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- N = [L = 0, F = 0, w = l / i, F, w, B = h / n, L, B],
- (t === Vr.ROTATE_ROW && u % 2 == 1 || t === Vr.ROTATE_TILE && (u + s) % 2 == 1) && (N = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- (t === Vr.FLIP_ROW && u % 2 == 1 || t === Vr.FLIP_TILE && (u + s) % 2 == 1) && (N = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- (t === Vr.FLIP_N_ROTATE_ROW && u % 2 == 1 || t === Vr.FLIP_N_ROTATE_TILE && (u + s) % 2 == 1) && (N = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- S = S.concat(N),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- M) {
- var U = [];
- for (L = 0,
- F = 1 - h / n,
- w = 1,
- B = 1,
- U[0] = [L, F, w, F, w, B, L, B],
- U[1] = [L, F, w, F, w, B, L, B],
- t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (U[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (U[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (U[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- P = 0; P < s; P++)
- b.push(P * i - d + f, g + _, 0),
- b.push((P + 1) * i - d + f, g + _, 0),
- b.push((P + 1) * i - d + f, g + h + _, 0),
- b.push(P * i - d + f, g + h + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(U[(P + 1) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(U[1]) : S.concat(U[0]),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- if (I) {
- var V = [];
- for (L = 0,
- F = 0,
- w = 1,
- B = h / n,
- V[0] = [L, F, w, F, w, B, L, B],
- V[1] = [L, F, w, F, w, B, L, B],
- t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (V[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (V[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (V[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- P = 0; P < s; P++)
- b.push(P * i - d + f, y - h + _, 0),
- b.push((P + 1) * i - d + f, y - h + _, 0),
- b.push((P + 1) * i - d + f, y + _, 0),
- b.push(P * i - d + f, y + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(V[(P + u) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(V[u % 2]) : S.concat(V[0]),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- if (O) {
- var k = [];
- for (L = 1 - l / i,
- F = 0,
- w = 1,
- B = 1,
- k[0] = [L, F, w, F, w, B, L, B],
- k[1] = [L, F, w, F, w, B, L, B],
- t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (k[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (k[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (k[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- C = 0; C < u; C++)
- b.push(m + f, C * n - p + _, 0),
- b.push(m + l + f, C * n - p + _, 0),
- b.push(m + l + f, (C + 1) * n - p + _, 0),
- b.push(m + f, (C + 1) * n - p + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(k[(C + 1) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(k[C % 2]) : S.concat(k[0]),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- if (D) {
- var G = [];
- for (L = 0,
- F = 0,
- w = l / n,
- B = 1,
- G[0] = [L, F, w, F, w, B, L, B],
- G[1] = [L, F, w, F, w, B, L, B],
- t !== Vr.ROTATE_TILE && t !== Vr.ROTATE_ROW || (G[1] = [1 - L, 1 - F, 1 - w, 1 - F, 1 - w, 1 - B, 1 - L, 1 - B]),
- t !== Vr.FLIP_TILE && t !== Vr.FLIP_ROW || (G[1] = [1 - L, F, 1 - w, F, 1 - w, B, 1 - L, B]),
- t !== Vr.FLIP_N_ROTATE_TILE && t !== Vr.FLIP_N_ROTATE_ROW || (G[1] = [L, 1 - F, w, 1 - F, w, 1 - B, L, 1 - B]),
- C = 0; C < u; C++)
- b.push(v - l + f, C * n - p + _, 0),
- b.push(v + f, C * n - p + _, 0),
- b.push(v + f, (C + 1) * n - p + _, 0),
- b.push(v - l + f, (C + 1) * n - p + _, 0),
- x.push(R, R + 1, R + 3, R + 1, R + 2, R + 3),
- R += 4,
- S = t === Vr.FLIP_TILE || t === Vr.ROTATE_TILE || t === Vr.FLIP_N_ROTATE_TILE ? S.concat(G[(C + s) % 2]) : t === Vr.FLIP_ROW || t === Vr.ROTATE_ROW || t === Vr.FLIP_N_ROTATE_ROW ? S.concat(G[C % 2]) : S.concat(G[0]),
- A.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- T.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- }
- var z = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE;
- $n._ComputeSides(z, b, x, T, S, e.frontUVs, e.backUVs);
- var W = new $n;
- W.indices = x,
- W.positions = b,
- W.normals = T,
- W.uvs = S;
- var H = z === $n.DOUBLESIDE ? A.concat(A) : A;
- return W.colors = H,
- W
- }
- function pv(e, t, i) {
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- dv(t).applyToMesh(n, t.updatable),
- n
- }
- var fv = {
- CreateTiledPlane: pv
- };
- function _v(e) {
- for (var t = e.faceUV || new Array(6), i = e.faceColors, n = e.pattern || Vr.NO_FLIP, r = e.width || e.size || 1, o = e.height || e.size || 1, a = e.depth || e.size || 1, s = e.tileWidth || e.tileSize || 1, l = e.tileHeight || e.tileSize || 1, c = e.alignHorizontal || 0, u = e.alignVertical || 0, h = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, d = 0; d < 6; d++)
- void 0 === t[d] && (t[d] = new R(0,0,1,1)),
- i && void 0 === i[d] && (i[d] = new N(1,1,1,1));
- var p = r / 2
- , f = o / 2
- , _ = a / 2
- , m = [];
- for (d = 0; d < 2; d++)
- m[d] = dv({
- pattern: n,
- tileWidth: s,
- tileHeight: l,
- width: r,
- height: o,
- alignVertical: u,
- alignHorizontal: c,
- sideOrientation: h
- });
- for (d = 2; d < 4; d++)
- m[d] = dv({
- pattern: n,
- tileWidth: s,
- tileHeight: l,
- width: a,
- height: o,
- alignVertical: u,
- alignHorizontal: c,
- sideOrientation: h
- });
- var g = u;
- for (u === Vr.BOTTOM ? g = Vr.TOP : u === Vr.TOP && (g = Vr.BOTTOM),
- d = 4; d < 6; d++)
- m[d] = dv({
- pattern: n,
- tileWidth: s,
- tileHeight: l,
- width: r,
- height: a,
- alignVertical: g,
- alignHorizontal: c,
- sideOrientation: h
- });
- var v = []
- , y = []
- , b = []
- , T = []
- , E = []
- , S = []
- , A = []
- , C = []
- , M = 0
- , I = 0;
- for (d = 0; d < 6; d++) {
- var O = m[d].positions.length;
- S[d] = [],
- A[d] = [];
- for (var D = 0; D < O / 3; D++)
- S[d].push(new x(m[d].positions[3 * D],m[d].positions[3 * D + 1],m[d].positions[3 * D + 2])),
- A[d].push(new x(m[d].normals[3 * D],m[d].normals[3 * D + 1],m[d].normals[3 * D + 2]));
- M = m[d].uvs.length,
- C[d] = [];
- for (var L = 0; L < M; L += 2)
- C[d][L] = t[d].x + (t[d].z - t[d].x) * m[d].uvs[L],
- C[d][L + 1] = t[d].y + (t[d].w - t[d].y) * m[d].uvs[L + 1],
- pr.UseOpenGLOrientationForUV && (C[d][L + 1] = 1 - C[d][L + 1]);
- if (b = b.concat(C[d]),
- T = T.concat(m[d].indices.map((function(e) {
- return e + I
- }
- ))),
- I += S[d].length,
- i)
- for (var F = 0; F < 4; F++)
- E.push(i[d].r, i[d].g, i[d].b, i[d].a)
- }
- var w = new x(0,0,_)
- , B = P.RotationY(Math.PI);
- v = S[0].map((function(e) {
- return x.TransformNormal(e, B).add(w)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), []),
- y = A[0].map((function(e) {
- return x.TransformNormal(e, B)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), []),
- v = v.concat(S[1].map((function(e) {
- return e.subtract(w)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), [])),
- y = y.concat(A[1].map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), []));
- var U = new x(p,0,0)
- , V = P.RotationY(-Math.PI / 2);
- v = v.concat(S[2].map((function(e) {
- return x.TransformNormal(e, V).add(U)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), [])),
- y = y.concat(A[2].map((function(e) {
- return x.TransformNormal(e, V)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), []));
- var k = P.RotationY(Math.PI / 2);
- v = v.concat(S[3].map((function(e) {
- return x.TransformNormal(e, k).subtract(U)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), [])),
- y = y.concat(A[3].map((function(e) {
- return x.TransformNormal(e, k)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), []));
- var G = new x(0,f,0)
- , z = P.RotationX(Math.PI / 2);
- v = v.concat(S[4].map((function(e) {
- return x.TransformNormal(e, z).add(G)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), [])),
- y = y.concat(A[4].map((function(e) {
- return x.TransformNormal(e, z)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), []));
- var W = P.RotationX(-Math.PI / 2);
- v = v.concat(S[5].map((function(e) {
- return x.TransformNormal(e, W).subtract(G)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), [])),
- y = y.concat(A[5].map((function(e) {
- return x.TransformNormal(e, W)
- }
- )).map((function(e) {
- return [e.x, e.y, e.z]
- }
- )).reduce((function(e, t) {
- return e.concat(t)
- }
- ), [])),
- $n._ComputeSides(h, v, T, y, b);
- var H = new $n;
- if (H.indices = T,
- H.positions = v,
- H.normals = y,
- H.uvs = b,
- i) {
- var X = h === $n.DOUBLESIDE ? E.concat(E) : E;
- H.colors = X
- }
- return H
- }
- function mv(e, t, i) {
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- _v(t).applyToMesh(n, t.updatable),
- n
- }
- $n.CreateTiledPlane = dv;
- var gv = {
- CreateTiledBox: mv
- };
- function vv(e) {
- var t, i, n = new Array, r = new Array, o = new Array, a = new Array, s = e.radius || 2, l = e.tube || .5, c = e.radialSegments || 32, u = e.tubularSegments || 32, h = e.p || 2, d = e.q || 3, p = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, f = function(e) {
- var t = Math.cos(e)
- , i = Math.sin(e)
- , n = d / h * e
- , r = Math.cos(n)
- , o = s * (2 + r) * .5 * t
- , a = s * (2 + r) * i * .5
- , l = s * Math.sin(n) * .5;
- return new x(o,a,l)
- };
- for (t = 0; t <= c; t++) {
- var _ = t % c / c * 2 * h * Math.PI
- , m = f(_)
- , g = f(_ + .01)
- , v = g.subtract(m)
- , y = g.add(m)
- , b = x.Cross(v, y);
- for (y = x.Cross(b, v),
- b.normalize(),
- y.normalize(),
- i = 0; i < u; i++) {
- var T = i % u / u * 2 * Math.PI
- , E = -l * Math.cos(T)
- , S = l * Math.sin(T);
- r.push(m.x + E * y.x + S * b.x),
- r.push(m.y + E * y.y + S * b.y),
- r.push(m.z + E * y.z + S * b.z),
- a.push(t / c),
- a.push(pr.UseOpenGLOrientationForUV ? 1 - i / u : i / u)
- }
- }
- for (t = 0; t < c; t++)
- for (i = 0; i < u; i++) {
- var A = (i + 1) % u
- , R = t * u + i
- , C = (t + 1) * u + i
- , P = (t + 1) * u + A
- , M = t * u + A;
- n.push(M),
- n.push(C),
- n.push(R),
- n.push(M),
- n.push(P),
- n.push(C)
- }
- $n.ComputeNormals(r, n, o),
- $n._ComputeSides(p, r, n, o, a, e.frontUVs, e.backUVs);
- var I = new $n;
- return I.indices = n,
- I.positions = r,
- I.normals = o,
- I.uvs = a,
- I
- }
- function yv(e, t, i) {
- void 0 === t && (t = {});
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- vv(t).applyToMesh(n, t.updatable),
- n
- }
- $n.CreateTiledBox = _v;
- var bv = {
- CreateTorusKnot: yv
- };
- $n.CreateTorusKnot = vv,
- Vr.CreateTorusKnot = function(e, t, i, n, r, o, a, s, l, c) {
- return yv(e, {
- radius: t,
- tube: i,
- radialSegments: n,
- tubularSegments: r,
- p: o,
- q: a,
- sideOrientation: c,
- updatable: l
- }, s)
- }
- ;
- var Tv = function(e) {
- function t(t, i) {
- var n = e.call(this, t.x, t.y) || this;
- return n.index = i,
- n
- }
- return U(t, e),
- t
- }(A)
- , Ev = function() {
- function e() {
- this.elements = new Array
- }
- return e.prototype.add = function(e) {
- var t = this
- , i = new Array;
- return e.forEach((function(e) {
- var n = new Tv(e,t.elements.length);
- i.push(n),
- t.elements.push(n)
- }
- )),
- i
- }
- ,
- e.prototype.computeBounds = function() {
- var e = new A(this.elements[0].x,this.elements[0].y)
- , t = new A(this.elements[0].x,this.elements[0].y);
- return this.elements.forEach((function(i) {
- i.x < e.x ? e.x = i.x : i.x > t.x && (t.x = i.x),
- i.y < e.y ? e.y = i.y : i.y > t.y && (t.y = i.y)
- }
- )),
- {
- min: e,
- max: t,
- width: t.x - e.x,
- height: t.y - e.y
- }
- }
- ,
- e
- }()
- , Sv = function() {
- function e() {}
- return e.Rectangle = function(e, t, i, n) {
- return [new A(e,t), new A(i,t), new A(i,n), new A(e,n)]
- }
- ,
- e.Circle = function(e, t, i, n) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- void 0 === n && (n = 32);
- for (var r = new Array, o = 0, a = 2 * Math.PI / n, s = 0; s < n; s++)
- r.push(new A(t + Math.cos(o) * e,i + Math.sin(o) * e)),
- o -= a;
- return r
- }
- ,
- e.Parse = function(e) {
- var t, i = e.split(/[^-+eE.\d]+/).map(parseFloat).filter((function(e) {
- return !isNaN(e)
- }
- )), n = [];
- for (t = 0; t < (2147483646 & i.length); t += 2)
- n.push(new A(i[t],i[t + 1]));
- return n
- }
- ,
- e.StartingAt = function(e, t) {
- return Rn.StartingAt(e, t)
- }
- ,
- e
- }()
- , Av = function() {
- function e(e, t, i, n) {
- var r;
- void 0 === n && (n = earcut),
- this._points = new Ev,
- this._outlinepoints = new Ev,
- this._holes = new Array,
- this._epoints = new Array,
- this._eholes = new Array,
- this.bjsEarcut = n,
- this._name = e,
- this._scene = i || E.LastCreatedScene,
- r = t instanceof Rn ? t.getPoints() : t,
- this._addToepoint(r),
- this._points.add(r),
- this._outlinepoints.add(r),
- void 0 === this.bjsEarcut && K.Warn("Earcut was not found, the polygon will not be built.")
- }
- return e.prototype._addToepoint = function(e) {
- for (var t = 0, i = e; t < i.length; t++) {
- var n = i[t];
- this._epoints.push(n.x, n.y)
- }
- }
- ,
- e.prototype.addHole = function(e) {
- this._points.add(e);
- var t = new Ev;
- return t.add(e),
- this._holes.push(t),
- this._eholes.push(this._epoints.length / 2),
- this._addToepoint(e),
- this
- }
- ,
- e.prototype.build = function(e, t, i) {
- void 0 === e && (e = !1),
- void 0 === t && (t = 0),
- void 0 === i && (i = 2);
- var n = new Vr(this._name,this._scene)
- , r = this.buildVertexData(t, i);
- return n.setVerticesData(Bi.PositionKind, r.positions, e),
- n.setVerticesData(Bi.NormalKind, r.normals, e),
- n.setVerticesData(Bi.UVKind, r.uvs, e),
- n.setIndices(r.indices),
- n
- }
- ,
- e.prototype.buildVertexData = function(e, t) {
- var i = this;
- void 0 === e && (e = 0),
- void 0 === t && (t = 2);
- var n = new $n
- , r = new Array
- , o = new Array
- , a = new Array
- , s = this._points.computeBounds();
- this._points.elements.forEach((function(e) {
- r.push(0, 1, 0),
- o.push(e.x, 0, e.y),
- a.push((e.x - s.min.x) / s.width, (e.y - s.min.y) / s.height)
- }
- ));
- for (var l = new Array, c = this.bjsEarcut(this._epoints, this._eholes, 2), u = 0; u < c.length; u++)
- l.push(c[u]);
- if (e > 0) {
- var h = o.length / 3;
- this._points.elements.forEach((function(t) {
- r.push(0, -1, 0),
- o.push(t.x, -e, t.y),
- a.push(1 - (t.x - s.min.x) / s.width, 1 - (t.y - s.min.y) / s.height)
- }
- ));
- var d = l.length;
- for (u = 0; u < d; u += 3) {
- var p = l[u + 0]
- , f = l[u + 1]
- , _ = l[u + 2];
- l.push(_ + h),
- l.push(f + h),
- l.push(p + h)
- }
- this._addSide(o, r, a, l, s, this._outlinepoints, e, !1, t),
- this._holes.forEach((function(n) {
- i._addSide(o, r, a, l, s, n, e, !0, t)
- }
- ))
- }
- return n.indices = l,
- n.positions = o,
- n.normals = r,
- n.uvs = a,
- n
- }
- ,
- e.prototype._addSide = function(e, t, i, n, r, o, a, s, l) {
- for (var c = e.length / 3, u = 0, h = 0; h < o.elements.length; h++) {
- var d = o.elements[h]
- , p = o.elements[(h + 1) % o.elements.length];
- e.push(d.x, 0, d.y),
- e.push(d.x, -a, d.y),
- e.push(p.x, 0, p.y),
- e.push(p.x, -a, p.y);
- var f = o.elements[(h + o.elements.length - 1) % o.elements.length]
- , _ = o.elements[(h + 2) % o.elements.length]
- , g = new x(-(p.y - d.y),0,p.x - d.x)
- , v = new x(-(d.y - f.y),0,d.x - f.x)
- , y = new x(-(_.y - p.y),0,_.x - p.x);
- s || (g = g.scale(-1),
- v = v.scale(-1),
- y = y.scale(-1));
- var b = g.normalizeToNew()
- , T = v.normalizeToNew()
- , E = y.normalizeToNew()
- , S = x.Dot(T, b);
- T = S > l ? S < m - 1 ? new x(d.x,0,d.y).subtract(new x(p.x,0,p.y)).normalize() : v.add(g).normalize() : b;
- var A = x.Dot(y, g);
- E = A > l ? A < m - 1 ? new x(p.x,0,p.y).subtract(new x(d.x,0,d.y)).normalize() : y.add(g).normalize() : b,
- i.push(u / r.width, 0),
- i.push(u / r.width, 1),
- u += g.length(),
- i.push(u / r.width, 0),
- i.push(u / r.width, 1),
- t.push(T.x, T.y, T.z),
- t.push(T.x, T.y, T.z),
- t.push(E.x, E.y, E.z),
- t.push(E.x, E.y, E.z),
- s ? (n.push(c),
- n.push(c + 2),
- n.push(c + 1),
- n.push(c + 1),
- n.push(c + 2),
- n.push(c + 3)) : (n.push(c),
- n.push(c + 1),
- n.push(c + 2),
- n.push(c + 1),
- n.push(c + 3),
- n.push(c + 2)),
- c += 4
- }
- }
- ,
- e
- }();
- function xv(e, t, i, n, r, o, a) {
- for (var s = i || new Array(3), l = n, c = [], u = a || !1, h = 0; h < 3; h++)
- void 0 === s[h] && (s[h] = new R(0,0,1,1)),
- l && void 0 === l[h] && (l[h] = new N(1,1,1,1));
- var d = e.getVerticesData(Bi.PositionKind)
- , p = e.getVerticesData(Bi.NormalKind)
- , f = e.getVerticesData(Bi.UVKind)
- , _ = e.getIndices()
- , m = d.length / 9
- , g = 0
- , v = 0
- , y = 0
- , b = 0
- , T = [0];
- if (u)
- for (var E = m; E < d.length / 3; E += 4)
- v = d[3 * (E + 2)] - d[3 * E],
- y = d[3 * (E + 2) + 2] - d[3 * E + 2],
- b += Math.sqrt(v * v + y * y),
- T.push(b);
- for (var S = 0, A = 0, x = 0; x < p.length; x += 3)
- Math.abs(p[x + 1]) < .001 && (A = 1),
- Math.abs(p[x + 1] - 1) < .001 && (A = 0),
- Math.abs(p[x + 1] + 1) < .001 && (A = 2),
- S = x / 3,
- 1 === A ? (g = S - m,
- f[2 * S] = g % 4 < 1.5 ? u ? s[A].x + (s[A].z - s[A].x) * T[Math.floor(g / 4)] / b : s[A].x : u ? s[A].x + (s[A].z - s[A].x) * T[Math.floor(g / 4) + 1] / b : s[A].z,
- f[2 * S + 1] = g % 2 == 0 ? pr.UseOpenGLOrientationForUV ? 1 - s[A].w : s[A].w : pr.UseOpenGLOrientationForUV ? 1 - s[A].y : s[A].y) : (f[2 * S] = (1 - f[2 * S]) * s[A].x + f[2 * S] * s[A].z,
- f[2 * S + 1] = (1 - f[2 * S + 1]) * s[A].y + f[2 * S + 1] * s[A].w,
- pr.UseOpenGLOrientationForUV && (f[2 * S + 1] = 1 - f[2 * S + 1])),
- l && c.push(l[A].r, l[A].g, l[A].b, l[A].a);
- $n._ComputeSides(t, d, _, p, f, r, o);
- var C = new $n;
- if (C.indices = _,
- C.positions = d,
- C.normals = p,
- C.uvs = f,
- l) {
- var P = t === $n.DOUBLESIDE ? c.concat(c) : c;
- C.colors = P
- }
- return C
- }
- function Rv(e, t, i, n) {
- void 0 === i && (i = null),
- void 0 === n && (n = earcut),
- t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation);
- for (var r = t.shape, o = t.holes || [], a = t.depth || 0, s = t.smoothingThreshold || 2, l = [], c = [], u = 0; u < r.length; u++)
- l[u] = new A(r[u].x,r[u].z);
- l[0].equalsWithEpsilon(l[l.length - 1], 1e-8) && l.pop();
- for (var h = new Av(e,l,i || E.LastCreatedScene,n), d = 0; d < o.length; d++) {
- c = [];
- for (var p = 0; p < o[d].length; p++)
- c.push(new A(o[d][p].x,o[d][p].z));
- h.addHole(c)
- }
- var f = h.build(!1, a, s);
- return f._originalBuilderSideOrientation = t.sideOrientation,
- xv(f, t.sideOrientation, t.faceUV, t.faceColors, t.frontUVs, t.backUVs, t.wrap).applyToMesh(f, t.updatable),
- f
- }
- function Cv(e, t, i, n) {
- return void 0 === i && (i = null),
- void 0 === n && (n = earcut),
- Rv(e, t, i, n)
- }
- var Pv = {
- ExtrudePolygon: Cv,
- CreatePolygon: Rv
- };
- function Mv(e, t, i) {
- void 0 === i && (i = null);
- var n, r, o = t.arc ? t.arc <= 0 || t.arc > 1 ? 1 : t.arc : 1, a = void 0 === t.closed || t.closed, s = t.shape, l = t.radius || 1, c = t.tessellation || 64, u = t.clip || 0, h = t.updatable, d = Vr._GetDefaultSideOrientation(t.sideOrientation), p = t.cap || Vr.NO_CAP, f = 2 * Math.PI, _ = new Array, m = t.invertUV || !1, g = 0, v = 0, y = f / c * o;
- for (g = 0; g <= c - u; g++) {
- for (r = [],
- p != Vr.CAP_START && p != Vr.CAP_ALL || (r.push(new x(0,s[0].y,0)),
- r.push(new x(Math.cos(g * y) * s[0].x * l,s[0].y,Math.sin(g * y) * s[0].x * l))),
- v = 0; v < s.length; v++)
- n = new x(Math.cos(g * y) * s[v].x * l,s[v].y,Math.sin(g * y) * s[v].x * l),
- r.push(n);
- p != Vr.CAP_END && p != Vr.CAP_ALL || (r.push(new x(Math.cos(g * y) * s[s.length - 1].x * l,s[s.length - 1].y,Math.sin(g * y) * s[s.length - 1].x * l)),
- r.push(new x(0,s[s.length - 1].y,0))),
- _.push(r)
- }
- return nc(e, {
- pathArray: _,
- closeArray: a,
- sideOrientation: d,
- updatable: h,
- invertUV: m,
- frontUVs: t.frontUVs,
- backUVs: t.backUVs
- }, i)
- }
- $n.CreatePolygon = xv,
- Vr.CreatePolygon = function(e, t, i, n, r, o, a) {
- return void 0 === a && (a = earcut),
- Rv(e, {
- shape: t,
- holes: n,
- updatable: r,
- sideOrientation: o
- }, i, a)
- }
- ,
- Vr.ExtrudePolygon = function(e, t, i, n, r, o, a, s) {
- return void 0 === s && (s = earcut),
- Cv(e, {
- shape: t,
- holes: r,
- depth: i,
- updatable: o,
- sideOrientation: a
- }, n, s)
- }
- ;
- var Iv = {
- CreateLathe: Mv
- };
- function Ov(e, t, i) {
- void 0 === i && (i = null);
- var n = t.path
- , r = t.instance
- , o = 1;
- void 0 !== t.radius ? o = t.radius : r && (o = r._creationDataStorage.radius);
- var a = t.tessellation || 64
- , s = t.radiusFunction || null
- , l = t.cap || Vr.NO_CAP
- , c = t.invertUV || !1
- , u = t.updatable
- , h = Vr._GetDefaultSideOrientation(t.sideOrientation);
- t.arc = t.arc && (t.arc <= 0 || t.arc > 1) ? 1 : t.arc || 1;
- var d, p, f = function(e, t, i, n, r, o, a, s) {
- for (var l, c, u, h, d = t.getTangents(), p = t.getNormals(), f = t.getDistances(), _ = 2 * Math.PI / r * s, m = o || function() {
- return n
- }
- , g = I.Matrix[0], v = a === Vr.NO_CAP || a === Vr.CAP_END ? 0 : 2, y = 0; y < e.length; y++) {
- c = m(y, f[y]),
- l = Array(),
- u = p[y];
- for (var b = 0; b < r; b++)
- P.RotationAxisToRef(d[y], _ * b, g),
- h = l[b] ? l[b] : x.Zero(),
- x.TransformCoordinatesToRef(u, g, h),
- h.scaleInPlace(c).addInPlace(e[y]),
- l[b] = h;
- i[v] = l,
- v++
- }
- var T = function(t, i) {
- for (var n = Array(), r = 0; r < t; r++)
- n.push(e[i]);
- return n
- };
- switch (a) {
- case Vr.NO_CAP:
- break;
- case Vr.CAP_START:
- i[0] = T(r, 0),
- i[1] = i[2].slice(0);
- break;
- case Vr.CAP_END:
- i[v] = i[v - 1].slice(0),
- i[v + 1] = T(r, e.length - 1);
- break;
- case Vr.CAP_ALL:
- i[0] = T(r, 0),
- i[1] = i[2].slice(0),
- i[v] = i[v - 1].slice(0),
- i[v + 1] = T(r, e.length - 1)
- }
- return i
- };
- if (r) {
- var _ = r._creationDataStorage
- , m = t.arc || _.arc;
- return r = nc("", {
- pathArray: p = f(n, d = _.path3D.update(n), _.pathArray, o, _.tessellation, s, _.cap, m),
- instance: r
- }),
- _.path3D = d,
- _.pathArray = p,
- _.arc = m,
- _.radius = o,
- r
- }
- l = l < 0 || l > 3 ? 0 : l;
- var g = nc(e, {
- pathArray: p = f(n, d = new Cn(n), new Array, o, a, s, l, t.arc),
- closePath: !0,
- closeArray: !1,
- updatable: u,
- sideOrientation: h,
- invertUV: c,
- frontUVs: t.frontUVs,
- backUVs: t.backUVs
- }, i);
- return g._creationDataStorage.pathArray = p,
- g._creationDataStorage.path3D = d,
- g._creationDataStorage.tessellation = a,
- g._creationDataStorage.cap = l,
- g._creationDataStorage.arc = t.arc,
- g._creationDataStorage.radius = o,
- g
- }
- Vr.CreateLathe = function(e, t, i, n, r, o, a) {
- return Mv(e, {
- shape: t,
- radius: i,
- tessellation: n,
- sideOrientation: a,
- updatable: o
- }, r)
- }
- ;
- var Dv = {
- CreateTube: Ov
- };
- function Nv(e) {
- var t, i = e.sideOrientation || $n.DEFAULTSIDE, n = e.radius || 1, r = void 0 === e.flat || e.flat, o = e.subdivisions || 4, a = e.radiusX || n, s = e.radiusY || n, l = e.radiusZ || n, c = (1 + Math.sqrt(5)) / 2, u = [-1, c, -0, 1, c, 0, -1, -c, 0, 1, -c, 0, 0, -1, -c, 0, 1, -c, 0, -1, c, 0, 1, c, c, 0, 1, c, 0, -1, -c, 0, 1, -c, 0, -1], h = [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], d = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 2, 3, 3, 3, 4, 7, 8, 9, 9, 10, 11], p = [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], f = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0], _ = new Array, m = new Array, g = new Array, v = new Array, y = 0, b = new Array(3), T = new Array(3);
- for (t = 0; t < 3; t++)
- b[t] = x.Zero(),
- T[t] = A.Zero();
- for (var E = 0; E < 20; E++) {
- for (t = 0; t < 3; t++) {
- var S = h[3 * E + t];
- b[t].copyFromFloats(u[3 * d[S]], u[3 * d[S] + 1], u[3 * d[S] + 2]),
- b[t].normalize().scaleInPlace(n),
- T[t].copyFromFloats(.134765625 * p[2 * S] + .05859375 + -.0390625 * f[E], .2333984375 * p[2 * S + 1] + .025390625 + .01953125 * f[E])
- }
- for (var R = function(e, t, i, n) {
- var c, u = x.Lerp(b[0], b[2], t / o), h = x.Lerp(b[1], b[2], t / o), d = o === t ? b[2] : x.Lerp(u, h, e / (o - t));
- if (d.normalize(),
- r) {
- var p = x.Lerp(b[0], b[2], n / o)
- , f = x.Lerp(b[1], b[2], n / o);
- c = x.Lerp(p, f, i / (o - n))
- } else
- c = new x(d.x,d.y,d.z);
- c.x /= a,
- c.y /= s,
- c.z /= l,
- c.normalize();
- var E = A.Lerp(T[0], T[2], t / o)
- , S = A.Lerp(T[1], T[2], t / o)
- , R = o === t ? T[2] : A.Lerp(E, S, e / (o - t));
- m.push(d.x * a, d.y * s, d.z * l),
- g.push(c.x, c.y, c.z),
- v.push(R.x, pr.UseOpenGLOrientationForUV ? 1 - R.y : R.y),
- _.push(y),
- y++
- }, C = 0; C < o; C++)
- for (var P = 0; P + C < o; P++)
- R(P, C, P + 1 / 3, C + 1 / 3),
- R(P + 1, C, P + 1 / 3, C + 1 / 3),
- R(P, C + 1, P + 1 / 3, C + 1 / 3),
- P + C + 1 < o && (R(P + 1, C, P + 2 / 3, C + 2 / 3),
- R(P + 1, C + 1, P + 2 / 3, C + 2 / 3),
- R(P, C + 1, P + 2 / 3, C + 2 / 3))
- }
- $n._ComputeSides(i, m, _, g, v, e.frontUVs, e.backUVs);
- var M = new $n;
- return M.indices = _,
- M.positions = m,
- M.normals = g,
- M.uvs = v,
- M
- }
- function Lv(e, t, i) {
- void 0 === t && (t = {}),
- void 0 === i && (i = null);
- var n = new Vr(e,i);
- return t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- n._originalBuilderSideOrientation = t.sideOrientation,
- Nv(t).applyToMesh(n, t.updatable),
- n
- }
- Vr.CreateTube = function(e, t, i, n, r, o, a, s, l, c) {
- return Ov(e, {
- path: t,
- radius: i,
- tessellation: n,
- radiusFunction: r,
- arc: 1,
- cap: o,
- updatable: s,
- sideOrientation: l,
- instance: c
- }, a)
- }
- ;
- var Fv = {
- CreateIcoSphere: Lv
- };
- function wv(e, t, i) {
- var n = t.getIndices()
- , r = t.getVerticesData(Bi.PositionKind)
- , o = t.getVerticesData(Bi.NormalKind)
- , a = t.getVerticesData(Bi.UVKind)
- , s = i.position || x.Zero()
- , l = i.normal || x.Up()
- , c = i.size || x.One()
- , u = i.angle || 0;
- if (!l) {
- var h = new x(0,0,1)
- , d = t.getScene().activeCamera
- , p = x.TransformCoordinates(h, d.getWorldMatrix());
- l = d.globalPosition.subtract(p)
- }
- var f = -Math.atan2(l.z, l.x) - Math.PI / 2
- , _ = Math.sqrt(l.x * l.x + l.z * l.z)
- , m = Math.atan2(l.y, _)
- , g = P.RotationYawPitchRoll(f, m, u).multiply(P.Translation(s.x, s.y, s.z))
- , v = P.Invert(g)
- , y = t.getWorldMatrix().multiply(v)
- , b = new $n;
- b.indices = [],
- b.positions = [],
- b.normals = [],
- b.uvs = [];
- for (var T = 0, E = function(e) {
- var t = new Ec;
- if (!n || !r || !o)
- return t;
- var s = n[e];
- if (t.position = new x(r[3 * s],r[3 * s + 1],r[3 * s + 2]),
- t.position = x.TransformCoordinates(t.position, y),
- t.normal = new x(o[3 * s],o[3 * s + 1],o[3 * s + 2]),
- t.normal = x.TransformNormal(t.normal, y),
- i.captureUVS && a) {
- var l = a[2 * s + 1];
- t.uv = new A(a[2 * s],pr.UseOpenGLOrientationForUV ? 1 - l : l)
- }
- return t
- }, S = function(e, t) {
- if (0 === e.length)
- return e;
- for (var i = .5 * Math.abs(x.Dot(c, t)), n = function(e, n) {
- var r = x.GetClipFactor(e.position, n.position, t, i);
- return new Ec(x.Lerp(e.position, n.position, r),x.Lerp(e.normal, n.normal, r))
- }, r = new Array, o = 0; o < e.length; o += 3) {
- var a = null
- , s = null
- , l = null
- , u = null
- , h = x.Dot(e[o].position, t) - i > 0
- , d = x.Dot(e[o + 1].position, t) - i > 0
- , p = x.Dot(e[o + 2].position, t) - i > 0;
- switch ((h ? 1 : 0) + (d ? 1 : 0) + (p ? 1 : 0)) {
- case 0:
- r.push(e[o]),
- r.push(e[o + 1]),
- r.push(e[o + 2]);
- break;
- case 1:
- if (h && (a = e[o + 1],
- s = e[o + 2],
- l = n(e[o], a),
- u = n(e[o], s)),
- d) {
- a = e[o],
- s = e[o + 2],
- l = n(e[o + 1], a),
- u = n(e[o + 1], s),
- r.push(l),
- r.push(s.clone()),
- r.push(a.clone()),
- r.push(s.clone()),
- r.push(l.clone()),
- r.push(u);
- break
- }
- p && (a = e[o],
- s = e[o + 1],
- l = n(e[o + 2], a),
- u = n(e[o + 2], s)),
- a && s && l && u && (r.push(a.clone()),
- r.push(s.clone()),
- r.push(l),
- r.push(u),
- r.push(l.clone()),
- r.push(s.clone()));
- break;
- case 2:
- h || (s = n(a = e[o].clone(), e[o + 1]),
- l = n(a, e[o + 2]),
- r.push(a),
- r.push(s),
- r.push(l)),
- d || (s = n(a = e[o + 1].clone(), e[o + 2]),
- l = n(a, e[o]),
- r.push(a),
- r.push(s),
- r.push(l)),
- p || (s = n(a = e[o + 2].clone(), e[o]),
- l = n(a, e[o + 1]),
- r.push(a),
- r.push(s),
- r.push(l))
- }
- }
- return r
- }, R = 0; R < n.length; R += 3) {
- var C = new Array;
- if (C.push(E(R)),
- C.push(E(R + 1)),
- C.push(E(R + 2)),
- C = S(C, new x(1,0,0)),
- C = S(C, new x(-1,0,0)),
- C = S(C, new x(0,1,0)),
- C = S(C, new x(0,-1,0)),
- C = S(C, new x(0,0,1)),
- 0 !== (C = S(C, new x(0,0,-1))).length)
- for (var M = 0; M < C.length; M++) {
- var I = C[M];
- if (b.indices.push(T),
- I.position.toArray(b.positions, 3 * T),
- I.normal.toArray(b.normals, 3 * T),
- i.captureUVS)
- I.uv.toArray(b.uvs, 2 * T);
- else {
- b.uvs.push(.5 + I.position.x / c.x);
- var O = .5 + I.position.y / c.y;
- b.uvs.push(pr.UseOpenGLOrientationForUV ? 1 - O : O)
- }
- T++
- }
- }
- var D = new Vr(e,t.getScene());
- return b.applyToMesh(D),
- D.position = s.clone(),
- D.rotation = new x(m,f,u),
- D
- }
- $n.CreateIcoSphere = Nv,
- Vr.CreateIcoSphere = function(e, t, i) {
- return Lv(e, t, i)
- }
- ;
- var Bv = {
- CreateDecal: wv
- };
- Vr.CreateDecal = function(e, t, i, n, r, o) {
- return wv(e, t, {
- position: i,
- normal: n,
- size: r,
- angle: o
- })
- }
- ;
- var Uv = function() {
- function e(e, t) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- this.x = e,
- this.y = t,
- e !== Math.floor(e) && (Math.floor(e),
- K.Warn("x is not an integer, floor(x) used")),
- t !== Math.floor(t) && (Math.floor(t),
- K.Warn("y is not an integer, floor(y) used"))
- }
- return e.prototype.clone = function() {
- return new e(this.x,this.y)
- }
- ,
- e.prototype.rotate60About = function(e) {
- var t = this.x;
- return this.x = e.x + e.y - this.y,
- this.y = t + this.y - e.x,
- this
- }
- ,
- e.prototype.rotateNeg60About = function(e) {
- var t = this.x;
- return this.x = t + this.y - e.y,
- this.y = e.x + e.y - t,
- this
- }
- ,
- e.prototype.rotate120 = function(e, t) {
- e !== Math.floor(e) && (Math.floor(e),
- K.Warn("m not an integer only floor(m) used")),
- t !== Math.floor(t) && (Math.floor(t),
- K.Warn("n not an integer only floor(n) used"));
- var i = this.x;
- return this.x = e - i - this.y,
- this.y = t + i,
- this
- }
- ,
- e.prototype.rotateNeg120 = function(e, t) {
- e !== Math.floor(e) && (Math.floor(e),
- K.Warn("m is not an integer, floor(m) used")),
- t !== Math.floor(t) && (Math.floor(t),
- K.Warn("n is not an integer, floor(n) used"));
- var i = this.x;
- return this.x = this.y - t,
- this.y = e + t - i - this.y,
- this
- }
- ,
- e.prototype.toCartesianOrigin = function(e, t) {
- var i = x.Zero();
- return i.x = e.x + 2 * this.x * t + this.y * t,
- i.y = e.y + Math.sqrt(3) * this.y * t,
- i
- }
- ,
- e.Zero = function() {
- return new e(0,0)
- }
- ,
- e
- }()
- , Vv = function() {
- function e() {
- this.cartesian = [],
- this.vertices = [],
- this.max = [],
- this.min = [],
- this.closestTo = [],
- this.innerFacets = [],
- this.isoVecsABOB = [],
- this.isoVecsOBOA = [],
- this.isoVecsBAOA = [],
- this.vertexTypes = [],
- this.IDATA = new kv("icosahedron","Regular",[[0, _, -1], [-_, 1, 0], [-1, 0, -_], [1, 0, -_], [_, 1, 0], [0, _, 1], [-1, 0, _], [-_, -1, 0], [0, -_, -1], [_, -1, 0], [1, 0, _], [0, -_, 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 e.prototype.setIndices = function() {
- var e, t, i, n, r, o, a, s = 12, l = {}, c = this.m, u = this.n, h = c;
- 0 !== u && (h = d.HCF(c, u)),
- e = c / h,
- t = u / h;
- var p, f, _, m = Uv.Zero(), g = new Uv(c,u), v = new Uv(-u,c + u), y = Uv.Zero(), b = Uv.Zero(), T = Uv.Zero(), E = [], S = [], A = this.vertByDist, x = function(e, t, i, n) {
- f = t + "|" + n,
- (p = e + "|" + i)in l || f in l ? p in l && !(f in l) ? l[f] = l[p] : f in l && !(p in l) && (l[p] = l[f]) : (l[p] = s,
- l[f] = s,
- s++),
- A[i][0] > 2 ? S[l[p]] = [-A[i][0], A[i][1], l[p]] : S[l[p]] = [E[A[i][0]], A[i][1], l[p]]
- };
- 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 R = 0; R < 20; R++) {
- if (r = (E = this.IDATA.face[R])[2],
- o = E[1],
- a = E[0],
- _ = m.x + "|" + m.y,
- (p = R + "|" + _)in l || (l[p] = r,
- S[r] = [E[A[_][0]], A[_][1]]),
- _ = g.x + "|" + g.y,
- (p = R + "|" + _)in l || (l[p] = o,
- S[o] = [E[A[_][0]], A[_][1]]),
- _ = v.x + "|" + v.y,
- (p = R + "|" + _)in l || (l[p] = a,
- S[a] = [E[A[_][0]], A[_][1]]),
- i = this.IDATA.edgematch[R][0],
- "B" === (n = this.IDATA.edgematch[R][1]))
- for (var C = 1; C < h; C++)
- b.x = c - C * (e + t),
- b.y = u + C * e,
- T.x = -C * t,
- T.y = C * (e + t),
- x(R, i, _ = b.x + "|" + b.y, T.x + "|" + T.y);
- if ("O" === n)
- for (C = 1; C < h; C++)
- T.x = -C * t,
- T.y = C * (e + t),
- y.x = C * e,
- y.y = C * t,
- x(R, i, _ = T.x + "|" + T.y, y.x + "|" + y.y);
- if (i = this.IDATA.edgematch[R][2],
- (n = this.IDATA.edgematch[R][3]) && "A" === n)
- for (C = 1; C < h; C++)
- y.x = C * e,
- y.y = C * t,
- b.x = c - (h - C) * (e + t),
- b.y = u + (h - C) * e,
- x(R, i, _ = y.x + "|" + y.y, b.x + "|" + b.y);
- for (C = 0; C < this.vertices.length; C++)
- _ = this.vertices[C].x + "|" + this.vertices[C].y,
- (p = R + "|" + _)in l || (l[p] = s++,
- A[_][0] > 2 ? S[l[p]] = [-A[_][0], A[_][1], l[p]] : S[l[p]] = [E[A[_][0]], A[_][1], l[p]])
- }
- this.closestTo = S,
- this.vecToidx = l
- }
- ,
- e.prototype.calcCoeffs = function() {
- var e = this.m
- , t = this.n
- , i = Math.sqrt(3) / 3
- , n = e * e + t * t + e * t;
- this.coau = (e + t) / n,
- this.cobu = -t / n,
- this.coav = -i * (e - t) / n,
- this.cobv = i * (2 * e + t) / n
- }
- ,
- e.prototype.createInnerFacets = function() {
- for (var e = this.m, t = this.n, i = 0; i < t + e + 1; i++)
- for (var n = this.min[i]; n < this.max[i] + 1; n++)
- n < this.max[i] && n < this.max[i + 1] + 1 && this.innerFacets.push(["|" + n + "|" + i, "|" + n + "|" + (i + 1), "|" + (n + 1) + "|" + i]),
- i > 0 && n < this.max[i - 1] && n + 1 < this.max[i] + 1 && this.innerFacets.push(["|" + n + "|" + i, "|" + (n + 1) + "|" + i, "|" + (n + 1) + "|" + (i - 1)])
- }
- ,
- e.prototype.edgeVecsABOB = function() {
- for (var e = this.m, t = this.n, i = new Uv(-t,e + t), n = 1; n < e + t; n++) {
- var r = new Uv(this.min[n],n)
- , o = new Uv(this.min[n - 1],n - 1)
- , a = new Uv(this.min[n + 1],n + 1)
- , s = r.clone()
- , l = o.clone()
- , c = a.clone();
- s.rotate60About(i),
- l.rotate60About(i),
- c.rotate60About(i);
- var u = new Uv(this.max[s.y],s.y)
- , h = new Uv(this.max[s.y - 1],s.y - 1)
- , d = new Uv(this.max[s.y - 1] - 1,s.y - 1);
- s.x === u.x && s.y === u.y || (s.x !== h.x ? (this.vertexTypes.push([1, 0, 0]),
- this.isoVecsABOB.push([r, h, d]),
- this.vertexTypes.push([1, 0, 0]),
- this.isoVecsABOB.push([r, d, u])) : s.y === c.y ? (this.vertexTypes.push([1, 1, 0]),
- this.isoVecsABOB.push([r, o, h]),
- this.vertexTypes.push([1, 0, 1]),
- this.isoVecsABOB.push([r, h, a])) : (this.vertexTypes.push([1, 1, 0]),
- this.isoVecsABOB.push([r, o, h]),
- this.vertexTypes.push([1, 0, 0]),
- this.isoVecsABOB.push([r, h, u])))
- }
- }
- ,
- e.prototype.mapABOBtoOBOA = function() {
- for (var e = new Uv(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
- for (var i = [], n = 0; n < 3; n++)
- e.x = this.isoVecsABOB[t][n].x,
- e.y = this.isoVecsABOB[t][n].y,
- 0 === this.vertexTypes[t][n] && e.rotateNeg120(this.m, this.n),
- i.push(e.clone());
- this.isoVecsOBOA.push(i)
- }
- }
- ,
- e.prototype.mapABOBtoBAOA = function() {
- for (var e = new Uv(0,0), t = 0; t < this.isoVecsABOB.length; t++) {
- for (var i = [], n = 0; n < 3; n++)
- e.x = this.isoVecsABOB[t][n].x,
- e.y = this.isoVecsABOB[t][n].y,
- 1 === this.vertexTypes[t][n] && e.rotate120(this.m, this.n),
- i.push(e.clone());
- this.isoVecsBAOA.push(i)
- }
- }
- ,
- e.prototype.MapToFace = function(e, t) {
- for (var i, n = this.IDATA.face[e], r = n[2], o = n[1], a = n[0], s = x.FromArray(this.IDATA.vertex[r]), l = x.FromArray(this.IDATA.vertex[o]), c = x.FromArray(this.IDATA.vertex[a]), u = l.subtract(s), h = c.subtract(s), d = u.scale(this.coau).add(h.scale(this.cobu)), p = u.scale(this.coav).add(h.scale(this.cobv)), f = [], _ = I.Vector3[0], m = 0; m < this.cartesian.length; m++)
- _ = d.scale(this.cartesian[m].x).add(p.scale(this.cartesian[m].y)).add(s),
- f[m] = [_.x, _.y, _.z],
- i = e + "|" + this.vertices[m].x + "|" + this.vertices[m].y,
- t.vertex[this.vecToidx[i]] = [_.x, _.y, _.z]
- }
- ,
- e.prototype.build = function(e, t) {
- var i = new Array
- , n = Uv.Zero()
- , r = new Uv(e,t)
- , o = new Uv(-t,e + t);
- i.push(n, r, o);
- for (var a = t; a < e + 1; a++)
- for (var s = 0; s < e + 1 - a; s++)
- i.push(new Uv(s,a));
- if (t > 0) {
- for (var l = d.HCF(e, t), c = e / l, u = t / l, h = 1; h < l; h++)
- i.push(new Uv(h * c,h * u)),
- i.push(new Uv(-h * u,h * (c + u))),
- i.push(new Uv(e - h * (c + u),t + h * c));
- for (var p = e / t, f = 1; f < t; f++)
- for (var _ = 0; _ < f * p; _++)
- i.push(new Uv(_,f)),
- i.push(new Uv(_,f).rotate120(e, t)),
- i.push(new Uv(_,f).rotateNeg120(e, t))
- }
- i.sort((function(e, t) {
- return e.x - t.x
- }
- )),
- i.sort((function(e, t) {
- return e.y - t.y
- }
- ));
- var m = new Array(e + t + 1)
- , g = new Array(e + t + 1);
- for (h = 0; h < m.length; h++)
- m[h] = 1 / 0,
- g[h] = -1 / 0;
- var v = 0
- , y = 0
- , b = i.length;
- for (h = 0; h < b; h++)
- y = i[h].x,
- m[v = i[h].y] = Math.min(y, m[v]),
- g[v] = Math.max(y, g[v]);
- var T = function(i, n) {
- var r = i.clone();
- return "A" === n && r.rotateNeg120(e, t),
- "B" === n && r.rotate120(e, t),
- r.x < 0 ? r.y : r.x + r.y
- }
- , E = []
- , S = []
- , A = []
- , x = []
- , R = {}
- , C = []
- , P = -1
- , M = -1;
- for (h = 0; h < b; h++)
- E[h] = i[h].toCartesianOrigin(new Uv(0,0), .5),
- S[h] = T(i[h], "O"),
- A[h] = T(i[h], "A"),
- x[h] = T(i[h], "B"),
- S[h] === A[h] && A[h] === x[h] ? (P = 3,
- M = S[h]) : S[h] === A[h] ? (P = 4,
- M = S[h]) : A[h] === x[h] ? (P = 5,
- M = A[h]) : x[h] === S[h] && (P = 6,
- M = S[h]),
- S[h] < A[h] && S[h] < x[h] && (P = 2,
- M = S[h]),
- A[h] < S[h] && A[h] < x[h] && (P = 1,
- M = A[h]),
- x[h] < A[h] && x[h] < S[h] && (P = 0,
- M = x[h]),
- C.push([P, M, i[h].x, i[h].y]);
- C.sort((function(e, t) {
- return e[2] - t[2]
- }
- )),
- C.sort((function(e, t) {
- return e[3] - t[3]
- }
- )),
- C.sort((function(e, t) {
- return e[1] - t[1]
- }
- )),
- C.sort((function(e, t) {
- return e[0] - t[0]
- }
- ));
- for (var I = 0; I < C.length; I++)
- R[C[I][2] + "|" + C[I][3]] = [C[I][0], C[I][1], I];
- return this.m = e,
- this.n = t,
- this.vertices = i,
- this.vertByDist = R,
- this.cartesian = E,
- this.min = m,
- this.max = g,
- this
- }
- ,
- e
- }()
- , kv = function(e, t, i, n) {
- this.name = e,
- this.category = t,
- this.vertex = i,
- this.face = n
- }
- , Gv = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.innerToData = function(e, t) {
- for (var i = 0; i < t.innerFacets.length; i++)
- this.face.push(t.innerFacets[i].map((function(i) {
- return t.vecToidx[e + i]
- }
- )))
- }
- ,
- t.prototype.mapABOBtoDATA = function(e, t) {
- for (var i = t.IDATA.edgematch[e][0], n = 0; n < t.isoVecsABOB.length; n++) {
- for (var r = [], o = 0; o < 3; o++)
- 0 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsABOB[n][o].x + "|" + t.isoVecsABOB[n][o].y) : r.push(i + "|" + t.isoVecsABOB[n][o].x + "|" + t.isoVecsABOB[n][o].y);
- this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
- }
- }
- ,
- t.prototype.mapOBOAtoDATA = function(e, t) {
- for (var i = t.IDATA.edgematch[e][0], n = 0; n < t.isoVecsOBOA.length; n++) {
- for (var r = [], o = 0; o < 3; o++)
- 1 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsOBOA[n][o].x + "|" + t.isoVecsOBOA[n][o].y) : r.push(i + "|" + t.isoVecsOBOA[n][o].x + "|" + t.isoVecsOBOA[n][o].y);
- this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
- }
- }
- ,
- t.prototype.mapBAOAtoDATA = function(e, t) {
- for (var i = t.IDATA.edgematch[e][2], n = 0; n < t.isoVecsBAOA.length; n++) {
- for (var r = [], o = 0; o < 3; o++)
- 1 === t.vertexTypes[n][o] ? r.push(e + "|" + t.isoVecsBAOA[n][o].x + "|" + t.isoVecsBAOA[n][o].y) : r.push(i + "|" + t.isoVecsBAOA[n][o].x + "|" + t.isoVecsBAOA[n][o].y);
- this.face.push([t.vecToidx[r[0]], t.vecToidx[r[1]], t.vecToidx[r[2]]])
- }
- }
- ,
- t.prototype.orderData = function(e) {
- for (var t = [], i = 0; i < 13; i++)
- t[i] = [];
- var n = e.closestTo;
- for (i = 0; i < n.length; i++)
- n[i][0] > -1 ? n[i][1] > 0 && t[n[i][0]].push([i, n[i][1]]) : t[12].push([i, n[i][0]]);
- var r = [];
- for (i = 0; i < 12; i++)
- r[i] = i;
- var o = 12;
- for (i = 0; i < 12; i++) {
- t[i].sort((function(e, t) {
- return e[1] - t[1]
- }
- ));
- for (var a = 0; a < t[i].length; a++)
- r[t[i][a][0]] = o++
- }
- for (a = 0; a < t[12].length; a++)
- r[t[12][a][0]] = o++;
- for (i = 0; i < this.vertex.length; i++)
- this.vertex[i].push(r[i]);
- for (this.vertex.sort((function(e, t) {
- return e[3] - t[3]
- }
- )),
- i = 0; i < this.vertex.length; i++)
- this.vertex[i].pop();
- for (i = 0; i < this.face.length; i++)
- for (a = 0; a < this.face[i].length; a++)
- this.face[i][a] = r[this.face[i][a]];
- this.sharedNodes = t[12].length,
- this.poleNodes = this.vertex.length - this.sharedNodes
- }
- ,
- t.prototype.setOrder = function(e, t) {
- var i = []
- , n = []
- , r = t.pop();
- n.push(r);
- var o = this.face[r].indexOf(e);
- o = (o + 2) % 3;
- var a = this.face[r][o];
- i.push(a);
- for (var s = 0; t.length > 0; )
- r = t[s],
- this.face[r].indexOf(a) > -1 ? (o = (this.face[r].indexOf(a) + 1) % 3,
- a = this.face[r][o],
- i.push(a),
- n.push(r),
- t.splice(s, 1),
- s = 0) : s++;
- return this.adjacentFaces.push(i),
- n
- }
- ,
- t.prototype.toGoldbergPolyhedronData = function() {
- var e = this
- , t = new kv("GeoDual","Goldberg",[],[]);
- t.name = "GD dual";
- for (var i = this.vertex.length, n = new Array(i), r = 0; r < i; r++)
- n[r] = [];
- for (var o = 0; o < this.face.length; o++)
- for (var a = 0; a < 3; a++)
- n[this.face[o][a]].push(o);
- var s = 0
- , l = 0
- , c = 0
- , u = []
- , h = [];
- this.adjacentFaces = [];
- for (var d = 0; d < n.length; d++)
- t.face[d] = this.setOrder(d, n[d].concat([])),
- n[d].forEach((function(i) {
- s = 0,
- l = 0,
- c = 0,
- u = e.face[i];
- for (var n = 0; n < 3; n++)
- h = e.vertex[u[n]],
- s += h[0],
- l += h[1],
- c += h[2];
- t.vertex[i] = [s / 3, l / 3, c / 3]
- }
- ));
- return t
- }
- ,
- t.BuildGeodesicData = function(e) {
- var i = new t("Geodesic-m-n","Geodesic",[[0, _, -1], [-_, 1, 0], [-1, 0, -_], [1, 0, -_], [_, 1, 0], [0, _, 1], [-1, 0, _], [-_, -1, 0], [0, -_, -1], [_, -1, 0], [1, 0, _], [0, -_, 1]],[]);
- e.setIndices(),
- e.calcCoeffs(),
- e.createInnerFacets(),
- e.edgeVecsABOB(),
- e.mapABOBtoOBOA(),
- e.mapABOBtoBAOA();
- for (var n = 0; n < e.IDATA.face.length; n++)
- e.MapToFace(n, i),
- i.innerToData(n, e),
- "B" === e.IDATA.edgematch[n][1] && i.mapABOBtoDATA(n, e),
- "O" === e.IDATA.edgematch[n][1] && i.mapOBOAtoDATA(n, e),
- "A" === e.IDATA.edgematch[n][3] && i.mapBAOAtoDATA(n, e);
- return i.orderData(e),
- i.vertex = i.vertex.map((function(e) {
- var t = e[0]
- , i = e[1]
- , n = e[2]
- , r = Math.sqrt(t * t + i * i + n * n);
- return e[0] *= 1 / r,
- e[1] *= 1 / r,
- e[2] *= 1 / r,
- e
- }
- )),
- i
- }
- ,
- t
- }(kv);
- function zv(e, t, i) {
- void 0 === i && (i = null);
- var n = t.m || 1;
- n !== Math.floor(n) && (Math.floor(n),
- K.Warn("m not an integer only floor(m) used"));
- var r = t.n || 0;
- if (r !== Math.floor(r) && (Math.floor(r),
- K.Warn("n not an integer only floor(n) used")),
- r > n) {
- var o = r;
- r = n,
- n = o,
- K.Warn("n > m therefore m and n swapped")
- }
- var a = new Vv;
- return a.build(n, r),
- Td(e, {
- custom: Gv.BuildGeodesicData(a),
- size: t.size,
- sizeX: t.sizeX,
- sizeY: t.sizeY,
- sizeZ: t.sizeZ,
- faceUV: t.faceUV,
- faceColors: t.faceColors,
- flat: t.flat,
- updatable: t.updatable,
- sideOrientation: t.sideOrientation,
- frontUVs: t.frontUVs,
- backUVs: t.backUVs
- }, i)
- }
- function Wv(e, t) {
- for (var i = e.size, n = e.sizeX || i || 1, r = e.sizeY || i || 1, o = e.sizeZ || i || 1, a = 0 === e.sideOrientation ? 0 : e.sideOrientation || $n.DEFAULTSIDE, s = new Array, l = new Array, c = new Array, u = new Array, h = 1 / 0, d = -1 / 0, p = 1 / 0, f = -1 / 0, _ = 0; _ < t.vertex.length; _++)
- h = Math.min(h, t.vertex[_][0] * n),
- d = Math.max(d, t.vertex[_][0] * n),
- p = Math.min(p, t.vertex[_][1] * r),
- f = Math.max(f, t.vertex[_][1] * r);
- for (var m = 0, g = 0; g < t.face.length; g++) {
- var v = t.face[g]
- , y = x.FromArray(t.vertex[v[0]])
- , b = x.FromArray(t.vertex[v[2]])
- , T = x.FromArray(t.vertex[v[1]])
- , E = b.subtract(y)
- , S = T.subtract(y)
- , A = x.Cross(S, E).normalize();
- for (_ = 0; _ < v.length; _++) {
- c.push(A.x, A.y, A.z);
- var R = t.vertex[v[_]];
- s.push(R[0] * n, R[1] * r, R[2] * o);
- var C = (R[1] * r - p) / (f - p);
- u.push((R[0] * n - h) / (d - h), pr.UseOpenGLOrientationForUV ? 1 - C : C)
- }
- for (_ = 0; _ < v.length - 2; _++)
- l.push(m, m + _ + 2, m + _ + 1);
- m += v.length
- }
- $n._ComputeSides(a, s, l, c, u);
- var P = new $n;
- return P.positions = s,
- P.indices = l,
- P.normals = c,
- P.uvs = u,
- P
- }
- function Hv(e, t, i) {
- void 0 === i && (i = null);
- var n = t.size
- , r = t.sizeX || n || 1
- , o = t.sizeY || n || 1
- , a = t.sizeZ || n || 1
- , s = t.m || 1;
- s !== Math.floor(s) && (Math.floor(s),
- K.Warn("m not an integer only floor(m) used"));
- var l = t.n || 0;
- if (l !== Math.floor(l) && (Math.floor(l),
- K.Warn("n not an integer only floor(n) used")),
- l > s) {
- var c = l;
- l = s,
- s = c,
- K.Warn("n > m therefore m and n swapped")
- }
- var u = new Vv;
- u.build(s, l);
- var h = Gv.BuildGeodesicData(u)
- , d = h.toGoldbergPolyhedronData()
- , p = new uv(e,i);
- t.sideOrientation = Vr._GetDefaultSideOrientation(t.sideOrientation),
- p._originalBuilderSideOrientation = t.sideOrientation,
- Wv(t, d).applyToMesh(p, t.updatable),
- p.goldbergData.nbSharedFaces = h.sharedNodes,
- p.goldbergData.nbUnsharedFaces = h.poleNodes,
- p.goldbergData.adjacentFaces = h.adjacentFaces,
- p.goldbergData.nbFaces = p.goldbergData.nbSharedFaces + p.goldbergData.nbUnsharedFaces,
- p.goldbergData.nbFacesAtPole = (p.goldbergData.nbUnsharedFaces - 12) / 12;
- for (var f = 0; f < h.vertex.length; f++)
- p.goldbergData.faceCenters.push(x.FromArray(h.vertex[f])),
- p.goldbergData.faceCenters[f].x *= r,
- p.goldbergData.faceCenters[f].y *= o,
- p.goldbergData.faceCenters[f].z *= a,
- p.goldbergData.faceColors.push(new N(1,1,1,1));
- for (f = 0; f < d.face.length; f++) {
- var _ = d.face[f]
- , m = x.FromArray(d.vertex[_[0]])
- , g = x.FromArray(d.vertex[_[2]])
- , v = x.FromArray(d.vertex[_[1]])
- , y = g.subtract(m)
- , b = v.subtract(m)
- , T = x.Cross(b, y).normalize()
- , E = x.Cross(b, T).normalize();
- p.goldbergData.faceXaxis.push(b.normalize()),
- p.goldbergData.faceYaxis.push(T),
- p.goldbergData.faceZaxis.push(E)
- }
- return p
- }
- Vr.CreateGoldberg = Hv;
- var Xv, jv = {
- CreateBox: Ml,
- CreateTiledBox: mv,
- CreateSphere: Dl,
- CreateDisc: Pd,
- CreateIcoSphere: Lv,
- CreateRibbon: nc,
- CreateCylinder: Ys,
- CreateTorus: qs,
- CreateTorusKnot: yv,
- CreateLineSystem: Zl,
- CreateLines: Jl,
- CreateDashedLines: $l,
- ExtrudeShape: oc,
- ExtrudeShapeCustom: ac,
- CreateLathe: Mv,
- CreateTiledPlane: pv,
- CreatePlane: vo,
- CreateGround: il,
- CreateTiledGround: nl,
- CreateGroundFromHeightMap: rl,
- CreatePolygon: Rv,
- ExtrudePolygon: Cv,
- CreateTube: Ov,
- CreatePolyhedron: Td,
- CreateGeodesic: zv,
- CreateGoldberg: Hv,
- CreateDecal: wv,
- CreateCapsule: Gl
- }, Yv = function(e, t, i) {
- this.quality = e,
- this.distance = t,
- this.optimizeMesh = i
- }, Kv = function() {
- function e() {
- this.running = !1,
- this._simplificationArray = []
- }
- return e.prototype.addTask = function(e) {
- this._simplificationArray.push(e)
- }
- ,
- e.prototype.executeNext = function() {
- var e = this._simplificationArray.pop();
- e ? (this.running = !0,
- this.runSimplification(e)) : this.running = !1
- }
- ,
- e.prototype.runSimplification = function(e) {
- var t = this;
- if (e.parallelProcessing)
- e.settings.forEach((function(i) {
- t._getSimplifier(e).simplify(i, (function(n) {
- void 0 !== i.distance && e.mesh.addLODLevel(i.distance, n),
- n.isVisible = !0,
- i.quality === e.settings[e.settings.length - 1].quality && e.successCallback && e.successCallback(),
- t.executeNext()
- }
- ))
- }
- ));
- else {
- var i = this._getSimplifier(e);
- yi.Run(e.settings.length, (function(t) {
- var n, r;
- n = e.settings[t.index],
- r = function() {
- t.executeNext()
- }
- ,
- i.simplify(n, (function(t) {
- void 0 !== n.distance && e.mesh.addLODLevel(n.distance, t),
- t.isVisible = !0,
- r()
- }
- ))
- }
- ), (function() {
- e.successCallback && e.successCallback(),
- t.executeNext()
- }
- ))
- }
- }
- ,
- e.prototype._getSimplifier = function(e) {
- return e.simplificationType,
- Xv.QUADRATIC,
- new $v(e.mesh)
- }
- ,
- e
- }();
- !function(e) {
- e[e.QUADRATIC = 0] = "QUADRATIC"
- }(Xv || (Xv = {}));
- var Qv = function(e) {
- this._vertices = e,
- this.error = new Array(4),
- this.deleted = !1,
- this.isDirty = !1,
- this.deletePending = !1,
- this.borderFactor = 0
- }
- , qv = function() {
- function e(e, t) {
- this.position = e,
- this.id = t,
- this.isBorder = !0,
- this.q = new Zv,
- this.triangleCount = 0,
- this.triangleStart = 0,
- this.originalOffsets = []
- }
- return e.prototype.updatePosition = function(e) {
- this.position.copyFrom(e)
- }
- ,
- e
- }()
- , Zv = function() {
- function e(e) {
- this.data = new Array(10);
- for (var t = 0; t < 10; ++t)
- e && e[t] ? this.data[t] = e[t] : this.data[t] = 0
- }
- return e.prototype.det = function(e, t, i, n, r, o, a, s, l) {
- return this.data[e] * this.data[r] * this.data[l] + this.data[i] * this.data[n] * this.data[s] + this.data[t] * this.data[o] * this.data[a] - this.data[i] * this.data[r] * this.data[a] - this.data[e] * this.data[o] * this.data[s] - this.data[t] * this.data[n] * this.data[l]
- }
- ,
- e.prototype.addInPlace = function(e) {
- for (var t = 0; t < 10; ++t)
- this.data[t] += e.data[t]
- }
- ,
- e.prototype.addArrayInPlace = function(e) {
- for (var t = 0; t < 10; ++t)
- this.data[t] += e[t]
- }
- ,
- e.prototype.add = function(t) {
- for (var i = new e, n = 0; n < 10; ++n)
- i.data[n] = this.data[n] + t.data[n];
- return i
- }
- ,
- e.FromData = function(t, i, n, r) {
- return new e(e.DataFromNumbers(t, i, n, r))
- }
- ,
- e.DataFromNumbers = function(e, t, i, n) {
- return [e * e, e * t, e * i, e * n, t * t, t * i, t * n, i * i, i * n, n * n]
- }
- ,
- e
- }()
- , Jv = function(e, t) {
- this.vertexId = e,
- this.triangleId = t
- }
- , $v = function() {
- function e(e) {
- this._mesh = e,
- this.syncIterations = 5e3,
- this.aggressiveness = 7,
- this.decimationIterations = 100,
- this.boundingBoxEpsilon = m
- }
- return e.prototype.simplify = function(e, t) {
- var i = this;
- this._initDecimatedMesh(),
- yi.Run(this._mesh.subMeshes.length, (function(t) {
- i._initWithMesh(t.index, (function() {
- i._runDecimation(e, t.index, (function() {
- t.executeNext()
- }
- ))
- }
- ), e.optimizeMesh)
- }
- ), (function() {
- setTimeout((function() {
- t(i._reconstructedMesh)
- }
- ), 0)
- }
- ))
- }
- ,
- e.prototype._runDecimation = function(e, t, i) {
- var n = this
- , r = ~~(this._triangles.length * e.quality)
- , o = 0
- , a = this._triangles.length;
- yi.Run(this.decimationIterations, (function(e) {
- var t, i;
- a - o <= r ? e.breakLoop() : (t = e.index,
- i = function() {
- e.executeNext()
- }
- ,
- setTimeout((function() {
- t % 5 == 0 && n._updateMesh(0 === t);
- for (var e = 0; e < n._triangles.length; ++e)
- n._triangles[e].isDirty = !1;
- var s = 1e-9 * Math.pow(t + 3, n.aggressiveness);
- yi.SyncAsyncForLoop(n._triangles.length, n.syncIterations, (function(e) {
- var t = ~~((n._triangles.length / 2 + e) % n._triangles.length)
- , i = n._triangles[t];
- if (i && !(i.error[3] > s || i.deleted || i.isDirty))
- for (var r = function(e) {
- if (i.error[e] < s) {
- var t = []
- , r = []
- , a = i._vertices[e]
- , l = i._vertices[(e + 1) % 3];
- if (a.isBorder || l.isBorder)
- return "continue";
- var c = x.Zero();
- n._calculateError(a, l, c);
- var u = new Array;
- if (n._isFlipped(a, l, c, t, u))
- return "continue";
- if (n._isFlipped(l, a, c, r, u))
- return "continue";
- if (t.indexOf(!0) < 0 || r.indexOf(!0) < 0)
- return "continue";
- var h = new Array;
- if (u.forEach((function(e) {
- -1 === h.indexOf(e) && (e.deletePending = !0,
- h.push(e))
- }
- )),
- h.length % 2 != 0)
- return "continue";
- a.q = l.q.add(a.q),
- a.updatePosition(c);
- var d = n._references.length;
- o = n._updateTriangles(a, a, t, o),
- o = n._updateTriangles(a, l, r, o);
- var p = n._references.length - d;
- if (p <= a.triangleCount) {
- if (p)
- for (var f = 0; f < p; f++)
- n._references[a.triangleStart + f] = n._references[d + f]
- } else
- a.triangleStart = d;
- return a.triangleCount = p,
- "break"
- }
- }, a = 0; a < 3 && "break" !== r(a); ++a)
- ;
- }
- ), i, (function() {
- return a - o <= r
- }
- ))
- }
- ), 0))
- }
- ), (function() {
- setTimeout((function() {
- n._reconstructMesh(t),
- i()
- }
- ), 0)
- }
- ))
- }
- ,
- e.prototype._initWithMesh = function(e, t, i) {
- var n = this;
- this._vertices = [],
- this._triangles = [];
- var r = this._mesh.getVerticesData(Bi.PositionKind)
- , o = this._mesh.getIndices()
- , a = this._mesh.subMeshes[e]
- , s = []
- , l = a.verticesCount;
- yi.SyncAsyncForLoop(l, this.syncIterations / 4 >> 0, (function(e) {
- if (r) {
- var t = e + a.verticesStart
- , o = x.FromArray(r, 3 * t)
- , l = function(e) {
- if (i)
- for (var t = 0; t < n._vertices.length; ++t)
- if (n._vertices[t].position.equalsWithEpsilon(e, 1e-4))
- return n._vertices[t];
- return null
- }(o) || new qv(o,n._vertices.length);
- l.originalOffsets.push(t),
- l.id === n._vertices.length && n._vertices.push(l),
- s.push(l.id)
- }
- }
- ), (function() {
- yi.SyncAsyncForLoop(a.indexCount / 3, n.syncIterations, (function(e) {
- if (o) {
- var t = 3 * (a.indexStart / 3 + e)
- , i = o[t + 0]
- , r = o[t + 1]
- , l = o[t + 2]
- , c = n._vertices[s[i - a.verticesStart]]
- , u = n._vertices[s[r - a.verticesStart]]
- , h = n._vertices[s[l - a.verticesStart]]
- , d = new Qv([c, u, h]);
- d.originalOffset = t,
- n._triangles.push(d)
- }
- }
- ), (function() {
- n._init(t)
- }
- ))
- }
- ))
- }
- ,
- e.prototype._init = function(e) {
- var t = this;
- yi.SyncAsyncForLoop(this._triangles.length, this.syncIterations, (function(e) {
- var i = t._triangles[e];
- i.normal = x.Cross(i._vertices[1].position.subtract(i._vertices[0].position), i._vertices[2].position.subtract(i._vertices[0].position)).normalize();
- for (var n = 0; n < 3; n++)
- i._vertices[n].q.addArrayInPlace(Zv.DataFromNumbers(i.normal.x, i.normal.y, i.normal.z, -x.Dot(i.normal, i._vertices[0].position)))
- }
- ), (function() {
- yi.SyncAsyncForLoop(t._triangles.length, t.syncIterations, (function(e) {
- for (var i = t._triangles[e], n = 0; n < 3; ++n)
- i.error[n] = t._calculateError(i._vertices[n], i._vertices[(n + 1) % 3]);
- i.error[3] = Math.min(i.error[0], i.error[1], i.error[2])
- }
- ), (function() {
- e()
- }
- ))
- }
- ))
- }
- ,
- e.prototype._reconstructMesh = function(e) {
- var t, i, n, r = [];
- for (t = 0; t < this._vertices.length; ++t)
- this._vertices[t].triangleCount = 0;
- for (t = 0; t < this._triangles.length; ++t)
- if (!this._triangles[t].deleted) {
- for (i = this._triangles[t],
- n = 0; n < 3; ++n)
- i._vertices[n].triangleCount = 1;
- r.push(i)
- }
- var o = this._reconstructedMesh.getVerticesData(Bi.PositionKind) || []
- , a = this._reconstructedMesh.getVerticesData(Bi.NormalKind) || []
- , s = this._reconstructedMesh.getVerticesData(Bi.UVKind) || []
- , l = this._reconstructedMesh.getVerticesData(Bi.ColorKind) || []
- , c = this._mesh.getVerticesData(Bi.NormalKind)
- , u = this._mesh.getVerticesData(Bi.UVKind)
- , h = this._mesh.getVerticesData(Bi.ColorKind)
- , d = 0
- , p = function() {
- var e = f._vertices[t];
- e.id = d,
- e.triangleCount && e.originalOffsets.forEach((function(t) {
- o.push(e.position.x),
- o.push(e.position.y),
- o.push(e.position.z),
- c && c.length && (a.push(c[3 * t]),
- a.push(c[3 * t + 1]),
- a.push(c[3 * t + 2])),
- u && u.length && (s.push(u[2 * t]),
- s.push(u[2 * t + 1])),
- h && h.length && (l.push(h[4 * t]),
- l.push(h[4 * t + 1]),
- l.push(h[4 * t + 2]),
- l.push(h[4 * t + 3])),
- ++d
- }
- ))
- }
- , f = this;
- for (t = 0; t < this._vertices.length; ++t)
- p();
- var _ = this._reconstructedMesh.getTotalIndices()
- , m = this._reconstructedMesh.getTotalVertices()
- , g = this._reconstructedMesh.subMeshes;
- this._reconstructedMesh.subMeshes = [];
- var v = this._reconstructedMesh.getIndices()
- , y = this._mesh.getIndices();
- for (t = 0; t < r.length; ++t)
- i = r[t],
- [0, 1, 2].forEach((function(e) {
- var t = y[i.originalOffset + e]
- , n = i._vertices[e].originalOffsets.indexOf(t);
- n < 0 && (n = 0),
- v.push(i._vertices[e].id + n + m)
- }
- ));
- this._reconstructedMesh.setIndices(v),
- this._reconstructedMesh.setVerticesData(Bi.PositionKind, o),
- a.length > 0 && this._reconstructedMesh.setVerticesData(Bi.NormalKind, a),
- s.length > 0 && this._reconstructedMesh.setVerticesData(Bi.UVKind, s),
- l.length > 0 && this._reconstructedMesh.setVerticesData(Bi.ColorKind, l);
- var b = this._mesh.subMeshes[e];
- e > 0 && (this._reconstructedMesh.subMeshes = [],
- g.forEach((function(e) {
- hr.AddToMesh(e.materialIndex, e.verticesStart, e.verticesCount, e.indexStart, e.indexCount, e.getMesh())
- }
- )),
- hr.AddToMesh(b.materialIndex, m, d, _, 3 * r.length, this._reconstructedMesh))
- }
- ,
- e.prototype._initDecimatedMesh = function() {
- this._reconstructedMesh = new Vr(this._mesh.name + "Decimated",this._mesh.getScene()),
- this._reconstructedMesh.material = this._mesh.material,
- this._reconstructedMesh.parent = this._mesh.parent,
- this._reconstructedMesh.isVisible = !1,
- this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId
- }
- ,
- e.prototype._isFlipped = function(e, t, i, n, r) {
- for (var o = 0; o < e.triangleCount; ++o) {
- var a = this._triangles[this._references[e.triangleStart + o].triangleId];
- if (!a.deleted) {
- var s = this._references[e.triangleStart + o].vertexId
- , l = a._vertices[(s + 1) % 3]
- , c = a._vertices[(s + 2) % 3];
- if (l !== t && c !== t) {
- var u = l.position.subtract(i);
- u = u.normalize();
- var h = c.position.subtract(i);
- if (h = h.normalize(),
- Math.abs(x.Dot(u, h)) > .999)
- return !0;
- var d = x.Cross(u, h).normalize();
- if (n[o] = !1,
- x.Dot(d, a.normal) < .2)
- return !0
- } else
- n[o] = !0,
- r.push(a)
- }
- }
- return !1
- }
- ,
- e.prototype._updateTriangles = function(e, t, i, n) {
- for (var r = n, o = 0; o < t.triangleCount; ++o) {
- var a = this._references[t.triangleStart + o]
- , s = this._triangles[a.triangleId];
- s.deleted || (i[o] && s.deletePending ? (s.deleted = !0,
- r++) : (s._vertices[a.vertexId] = e,
- s.isDirty = !0,
- s.error[0] = this._calculateError(s._vertices[0], s._vertices[1]) + s.borderFactor / 2,
- s.error[1] = this._calculateError(s._vertices[1], s._vertices[2]) + s.borderFactor / 2,
- s.error[2] = this._calculateError(s._vertices[2], s._vertices[0]) + s.borderFactor / 2,
- s.error[3] = Math.min(s.error[0], s.error[1], s.error[2]),
- this._references.push(a)))
- }
- return r
- }
- ,
- e.prototype._identifyBorder = function() {
- for (var e = 0; e < this._vertices.length; ++e) {
- var t = []
- , i = []
- , n = this._vertices[e]
- , r = void 0;
- for (r = 0; r < n.triangleCount; ++r)
- for (var o = this._triangles[this._references[n.triangleStart + r].triangleId], a = 0; a < 3; a++) {
- for (var s = 0, l = o._vertices[a]; s < t.length && i[s] !== l.id; )
- ++s;
- s === t.length ? (t.push(1),
- i.push(l.id)) : t[s]++
- }
- for (r = 0; r < t.length; ++r)
- 1 === t[r] ? this._vertices[i[r]].isBorder = !0 : this._vertices[i[r]].isBorder = !1
- }
- }
- ,
- e.prototype._updateMesh = function(e) {
- var t, i, n, r;
- if (void 0 === e && (e = !1),
- !e) {
- var o = [];
- for (t = 0; t < this._triangles.length; ++t)
- this._triangles[t].deleted || o.push(this._triangles[t]);
- this._triangles = o
- }
- for (t = 0; t < this._vertices.length; ++t)
- this._vertices[t].triangleCount = 0,
- this._vertices[t].triangleStart = 0;
- for (t = 0; t < this._triangles.length; ++t)
- for (i = this._triangles[t],
- n = 0; n < 3; ++n)
- (r = i._vertices[n]).triangleCount++;
- var a = 0;
- for (t = 0; t < this._vertices.length; ++t)
- this._vertices[t].triangleStart = a,
- a += this._vertices[t].triangleCount,
- this._vertices[t].triangleCount = 0;
- var s = new Array(3 * this._triangles.length);
- for (t = 0; t < this._triangles.length; ++t)
- for (i = this._triangles[t],
- n = 0; n < 3; ++n)
- s[(r = i._vertices[n]).triangleStart + r.triangleCount] = new Jv(n,t),
- r.triangleCount++;
- this._references = s,
- e && this._identifyBorder()
- }
- ,
- e.prototype._vertexError = function(e, t) {
- var i = t.x
- , n = t.y
- , r = t.z;
- return e.data[0] * i * i + 2 * e.data[1] * i * n + 2 * e.data[2] * i * r + 2 * e.data[3] * i + e.data[4] * n * n + 2 * e.data[5] * n * r + 2 * e.data[6] * n + e.data[7] * r * r + 2 * e.data[8] * r + e.data[9]
- }
- ,
- e.prototype._calculateError = function(e, t, i) {
- var n = e.q.add(t.q)
- , r = e.isBorder && t.isBorder
- , o = 0
- , a = n.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
- if (0 === a || r) {
- var s = e.position.add(t.position).divide(new x(2,2,2))
- , l = this._vertexError(n, e.position)
- , c = this._vertexError(n, t.position)
- , u = this._vertexError(n, s);
- (o = Math.min(l, c, u)) === l ? i && i.copyFrom(e.position) : o === c ? i && i.copyFrom(t.position) : i && i.copyFrom(s)
- } else
- i || (i = x.Zero()),
- i.x = -1 / a * n.det(1, 2, 3, 4, 5, 6, 5, 7, 8),
- i.y = 1 / a * n.det(0, 2, 3, 1, 5, 6, 2, 7, 8),
- i.z = -1 / a * n.det(0, 1, 3, 1, 4, 6, 2, 5, 8),
- o = this._vertexError(n, i);
- return o
- }
- ,
- e
- }();
- Object.defineProperty(mn.prototype, "simplificationQueue", {
- get: function() {
- if (!this._simplificationQueue) {
- this._simplificationQueue = new Kv;
- var e = this._getComponent(Wi.NAME_SIMPLIFICATIONQUEUE);
- e || (e = new ey(this),
- this._addComponent(e))
- }
- return this._simplificationQueue
- },
- set: function(e) {
- this._simplificationQueue = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Vr.prototype.simplify = function(e, t, i, n) {
- return void 0 === t && (t = !0),
- void 0 === i && (i = Xv.QUADRATIC),
- this.getScene().simplificationQueue.addTask({
- settings: e,
- parallelProcessing: t,
- mesh: this,
- simplificationType: i,
- successCallback: n
- }),
- this
- }
- ;
- var ey = function() {
- function e(e) {
- this.name = Wi.NAME_SIMPLIFICATIONQUEUE,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._beforeCameraUpdateStage.registerStep(Wi.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {}
- ,
- e.prototype._beforeCameraUpdate = function() {
- this.scene._simplificationQueue && !this.scene._simplificationQueue.running && this.scene._simplificationQueue.executeNext()
- }
- ,
- e
- }();
- Vr.prototype.thinInstanceAdd = function(e, t) {
- void 0 === t && (t = !0),
- this._thinInstanceUpdateBufferSize("matrix", Array.isArray(e) ? e.length : 1);
- var i = this._thinInstanceDataStorage.instancesCount;
- if (Array.isArray(e))
- for (var n = 0; n < e.length; ++n)
- this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e[n], n === e.length - 1 && t);
- else
- this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, e, t);
- return i
- }
- ,
- Vr.prototype.thinInstanceAddSelf = function(e) {
- return void 0 === e && (e = !0),
- this.thinInstanceAdd(P.IdentityReadOnly, e)
- }
- ,
- Vr.prototype.thinInstanceRegisterAttribute = function(e, t) {
- this.removeVerticesData(e),
- this._thinInstanceInitializeUserStorage(),
- this._userThinInstanceBuffersStorage.strides[e] = t,
- this._userThinInstanceBuffersStorage.sizes[e] = t * Math.max(32, this._thinInstanceDataStorage.instancesCount),
- this._userThinInstanceBuffersStorage.data[e] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[e]),
- this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),this._userThinInstanceBuffersStorage.data[e],e,!0,!1,t,!0),
- this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])
- }
- ,
- Vr.prototype.thinInstanceSetMatrixAt = function(e, t, i) {
- if (void 0 === i && (i = !0),
- !this._thinInstanceDataStorage.matrixData || e >= this._thinInstanceDataStorage.instancesCount)
- return !1;
- var n = this._thinInstanceDataStorage.matrixData;
- return t.copyToArray(n, 16 * e),
- this._thinInstanceDataStorage.worldMatrices && (this._thinInstanceDataStorage.worldMatrices[e] = t),
- i && (this.thinInstanceBufferUpdated("matrix"),
- this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)),
- !0
- }
- ,
- Vr.prototype.thinInstanceSetAttributeAt = function(e, t, i, n) {
- return void 0 === n && (n = !0),
- !(!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.data[e] || t >= this._thinInstanceDataStorage.instancesCount || (this._thinInstanceUpdateBufferSize(e, 0),
- this._userThinInstanceBuffersStorage.data[e].set(i, t * this._userThinInstanceBuffersStorage.strides[e]),
- n && this.thinInstanceBufferUpdated(e),
- 0))
- }
- ,
- Object.defineProperty(Vr.prototype, "thinInstanceCount", {
- get: function() {
- return this._thinInstanceDataStorage.instancesCount
- },
- set: function(e) {
- var t, i;
- e <= (null !== (i = null === (t = this._thinInstanceDataStorage.matrixData) || void 0 === t ? void 0 : t.length) && void 0 !== i ? i : 0) / 16 && (this._thinInstanceDataStorage.instancesCount = e)
- },
- enumerable: !0,
- configurable: !0
- }),
- Vr.prototype._thinInstanceCreateMatrixBuffer = function(e, t, i) {
- void 0 === i && (i = !1);
- for (var n = new wi(this.getEngine(),t,!i,16,!1,!0), r = 0; r < 4; r++)
- this.setVerticesBuffer(n.createVertexBuffer(e + r, 4 * r, 4));
- return n
- }
- ,
- Vr.prototype.thinInstanceSetBuffer = function(e, t, i, n) {
- var r, o, a;
- void 0 === i && (i = 0),
- void 0 === n && (n = !1),
- i = i || 16,
- "matrix" === e ? (null === (r = this._thinInstanceDataStorage.matrixBuffer) || void 0 === r || r.dispose(),
- this._thinInstanceDataStorage.matrixBuffer = null,
- this._thinInstanceDataStorage.matrixBufferSize = t ? t.length : 32 * i,
- this._thinInstanceDataStorage.matrixData = t,
- this._thinInstanceDataStorage.worldMatrices = null,
- null !== t ? (this._thinInstanceDataStorage.instancesCount = t.length / i,
- this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", t, n),
- this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1)) : (this._thinInstanceDataStorage.instancesCount = 0,
- this.doNotSyncBoundingInfo || this.refreshBoundingInfo())) : "previousMatrix" === e ? (null === (o = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === o || o.dispose(),
- this._thinInstanceDataStorage.previousMatrixBuffer = null,
- this._thinInstanceDataStorage.previousMatrixData = t,
- null !== t && (this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", t, n))) : (e === Bi.ColorKind && (e = Bi.ColorInstanceKind),
- null === t ? (null === (a = this._userThinInstanceBuffersStorage) || void 0 === a ? void 0 : a.data[e]) && (this.removeVerticesData(e),
- delete this._userThinInstanceBuffersStorage.data[e],
- delete this._userThinInstanceBuffersStorage.strides[e],
- delete this._userThinInstanceBuffersStorage.sizes[e],
- delete this._userThinInstanceBuffersStorage.vertexBuffers[e]) : (this._thinInstanceInitializeUserStorage(),
- this._userThinInstanceBuffersStorage.data[e] = t,
- this._userThinInstanceBuffersStorage.strides[e] = i,
- this._userThinInstanceBuffersStorage.sizes[e] = t.length,
- this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),t,e,!n,!1,i,!0),
- this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])))
- }
- ,
- Vr.prototype.thinInstanceBufferUpdated = function(e) {
- var t, i, n;
- "matrix" === e ? null === (t = this._thinInstanceDataStorage.matrixBuffer) || void 0 === t || t.updateDirectly(this._thinInstanceDataStorage.matrixData, 0, this._thinInstanceDataStorage.instancesCount) : "previousMatrix" === e ? null === (i = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === i || i.updateDirectly(this._thinInstanceDataStorage.previousMatrixData, 0, this._thinInstanceDataStorage.instancesCount) : (null === (n = this._userThinInstanceBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e], 0)
- }
- ,
- Vr.prototype.thinInstancePartialBufferUpdate = function(e, t, i) {
- var n;
- "matrix" === e ? this._thinInstanceDataStorage.matrixBuffer && this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t, i) : (null === (n = this._userThinInstanceBuffersStorage) || void 0 === n ? void 0 : n.vertexBuffers[e]) && this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t, i)
- }
- ,
- Vr.prototype.thinInstanceGetWorldMatrices = function() {
- if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer)
- return [];
- var e = this._thinInstanceDataStorage.matrixData;
- if (!this._thinInstanceDataStorage.worldMatrices) {
- this._thinInstanceDataStorage.worldMatrices = new Array;
- for (var t = 0; t < this._thinInstanceDataStorage.instancesCount; ++t)
- this._thinInstanceDataStorage.worldMatrices[t] = P.FromArray(e, 16 * t)
- }
- return this._thinInstanceDataStorage.worldMatrices
- }
- ,
- Vr.prototype.thinInstanceRefreshBoundingInfo = function(e, t, i) {
- if (void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- this._thinInstanceDataStorage.matrixData && this._thinInstanceDataStorage.matrixBuffer) {
- var n = this._thinInstanceDataStorage.boundingVectors;
- e && (n.length = 0,
- this.refreshBoundingInfo(t, i));
- var r = this.getBoundingInfo()
- , o = this._thinInstanceDataStorage.matrixData;
- if (0 === n.length)
- for (var a = 0; a < r.boundingBox.vectors.length; ++a)
- n.push(r.boundingBox.vectors[a].clone());
- I.Vector3[0].setAll(Number.POSITIVE_INFINITY),
- I.Vector3[1].setAll(Number.NEGATIVE_INFINITY);
- for (var s = 0; s < this._thinInstanceDataStorage.instancesCount; ++s)
- for (P.FromArrayToRef(o, 16 * s, I.Matrix[0]),
- a = 0; a < n.length; ++a)
- x.TransformCoordinatesToRef(n[a], I.Matrix[0], I.Vector3[2]),
- I.Vector3[0].minimizeInPlace(I.Vector3[2]),
- I.Vector3[1].maximizeInPlace(I.Vector3[2]);
- r.reConstruct(I.Vector3[0], I.Vector3[1]),
- this._updateBoundingInfo()
- }
- }
- ,
- Vr.prototype._thinInstanceUpdateBufferSize = function(e, t) {
- var i, n, r;
- void 0 === t && (t = 1);
- var o = "matrix" === e;
- if (o || this._userThinInstanceBuffersStorage && this._userThinInstanceBuffersStorage.strides[e]) {
- for (var a = o ? 16 : this._userThinInstanceBuffersStorage.strides[e], s = o ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[e], l = o ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[e], c = (this._thinInstanceDataStorage.instancesCount + t) * a, u = s; u < c; )
- u *= 2;
- if (!l || s != u) {
- if (l) {
- var h = new Float32Array(u);
- h.set(l, 0),
- l = h
- } else
- l = new Float32Array(u);
- o ? (null === (i = this._thinInstanceDataStorage.matrixBuffer) || void 0 === i || i.dispose(),
- this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer("world", l, !1),
- this._thinInstanceDataStorage.matrixData = l,
- this._thinInstanceDataStorage.matrixBufferSize = u,
- this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData && (null === (n = this._thinInstanceDataStorage.previousMatrixBuffer) || void 0 === n || n.dispose(),
- this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer("previousWorld", l, !1))) : (null === (r = this._userThinInstanceBuffersStorage.vertexBuffers[e]) || void 0 === r || r.dispose(),
- this._userThinInstanceBuffersStorage.data[e] = l,
- this._userThinInstanceBuffersStorage.sizes[e] = u,
- this._userThinInstanceBuffersStorage.vertexBuffers[e] = new Bi(this.getEngine(),l,e,!0,!1,a,!0),
- this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))
- }
- }
- }
- ,
- Vr.prototype._thinInstanceInitializeUserStorage = function() {
- this._userThinInstanceBuffersStorage || (this._userThinInstanceBuffersStorage = {
- data: {},
- sizes: {},
- vertexBuffers: {},
- strides: {}
- })
- }
- ,
- Vr.prototype._disposeThinInstanceSpecificData = function() {
- var e;
- (null === (e = this._thinInstanceDataStorage) || void 0 === e ? void 0 : e.matrixBuffer) && (this._thinInstanceDataStorage.matrixBuffer.dispose(),
- this._thinInstanceDataStorage.matrixBuffer = null)
- }
- ;
- var ty = function() {
- function e(e) {
- void 0 === e && (e = Recast),
- this.bjsRECAST = {},
- this.name = "RecastJSPlugin",
- this._maximumSubStepCount = 10,
- this._timeStep = 1 / 60,
- this._worker = null,
- "function" == typeof e ? K.Error("RecastJS is not ready. Please make sure you await Recast() before using the plugin.") : this.bjsRECAST = e,
- this.isSupported() ? (this.setTimeStep(),
- this._tempVec1 = new this.bjsRECAST.Vec3,
- this._tempVec2 = new this.bjsRECAST.Vec3) : K.Error("RecastJS is not available. Please make sure you included the js file.")
- }
- return e.prototype.setWorkerURL = function(e) {
- return !(!window || !window.Worker || (this._worker = new Worker(e),
- 0))
- }
- ,
- e.prototype.setTimeStep = function(e) {
- void 0 === e && (e = 1 / 60),
- this._timeStep = e
- }
- ,
- e.prototype.getTimeStep = function() {
- return this._timeStep
- }
- ,
- e.prototype.setMaximumSubStepCount = function(e) {
- void 0 === e && (e = 10),
- this._maximumSubStepCount = e
- }
- ,
- e.prototype.getMaximumSubStepCount = function() {
- return this._maximumSubStepCount
- }
- ,
- e.prototype.createNavMesh = function(e, t, i) {
- var n, r, o;
- this._worker && !i ? console.warn("A worker is avaible but no completion callback. Defaulting to blocking navmesh creation") : !this._worker && i && console.warn("A completion callback is avaible but no worker. Defaulting to blocking navmesh creation"),
- this.navMesh = new this.bjsRECAST.NavMesh;
- var a = []
- , s = []
- , l = 0;
- for (n = 0; n < e.length; n++)
- if (e[n]) {
- var c = e[n]
- , u = c.getIndices();
- if (!u)
- continue;
- var h = c.getVerticesData(Bi.PositionKind, !1, !1);
- if (!h)
- continue;
- var d = []
- , p = c.computeWorldMatrix(!0);
- if (c.hasThinInstances)
- for (var f = c.thinInstanceGetWorldMatrices(), _ = 0; _ < f.length; _++) {
- var m = new P;
- f[_].multiplyToRef(p, m),
- d.push(m)
- }
- else
- d.push(p);
- for (var g = 0; g < d.length; g++) {
- var v = d[g];
- for (r = 0; r < u.length; r++)
- a.push(u[r] + l);
- var y = x.Zero()
- , b = x.Zero();
- for (o = 0; o < h.length; o += 3)
- x.FromArrayToRef(h, o, b),
- x.TransformCoordinatesToRef(b, v, y),
- s.push(y.x, y.y, y.z);
- l += h.length / 3
- }
- }
- if (this._worker && i)
- this._worker.postMessage([s, l, a, a.length, t]),
- this._worker.onmessage = function(e) {
- i(e.data)
- }
- ;
- else {
- var T = new this.bjsRECAST.rcConfig;
- T.cs = t.cs,
- T.ch = t.ch,
- T.borderSize = t.borderSize ? t.borderSize : 0,
- T.tileSize = t.tileSize ? t.tileSize : 0,
- T.walkableSlopeAngle = t.walkableSlopeAngle,
- T.walkableHeight = t.walkableHeight,
- T.walkableClimb = t.walkableClimb,
- T.walkableRadius = t.walkableRadius,
- T.maxEdgeLen = t.maxEdgeLen,
- T.maxSimplificationError = t.maxSimplificationError,
- T.minRegionArea = t.minRegionArea,
- T.mergeRegionArea = t.mergeRegionArea,
- T.maxVertsPerPoly = t.maxVertsPerPoly,
- T.detailSampleDist = t.detailSampleDist,
- T.detailSampleMaxError = t.detailSampleMaxError,
- this.navMesh.build(s, l, a, a.length, T)
- }
- }
- ,
- e.prototype.createDebugNavMesh = function(e) {
- var t, i, n = this.navMesh.getDebugNavMesh(), r = n.getTriangleCount(), o = [], a = [];
- for (t = 0; t < 3 * r; t++)
- o.push(t);
- for (t = 0; t < r; t++)
- for (i = 0; i < 3; i++) {
- var s = n.getTriangle(t).getPoint(i);
- a.push(s.x, s.y, s.z)
- }
- var l = new Vr("NavMeshDebug",e)
- , c = new $n;
- return c.indices = o,
- c.positions = a,
- c.applyToMesh(l, !1),
- l
- }
- ,
- e.prototype.getClosestPoint = function(e) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z;
- var t = this.navMesh.getClosestPoint(this._tempVec1);
- return new x(t.x,t.y,t.z)
- }
- ,
- e.prototype.getClosestPointToRef = function(e, t) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z;
- var i = this.navMesh.getClosestPoint(this._tempVec1);
- t.set(i.x, i.y, i.z)
- }
- ,
- e.prototype.getRandomPointAround = function(e, t) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z;
- var i = this.navMesh.getRandomPointAround(this._tempVec1, t);
- return new x(i.x,i.y,i.z)
- }
- ,
- e.prototype.getRandomPointAroundToRef = function(e, t, i) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z;
- var n = this.navMesh.getRandomPointAround(this._tempVec1, t);
- i.set(n.x, n.y, n.z)
- }
- ,
- e.prototype.moveAlong = function(e, t) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z,
- this._tempVec2.x = t.x,
- this._tempVec2.y = t.y,
- this._tempVec2.z = t.z;
- var i = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
- return new x(i.x,i.y,i.z)
- }
- ,
- e.prototype.moveAlongToRef = function(e, t, i) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z,
- this._tempVec2.x = t.x,
- this._tempVec2.y = t.y,
- this._tempVec2.z = t.z;
- var n = this.navMesh.moveAlong(this._tempVec1, this._tempVec2);
- i.set(n.x, n.y, n.z)
- }
- ,
- e.prototype.computePath = function(e, t) {
- var i;
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z,
- this._tempVec2.x = t.x,
- this._tempVec2.y = t.y,
- this._tempVec2.z = t.z;
- var n = this.navMesh.computePath(this._tempVec1, this._tempVec2)
- , r = n.getPointCount()
- , o = [];
- for (i = 0; i < r; i++) {
- var a = n.getPoint(i);
- o.push(new x(a.x,a.y,a.z))
- }
- return o
- }
- ,
- e.prototype.createCrowd = function(e, t, i) {
- return new iy(this,e,t,i)
- }
- ,
- e.prototype.setDefaultQueryExtent = function(e) {
- this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z,
- this.navMesh.setDefaultQueryExtent(this._tempVec1)
- }
- ,
- e.prototype.getDefaultQueryExtent = function() {
- var e = this.navMesh.getDefaultQueryExtent();
- return new x(e.x,e.y,e.z)
- }
- ,
- e.prototype.buildFromNavmeshData = function(e) {
- var t = e.length * e.BYTES_PER_ELEMENT
- , i = this.bjsRECAST._malloc(t)
- , n = new Uint8Array(this.bjsRECAST.HEAPU8.buffer,i,t);
- n.set(e);
- var r = new this.bjsRECAST.NavmeshData;
- r.dataPointer = n.byteOffset,
- r.size = e.length,
- this.navMesh = new this.bjsRECAST.NavMesh,
- this.navMesh.buildFromNavmeshData(r),
- this.bjsRECAST._free(n.byteOffset)
- }
- ,
- e.prototype.getNavmeshData = function() {
- var e = this.navMesh.getNavmeshData()
- , t = new Uint8Array(this.bjsRECAST.HEAPU8.buffer,e.dataPointer,e.size)
- , i = new Uint8Array(e.size);
- return i.set(t),
- this.navMesh.freeNavmeshData(e),
- i
- }
- ,
- e.prototype.getDefaultQueryExtentToRef = function(e) {
- var t = this.navMesh.getDefaultQueryExtent();
- e.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.dispose = function() {}
- ,
- e.prototype.addCylinderObstacle = function(e, t, i) {
- return this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z,
- this.navMesh.addCylinderObstacle(this._tempVec1, t, i)
- }
- ,
- e.prototype.addBoxObstacle = function(e, t, i) {
- return this._tempVec1.x = e.x,
- this._tempVec1.y = e.y,
- this._tempVec1.z = e.z,
- this._tempVec2.x = t.x,
- this._tempVec2.y = t.y,
- this._tempVec2.z = t.z,
- this.navMesh.addBoxObstacle(this._tempVec1, this._tempVec2, i)
- }
- ,
- e.prototype.removeObstacle = function(e) {
- this.navMesh.removeObstacle(e)
- }
- ,
- e.prototype.isSupported = function() {
- return void 0 !== this.bjsRECAST
- }
- ,
- e
- }()
- , iy = function() {
- function e(e, t, i, n) {
- var r = this;
- this.recastCrowd = {},
- this.transforms = new Array,
- this.agents = new Array,
- this.reachRadii = new Array,
- this._agentDestinationArmed = new Array,
- this._agentDestination = new Array,
- this._onBeforeAnimationsObserver = null,
- this.onReachTargetObservable = new h,
- this.bjsRECASTPlugin = e,
- this.recastCrowd = new this.bjsRECASTPlugin.bjsRECAST.Crowd(t,i,this.bjsRECASTPlugin.navMesh.getNavMesh()),
- this._scene = n,
- this._onBeforeAnimationsObserver = n.onBeforeAnimationsObservable.add((function() {
- r.update(.001 * n.getEngine().getDeltaTime())
- }
- ))
- }
- return e.prototype.addAgent = function(e, t, i) {
- var n = new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams;
- n.radius = t.radius,
- n.height = t.height,
- n.maxAcceleration = t.maxAcceleration,
- n.maxSpeed = t.maxSpeed,
- n.collisionQueryRange = t.collisionQueryRange,
- n.pathOptimizationRange = t.pathOptimizationRange,
- n.separationWeight = t.separationWeight,
- n.updateFlags = 7,
- n.obstacleAvoidanceType = 0,
- n.queryFilterType = 0,
- n.userData = 0;
- var r = this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z), n);
- return this.transforms.push(i),
- this.agents.push(r),
- this.reachRadii.push(t.reachRadius ? t.reachRadius : t.radius),
- this._agentDestinationArmed.push(!1),
- this._agentDestination.push(new x(0,0,0)),
- r
- }
- ,
- e.prototype.getAgentPosition = function(e) {
- var t = this.recastCrowd.getAgentPosition(e);
- return new x(t.x,t.y,t.z)
- }
- ,
- e.prototype.getAgentPositionToRef = function(e, t) {
- var i = this.recastCrowd.getAgentPosition(e);
- t.set(i.x, i.y, i.z)
- }
- ,
- e.prototype.getAgentVelocity = function(e) {
- var t = this.recastCrowd.getAgentVelocity(e);
- return new x(t.x,t.y,t.z)
- }
- ,
- e.prototype.getAgentVelocityToRef = function(e, t) {
- var i = this.recastCrowd.getAgentVelocity(e);
- t.set(i.x, i.y, i.z)
- }
- ,
- e.prototype.getAgentNextTargetPath = function(e) {
- var t = this.recastCrowd.getAgentNextTargetPath(e);
- return new x(t.x,t.y,t.z)
- }
- ,
- e.prototype.getAgentNextTargetPathToRef = function(e, t) {
- var i = this.recastCrowd.getAgentNextTargetPath(e);
- t.set(i.x, i.y, i.z)
- }
- ,
- e.prototype.getAgentState = function(e) {
- return this.recastCrowd.getAgentState(e)
- }
- ,
- e.prototype.overOffmeshConnection = function(e) {
- return this.recastCrowd.overOffmeshConnection(e)
- }
- ,
- e.prototype.agentGoto = function(e, t) {
- this.recastCrowd.agentGoto(e, new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z));
- var i = this.agents.indexOf(e);
- i > -1 && (this._agentDestinationArmed[i] = !0,
- this._agentDestination[i].set(t.x, t.y, t.z))
- }
- ,
- e.prototype.agentTeleport = function(e, t) {
- this.recastCrowd.agentTeleport(e, new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z))
- }
- ,
- e.prototype.updateAgentParameters = function(e, t) {
- var i = this.recastCrowd.getAgentParameters(e);
- void 0 !== t.radius && (i.radius = t.radius),
- void 0 !== t.height && (i.height = t.height),
- void 0 !== t.maxAcceleration && (i.maxAcceleration = t.maxAcceleration),
- void 0 !== t.maxSpeed && (i.maxSpeed = t.maxSpeed),
- void 0 !== t.collisionQueryRange && (i.collisionQueryRange = t.collisionQueryRange),
- void 0 !== t.pathOptimizationRange && (i.pathOptimizationRange = t.pathOptimizationRange),
- void 0 !== t.separationWeight && (i.separationWeight = t.separationWeight),
- this.recastCrowd.setAgentParameters(e, i)
- }
- ,
- e.prototype.removeAgent = function(e) {
- this.recastCrowd.removeAgent(e);
- var t = this.agents.indexOf(e);
- t > -1 && (this.agents.splice(t, 1),
- this.transforms.splice(t, 1),
- this.reachRadii.splice(t, 1),
- this._agentDestinationArmed.splice(t, 1),
- this._agentDestination.splice(t, 1))
- }
- ,
- e.prototype.getAgents = function() {
- return this.agents
- }
- ,
- e.prototype.update = function(e) {
- this.bjsRECASTPlugin.navMesh.update();
- var t = this.bjsRECASTPlugin.getTimeStep()
- , i = this.bjsRECASTPlugin.getMaximumSubStepCount();
- if (t <= m)
- this.recastCrowd.update(e);
- else {
- var n = Math.floor(e / t);
- i && n > i && (n = i),
- n < 1 && (n = 1);
- for (var r = e / n, o = 0; o < n; o++)
- this.recastCrowd.update(r)
- }
- for (var a = 0; a < this.agents.length; a++) {
- var s = this.agents[a]
- , l = this.getAgentPosition(s);
- if (this.transforms[a].position = l,
- this._agentDestinationArmed[a]) {
- var c = l.x - this._agentDestination[a].x
- , u = l.z - this._agentDestination[a].z
- , h = this.reachRadii[a]
- , d = this._agentDestination[a].y - this.reachRadii[a]
- , p = this._agentDestination[a].y + this.reachRadii[a]
- , f = c * c + u * u;
- l.y > d && l.y < p && f < h * h && (this.onReachTargetObservable.notifyObservers({
- agentIndex: s,
- destination: this._agentDestination[a]
- }),
- this._agentDestinationArmed[a] = !1)
- }
- }
- }
- ,
- e.prototype.setDefaultQueryExtent = function(e) {
- var t = new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z);
- this.recastCrowd.setDefaultQueryExtent(t)
- }
- ,
- e.prototype.getDefaultQueryExtent = function() {
- var e = this.recastCrowd.getDefaultQueryExtent();
- return new x(e.x,e.y,e.z)
- }
- ,
- e.prototype.getDefaultQueryExtentToRef = function(e) {
- var t = this.recastCrowd.getDefaultQueryExtent();
- e.set(t.x, t.y, t.z)
- }
- ,
- e.prototype.getCorners = function(e) {
- var t, i = this.recastCrowd.getPath(e), n = i.getPointCount(), r = [];
- for (t = 0; t < n; t++) {
- var o = i.getPoint(t);
- r.push(new x(o.x,o.y,o.z))
- }
- return r
- }
- ,
- e.prototype.dispose = function() {
- this.recastCrowd.destroy(),
- this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),
- this._onBeforeAnimationsObserver = null,
- this.onReachTargetObservable.clear()
- }
- ,
- e
- }();
- vr.OfflineProviderFactory = function(e, t, i) {
- return void 0 === i && (i = !1),
- new ny(e,t,i)
- }
- ;
- var ny = function() {
- function e(t, i, n) {
- void 0 === n && (n = !1),
- this._idbFactory = "undefined" != typeof window ? window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB : indexedDB,
- this._currentSceneUrl = e._ReturnFullUrlLocation(t),
- this._db = null,
- this._enableSceneOffline = !1,
- this._enableTexturesOffline = !1,
- this._manifestVersionFound = 0,
- this._mustUpdateRessources = !1,
- this._hasReachedQuota = !1,
- e.IDBStorageEnabled ? n ? (this._enableSceneOffline = !0,
- this._enableTexturesOffline = !0,
- this._manifestVersionFound = 1,
- gi.SetImmediate((function() {
- i(!0)
- }
- ))) : this._checkManifestFile(i) : i(!0)
- }
- return Object.defineProperty(e.prototype, "enableSceneOffline", {
- get: function() {
- return this._enableSceneOffline
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enableTexturesOffline", {
- get: function() {
- return this._enableTexturesOffline
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._checkManifestFile = function(t) {
- var i = this
- , n = function() {
- i._enableSceneOffline = !1,
- i._enableTexturesOffline = !1,
- t(!1)
- }
- , r = function() {
- try {
- if ("function" == typeof URL && 0 === i._currentSceneUrl.indexOf("http")) {
- var e = new URL(i._currentSceneUrl);
- return e.pathname += ".manifest",
- e.toString()
- }
- } catch (e) {}
- return "".concat(i._currentSceneUrl, ".manifest")
- }
- , o = !1
- , a = r()
- , s = new Ye;
- navigator.onLine && (o = !0,
- a = a + (null == a.match(/\?/) ? "?" : "&") + Date.now()),
- s.open("GET", a),
- s.addEventListener("load", (function() {
- if (200 === s.status || e._ValidateXHRData(s, 1))
- try {
- var r = JSON.parse(s.response);
- i._enableSceneOffline = r.enableSceneOffline,
- i._enableTexturesOffline = r.enableTexturesOffline && e._IsUASupportingBlobStorage,
- r.version && !isNaN(parseInt(r.version)) && (i._manifestVersionFound = r.version),
- t(!0)
- } catch (e) {
- n()
- }
- else
- n()
- }
- ), !1),
- s.addEventListener("error", (function() {
- if (o) {
- o = !1;
- var e = r();
- s.open("GET", e),
- s.send()
- } else
- n()
- }
- ), !1);
- try {
- s.send()
- } catch (e) {
- K.Error("Error on XHR send request."),
- t(!1)
- }
- }
- ,
- e.prototype.open = function(e, t) {
- var i = this
- , n = function() {
- i._isSupported = !1,
- t && t()
- };
- if (this._idbFactory && (this._enableSceneOffline || this._enableTexturesOffline))
- if (this._db)
- e && e();
- else {
- this._hasReachedQuota = !1,
- this._isSupported = !0;
- var r = this._idbFactory.open("babylonjs", 1);
- r.onerror = function() {
- n()
- }
- ,
- r.onblocked = function() {
- K.Error("IDB request blocked. Please reload the page."),
- n()
- }
- ,
- r.onsuccess = function() {
- i._db = r.result,
- e()
- }
- ,
- r.onupgradeneeded = function(e) {
- if (i._db = e.target.result,
- i._db)
- try {
- i._db.createObjectStore("scenes", {
- keyPath: "sceneUrl"
- }),
- i._db.createObjectStore("versions", {
- keyPath: "sceneUrl"
- }),
- i._db.createObjectStore("textures", {
- keyPath: "textureUrl"
- })
- } catch (e) {
- K.Error("Error while creating object stores. Exception: " + e.message),
- n()
- }
- }
- }
- else
- this._isSupported = !1,
- t && t()
- }
- ,
- e.prototype.loadImage = function(t, i) {
- var n = this
- , r = e._ReturnFullUrlLocation(t)
- , o = function() {
- n._hasReachedQuota || null === n._db ? i.src = t : n._saveImageIntoDBAsync(r, i)
- };
- this._mustUpdateRessources ? o() : this._loadImageFromDBAsync(r, i, o)
- }
- ,
- e.prototype._loadImageFromDBAsync = function(e, t, i) {
- if (this._isSupported && null !== this._db) {
- var n, r = this._db.transaction(["textures"]);
- r.onabort = function() {
- t.src = e
- }
- ,
- r.oncomplete = function() {
- var r;
- if (n) {
- var o = window.URL || window.webkitURL;
- r = o.createObjectURL(n.data),
- t.onerror = function() {
- K.Error("Error loading image from blob URL: " + r + " switching back to web url: " + e),
- t.src = e
- }
- ,
- t.src = r
- } else
- i()
- }
- ;
- var o = r.objectStore("textures").get(e);
- o.onsuccess = function(e) {
- n = e.target.result
- }
- ,
- o.onerror = function() {
- K.Error("Error loading texture " + e + " from DB."),
- t.src = e
- }
- } else
- K.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),
- t.src = e
- }
- ,
- e.prototype._saveImageIntoDBAsync = function(t, i) {
- var n, r = this;
- if (this._isSupported) {
- var o = function() {
- var e;
- if (n) {
- var t = window.URL || window.webkitURL;
- try {
- e = t.createObjectURL(n)
- } catch (i) {
- e = t.createObjectURL(n)
- }
- }
- e && (i.src = e)
- };
- if (e._IsUASupportingBlobStorage) {
- var a = new Ye;
- a.open("GET", t),
- a.responseType = "blob",
- a.addEventListener("load", (function() {
- if (200 === a.status && r._db) {
- n = a.response;
- var s = r._db.transaction(["textures"], "readwrite");
- s.onabort = function(e) {
- try {
- var t = (e.srcElement || e.target).error;
- t && "QuotaExceededError" === t.name && (r._hasReachedQuota = !0)
- } catch (e) {}
- o()
- }
- ,
- s.oncomplete = function() {
- o()
- }
- ;
- var l = {
- textureUrl: t,
- data: n
- };
- try {
- var c = s.objectStore("textures").put(l);
- c.onsuccess = function() {}
- ,
- c.onerror = function() {
- o()
- }
- } catch (n) {
- 25 === n.code && (e._IsUASupportingBlobStorage = !1,
- r._enableTexturesOffline = !1),
- i.src = t
- }
- } else
- i.src = t
- }
- ), !1),
- a.addEventListener("error", (function() {
- K.Error("Error in XHR request in BABYLON.Database."),
- i.src = t
- }
- ), !1),
- a.send()
- } else
- i.src = t
- } else
- K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
- i.src = t
- }
- ,
- e.prototype._checkVersionFromDB = function(e, t) {
- var i = this;
- this._loadVersionFromDBAsync(e, t, (function() {
- i._saveVersionIntoDBAsync(e, t)
- }
- ))
- }
- ,
- e.prototype._loadVersionFromDBAsync = function(e, t, i) {
- var n, r = this;
- if (this._isSupported && this._db)
- try {
- var o = this._db.transaction(["versions"]);
- o.oncomplete = function() {
- n ? r._manifestVersionFound !== n.data ? (r._mustUpdateRessources = !0,
- i()) : t(n.data) : (r._mustUpdateRessources = !0,
- i())
- }
- ,
- o.onabort = function() {
- t(-1)
- }
- ;
- var a = o.objectStore("versions").get(e);
- a.onsuccess = function(e) {
- n = e.target.result
- }
- ,
- a.onerror = function() {
- K.Error("Error loading version for scene " + e + " from DB."),
- t(-1)
- }
- } catch (e) {
- K.Error("Error while accessing 'versions' object store (READ OP). Exception: " + e.message),
- t(-1)
- }
- else
- K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
- t(-1)
- }
- ,
- e.prototype._saveVersionIntoDBAsync = function(e, t) {
- var i = this;
- if (this._isSupported && !this._hasReachedQuota && this._db)
- try {
- var n = this._db.transaction(["versions"], "readwrite");
- n.onabort = function(e) {
- try {
- var n = e.srcElement.error;
- n && "QuotaExceededError" === n.name && (i._hasReachedQuota = !0)
- } catch (e) {}
- t(-1)
- }
- ,
- n.oncomplete = function() {
- t(i._manifestVersionFound)
- }
- ;
- var r = {
- sceneUrl: e,
- data: this._manifestVersionFound
- }
- , o = n.objectStore("versions").put(r);
- o.onsuccess = function() {}
- ,
- o.onerror = function() {
- K.Error("Error in DB add version request in BABYLON.Database.")
- }
- } catch (e) {
- K.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + e.message),
- t(-1)
- }
- else
- t(-1)
- }
- ,
- e.prototype.loadFile = function(t, i, n, r, o) {
- var a = this
- , s = e._ReturnFullUrlLocation(t)
- , l = function() {
- a._saveFileAsync(s, i, n, o, r)
- };
- this._checkVersionFromDB(s, (function(e) {
- -1 !== e ? a._mustUpdateRessources ? a._saveFileAsync(s, i, n, o, r) : a._loadFileAsync(s, i, l) : r && r()
- }
- ))
- }
- ,
- e.prototype._loadFileAsync = function(e, t, i) {
- if (this._isSupported && this._db) {
- var n, r;
- r = -1 !== e.indexOf(".babylon") ? "scenes" : "textures";
- var o = this._db.transaction([r]);
- o.oncomplete = function() {
- n ? t(n.data) : i()
- }
- ,
- o.onabort = function() {
- i()
- }
- ;
- var a = o.objectStore(r).get(e);
- a.onsuccess = function(e) {
- n = e.target.result
- }
- ,
- a.onerror = function() {
- K.Error("Error loading file " + e + " from DB."),
- i()
- }
- } else
- K.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),
- t()
- }
- ,
- e.prototype._saveFileAsync = function(t, i, n, r, o) {
- var a = this;
- if (this._isSupported) {
- var s;
- s = -1 !== t.indexOf(".babylon") ? "scenes" : "textures";
- var l, c = new Ye;
- c.open("GET", t + (null == t.match(/\?/) ? "?" : "&") + Date.now()),
- r && (c.responseType = "arraybuffer"),
- n && (c.onprogress = n),
- c.addEventListener("load", (function() {
- if (200 === c.status || c.status < 400 && e._ValidateXHRData(c, r ? 6 : 1))
- if (l = r ? c.response : c.responseText,
- !a._hasReachedQuota && a._db) {
- var n = a._db.transaction([s], "readwrite");
- n.onabort = function(e) {
- try {
- var t = e.srcElement.error;
- t && "QuotaExceededError" === t.name && (a._hasReachedQuota = !0)
- } catch (e) {}
- i(l)
- }
- ,
- n.oncomplete = function() {
- i(l)
- }
- ;
- var u;
- u = "scenes" === s ? {
- sceneUrl: t,
- data: l,
- version: a._manifestVersionFound
- } : {
- textureUrl: t,
- data: l
- };
- try {
- var h = n.objectStore(s).put(u);
- h.onsuccess = function() {}
- ,
- h.onerror = function() {
- K.Error("Error in DB add file request in BABYLON.Database.")
- }
- } catch (e) {
- i(l)
- }
- } else
- i(l);
- else
- c.status >= 400 && o ? o(c) : i()
- }
- ), !1),
- c.addEventListener("error", (function() {
- K.Error("error on XHR request."),
- i()
- }
- ), !1),
- c.send()
- } else
- K.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),
- i()
- }
- ,
- e._ValidateXHRData = function(e, t) {
- void 0 === t && (t = 7);
- try {
- if (1 & t) {
- if (e.responseText && e.responseText.length > 0)
- return !0;
- if (1 === t)
- return !1
- }
- if (2 & t) {
- var i = q_(e.response);
- if (i.width && i.height && i.width > 0 && i.height > 0)
- return !0;
- if (2 === t)
- return !1
- }
- if (4 & t) {
- var n = new Uint8Array(e.response,0,3);
- return 68 === n[0] && 68 === n[1] && 83 === n[2]
- }
- } catch (e) {}
- return !1
- }
- ,
- e._IsUASupportingBlobStorage = !0,
- e.IDBStorageEnabled = !1,
- e._ParseURL = function(e) {
- document.createElement("a").href = e;
- var t = e.substring(0, e.lastIndexOf("#"))
- , i = e.substring(t.lastIndexOf("/") + 1, e.length);
- return e.substring(0, e.indexOf(i, 0))
- }
- ,
- e._ReturnFullUrlLocation = function(t) {
- return -1 === t.indexOf("http:/") && -1 === t.indexOf("https:/") && "undefined" != typeof window ? e._ParseURL(window.location.href) + t : t
- }
- ,
- e
- }()
- , ry = function() {
- function e(e) {
- this._isUbo(e) ? (this.setMatrix3x3 = e.updateMatrix3x3.bind(e),
- this.setMatrix2x2 = e.updateMatrix2x2.bind(e),
- this.setFloat = e.updateFloat.bind(e),
- this.setFloat2 = e.updateFloat2.bind(e),
- this.setFloat3 = e.updateFloat3.bind(e),
- this.setFloat4 = e.updateFloat4.bind(e),
- this.setFloatArray = e.updateFloatArray.bind(e),
- this.setArray = e.updateArray.bind(e),
- this.setIntArray = e.updateIntArray.bind(e),
- this.setMatrix = e.updateMatrix.bind(e),
- this.setMatrices = e.updateMatrices.bind(e),
- this.setVector3 = e.updateVector3.bind(e),
- this.setVector4 = e.updateVector4.bind(e),
- this.setColor3 = e.updateColor3.bind(e),
- this.setColor4 = e.updateColor4.bind(e),
- this.setDirectColor4 = e.updateDirectColor4.bind(e),
- this.setInt = e.updateInt.bind(e),
- this.setInt2 = e.updateInt2.bind(e),
- this.setInt3 = e.updateInt3.bind(e),
- this.setInt4 = e.updateInt4.bind(e)) : (this.setMatrix3x3 = e.setMatrix3x3.bind(e),
- this.setMatrix2x2 = e.setMatrix2x2.bind(e),
- this.setFloat = e.setFloat.bind(e),
- this.setFloat2 = e.setFloat2.bind(e),
- this.setFloat3 = e.setFloat3.bind(e),
- this.setFloat4 = e.setFloat4.bind(e),
- this.setFloatArray = e.setFloatArray.bind(e),
- this.setArray = e.setArray.bind(e),
- this.setIntArray = e.setIntArray.bind(e),
- this.setMatrix = e.setMatrix.bind(e),
- this.setMatrices = e.setMatrices.bind(e),
- this.setVector3 = e.setVector3.bind(e),
- this.setVector4 = e.setVector4.bind(e),
- this.setColor3 = e.setColor3.bind(e),
- this.setColor4 = e.setColor4.bind(e),
- this.setDirectColor4 = e.setDirectColor4.bind(e),
- this.setInt = e.setInt.bind(e),
- this.setInt2 = e.setInt2.bind(e),
- this.setInt3 = e.setInt3.bind(e),
- this.setInt4 = e.setInt4.bind(e))
- }
- return e.prototype._isUbo = function(e) {
- return void 0 !== e.addUniform
- }
- ,
- e
- }();
- Pt.ShadersStore.gpuUpdateParticlesPixelShader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
- Pt.ShadersStore.gpuUpdateParticlesVertexShader = "#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\nin vec3 position;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\nin float age;\nin float life;\nin vec4 seed;\nin vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;\nin vec3 noiseCoordinates2;\n#endif\nout vec3 outPosition;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;\nout vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec4 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta; \nif (newAge>=life && stopFactor != 0.) {\nvec3 newPosition;\nvec3 newDirection;\nvec4 randoms=getRandomVec4(seed.x);\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=newAge-life;\noutSeed=seed;\n#ifdef SIZEGRADIENTS \noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=vec3(0,0,0);\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\nnewDirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\nnewDirection=newPosition+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=normalize(direction1+(direction2-direction1)*randoms3);\n#else\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nnewPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\nangle=angle+((randoms3.x-0.5)*PI)*directionRandomizer;\nnewDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,sin(angle));\nnewDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\n#else\nfloat h=randoms2.y*height.y;\nh=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h *height.x;\nnewPosition=vec3(randX,randY,randZ); \nif (abs(cos(coneAngle))==1.0) {\nnewDirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\nnewDirection=normalize(newPosition+directionRandomizer*randoms3); \n}\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;\noutInitialPosition=initialPosition;\n#else \nnewPosition=vec3(0.,0.,0.);\nnewDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\n#ifdef LOCAL\noutPosition=newPosition;\n#else\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#ifndef BILLBOARD \noutInitialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nvec3 initial=newDirection;\n#else \nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\n#endif\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#if defined(CUSTOMEMITTER)\noutPosition=position+(direction-position)*ageGradient; \noutInitialPosition=initialPosition;\n#else\noutPosition=position+direction*directionScale;\n#endif\noutLife=life;\noutSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#else\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#else\nfloat cellStartOffset=0.;\n#endif \nfloat ratio=0.;\nif (cellInfos.w==1.0) {\nratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);\n}\nelse {\nratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);\n}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";
- var oy = function() {
- function e(e, t) {
- this._renderVAO = [],
- this._updateVAO = [],
- this.alignDataInBuffer = !1,
- this._parent = e,
- this._engine = t,
- this._updateEffectOptions = {
- attributes: ["position", "initialPosition", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
- uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower", "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor", "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
- uniformBuffersNames: [],
- samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
- defines: "",
- fallbacks: null,
- onCompiled: null,
- onError: null,
- indexParameters: null,
- maxSimultaneousLights: 0,
- transformFeedbackVaryings: []
- }
- }
- return e.prototype.isUpdateBufferCreated = function() {
- return !!this._updateEffect
- }
- ,
- e.prototype.isUpdateBufferReady = function() {
- var e, t;
- return null !== (t = null === (e = this._updateEffect) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t
- }
- ,
- e.prototype.createUpdateBuffer = function(e) {
- return this._updateEffectOptions.transformFeedbackVaryings = ["outPosition"],
- this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),
- this._updateEffectOptions.transformFeedbackVaryings.push("outSize"),
- this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),
- this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),
- this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),
- this._parent.particleEmitterType instanceof yf && this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),
- this._parent._colorGradientsTexture || this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),
- this._parent._isBillboardBased || this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),
- this._parent.noiseTexture && (this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),
- this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),
- this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),
- this._parent.isAnimationSheetEnabled && (this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),
- this._parent.spriteRandomStartCell && this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),
- this._updateEffectOptions.defines = e,
- this._updateEffect = new Mt("gpuUpdateParticles",this._updateEffectOptions,this._engine),
- new ry(this._updateEffect)
- }
- ,
- e.prototype.createVertexBuffers = function(e, t) {
- this._updateVAO.push(this._createUpdateVAO(e)),
- this._renderVAO.push(this._engine.recordVertexArrayObject(t, null, this._parent._getWrapper(this._parent.blendMode).effect)),
- this._engine.bindArrayBuffer(null)
- }
- ,
- e.prototype.createParticleBuffer = function(e) {
- return e
- }
- ,
- e.prototype.bindDrawBuffers = function(e) {
- this._engine.bindVertexArrayObject(this._renderVAO[e], null)
- }
- ,
- e.prototype.preUpdateParticleBuffer = function() {
- var e = this._engine;
- if (this._engine.enableEffect(this._updateEffect),
- !e.setState)
- throw new Error("GPU particles cannot work without a full Engine. ThinEngine is not supported")
- }
- ,
- e.prototype.updateParticleBuffer = function(e, t, i) {
- this._updateEffect.setTexture("randomSampler", this._parent._randomTexture),
- this._updateEffect.setTexture("randomSampler2", this._parent._randomTexture2),
- this._parent._sizeGradientsTexture && this._updateEffect.setTexture("sizeGradientSampler", this._parent._sizeGradientsTexture),
- this._parent._angularSpeedGradientsTexture && this._updateEffect.setTexture("angularSpeedGradientSampler", this._parent._angularSpeedGradientsTexture),
- this._parent._velocityGradientsTexture && this._updateEffect.setTexture("velocityGradientSampler", this._parent._velocityGradientsTexture),
- this._parent._limitVelocityGradientsTexture && this._updateEffect.setTexture("limitVelocityGradientSampler", this._parent._limitVelocityGradientsTexture),
- this._parent._dragGradientsTexture && this._updateEffect.setTexture("dragGradientSampler", this._parent._dragGradientsTexture),
- this._parent.noiseTexture && this._updateEffect.setTexture("noiseSampler", this._parent.noiseTexture),
- this._engine.bindVertexArrayObject(this._updateVAO[e], null);
- var n = this._engine;
- n.bindTransformFeedbackBuffer(t.getBuffer()),
- n.setRasterizerState(!1),
- n.beginTransformFeedback(!0),
- n.drawArraysType(a.MATERIAL_PointListDrawMode, 0, i),
- n.endTransformFeedback(),
- n.setRasterizerState(!0),
- n.bindTransformFeedbackBuffer(null)
- }
- ,
- e.prototype.releaseBuffers = function() {}
- ,
- e.prototype.releaseVertexBuffers = function() {
- for (var e = 0; e < this._updateVAO.length; e++)
- this._engine.releaseVertexArrayObject(this._updateVAO[e]);
- for (this._updateVAO = [],
- e = 0; e < this._renderVAO.length; e++)
- this._engine.releaseVertexArrayObject(this._renderVAO[e]);
- this._renderVAO = []
- }
- ,
- e.prototype._createUpdateVAO = function(e) {
- var t = {};
- t.position = e.createVertexBuffer("position", 0, 3);
- var i = 3;
- t.age = e.createVertexBuffer("age", i, 1),
- i += 1,
- t.size = e.createVertexBuffer("size", i, 3),
- i += 3,
- t.life = e.createVertexBuffer("life", i, 1),
- i += 1,
- t.seed = e.createVertexBuffer("seed", i, 4),
- i += 4,
- t.direction = e.createVertexBuffer("direction", i, 3),
- i += 3,
- this._parent.particleEmitterType instanceof yf && (t.initialPosition = e.createVertexBuffer("initialPosition", i, 3),
- i += 3),
- this._parent._colorGradientsTexture || (t.color = e.createVertexBuffer("color", i, 4),
- i += 4),
- this._parent._isBillboardBased || (t.initialDirection = e.createVertexBuffer("initialDirection", i, 3),
- i += 3),
- this._parent.noiseTexture && (t.noiseCoordinates1 = e.createVertexBuffer("noiseCoordinates1", i, 3),
- i += 3,
- t.noiseCoordinates2 = e.createVertexBuffer("noiseCoordinates2", i, 3),
- i += 3),
- this._parent._angularSpeedGradientsTexture ? (t.angle = e.createVertexBuffer("angle", i, 1),
- i += 1) : (t.angle = e.createVertexBuffer("angle", i, 2),
- i += 2),
- this._parent._isAnimationSheetEnabled && (t.cellIndex = e.createVertexBuffer("cellIndex", i, 1),
- i += 1,
- this._parent.spriteRandomStartCell && (t.cellStartOffset = e.createVertexBuffer("cellStartOffset", i, 1),
- i += 1));
- var n = this._engine.recordVertexArrayObject(t, null, this._updateEffect);
- return this._engine.bindArrayBuffer(null),
- n
- }
- ,
- e
- }();
- y("BABYLON.WebGL2ParticleSystem", oy);
- Pt.ShadersStoreWGSL.gpuUpdateParticlesComputeShader = "struct Particle {\nposition : vec3<f32>;\nage : f32;\nsize : vec3<f32>;\nlife : f32;\nseed : vec4<f32>;\ndirection : vec3<f32>;\ndummy0: f32;\n#ifdef CUSTOMEMITTER\ninitialPosition : vec3<f32>;\ndummy1: f32;\n#endif\n#ifndef COLORGRADIENTS\ncolor : vec4<f32>;\n#endif\n#ifndef BILLBOARD\ninitialDirection : vec3<f32>;\ndummy2: f32;\n#endif\n#ifdef NOISE\nnoiseCoordinates1 : vec3<f32>;\ndummy3: f32;\nnoiseCoordinates2 : vec3<f32>;\ndummy4: f32;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nangle : f32;\n#else\nangle : vec2<f32>;\n#endif\n#ifdef ANIMATESHEET\ncellIndex : f32;\n#ifdef ANIMATESHEETRANDOMSTART\ncellStartOffset : f32;\n#endif\n#endif\n};\nstruct Particles {\nparticles : array<Particle>;\n};\nstruct SimParams {\ncurrentCount : f32;\ntimeDelta : f32;\nstopFactor : f32;\nrandomTextureSize: i32;\nlifeTime : vec2<f32>;\nemitPower : vec2<f32>;\n#ifndef COLORGRADIENTS\ncolor1 : vec4<f32>;\ncolor2 : vec4<f32>;\n#endif\nsizeRange : vec2<f32>;\nscaleRange : vec4<f32>;\nangleRange : vec4<f32>;\ngravity : vec3<f32>;\n#ifdef LIMITVELOCITYGRADIENTS\nlimitVelocityDamping : f32;\n#endif\n#ifdef ANIMATESHEET\ncellInfos : vec4<f32>;\n#endif\n#ifdef NOISE\nnoiseStrength : vec3<f32>;\n#endif\n#ifndef LOCAL\nemitterWM : mat4x4<f32>;\n#endif\n#ifdef BOXEMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\nminEmitBox : vec3<f32>;\nmaxEmitBox : vec3<f32>;\n#endif\n#ifdef CONEEMITTER\nradius : vec2<f32>;\nconeAngle : f32;\nheight : vec2<f32>;\ndirectionRandomizer : f32;\n#endif\n#ifdef CYLINDEREMITTER\nradius : f32;\nheight : f32;\nradiusRange : f32;\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\n#else\ndirectionRandomizer : f32;\n#endif\n#endif\n#ifdef HEMISPHERICEMITTER\nradius : f32;\nradiusRange : f32;\ndirectionRandomizer : f32;\n#endif\n#ifdef POINTEMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\n#endif\n#ifdef SPHEREEMITTER\nradius : f32;\nradiusRange : f32;\n#ifdef DIRECTEDSPHEREEMITTER\ndirection1 : vec3<f32>;\ndirection2 : vec3<f32>;\n#else\ndirectionRandomizer : f32;\n#endif\n#endif\n};\n@binding(0) @group(0) var<uniform> params : SimParams;\n@binding(1) @group(0) var<storage,read> particlesIn : Particles;\n@binding(2) @group(0) var<storage,read_write> particlesOut : Particles;\n@binding(3) @group(0) var randomTexture : texture_2d<f32>;\n@binding(4) @group(0) var randomTexture2 : texture_2d<f32>;\n#ifdef SIZEGRADIENTS\n@binding(0) @group(1) var sizeGradientSampler : sampler;\n@binding(1) @group(1) var sizeGradientTexture : texture_2d<f32>;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\n@binding(2) @group(1) var angularSpeedGradientSampler : sampler;\n@binding(3) @group(1) var angularSpeedGradientTexture : texture_2d<f32>;\n#endif \n#ifdef VELOCITYGRADIENTS\n@binding(4) @group(1) var velocityGradientSampler : sampler;\n@binding(5) @group(1) var velocityGradientTexture : texture_2d<f32>;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\n@binding(6) @group(1) var limitVelocityGradientSampler : sampler;\n@binding(7) @group(1) var limitVelocityGradientTexture : texture_2d<f32>;\n#endif\n#ifdef DRAGGRADIENTS\n@binding(8) @group(1) var dragGradientSampler : sampler;\n@binding(9) @group(1) var dragGradientTexture : texture_2d<f32>;\n#endif\n#ifdef NOISE\n@binding(10) @group(1) var noiseSampler : sampler;\n@binding(11) @group(1) var noiseTexture : texture_2d<f32>;\n#endif\nfn getRandomVec3(offset : f32,vertexID : f32)->vec3<f32> {\nreturn textureLoad(randomTexture2,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0).rgb;\n}\nfn getRandomVec4(offset : f32,vertexID : f32)->vec4<f32> {\nreturn textureLoad(randomTexture,vec2<i32>(i32(vertexID*offset/params.currentCount*f32(params.randomTextureSize)) % params.randomTextureSize,0),0);\n}\n@stage(compute) @workgroup_size(64)\nfn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {\nlet index : u32=GlobalInvocationID.x;\nlet vertexID : f32=f32(index);\nif (index>=u32(params.currentCount)) {\nreturn;\n}\nlet PI : f32=3.14159;\nlet timeDelta : f32=params.timeDelta;\nlet newAge : f32=particlesIn.particles[index].age+timeDelta;\nlet life : f32=particlesIn.particles[index].life;\nlet seed : vec4<f32>=particlesIn.particles[index].seed;\nlet direction : vec3<f32>=particlesIn.particles[index].direction;\nif (newAge>=life && params.stopFactor != 0.) {\nvar newPosition : vec3<f32>;\nvar newDirection : vec3<f32>;\nlet randoms : vec4<f32>=getRandomVec4(seed.x,vertexID);\nlet outLife : f32=params.lifeTime.x+(params.lifeTime.y-params.lifeTime.x)*randoms.r;\nparticlesOut.particles[index].life=outLife;\nparticlesOut.particles[index].age=newAge-life;\nparticlesOut.particles[index].seed=seed;\nvar sizex : f32;\n#ifdef SIZEGRADIENTS \nsizex=textureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(0.,0.),0.).r;\n#else\nsizex=params.sizeRange.x+(params.sizeRange.y-params.sizeRange.x)*randoms.g;\n#endif\nparticlesOut.particles[index].size=vec3<f32>(\nsizex,\nparams.scaleRange.x+(params.scaleRange.y-params.scaleRange.x)*randoms.b,\nparams.scaleRange.z+(params.scaleRange.w-params.scaleRange.z)*randoms.a);\n#ifndef COLORGRADIENTS\nparticlesOut.particles[index].color=params.color1+(params.color2-params.color1)*randoms.b;\n#endif\n#ifndef ANGULARSPEEDGRADIENTS \nparticlesOut.particles[index].angle=vec2<f32>(\nparams.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r,\nparams.angleRange.x+(params.angleRange.y-params.angleRange.x)*randoms.a);\n#else\nparticlesOut.particles[index].angle=params.angleRange.z+(params.angleRange.w-params.angleRange.z)*randoms.r;\n#endif \n#if defined(POINTEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nnewPosition=vec3<f32>(0.,0.,0.);\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3;\n#elif defined(BOXEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nnewPosition=params.minEmitBox+(params.maxEmitBox-params.minEmitBox)*randoms2;\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nlet phi : f32=2.0*PI*randoms2.x;\nlet theta : f32=acos(-1.0+2.0*randoms2.y);\nlet randX : f32=cos(phi)*sin(theta);\nlet randY : f32=cos(theta);\nlet randZ : f32=sin(phi)*sin(theta);\nnewPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,abs(randY),randZ);\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3);\n#elif defined(SPHEREEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nlet phi : f32=2.0*PI*randoms2.x;\nlet theta : f32=acos(-1.0+2.0*randoms2.y);\nlet randX : f32=cos(phi)*sin(theta);\nlet randY : f32=cos(theta);\nlet randZ : f32=sin(phi)*sin(theta);\nnewPosition=(params.radius-(params.radius*params.radiusRange*randoms2.z))*vec3<f32>(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=normalize(params.direction1+(params.direction2-params.direction1)*randoms3);\n#else\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3);\n#endif\n#elif defined(CYLINDEREMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nlet yPos : f32=(-0.5+randoms2.x)*params.height;\nvar angle : f32=randoms2.y*PI*2.;\nlet inverseRadiusRangeSquared : f32=(1.-params.radiusRange)*(1.-params.radiusRange);\nlet positionRadius : f32=params.radius*sqrt(inverseRadiusRangeSquared+randoms2.z*(1.-inverseRadiusRangeSquared));\nlet xPos : f32=positionRadius*cos(angle);\nlet zPos : f32=positionRadius*sin(angle);\nnewPosition=vec3<f32>(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=params.direction1+(params.direction2-params.direction1)*randoms3;\n#else\nangle=angle+(-0.5+randoms3.x)*PI*params.directionRandomizer;\nnewDirection=vec3<f32>(cos(angle),(-0.5+randoms3.y)*params.directionRandomizer,sin(angle));\nnewDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nlet randoms2 : vec3<f32>=getRandomVec3(seed.y,vertexID);\nlet s : f32=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nlet h : f32=0.0001;\n#else\nvar h : f32=randoms2.y*params.height.y;\nh=1.-h*h; \n#endif\nvar lRadius : f32=params.radius.x-params.radius.x*randoms2.z*params.radius.y;\nlRadius=lRadius*h;\nlet randX : f32=lRadius*sin(s);\nlet randZ : f32=lRadius*cos(s);\nlet randY : f32=h *params.height.x;\nnewPosition=vec3<f32>(randX,randY,randZ); \nif (abs(cos(params.coneAngle))==1.0) {\nnewDirection=vec3<f32>(0.,1.0,0.);\n} else {\nlet randoms3 : vec3<f32>=getRandomVec3(seed.z,vertexID);\nnewDirection=normalize(newPosition+params.directionRandomizer*randoms3); \n}\n#elif defined(CUSTOMEMITTER)\nnewPosition=particlesIn.particles[index].initialPosition;\nparticlesOut.particles[index].initialPosition=newPosition;\n#else \nnewPosition=vec3<f32>(0.,0.,0.);\nnewDirection=2.0*(getRandomVec3(seed.w,vertexID)-vec3<f32>(0.5,0.5,0.5));\n#endif\nlet power : f32=params.emitPower.x+(params.emitPower.y-params.emitPower.x)*randoms.a;\n#ifdef LOCAL\nparticlesOut.particles[index].position=newPosition;\n#else\nparticlesOut.particles[index].position=(params.emitterWM*vec4<f32>(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\nparticlesOut.particles[index].direction=direction;\n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nlet initial : vec3<f32>=newDirection;\n#else \nlet initial : vec3<f32>=(params.emitterWM*vec4<f32>(newDirection,0.)).xyz;\n#endif\nparticlesOut.particles[index].direction=initial*power;\n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=initial;\n#endif\n#endif\n#ifdef ANIMATESHEET \nparticlesOut.particles[index].cellIndex=params.cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\nparticlesOut.particles[index].cellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\nparticlesOut.particles[index].noiseCoordinates1=particlesIn.particles[index].noiseCoordinates1;\nparticlesOut.particles[index].noiseCoordinates2=particlesIn.particles[index].noiseCoordinates2;\n#endif\n} else {\nvar directionScale : f32=timeDelta;\nparticlesOut.particles[index].age=newAge;\nlet ageGradient : f32=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale=directionScale*textureSampleLevel(velocityGradientTexture,velocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale=directionScale*(1.0-textureSampleLevel(dragGradientTexture,dragGradientSampler,vec2<f32>(ageGradient,0.),0.).r);\n#endif\nlet position : vec3<f32>=particlesIn.particles[index].position;\n#if defined(CUSTOMEMITTER)\nparticlesOut.particles[index].position=position+(direction-position)*ageGradient; \nparticlesOut.particles[index].initialPosition=particlesIn.particles[index].initialPosition;\n#else\nparticlesOut.particles[index].position=position+direction*directionScale;\n#endif\nparticlesOut.particles[index].life=life;\nparticlesOut.particles[index].seed=seed;\n#ifndef COLORGRADIENTS \nparticlesOut.particles[index].color=particlesIn.particles[index].color;\n#endif\n#ifdef SIZEGRADIENTS\nparticlesOut.particles[index].size=vec3<f32>(\ntextureSampleLevel(sizeGradientTexture,sizeGradientSampler,vec2<f32>(ageGradient,0.),0.).r,\nparticlesIn.particles[index].size.yz);\n#else\nparticlesOut.particles[index].size=particlesIn.particles[index].size;\n#endif \n#ifndef BILLBOARD \nparticlesOut.particles[index].initialDirection=particlesIn.particles[index].initialDirection;\n#endif\n#ifdef CUSTOMEMITTER\nparticlesOut.particles[index].direction=direction;\n#else\nvar updatedDirection : vec3<f32>=direction+params.gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nlet limitVelocity : f32=textureSampleLevel(limitVelocityGradientTexture,limitVelocityGradientSampler,vec2<f32>(ageGradient,0.),0.).r;\nlet currentVelocity : f32=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*params.limitVelocityDamping;\n}\n#endif\nparticlesOut.particles[index].direction=updatedDirection;\n#ifdef NOISE\nlet noiseCoordinates1 : vec3<f32>=particlesIn.particles[index].noiseCoordinates1;\nlet noiseCoordinates2 : vec3<f32>=particlesIn.particles[index].noiseCoordinates2;\nlet fetchedR : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.x,noiseCoordinates1.y)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;\nlet fetchedG : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates1.z,noiseCoordinates2.x)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;\nlet fetchedB : f32=textureSampleLevel(noiseTexture,noiseSampler,vec2<f32>(noiseCoordinates2.y,noiseCoordinates2.z)*vec2<f32>(0.5,0.5)+vec2<f32>(0.5,0.5),0.).r;\nlet force : vec3<f32>=vec3<f32>(-1.+2.*fetchedR,-1.+2.*fetchedG,-1.+2.*fetchedB)*params.noiseStrength;\nparticlesOut.particles[index].direction=particlesOut.particles[index].direction+force*timeDelta;\nparticlesOut.particles[index].noiseCoordinates1=noiseCoordinates1;\nparticlesOut.particles[index].noiseCoordinates2=noiseCoordinates2;\n#endif \n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nlet angularSpeed : f32=textureSampleLevel(angularSpeedGradientTexture,angularSpeedGradientSampler,vec2<f32>(ageGradient,0.),0.).r;\nparticlesOut.particles[index].angle=particlesIn.particles[index].angle+angularSpeed*timeDelta;\n#else\nlet angle : vec2<f32>=particlesIn.particles[index].angle;\nparticlesOut.particles[index].angle=vec2<f32>(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nvar offsetAge : f32=particlesOut.particles[index].age;\nlet dist : f32=params.cellInfos.y-params.cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\nlet cellStartOffset : f32=particlesIn.particles[index].cellStartOffset;\nparticlesOut.particles[index].cellStartOffset=cellStartOffset;\noffsetAge=offsetAge+cellStartOffset;\n#else\nlet cellStartOffset : f32=0.;\n#endif \nvar ratio : f32;\nif (params.cellInfos.w==1.0) {\nratio=clamp(((cellStartOffset+params.cellInfos.z*offsetAge) % life)/life,0.,1.0);\n}\nelse {\nratio=clamp((cellStartOffset+params.cellInfos.z*offsetAge)/life,0.,1.0);\n}\nparticlesOut.particles[index].cellIndex=f32(i32(params.cellInfos.x+ratio*dist));\n#endif\n}\n}\n";
- var ay = function() {
- function e(e, t) {
- this._bufferComputeShader = [],
- this._renderVertexBuffers = [],
- this.alignDataInBuffer = !0,
- this._parent = e,
- this._engine = t
- }
- return e.prototype.isUpdateBufferCreated = function() {
- return !!this._updateComputeShader
- }
- ,
- e.prototype.isUpdateBufferReady = function() {
- var e, t;
- return null !== (t = null === (e = this._updateComputeShader) || void 0 === e ? void 0 : e.isReady()) && void 0 !== t && t
- }
- ,
- e.prototype.createUpdateBuffer = function(e) {
- var t, i = {
- params: {
- group: 0,
- binding: 0
- },
- particlesIn: {
- group: 0,
- binding: 1
- },
- particlesOut: {
- group: 0,
- binding: 2
- },
- randomTexture: {
- group: 0,
- binding: 3
- },
- randomTexture2: {
- group: 0,
- binding: 4
- }
- };
- return this._parent._sizeGradientsTexture && (i.sizeGradientTexture = {
- group: 1,
- binding: 1
- }),
- this._parent._angularSpeedGradientsTexture && (i.angularSpeedGradientTexture = {
- group: 1,
- binding: 3
- }),
- this._parent._velocityGradientsTexture && (i.velocityGradientTexture = {
- group: 1,
- binding: 5
- }),
- this._parent._limitVelocityGradientsTexture && (i.limitVelocityGradientTexture = {
- group: 1,
- binding: 7
- }),
- this._parent._dragGradientsTexture && (i.dragGradientTexture = {
- group: 1,
- binding: 9
- }),
- this._parent.noiseTexture && (i.noiseTexture = {
- group: 1,
- binding: 11
- }),
- this._updateComputeShader = new gl("updateParticles",this._engine,"gpuUpdateParticles",{
- bindingsMapping: i,
- defines: e.split("\n")
- }),
- null === (t = this._simParamsComputeShader) || void 0 === t || t.dispose(),
- this._simParamsComputeShader = new Fi(this._engine),
- this._simParamsComputeShader.addUniform("currentCount", 1),
- this._simParamsComputeShader.addUniform("timeDelta", 1),
- this._simParamsComputeShader.addUniform("stopFactor", 1),
- this._simParamsComputeShader.addUniform("randomTextureSize", 1),
- this._simParamsComputeShader.addUniform("lifeTime", 2),
- this._simParamsComputeShader.addUniform("emitPower", 2),
- this._parent._colorGradientsTexture || (this._simParamsComputeShader.addUniform("color1", 4),
- this._simParamsComputeShader.addUniform("color2", 4)),
- this._simParamsComputeShader.addUniform("sizeRange", 2),
- this._simParamsComputeShader.addUniform("scaleRange", 4),
- this._simParamsComputeShader.addUniform("angleRange", 4),
- this._simParamsComputeShader.addUniform("gravity", 3),
- this._parent._limitVelocityGradientsTexture && this._simParamsComputeShader.addUniform("limitVelocityDamping", 1),
- this._parent.isAnimationSheetEnabled && this._simParamsComputeShader.addUniform("cellInfos", 4),
- this._parent.noiseTexture && this._simParamsComputeShader.addUniform("noiseStrength", 3),
- this._parent.isLocal || this._simParamsComputeShader.addUniform("emitterWM", 16),
- this._parent.particleEmitterType && this._parent.particleEmitterType.buildUniformLayout(this._simParamsComputeShader),
- this._updateComputeShader.setUniformBuffer("params", this._simParamsComputeShader),
- new ry(this._simParamsComputeShader)
- }
- ,
- e.prototype.createVertexBuffers = function(e, t) {
- this._renderVertexBuffers.push(t)
- }
- ,
- e.prototype.createParticleBuffer = function(e) {
- var t = new wo(this._engine,4 * e.length,a.BUFFER_CREATIONFLAG_READWRITE | a.BUFFER_CREATIONFLAG_VERTEX);
- return t.update(e),
- this._bufferComputeShader.push(t),
- t.getBuffer()
- }
- ,
- e.prototype.bindDrawBuffers = function(e, t) {
- this._engine.bindBuffers(this._renderVertexBuffers[e], null, t)
- }
- ,
- e.prototype.preUpdateParticleBuffer = function() {}
- ,
- e.prototype.updateParticleBuffer = function(e, t, i) {
- this._simParamsComputeShader.update(),
- this._updateComputeShader.setTexture("randomTexture", this._parent._randomTexture, !1),
- this._updateComputeShader.setTexture("randomTexture2", this._parent._randomTexture2, !1),
- this._parent._sizeGradientsTexture && this._updateComputeShader.setTexture("sizeGradientTexture", this._parent._sizeGradientsTexture),
- this._parent._angularSpeedGradientsTexture && this._updateComputeShader.setTexture("angularSpeedGradientTexture", this._parent._angularSpeedGradientsTexture),
- this._parent._velocityGradientsTexture && this._updateComputeShader.setTexture("velocityGradientTexture", this._parent._velocityGradientsTexture),
- this._parent._limitVelocityGradientsTexture && this._updateComputeShader.setTexture("limitVelocityGradientTexture", this._parent._limitVelocityGradientsTexture),
- this._parent._dragGradientsTexture && this._updateComputeShader.setTexture("dragGradientTexture", this._parent._dragGradientsTexture),
- this._parent.noiseTexture && this._updateComputeShader.setTexture("noiseTexture", this._parent.noiseTexture),
- this._updateComputeShader.setStorageBuffer("particlesIn", this._bufferComputeShader[e]),
- this._updateComputeShader.setStorageBuffer("particlesOut", this._bufferComputeShader[1 ^ e]),
- this._updateComputeShader.dispatch(Math.ceil(i / 64))
- }
- ,
- e.prototype.releaseBuffers = function() {
- for (var e, t = 0; t < this._bufferComputeShader.length; ++t)
- this._bufferComputeShader[t].dispose();
- this._bufferComputeShader = [],
- null === (e = this._simParamsComputeShader) || void 0 === e || e.dispose(),
- this._simParamsComputeShader = null,
- this._updateComputeShader = null
- }
- ,
- e.prototype.releaseVertexBuffers = function() {
- this._renderVertexBuffers = []
- }
- ,
- e
- }();
- y("BABYLON.ComputeShaderParticleSystem", ay);
- var sy, ly = function() {
- function e(e, t, i) {
- this.gradient = e,
- this.color1 = t,
- this.color2 = i
- }
- return e.prototype.getColorToRef = function(e) {
- this.color2 ? N.LerpToRef(this.color1, this.color2, Math.random(), e) : e.copyFrom(this.color1)
- }
- ,
- e
- }(), cy = function(e, t) {
- this.gradient = e,
- this.color = t
- }, uy = function() {
- function e(e, t, i) {
- this.gradient = e,
- this.factor1 = t,
- this.factor2 = i
- }
- return e.prototype.getFactor = function() {
- return void 0 === this.factor2 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random()
- }
- ,
- e
- }(), hy = function() {
- function e() {}
- return e.GetCurrentGradient = function(e, t, i) {
- if (t[0].gradient > e)
- i(t[0], t[0], 1);
- else {
- for (var n = 0; n < t.length - 1; n++) {
- var r = t[n]
- , o = t[n + 1];
- if (e >= r.gradient && e <= o.gradient)
- return void i(r, o, (e - r.gradient) / (o.gradient - r.gradient))
- }
- var a = t.length - 1;
- i(t[a], t[a], 1)
- }
- }
- ,
- e
- }(), dy = function() {
- function e(t) {
- this.particleSystem = t,
- this.position = x.Zero(),
- this.direction = x.Zero(),
- this.color = new N(0,0,0,0),
- this.colorStep = new N(0,0,0,0),
- this.lifeTime = 1,
- this.age = 0,
- this.size = 0,
- this.scale = new A(1,1),
- this.angle = 0,
- this.angularSpeed = 0,
- this.cellIndex = 0,
- this._attachedSubEmitters = null,
- this._currentColor1 = new N(0,0,0,0),
- this._currentColor2 = new N(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 = e._Count++,
- this.particleSystem.isAnimationSheetEnabled && this._updateCellInfoFromSystem()
- }
- return e.prototype._updateCellInfoFromSystem = function() {
- this.cellIndex = this.particleSystem.startSpriteCellID
- }
- ,
- e.prototype.updateCellIndex = function() {
- var e = this.age
- , t = this.particleSystem.spriteCellChangeSpeed;
- this.particleSystem.spriteRandomStartCell && (void 0 === this._randomCellOffset && (this._randomCellOffset = Math.random() * this.lifeTime),
- 0 === t ? (t = 1,
- e = this._randomCellOffset) : e += this._randomCellOffset);
- var i, n = this._initialEndSpriteCellID - this._initialStartSpriteCellID;
- i = this._initialSpriteCellLoop ? d.Clamp(e * t % this.lifeTime / this.lifeTime) : d.Clamp(e * t / this.lifeTime),
- this.cellIndex = this._initialStartSpriteCellID + i * n | 0
- }
- ,
- e.prototype._inheritParticleInfoToSubEmitter = function(e) {
- if (e.particleSystem.emitter.position) {
- var t = e.particleSystem.emitter;
- if (t.position.copyFrom(this.position),
- e.inheritDirection) {
- var i = I.Vector3[0];
- this.direction.normalizeToRef(i),
- t.setDirection(i, 0, Math.PI / 2)
- }
- } else
- e.particleSystem.emitter.copyFrom(this.position);
- this.direction.scaleToRef(e.inheritedVelocityAmount / 2, I.Vector3[0]),
- e.particleSystem._inheritedVelocityOffset.copyFrom(I.Vector3[0])
- }
- ,
- e.prototype._inheritParticleInfoToSubEmitters = function() {
- var e = this;
- this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach((function(t) {
- e._inheritParticleInfoToSubEmitter(t)
- }
- ))
- }
- ,
- e.prototype._reset = function() {
- this.age = 0,
- this.id = e._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
- }
- ,
- e.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 R(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()))
- }
- ,
- e._Count = 0,
- e
- }();
- !function(e) {
- e[e.ATTACHED = 0] = "ATTACHED",
- e[e.END = 1] = "END"
- }(sy || (sy = {}));
- var py = function() {
- function e(e) {
- if (this.particleSystem = e,
- this.type = sy.END,
- this.inheritDirection = !1,
- this.inheritedVelocityAmount = 0,
- !e.emitter || !e.emitter.dispose) {
- var t = b("BABYLON.AbstractMesh");
- e.emitter = new t("SubemitterSystemEmitter",e.getScene()),
- e._disposeEmitterOnDispose = !0
- }
- }
- return e.prototype.clone = function() {
- var t = this.particleSystem.emitter;
- t ? t instanceof x ? t = t.clone() : -1 !== t.getClassName().indexOf("Mesh") && ((t = new (b("BABYLON.Mesh"))("",t.getScene())).isVisible = !1) : t = new x;
- var i = new e(this.particleSystem.clone(this.particleSystem.name, t));
- return i.particleSystem.name += "Clone",
- i.type = this.type,
- i.inheritDirection = this.inheritDirection,
- i.inheritedVelocityAmount = this.inheritedVelocityAmount,
- i.particleSystem._disposeEmitterOnDispose = !0,
- i.particleSystem.disposeOnStop = !0,
- i
- }
- ,
- e.prototype.serialize = function(e) {
- void 0 === e && (e = !1);
- var t = {};
- return t.type = this.type,
- t.inheritDirection = this.inheritDirection,
- t.inheritedVelocityAmount = this.inheritedVelocityAmount,
- t.particleSystem = this.particleSystem.serialize(e),
- t
- }
- ,
- e._ParseParticleSystem = function(e, t, i, n) {
- throw void 0 === n && (n = !1),
- be("ParseParticle")
- }
- ,
- e.Parse = function(t, i, n) {
- var r = t.particleSystem
- , o = new e(e._ParseParticleSystem(r, i, n, !0));
- return o.type = t.type,
- o.inheritDirection = t.inheritDirection,
- o.inheritedVelocityAmount = t.inheritedVelocityAmount,
- o.particleSystem._isSubEmitter = !0,
- o
- }
- ,
- e.prototype.dispose = function() {
- this.particleSystem.dispose()
- }
- ,
- e
- }();
- Pt.ShadersStore.particlesPixelShader = "varying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include<clipPlaneFragmentDeclaration>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.particlesVertexShader = "attribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos; \n#endif\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vPositionW;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration>\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y -0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvPositionW=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\nvPositionW=(invView*vec4(viewPos,1)).xyz;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\ngl_Position=projection*vec4(viewPos,1.0);\n#else\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvPositionW=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(vPositionW,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex*particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset/particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include<clipPlaneVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var fy = function(e) {
- function t(t, i, n, r, o, a) {
- void 0 === r && (r = null),
- void 0 === o && (o = !1),
- void 0 === a && (a = .01);
- var s = e.call(this, t) || this;
- s._emitterInverseWorldMatrix = P.Identity(),
- s._inheritedVelocityOffset = new x,
- s.onDisposeObservable = new h,
- s.onStoppedObservable = new h,
- s._particles = new Array,
- s._stockParticles = new Array,
- s._newPartsExcess = 0,
- s._vertexBuffers = {},
- s._scaledColorStep = new N(0,0,0,0),
- s._colorDiff = new N(0,0,0,0),
- s._scaledDirection = x.Zero(),
- s._scaledGravity = x.Zero(),
- s._currentRenderId = -1,
- s._useInstancing = !1,
- s._started = !1,
- s._stopped = !1,
- s._actualFrame = 0,
- s._currentEmitRate1 = 0,
- s._currentEmitRate2 = 0,
- s._currentStartSize1 = 0,
- s._currentStartSize2 = 0,
- s._rawTextureWidth = 256,
- s._useRampGradients = !1,
- s._disposeEmitterOnDispose = !1,
- s.isLocal = !1,
- s._onBeforeDrawParticlesObservable = null,
- s.recycleParticle = function(e) {
- var t = s._particles.pop();
- t !== e && t.copyTo(e),
- s._stockParticles.push(t)
- }
- ,
- s._createParticle = function() {
- var e;
- if (0 !== s._stockParticles.length ? (e = s._stockParticles.pop())._reset() : e = new dy(s),
- s._subEmitters && s._subEmitters.length > 0) {
- var t = s._subEmitters[Math.floor(Math.random() * s._subEmitters.length)];
- e._attachedSubEmitters = [],
- t.forEach((function(t) {
- if (t.type === sy.ATTACHED) {
- var i = t.clone();
- e._attachedSubEmitters.push(i),
- i.particleSystem.start()
- }
- }
- ))
- }
- return e
- }
- ,
- s._emitFromParticle = function(e) {
- if (s._subEmitters && 0 !== s._subEmitters.length) {
- var t = Math.floor(Math.random() * s._subEmitters.length);
- s._subEmitters[t].forEach((function(t) {
- if (t.type === sy.END) {
- var i = t.clone();
- e._inheritParticleInfoToSubEmitter(i),
- i.particleSystem._rootParticleSystem = s,
- s.activeSubSystems.push(i.particleSystem),
- i.particleSystem.start()
- }
- }
- ))
- }
- }
- ,
- s._capacity = i,
- s._epsilon = a,
- s._isAnimationSheetEnabled = o,
- n && "Scene" !== n.getClassName() ? (s._engine = n,
- s.defaultProjectionMatrix = P.PerspectiveFovLH(.8, 1, .1, 100, s._engine.isNDCHalfZRange)) : (s._scene = n || E.LastCreatedScene,
- s._engine = s._scene.getEngine(),
- s.uniqueId = s._scene.getUniqueId(),
- s._scene.particleSystems.push(s)),
- s._engine.getCaps().vertexArrayObject && (s._vertexArrayObject = null),
- s._attachImageProcessingConfiguration(null),
- s._customWrappers = {
- 0: new Gt(s._engine)
- },
- s._customWrappers[0].effect = r,
- s._drawWrappers = [],
- s._useInstancing = s._engine.getCaps().instancedArrays,
- s._createIndexBuffer(),
- s._createVertexBuffers(),
- s.particleEmitterType = new hf;
- var l = null;
- return s.updateFunction = function(e) {
- var t, i = null;
- s.noiseTexture && (i = s.noiseTexture.getSize(),
- null === (t = s.noiseTexture.getContent()) || void 0 === t || t.then((function(e) {
- l = e
- }
- )));
- for (var n, r = function(t) {
- var r = e[t]
- , o = s._scaledUpdateSpeed
- , a = r.age;
- if (r.age += o,
- r.age > r.lifeTime) {
- var c = r.age - a;
- o = (r.lifeTime - a) * o / c,
- r.age = r.lifeTime
- }
- var u = r.age / r.lifeTime;
- s._colorGradients && s._colorGradients.length > 0 ? hy.GetCurrentGradient(u, s._colorGradients, (function(e, t, i) {
- e !== r._currentColorGradient && (r._currentColor1.copyFrom(r._currentColor2),
- t.getColorToRef(r._currentColor2),
- r._currentColorGradient = e),
- N.LerpToRef(r._currentColor1, r._currentColor2, i, r.color)
- }
- )) : (r.colorStep.scaleToRef(o, s._scaledColorStep),
- r.color.addInPlace(s._scaledColorStep),
- r.color.a < 0 && (r.color.a = 0)),
- s._angularSpeedGradients && s._angularSpeedGradients.length > 0 && hy.GetCurrentGradient(u, s._angularSpeedGradients, (function(e, t, i) {
- e !== r._currentAngularSpeedGradient && (r._currentAngularSpeed1 = r._currentAngularSpeed2,
- r._currentAngularSpeed2 = t.getFactor(),
- r._currentAngularSpeedGradient = e),
- r.angularSpeed = d.Lerp(r._currentAngularSpeed1, r._currentAngularSpeed2, i)
- }
- )),
- r.angle += r.angularSpeed * o;
- var h = o;
- if (s._velocityGradients && s._velocityGradients.length > 0 && hy.GetCurrentGradient(u, s._velocityGradients, (function(e, t, i) {
- e !== r._currentVelocityGradient && (r._currentVelocity1 = r._currentVelocity2,
- r._currentVelocity2 = t.getFactor(),
- r._currentVelocityGradient = e),
- h *= d.Lerp(r._currentVelocity1, r._currentVelocity2, i)
- }
- )),
- r.direction.scaleToRef(h, s._scaledDirection),
- s._limitVelocityGradients && s._limitVelocityGradients.length > 0 && hy.GetCurrentGradient(u, s._limitVelocityGradients, (function(e, t, i) {
- e !== r._currentLimitVelocityGradient && (r._currentLimitVelocity1 = r._currentLimitVelocity2,
- r._currentLimitVelocity2 = t.getFactor(),
- r._currentLimitVelocityGradient = e);
- var n = d.Lerp(r._currentLimitVelocity1, r._currentLimitVelocity2, i);
- r.direction.length() > n && r.direction.scaleInPlace(s.limitVelocityDamping)
- }
- )),
- s._dragGradients && s._dragGradients.length > 0 && hy.GetCurrentGradient(u, s._dragGradients, (function(e, t, i) {
- e !== r._currentDragGradient && (r._currentDrag1 = r._currentDrag2,
- r._currentDrag2 = t.getFactor(),
- r._currentDragGradient = e);
- var n = d.Lerp(r._currentDrag1, r._currentDrag2, i);
- s._scaledDirection.scaleInPlace(1 - n)
- }
- )),
- s.isLocal && r._localPosition ? (r._localPosition.addInPlace(s._scaledDirection),
- x.TransformCoordinatesToRef(r._localPosition, s._emitterWorldMatrix, r.position)) : r.position.addInPlace(s._scaledDirection),
- l && i && r._randomNoiseCoordinates1) {
- var p = s._fetchR(r._randomNoiseCoordinates1.x, r._randomNoiseCoordinates1.y, i.width, i.height, l)
- , f = s._fetchR(r._randomNoiseCoordinates1.z, r._randomNoiseCoordinates2.x, i.width, i.height, l)
- , _ = s._fetchR(r._randomNoiseCoordinates2.y, r._randomNoiseCoordinates2.z, i.width, i.height, l)
- , m = I.Vector3[0]
- , g = I.Vector3[1];
- m.copyFromFloats((2 * p - 1) * s.noiseStrength.x, (2 * f - 1) * s.noiseStrength.y, (2 * _ - 1) * s.noiseStrength.z),
- m.scaleToRef(o, g),
- r.direction.addInPlace(g)
- }
- if (s.gravity.scaleToRef(o, s._scaledGravity),
- r.direction.addInPlace(s._scaledGravity),
- s._sizeGradients && s._sizeGradients.length > 0 && hy.GetCurrentGradient(u, s._sizeGradients, (function(e, t, i) {
- e !== r._currentSizeGradient && (r._currentSize1 = r._currentSize2,
- r._currentSize2 = t.getFactor(),
- r._currentSizeGradient = e),
- r.size = d.Lerp(r._currentSize1, r._currentSize2, i)
- }
- )),
- s._useRampGradients && (s._colorRemapGradients && s._colorRemapGradients.length > 0 && hy.GetCurrentGradient(u, s._colorRemapGradients, (function(e, t, i) {
- var n = d.Lerp(e.factor1, t.factor1, i)
- , o = d.Lerp(e.factor2, t.factor2, i);
- r.remapData.x = n,
- r.remapData.y = o - n
- }
- )),
- s._alphaRemapGradients && s._alphaRemapGradients.length > 0 && hy.GetCurrentGradient(u, s._alphaRemapGradients, (function(e, t, i) {
- var n = d.Lerp(e.factor1, t.factor1, i)
- , o = d.Lerp(e.factor2, t.factor2, i);
- r.remapData.z = n,
- r.remapData.w = o - n
- }
- ))),
- s._isAnimationSheetEnabled && r.updateCellIndex(),
- r._inheritParticleInfoToSubEmitters(),
- r.age >= r.lifeTime)
- return s._emitFromParticle(r),
- r._attachedSubEmitters && (r._attachedSubEmitters.forEach((function(e) {
- e.particleSystem.disposeOnStop = !0,
- e.particleSystem.stop()
- }
- )),
- r._attachedSubEmitters = null),
- s.recycleParticle(r),
- t--,
- n = t,
- "continue";
- n = t
- }, o = 0; o < e.length; o++)
- r(o),
- o = n
- }
- ,
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "useRampGradients", {
- get: function() {
- return this._useRampGradients
- },
- set: function(e) {
- this._useRampGradients !== e && (this._useRampGradients = e,
- this._resetEffect())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "particles", {
- get: function() {
- return this._particles
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getActiveCount = function() {
- return this._particles.length
- }
- ,
- t.prototype.getClassName = function() {
- return "ParticleSystem"
- }
- ,
- t.prototype.isStopping = function() {
- return this._stopped && this.isAlive()
- }
- ,
- t.prototype.getCustomEffect = function(e) {
- var t, i;
- return void 0 === e && (e = 0),
- null !== (i = null === (t = this._customWrappers[e]) || void 0 === t ? void 0 : t.effect) && void 0 !== i ? i : this._customWrappers[0].effect
- }
- ,
- t.prototype._getCustomDrawWrapper = function(e) {
- var t;
- return void 0 === e && (e = 0),
- null !== (t = this._customWrappers[e]) && void 0 !== t ? t : this._customWrappers[0]
- }
- ,
- t.prototype.setCustomEffect = function(e, t) {
- void 0 === t && (t = 0),
- this._customWrappers[t] = new Gt(this._engine),
- this._customWrappers[t].effect = e,
- this._customWrappers[t].drawContext && (this._customWrappers[t].drawContext.useInstancing = this._useInstancing)
- }
- ,
- Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", {
- get: function() {
- return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new h),
- this._onBeforeDrawParticlesObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vertexShaderName", {
- get: function() {
- return "particles"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vertexBuffers", {
- get: function() {
- return this._vertexBuffers
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "indexBuffer", {
- get: function() {
- return this._indexBuffer
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._addFactorGradient = function(e, t, i, n) {
- var r = new uy(t,i,n);
- e.push(r),
- e.sort((function(e, t) {
- return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
- }
- ))
- }
- ,
- t.prototype._removeFactorGradient = function(e, t) {
- if (e)
- for (var i = 0, n = 0, r = e; n < r.length; n++) {
- if (r[n].gradient === t) {
- e.splice(i, 1);
- break
- }
- i++
- }
- }
- ,
- t.prototype.addLifeTimeGradient = function(e, t, i) {
- return this._lifeTimeGradients || (this._lifeTimeGradients = []),
- this._addFactorGradient(this._lifeTimeGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeLifeTimeGradient = function(e) {
- return this._removeFactorGradient(this._lifeTimeGradients, e),
- this
- }
- ,
- t.prototype.addSizeGradient = function(e, t, i) {
- return this._sizeGradients || (this._sizeGradients = []),
- this._addFactorGradient(this._sizeGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeSizeGradient = function(e) {
- return this._removeFactorGradient(this._sizeGradients, e),
- this
- }
- ,
- t.prototype.addColorRemapGradient = function(e, t, i) {
- return this._colorRemapGradients || (this._colorRemapGradients = []),
- this._addFactorGradient(this._colorRemapGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeColorRemapGradient = function(e) {
- return this._removeFactorGradient(this._colorRemapGradients, e),
- this
- }
- ,
- t.prototype.addAlphaRemapGradient = function(e, t, i) {
- return this._alphaRemapGradients || (this._alphaRemapGradients = []),
- this._addFactorGradient(this._alphaRemapGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeAlphaRemapGradient = function(e) {
- return this._removeFactorGradient(this._alphaRemapGradients, e),
- this
- }
- ,
- t.prototype.addAngularSpeedGradient = function(e, t, i) {
- return this._angularSpeedGradients || (this._angularSpeedGradients = []),
- this._addFactorGradient(this._angularSpeedGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeAngularSpeedGradient = function(e) {
- return this._removeFactorGradient(this._angularSpeedGradients, e),
- this
- }
- ,
- t.prototype.addVelocityGradient = function(e, t, i) {
- return this._velocityGradients || (this._velocityGradients = []),
- this._addFactorGradient(this._velocityGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeVelocityGradient = function(e) {
- return this._removeFactorGradient(this._velocityGradients, e),
- this
- }
- ,
- t.prototype.addLimitVelocityGradient = function(e, t, i) {
- return this._limitVelocityGradients || (this._limitVelocityGradients = []),
- this._addFactorGradient(this._limitVelocityGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeLimitVelocityGradient = function(e) {
- return this._removeFactorGradient(this._limitVelocityGradients, e),
- this
- }
- ,
- t.prototype.addDragGradient = function(e, t, i) {
- return this._dragGradients || (this._dragGradients = []),
- this._addFactorGradient(this._dragGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeDragGradient = function(e) {
- return this._removeFactorGradient(this._dragGradients, e),
- this
- }
- ,
- t.prototype.addEmitRateGradient = function(e, t, i) {
- return this._emitRateGradients || (this._emitRateGradients = []),
- this._addFactorGradient(this._emitRateGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeEmitRateGradient = function(e) {
- return this._removeFactorGradient(this._emitRateGradients, e),
- this
- }
- ,
- t.prototype.addStartSizeGradient = function(e, t, i) {
- return this._startSizeGradients || (this._startSizeGradients = []),
- this._addFactorGradient(this._startSizeGradients, e, t, i),
- this
- }
- ,
- t.prototype.removeStartSizeGradient = function(e) {
- return this._removeFactorGradient(this._startSizeGradients, e),
- this
- }
- ,
- t.prototype._createRampGradientTexture = function() {
- if (this._rampGradients && this._rampGradients.length && !this._rampGradientsTexture && this._scene) {
- for (var e = new Uint8Array(4 * this._rawTextureWidth), t = L.Color3[0], i = function(i) {
- var r = i / n._rawTextureWidth;
- hy.GetCurrentGradient(r, n._rampGradients, (function(n, r, o) {
- D.LerpToRef(n.color, r.color, o, t),
- e[4 * i] = 255 * t.r,
- e[4 * i + 1] = 255 * t.g,
- e[4 * i + 2] = 255 * t.b,
- e[4 * i + 3] = 255
- }
- ))
- }, n = this, r = 0; r < this._rawTextureWidth; r++)
- i(r);
- this._rampGradientsTexture = ao.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
- }
- }
- ,
- t.prototype.getRampGradients = function() {
- return this._rampGradients
- }
- ,
- t.prototype.forceRefreshGradients = function() {
- this._syncRampGradientTexture()
- }
- ,
- t.prototype._syncRampGradientTexture = function() {
- this._rampGradients && (this._rampGradients.sort((function(e, t) {
- return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
- }
- )),
- this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
- this._rampGradientsTexture = null),
- this._createRampGradientTexture())
- }
- ,
- t.prototype.addRampGradient = function(e, t) {
- this._rampGradients || (this._rampGradients = []);
- var i = new cy(e,t);
- return this._rampGradients.push(i),
- this._syncRampGradientTexture(),
- this
- }
- ,
- t.prototype.removeRampGradient = function(e) {
- return this._removeGradientAndTexture(e, this._rampGradients, this._rampGradientsTexture),
- this._rampGradientsTexture = null,
- this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(),
- this
- }
- ,
- t.prototype.addColorGradient = function(e, t, i) {
- this._colorGradients || (this._colorGradients = []);
- var n = new ly(e,t,i);
- return this._colorGradients.push(n),
- this._colorGradients.sort((function(e, t) {
- return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
- }
- )),
- this
- }
- ,
- t.prototype.removeColorGradient = function(e) {
- if (!this._colorGradients)
- return this;
- for (var t = 0, i = 0, n = this._colorGradients; i < n.length; i++) {
- if (n[i].gradient === e) {
- this._colorGradients.splice(t, 1);
- break
- }
- t++
- }
- return this
- }
- ,
- t.prototype.resetDrawCache = function() {
- for (var e = 0, t = this._drawWrappers; e < t.length; e++) {
- var i = t[e];
- if (i)
- for (var n = 0, r = i; n < r.length; n++) {
- var o = r[n];
- null == o || o.dispose()
- }
- }
- this._drawWrappers = []
- }
- ,
- t.prototype._fetchR = function(e, t, i, n, r) {
- return r[4 * (((e = .5 * Math.abs(e) + .5) * i % i | 0) + ((t = .5 * Math.abs(t) + .5) * n % n | 0) * i)] / 255
- }
- ,
- t.prototype._reset = function() {
- this._resetEffect()
- }
- ,
- t.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()
- }
- ,
- t.prototype._createVertexBuffers = function() {
- this._vertexBufferSize = this._useInstancing ? 10 : 12,
- this._isAnimationSheetEnabled && (this._vertexBufferSize += 1),
- this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED || (this._vertexBufferSize += 3),
- this._useRampGradients && (this._vertexBufferSize += 4);
- var e = this._engine;
- this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
- this._vertexBuffer = new wi(e,this._vertexData,!0,this._vertexBufferSize);
- var i = 0
- , n = this._vertexBuffer.createVertexBuffer(Bi.PositionKind, i, 3, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers[Bi.PositionKind] = n,
- i += 3;
- var r = this._vertexBuffer.createVertexBuffer(Bi.ColorKind, i, 4, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers[Bi.ColorKind] = r,
- i += 4;
- var o = this._vertexBuffer.createVertexBuffer("angle", i, 1, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.angle = o,
- i += 1;
- var a, s = this._vertexBuffer.createVertexBuffer("size", i, 2, this._vertexBufferSize, this._useInstancing);
- if (this._vertexBuffers.size = s,
- i += 2,
- this._isAnimationSheetEnabled) {
- var l = this._vertexBuffer.createVertexBuffer("cellIndex", i, 1, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.cellIndex = l,
- i += 1
- }
- if (!this._isBillboardBased || this.billboardMode === t.BILLBOARDMODE_STRETCHED) {
- var c = this._vertexBuffer.createVertexBuffer("direction", i, 3, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.direction = c,
- i += 3
- }
- if (this._useRampGradients) {
- var u = this._vertexBuffer.createVertexBuffer("remapData", i, 4, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.remapData = u,
- i += 4
- }
- if (this._useInstancing) {
- var h = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
- this._spriteBuffer = new wi(e,h,!1,2),
- a = this._spriteBuffer.createVertexBuffer("offset", 0, 2)
- } else
- a = this._vertexBuffer.createVertexBuffer("offset", i, 2, this._vertexBufferSize, this._useInstancing),
- i += 2;
- this._vertexBuffers.offset = a,
- this.resetDrawCache()
- }
- ,
- t.prototype._createIndexBuffer = function() {
- if (!this._useInstancing) {
- for (var e = [], t = 0, i = 0; i < this._capacity; i++)
- e.push(t),
- e.push(t + 1),
- e.push(t + 2),
- e.push(t),
- e.push(t + 2),
- e.push(t + 3),
- t += 4;
- this._indexBuffer = this._engine.createIndexBuffer(e)
- }
- }
- ,
- t.prototype.getCapacity = function() {
- return this._capacity
- }
- ,
- t.prototype.isAlive = function() {
- return this._alive
- }
- ,
- t.prototype.isStarted = function() {
- return this._started
- }
- ,
- t.prototype._prepareSubEmitterInternalArray = function() {
- var e = this;
- this._subEmitters = new Array,
- this.subEmitters && this.subEmitters.forEach((function(i) {
- i instanceof t ? e._subEmitters.push([new py(i)]) : i instanceof py ? e._subEmitters.push([i]) : i instanceof Array && e._subEmitters.push(i)
- }
- ))
- }
- ,
- t.prototype.start = function(e) {
- var t, i = this;
- if (void 0 === e && (e = this.startDelay),
- !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
- throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
- if (e)
- setTimeout((function() {
- i.start(0)
- }
- ), e);
- else {
- if (this._prepareSubEmitterInternalArray(),
- this._started = !0,
- this._stopped = !1,
- this._actualFrame = 0,
- this._subEmitters && 0 != this._subEmitters.length && (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) {
- -1 !== (null === (t = this.emitter) || void 0 === t ? void 0 : t.getClassName().indexOf("Mesh")) && this.emitter.computeWorldMatrix(!0);
- var n = this.noiseTexture;
- if (n && n.onGeneratedObservable)
- n.onGeneratedObservable.addOnce((function() {
- setTimeout((function() {
- for (var e = 0; e < i.preWarmCycles; e++)
- i.animate(!0),
- n.render()
- }
- ))
- }
- ));
- else
- for (var r = 0; r < this.preWarmCycles; r++)
- this.animate(!0)
- }
- this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
- }
- }
- ,
- t.prototype.stop = function(e) {
- void 0 === e && (e = !0),
- this._stopped || (this.onStoppedObservable.notifyObservers(this),
- this._stopped = !0,
- e && this._stopSubEmitters())
- }
- ,
- t.prototype.reset = function() {
- this._stockParticles = [],
- this._particles = []
- }
- ,
- t.prototype._appendParticleVertex = function(e, i, n, r) {
- var o = e * this._vertexBufferSize;
- if (this._vertexData[o++] = i.position.x + this.worldOffset.x,
- this._vertexData[o++] = i.position.y + this.worldOffset.y,
- this._vertexData[o++] = i.position.z + this.worldOffset.z,
- this._vertexData[o++] = i.color.r,
- this._vertexData[o++] = i.color.g,
- this._vertexData[o++] = i.color.b,
- this._vertexData[o++] = i.color.a,
- this._vertexData[o++] = i.angle,
- this._vertexData[o++] = i.scale.x * i.size,
- this._vertexData[o++] = i.scale.y * i.size,
- this._isAnimationSheetEnabled && (this._vertexData[o++] = i.cellIndex),
- this._isBillboardBased)
- this.billboardMode === t.BILLBOARDMODE_STRETCHED && (this._vertexData[o++] = i.direction.x,
- this._vertexData[o++] = i.direction.y,
- this._vertexData[o++] = i.direction.z);
- else if (i._initialDirection) {
- var a = i._initialDirection;
- this.isLocal && (x.TransformNormalToRef(a, this._emitterWorldMatrix, I.Vector3[0]),
- a = I.Vector3[0]),
- 0 === a.x && 0 === a.z && (a.x = .001),
- this._vertexData[o++] = a.x,
- this._vertexData[o++] = a.y,
- this._vertexData[o++] = a.z
- } else {
- var s = i.direction;
- this.isLocal && (x.TransformNormalToRef(s, this._emitterWorldMatrix, I.Vector3[0]),
- s = I.Vector3[0]),
- 0 === s.x && 0 === s.z && (s.x = .001),
- this._vertexData[o++] = s.x,
- this._vertexData[o++] = s.y,
- this._vertexData[o++] = s.z
- }
- this._useRampGradients && i.remapData && (this._vertexData[o++] = i.remapData.x,
- this._vertexData[o++] = i.remapData.y,
- this._vertexData[o++] = i.remapData.z,
- this._vertexData[o++] = i.remapData.w),
- this._useInstancing || (this._isAnimationSheetEnabled && (0 === n ? n = this._epsilon : 1 === n && (n = 1 - this._epsilon),
- 0 === r ? r = this._epsilon : 1 === r && (r = 1 - this._epsilon)),
- this._vertexData[o++] = n,
- this._vertexData[o++] = r)
- }
- ,
- t.prototype._stopSubEmitters = function() {
- this.activeSubSystems && (this.activeSubSystems.forEach((function(e) {
- e.stop(!0)
- }
- )),
- this.activeSubSystems = new Array)
- }
- ,
- t.prototype._removeFromRoot = function() {
- if (this._rootParticleSystem) {
- var e = this._rootParticleSystem.activeSubSystems.indexOf(this);
- -1 !== e && this._rootParticleSystem.activeSubSystems.splice(e, 1),
- this._rootParticleSystem = null
- }
- }
- ,
- t.prototype._update = function(e) {
- var t, i = this;
- if (this._alive = this._particles.length > 0,
- this.emitter.position) {
- var n = this.emitter;
- this._emitterWorldMatrix = n.getWorldMatrix()
- } else {
- var r = this.emitter;
- this._emitterWorldMatrix = P.Translation(r.x, r.y, r.z)
- }
- this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),
- this.updateFunction(this._particles);
- for (var o = function(e) {
- if (a._particles.length === a._capacity)
- return "break";
- if (t = a._createParticle(),
- a._particles.push(t),
- a.targetStopDuration && a._lifeTimeGradients && a._lifeTimeGradients.length > 0) {
- var n = d.Clamp(a._actualFrame / a.targetStopDuration);
- hy.GetCurrentGradient(n, a._lifeTimeGradients, (function(e, i) {
- var r = e
- , o = i
- , a = r.getFactor()
- , s = o.getFactor()
- , l = (n - r.gradient) / (o.gradient - r.gradient);
- t.lifeTime = d.Lerp(a, s, l)
- }
- ))
- } else
- t.lifeTime = d.RandomRange(a.minLifeTime, a.maxLifeTime);
- var r = d.RandomRange(a.minEmitPower, a.maxEmitPower);
- if (a.startPositionFunction ? a.startPositionFunction(a._emitterWorldMatrix, t.position, t, a.isLocal) : a.particleEmitterType.startPositionFunction(a._emitterWorldMatrix, t.position, t, a.isLocal),
- a.isLocal && (t._localPosition ? t._localPosition.copyFrom(t.position) : t._localPosition = t.position.clone(),
- x.TransformCoordinatesToRef(t._localPosition, a._emitterWorldMatrix, t.position)),
- a.startDirectionFunction ? a.startDirectionFunction(a._emitterWorldMatrix, t.direction, t, a.isLocal) : a.particleEmitterType.startDirectionFunction(a._emitterWorldMatrix, t.direction, t, a.isLocal, a._emitterInverseWorldMatrix),
- 0 === r ? t._initialDirection ? t._initialDirection.copyFrom(t.direction) : t._initialDirection = t.direction.clone() : t._initialDirection = null,
- t.direction.scaleInPlace(r),
- a._sizeGradients && 0 !== a._sizeGradients.length ? (t._currentSizeGradient = a._sizeGradients[0],
- t._currentSize1 = t._currentSizeGradient.getFactor(),
- t.size = t._currentSize1,
- a._sizeGradients.length > 1 ? t._currentSize2 = a._sizeGradients[1].getFactor() : t._currentSize2 = t._currentSize1) : t.size = d.RandomRange(a.minSize, a.maxSize),
- t.scale.copyFromFloats(d.RandomRange(a.minScaleX, a.maxScaleX), d.RandomRange(a.minScaleY, a.maxScaleY)),
- a._startSizeGradients && a._startSizeGradients[0] && a.targetStopDuration) {
- var o = a._actualFrame / a.targetStopDuration;
- hy.GetCurrentGradient(o, a._startSizeGradients, (function(e, n, r) {
- e !== i._currentStartSizeGradient && (i._currentStartSize1 = i._currentStartSize2,
- i._currentStartSize2 = n.getFactor(),
- i._currentStartSizeGradient = e);
- var o = d.Lerp(i._currentStartSize1, i._currentStartSize2, r);
- t.scale.scaleInPlace(o)
- }
- ))
- }
- if (a._angularSpeedGradients && 0 !== a._angularSpeedGradients.length ? (t._currentAngularSpeedGradient = a._angularSpeedGradients[0],
- t.angularSpeed = t._currentAngularSpeedGradient.getFactor(),
- t._currentAngularSpeed1 = t.angularSpeed,
- a._angularSpeedGradients.length > 1 ? t._currentAngularSpeed2 = a._angularSpeedGradients[1].getFactor() : t._currentAngularSpeed2 = t._currentAngularSpeed1) : t.angularSpeed = d.RandomRange(a.minAngularSpeed, a.maxAngularSpeed),
- t.angle = d.RandomRange(a.minInitialRotation, a.maxInitialRotation),
- a._velocityGradients && a._velocityGradients.length > 0 && (t._currentVelocityGradient = a._velocityGradients[0],
- t._currentVelocity1 = t._currentVelocityGradient.getFactor(),
- a._velocityGradients.length > 1 ? t._currentVelocity2 = a._velocityGradients[1].getFactor() : t._currentVelocity2 = t._currentVelocity1),
- a._limitVelocityGradients && a._limitVelocityGradients.length > 0 && (t._currentLimitVelocityGradient = a._limitVelocityGradients[0],
- t._currentLimitVelocity1 = t._currentLimitVelocityGradient.getFactor(),
- a._limitVelocityGradients.length > 1 ? t._currentLimitVelocity2 = a._limitVelocityGradients[1].getFactor() : t._currentLimitVelocity2 = t._currentLimitVelocity1),
- a._dragGradients && a._dragGradients.length > 0 && (t._currentDragGradient = a._dragGradients[0],
- t._currentDrag1 = t._currentDragGradient.getFactor(),
- a._dragGradients.length > 1 ? t._currentDrag2 = a._dragGradients[1].getFactor() : t._currentDrag2 = t._currentDrag1),
- a._colorGradients && 0 !== a._colorGradients.length)
- t._currentColorGradient = a._colorGradients[0],
- t._currentColorGradient.getColorToRef(t.color),
- t._currentColor1.copyFrom(t.color),
- a._colorGradients.length > 1 ? a._colorGradients[1].getColorToRef(t._currentColor2) : t._currentColor2.copyFrom(t.color);
- else {
- var s = d.RandomRange(0, 1);
- N.LerpToRef(a.color1, a.color2, s, t.color),
- a.colorDead.subtractToRef(t.color, a._colorDiff),
- a._colorDiff.scaleToRef(1 / t.lifeTime, t.colorStep)
- }
- a._isAnimationSheetEnabled && (t._initialStartSpriteCellID = a.startSpriteCellID,
- t._initialEndSpriteCellID = a.endSpriteCellID,
- t._initialSpriteCellLoop = a.spriteCellLoop),
- t.direction.addInPlace(a._inheritedVelocityOffset),
- a._useRampGradients && (t.remapData = new R(0,1,0,1)),
- a.noiseTexture && (t._randomNoiseCoordinates1 ? (t._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()),
- t._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (t._randomNoiseCoordinates1 = new x(Math.random(),Math.random(),Math.random()),
- t._randomNoiseCoordinates2 = new x(Math.random(),Math.random(),Math.random()))),
- t._inheritParticleInfoToSubEmitters()
- }, a = this, s = 0; s < e && "break" !== o(); s++)
- ;
- }
- ,
- t._GetAttributeNamesOrOptions = function(e, t, i) {
- void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- void 0 === i && (i = !1);
- var n = [Bi.PositionKind, Bi.ColorKind, "angle", "offset", "size"];
- return e && n.push("cellIndex"),
- t || n.push("direction"),
- i && n.push("remapData"),
- n
- }
- ,
- t._GetEffectCreationOptions = function(e) {
- void 0 === e && (e = !1);
- var t = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
- return e && t.push("particlesInfos"),
- t
- }
- ,
- t.prototype.fillDefines = function(e, i) {
- if (this._scene && (this._scene.clipPlane && e.push("#define CLIPPLANE"),
- this._scene.clipPlane2 && e.push("#define CLIPPLANE2"),
- this._scene.clipPlane3 && e.push("#define CLIPPLANE3"),
- this._scene.clipPlane4 && e.push("#define CLIPPLANE4"),
- this._scene.clipPlane5 && e.push("#define CLIPPLANE5"),
- this._scene.clipPlane6 && e.push("#define CLIPPLANE6")),
- this._isAnimationSheetEnabled && e.push("#define ANIMATESHEET"),
- i === t.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"),
- this._useRampGradients && e.push("#define RAMPGRADIENT"),
- this._isBillboardBased)
- switch (e.push("#define BILLBOARD"),
- this.billboardMode) {
- case t.BILLBOARDMODE_Y:
- e.push("#define BILLBOARDY");
- break;
- case t.BILLBOARDMODE_STRETCHED:
- e.push("#define BILLBOARDSTRETCHED");
- break;
- case t.BILLBOARDMODE_ALL:
- e.push("#define BILLBOARDMODE_ALL")
- }
- this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
- e.push(this._imageProcessingConfigurationDefines.toString()))
- }
- ,
- t.prototype.fillUniformsAttributesAndSamplerNames = function(e, i, n) {
- i.push.apply(i, t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== t.BILLBOARDMODE_STRETCHED, this._useRampGradients)),
- e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
- n.push("diffuseSampler", "rampSampler"),
- this._imageProcessingConfiguration && (Ri.PrepareUniforms(e, this._imageProcessingConfigurationDefines),
- Ri.PrepareSamplers(n, this._imageProcessingConfigurationDefines))
- }
- ,
- t.prototype._getWrapper = function(e) {
- var t = this._getCustomDrawWrapper(e);
- if (null == t ? void 0 : t.effect)
- return t;
- var i = [];
- this.fillDefines(i, e);
- var n = this._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : a.RENDERPASS_MAIN
- , r = this._drawWrappers[n];
- r || (r = this._drawWrappers[n] = []);
- var o = r[e];
- o || ((o = new Gt(this._engine)).drawContext && (o.drawContext.useInstancing = this._useInstancing),
- r[e] = o);
- var s = i.join("\n");
- if (o.defines !== s) {
- var l = []
- , c = []
- , u = [];
- this.fillUniformsAttributesAndSamplerNames(c, l, u),
- o.setEffect(this._engine.createEffect("particles", l, c, u, s), s)
- }
- return o
- }
- ,
- t.prototype.animate = function(e) {
- var t, i = this;
- if (void 0 === e && (e = !1),
- this._started) {
- if (!e && this._scene) {
- if (!this.isReady())
- return;
- if (this._currentRenderId === this._scene.getFrameId())
- return;
- this._currentRenderId = this._scene.getFrameId()
- }
- var n;
- if (this._scaledUpdateSpeed = this.updateSpeed * (e ? this.preWarmStepOffset : (null === (t = this._scene) || void 0 === t ? void 0 : t.getAnimationRatio()) || 1),
- this.manualEmitCount > -1)
- n = this.manualEmitCount,
- this._newPartsExcess = 0,
- this.manualEmitCount = 0;
- else {
- var r = this.emitRate;
- if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
- var o = this._actualFrame / this.targetStopDuration;
- hy.GetCurrentGradient(o, this._emitRateGradients, (function(e, t, n) {
- e !== i._currentEmitRateGradient && (i._currentEmitRate1 = i._currentEmitRate2,
- i._currentEmitRate2 = t.getFactor(),
- i._currentEmitRateGradient = e),
- r = d.Lerp(i._currentEmitRate1, i._currentEmitRate2, n)
- }
- ))
- }
- n = r * this._scaledUpdateSpeed >> 0,
- this._newPartsExcess += r * this._scaledUpdateSpeed - n
- }
- if (this._newPartsExcess > 1 && (n += this._newPartsExcess >> 0,
- this._newPartsExcess -= this._newPartsExcess >> 0),
- this._alive = !1,
- this._stopped ? n = 0 : (this._actualFrame += this._scaledUpdateSpeed,
- this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()),
- this._update(n),
- this._stopped && (this._alive || (this._started = !1,
- this.onAnimationEnd && this.onAnimationEnd(),
- this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))),
- !e) {
- for (var a = 0, s = 0; s < this._particles.length; s++) {
- var l = this._particles[s];
- this._appendParticleVertices(a, l),
- a += this._useInstancing ? 1 : 4
- }
- this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length)
- }
- 0 === this.manualEmitCount && this.disposeOnStop && this.stop()
- }
- }
- ,
- t.prototype._appendParticleVertices = function(e, t) {
- this._appendParticleVertex(e++, t, 0, 0),
- this._useInstancing || (this._appendParticleVertex(e++, t, 1, 0),
- this._appendParticleVertex(e++, t, 1, 1),
- this._appendParticleVertex(e++, t, 0, 1))
- }
- ,
- t.prototype.rebuild = function() {
- var e, t;
- for (var i in this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null),
- this._createIndexBuffer(),
- null === (e = this._spriteBuffer) || void 0 === e || e._rebuild(),
- null === (t = this._vertexBuffer) || void 0 === t || t._rebuild(),
- this._vertexBuffers)
- this._vertexBuffers[i]._rebuild();
- this.resetDrawCache()
- }
- ,
- t.prototype.isReady = function() {
- if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
- return !1;
- if (this.blendMode !== t.BLENDMODE_MULTIPLYADD) {
- if (!this._getWrapper(this.blendMode).effect.isReady())
- return !1
- } else {
- if (!this._getWrapper(t.BLENDMODE_MULTIPLY).effect.isReady())
- return !1;
- if (!this._getWrapper(t.BLENDMODE_ADD).effect.isReady())
- return !1
- }
- return !0
- }
- ,
- t.prototype._render = function(e) {
- var i, n, r = this._getWrapper(e), o = r.effect, s = this._engine;
- s.enableEffect(r);
- var l = null !== (i = this.defaultViewMatrix) && void 0 !== i ? i : this._scene.getViewMatrix();
- if (o.setTexture("diffuseSampler", this.particleTexture),
- o.setMatrix("view", l),
- o.setMatrix("projection", null !== (n = this.defaultProjectionMatrix) && void 0 !== n ? n : this._scene.getProjectionMatrix()),
- this._isAnimationSheetEnabled && this.particleTexture) {
- var c = this.particleTexture.getBaseSize();
- o.setFloat3("particlesInfos", this.spriteCellWidth / c.width, this.spriteCellHeight / c.height, this.spriteCellWidth / c.width)
- }
- if (o.setVector2("translationPivot", this.translationPivot),
- o.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a),
- this._isBillboardBased && this._scene) {
- var u = this._scene.activeCamera;
- o.setVector3("eyePosition", u.globalPosition)
- }
- this._rampGradientsTexture && (this._rampGradients && this._rampGradients.length || (this._rampGradientsTexture.dispose(),
- this._rampGradientsTexture = null),
- o.setTexture("rampSampler", this._rampGradientsTexture));
- var h = o.defines;
- switch (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && Pr.BindClipPlane(o, this._scene),
- h.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (l.invertToRef(I.Matrix[0]),
- o.setMatrix("invView", I.Matrix[0])),
- void 0 !== this._vertexArrayObject ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, o)),
- this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : s.bindBuffers(this._vertexBuffers, this._indexBuffer, o),
- this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o),
- e) {
- case t.BLENDMODE_ADD:
- s.setAlphaMode(a.ALPHA_ADD);
- break;
- case t.BLENDMODE_ONEONE:
- s.setAlphaMode(a.ALPHA_ONEONE);
- break;
- case t.BLENDMODE_STANDARD:
- s.setAlphaMode(a.ALPHA_COMBINE);
- break;
- case t.BLENDMODE_MULTIPLY:
- s.setAlphaMode(a.ALPHA_MULTIPLY)
- }
- return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o),
- this._useInstancing ? s.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, this._particles.length) : s.drawElementsType(a.MATERIAL_TriangleFillMode, 0, 6 * this._particles.length),
- this._particles.length
- }
- ,
- t.prototype.render = function() {
- if (!this.isReady() || !this._particles.length)
- return 0;
- var e = this._engine;
- e.setState && (e.setState(!1),
- this.forceDepthWrite && e.setDepthWrite(!0));
- var i;
- return i = this.blendMode === t.BLENDMODE_MULTIPLYADD ? this._render(t.BLENDMODE_MULTIPLY) + this._render(t.BLENDMODE_ADD) : this._render(this.blendMode),
- this._engine.unbindInstanceAttributes(),
- this._engine.setAlphaMode(a.ALPHA_DISABLE),
- i
- }
- ,
- t.prototype.dispose = function(e) {
- if (void 0 === e && (e = !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),
- e && this.particleTexture && (this.particleTexture.dispose(),
- this.particleTexture = null),
- e && this.noiseTexture && (this.noiseTexture.dispose(),
- this.noiseTexture = null),
- this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
- this._rampGradientsTexture = null),
- this._removeFromRoot(),
- this.subEmitters && !this._subEmitters && this._prepareSubEmitterInternalArray(),
- this._subEmitters && this._subEmitters.length) {
- for (var t = 0; t < this._subEmitters.length; t++)
- for (var i = 0, n = this._subEmitters[t]; i < n.length; i++)
- n[i].dispose();
- this._subEmitters = [],
- this.subEmitters = []
- }
- this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0),
- this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(),
- this._scene && ((t = this._scene.particleSystems.indexOf(this)) > -1 && this._scene.particleSystems.splice(t, 1),
- this._scene._activeParticleSystems.dispose()),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onStoppedObservable.clear(),
- this.reset()
- }
- ,
- t.prototype.clone = function(e, i) {
- var n = V({}, this._customWrappers)
- , r = null
- , o = this._engine;
- if (o.createEffectForParticles && null != this.customShader) {
- var a = (r = this.customShader).shaderOptions.defines.length > 0 ? r.shaderOptions.defines.join("\n") : ""
- , s = o.createEffectForParticles(r.shaderPath.fragmentElement, r.shaderOptions.uniforms, r.shaderOptions.samplers, a);
- n[0] ? n[0].effect = s : this.setCustomEffect(s, 0)
- }
- var l = this.serialize()
- , c = t.Parse(l, this._scene || this._engine, this._rootUrl);
- return c.name = e,
- c.customShader = r,
- c._customWrappers = n,
- void 0 === i && (i = this.emitter),
- this.noiseTexture && (c.noiseTexture = this.noiseTexture.clone()),
- c.emitter = i,
- this.preventAutoStart || c.start(),
- c
- }
- ,
- t.prototype.serialize = function(e) {
- void 0 === e && (e = !1);
- var i = {};
- if (t._Serialize(i, this, e),
- i.textureMask = this.textureMask.asArray(),
- i.customShader = this.customShader,
- i.preventAutoStart = this.preventAutoStart,
- this.subEmitters) {
- i.subEmitters = [],
- this._subEmitters || this._prepareSubEmitterInternalArray();
- for (var n = 0, r = this._subEmitters; n < r.length; n++) {
- for (var o = [], a = 0, s = r[n]; a < s.length; a++) {
- var l = s[a];
- o.push(l.serialize(e))
- }
- i.subEmitters.push(o)
- }
- }
- return i
- }
- ,
- t._Serialize = function(e, t, i) {
- if (e.name = t.name,
- e.id = t.id,
- e.capacity = t.getCapacity(),
- e.disposeOnStop = t.disposeOnStop,
- e.manualEmitCount = t.manualEmitCount,
- t.emitter.position) {
- var n = t.emitter;
- e.emitterId = n.id
- } else {
- var r = t.emitter;
- e.emitter = r.asArray()
- }
- t.particleEmitterType && (e.particleEmitterType = t.particleEmitterType.serialize()),
- t.particleTexture && (i ? e.texture = t.particleTexture.serialize() : (e.textureName = t.particleTexture.name,
- e.invertY = !!t.particleTexture._invertY)),
- e.isLocal = t.isLocal,
- Ge.AppendSerializedAnimations(t, e),
- e.beginAnimationOnStart = t.beginAnimationOnStart,
- e.beginAnimationFrom = t.beginAnimationFrom,
- e.beginAnimationTo = t.beginAnimationTo,
- e.beginAnimationLoop = t.beginAnimationLoop,
- e.startDelay = t.startDelay,
- e.renderingGroupId = t.renderingGroupId,
- e.isBillboardBased = t.isBillboardBased,
- e.billboardMode = t.billboardMode,
- e.minAngularSpeed = t.minAngularSpeed,
- e.maxAngularSpeed = t.maxAngularSpeed,
- e.minSize = t.minSize,
- e.maxSize = t.maxSize,
- e.minScaleX = t.minScaleX,
- e.maxScaleX = t.maxScaleX,
- e.minScaleY = t.minScaleY,
- e.maxScaleY = t.maxScaleY,
- e.minEmitPower = t.minEmitPower,
- e.maxEmitPower = t.maxEmitPower,
- e.minLifeTime = t.minLifeTime,
- e.maxLifeTime = t.maxLifeTime,
- e.emitRate = t.emitRate,
- e.gravity = t.gravity.asArray(),
- e.noiseStrength = t.noiseStrength.asArray(),
- e.color1 = t.color1.asArray(),
- e.color2 = t.color2.asArray(),
- e.colorDead = t.colorDead.asArray(),
- e.updateSpeed = t.updateSpeed,
- e.targetStopDuration = t.targetStopDuration,
- e.blendMode = t.blendMode,
- e.preWarmCycles = t.preWarmCycles,
- e.preWarmStepOffset = t.preWarmStepOffset,
- e.minInitialRotation = t.minInitialRotation,
- e.maxInitialRotation = t.maxInitialRotation,
- e.startSpriteCellID = t.startSpriteCellID,
- e.spriteCellLoop = t.spriteCellLoop,
- e.endSpriteCellID = t.endSpriteCellID,
- e.spriteCellChangeSpeed = t.spriteCellChangeSpeed,
- e.spriteCellWidth = t.spriteCellWidth,
- e.spriteCellHeight = t.spriteCellHeight,
- e.spriteRandomStartCell = t.spriteRandomStartCell,
- e.isAnimationSheetEnabled = t.isAnimationSheetEnabled;
- var o = t.getColorGradients();
- if (o) {
- e.colorGradients = [];
- for (var a = 0, s = o; a < s.length; a++) {
- var l = s[a]
- , c = {
- gradient: l.gradient,
- color1: l.color1.asArray()
- };
- l.color2 ? c.color2 = l.color2.asArray() : c.color2 = l.color1.asArray(),
- e.colorGradients.push(c)
- }
- }
- var u = t.getRampGradients();
- if (u) {
- e.rampGradients = [];
- for (var h = 0, d = u; h < d.length; h++) {
- var p = d[h];
- c = {
- gradient: p.gradient,
- color: p.color.asArray()
- },
- e.rampGradients.push(c)
- }
- e.useRampGradients = t.useRampGradients
- }
- var f = t.getColorRemapGradients();
- if (f) {
- e.colorRemapGradients = [];
- for (var _ = 0, m = f; _ < m.length; _++) {
- var g = m[_];
- c = {
- gradient: g.gradient,
- factor1: g.factor1
- },
- void 0 !== g.factor2 ? c.factor2 = g.factor2 : c.factor2 = g.factor1,
- e.colorRemapGradients.push(c)
- }
- }
- var v = t.getAlphaRemapGradients();
- if (v) {
- e.alphaRemapGradients = [];
- for (var y = 0, b = v; y < b.length; y++) {
- var T = b[y];
- c = {
- gradient: T.gradient,
- factor1: T.factor1
- },
- void 0 !== T.factor2 ? c.factor2 = T.factor2 : c.factor2 = T.factor1,
- e.alphaRemapGradients.push(c)
- }
- }
- var E = t.getSizeGradients();
- if (E) {
- e.sizeGradients = [];
- for (var S = 0, A = E; S < A.length; S++) {
- var x = A[S];
- c = {
- gradient: x.gradient,
- factor1: x.factor1
- },
- void 0 !== x.factor2 ? c.factor2 = x.factor2 : c.factor2 = x.factor1,
- e.sizeGradients.push(c)
- }
- }
- var R = t.getAngularSpeedGradients();
- if (R) {
- e.angularSpeedGradients = [];
- for (var C = 0, P = R; C < P.length; C++) {
- var M = P[C];
- c = {
- gradient: M.gradient,
- factor1: M.factor1
- },
- void 0 !== M.factor2 ? c.factor2 = M.factor2 : c.factor2 = M.factor1,
- e.angularSpeedGradients.push(c)
- }
- }
- var I = t.getVelocityGradients();
- if (I) {
- e.velocityGradients = [];
- for (var O = 0, D = I; O < D.length; O++) {
- var N = D[O];
- c = {
- gradient: N.gradient,
- factor1: N.factor1
- },
- void 0 !== N.factor2 ? c.factor2 = N.factor2 : c.factor2 = N.factor1,
- e.velocityGradients.push(c)
- }
- }
- var L = t.getDragGradients();
- if (L) {
- e.dragGradients = [];
- for (var F = 0, w = L; F < w.length; F++) {
- var B = w[F];
- c = {
- gradient: B.gradient,
- factor1: B.factor1
- },
- void 0 !== B.factor2 ? c.factor2 = B.factor2 : c.factor2 = B.factor1,
- e.dragGradients.push(c)
- }
- }
- var U = t.getEmitRateGradients();
- if (U) {
- e.emitRateGradients = [];
- for (var V = 0, k = U; V < k.length; V++) {
- var G = k[V];
- c = {
- gradient: G.gradient,
- factor1: G.factor1
- },
- void 0 !== G.factor2 ? c.factor2 = G.factor2 : c.factor2 = G.factor1,
- e.emitRateGradients.push(c)
- }
- }
- var z = t.getStartSizeGradients();
- if (z) {
- e.startSizeGradients = [];
- for (var W = 0, H = z; W < H.length; W++) {
- var X = H[W];
- c = {
- gradient: X.gradient,
- factor1: X.factor1
- },
- void 0 !== X.factor2 ? c.factor2 = X.factor2 : c.factor2 = X.factor1,
- e.startSizeGradients.push(c)
- }
- }
- var j = t.getLifeTimeGradients();
- if (j) {
- e.lifeTimeGradients = [];
- for (var Y = 0, K = j; Y < K.length; Y++) {
- var Q = K[Y];
- c = {
- gradient: Q.gradient,
- factor1: Q.factor1
- },
- void 0 !== Q.factor2 ? c.factor2 = Q.factor2 : c.factor2 = Q.factor1,
- e.lifeTimeGradients.push(c)
- }
- }
- var q = t.getLimitVelocityGradients();
- if (q) {
- e.limitVelocityGradients = [];
- for (var Z = 0, J = q; Z < J.length; Z++) {
- var $ = J[Z];
- c = {
- gradient: $.gradient,
- factor1: $.factor1
- },
- void 0 !== $.factor2 ? c.factor2 = $.factor2 : c.factor2 = $.factor1,
- e.limitVelocityGradients.push(c)
- }
- e.limitVelocityDamping = t.limitVelocityDamping
- }
- t.noiseTexture && (e.noiseTexture = t.noiseTexture.serialize())
- }
- ,
- t._Parse = function(e, t, i, n) {
- var r, o, a, s;
- s = i instanceof Ht ? null : i;
- var l, c = b("BABYLON.Texture");
- if (c && s && (e.texture ? t.particleTexture = c.Parse(e.texture, s, n) : e.textureName && (t.particleTexture = new c(n + e.textureName,s,!1,void 0 === e.invertY || e.invertY),
- t.particleTexture.name = e.textureName)),
- e.emitterId || 0 === e.emitterId || void 0 !== e.emitter ? e.emitterId && s ? t.emitter = s.getLastMeshById(e.emitterId) : t.emitter = x.FromArray(e.emitter) : t.emitter = x.Zero(),
- t.isLocal = !!e.isLocal,
- void 0 !== e.renderingGroupId && (t.renderingGroupId = e.renderingGroupId),
- void 0 !== e.isBillboardBased && (t.isBillboardBased = e.isBillboardBased),
- void 0 !== e.billboardMode && (t.billboardMode = e.billboardMode),
- e.animations) {
- for (var u = 0; u < e.animations.length; u++) {
- var h = e.animations[u]
- , d = b("BABYLON.Animation");
- d && t.animations.push(d.Parse(h))
- }
- t.beginAnimationOnStart = e.beginAnimationOnStart,
- t.beginAnimationFrom = e.beginAnimationFrom,
- t.beginAnimationTo = e.beginAnimationTo,
- t.beginAnimationLoop = e.beginAnimationLoop
- }
- if (e.autoAnimate && s && s.beginAnimation(t, e.autoAnimateFrom, e.autoAnimateTo, e.autoAnimateLoop, e.autoAnimateSpeed || 1),
- t.startDelay = 0 | e.startDelay,
- t.minAngularSpeed = e.minAngularSpeed,
- t.maxAngularSpeed = e.maxAngularSpeed,
- t.minSize = e.minSize,
- t.maxSize = e.maxSize,
- e.minScaleX && (t.minScaleX = e.minScaleX,
- t.maxScaleX = e.maxScaleX,
- t.minScaleY = e.minScaleY,
- t.maxScaleY = e.maxScaleY),
- void 0 !== e.preWarmCycles && (t.preWarmCycles = e.preWarmCycles,
- t.preWarmStepOffset = e.preWarmStepOffset),
- void 0 !== e.minInitialRotation && (t.minInitialRotation = e.minInitialRotation,
- t.maxInitialRotation = e.maxInitialRotation),
- t.minLifeTime = e.minLifeTime,
- t.maxLifeTime = e.maxLifeTime,
- t.minEmitPower = e.minEmitPower,
- t.maxEmitPower = e.maxEmitPower,
- t.emitRate = e.emitRate,
- t.gravity = x.FromArray(e.gravity),
- e.noiseStrength && (t.noiseStrength = x.FromArray(e.noiseStrength)),
- t.color1 = N.FromArray(e.color1),
- t.color2 = N.FromArray(e.color2),
- t.colorDead = N.FromArray(e.colorDead),
- t.updateSpeed = e.updateSpeed,
- t.targetStopDuration = e.targetStopDuration,
- t.blendMode = e.blendMode,
- e.colorGradients)
- for (var p = 0, f = e.colorGradients; p < f.length; p++) {
- var _ = f[p];
- t.addColorGradient(_.gradient, N.FromArray(_.color1), _.color2 ? N.FromArray(_.color2) : void 0)
- }
- if (e.rampGradients) {
- for (var m = 0, g = e.rampGradients; m < g.length; m++) {
- var v = g[m];
- t.addRampGradient(v.gradient, D.FromArray(v.color))
- }
- t.useRampGradients = e.useRampGradients
- }
- if (e.colorRemapGradients)
- for (var y = 0, T = e.colorRemapGradients; y < T.length; y++) {
- var E = T[y];
- t.addColorRemapGradient(E.gradient, void 0 !== E.factor1 ? E.factor1 : E.factor, E.factor2)
- }
- if (e.alphaRemapGradients)
- for (var S = 0, A = e.alphaRemapGradients; S < A.length; S++) {
- var R = A[S];
- t.addAlphaRemapGradient(R.gradient, void 0 !== R.factor1 ? R.factor1 : R.factor, R.factor2)
- }
- if (e.sizeGradients)
- for (var C = 0, P = e.sizeGradients; C < P.length; C++) {
- var M = P[C];
- t.addSizeGradient(M.gradient, void 0 !== M.factor1 ? M.factor1 : M.factor, M.factor2)
- }
- if (e.angularSpeedGradients)
- for (var I = 0, O = e.angularSpeedGradients; I < O.length; I++) {
- var L = O[I];
- t.addAngularSpeedGradient(L.gradient, void 0 !== L.factor1 ? L.factor1 : L.factor, L.factor2)
- }
- if (e.velocityGradients)
- for (var F = 0, w = e.velocityGradients; F < w.length; F++) {
- var B = w[F];
- t.addVelocityGradient(B.gradient, void 0 !== B.factor1 ? B.factor1 : B.factor, B.factor2)
- }
- if (e.dragGradients)
- for (var U = 0, V = e.dragGradients; U < V.length; U++) {
- var k = V[U];
- t.addDragGradient(k.gradient, void 0 !== k.factor1 ? k.factor1 : k.factor, k.factor2)
- }
- if (e.emitRateGradients)
- for (var G = 0, z = e.emitRateGradients; G < z.length; G++) {
- var W = z[G];
- t.addEmitRateGradient(W.gradient, void 0 !== W.factor1 ? W.factor1 : W.factor, W.factor2)
- }
- if (e.startSizeGradients)
- for (var H = 0, X = e.startSizeGradients; H < X.length; H++) {
- var j = X[H];
- t.addStartSizeGradient(j.gradient, void 0 !== j.factor1 ? j.factor1 : j.factor, j.factor2)
- }
- if (e.lifeTimeGradients)
- for (var Y = 0, K = e.lifeTimeGradients; Y < K.length; Y++) {
- var Q = K[Y];
- t.addLifeTimeGradient(Q.gradient, void 0 !== Q.factor1 ? Q.factor1 : Q.factor, Q.factor2)
- }
- if (e.limitVelocityGradients) {
- for (var q = 0, Z = e.limitVelocityGradients; q < Z.length; q++) {
- var J = Z[q];
- t.addLimitVelocityGradient(J.gradient, void 0 !== J.factor1 ? J.factor1 : J.factor, J.factor2)
- }
- t.limitVelocityDamping = e.limitVelocityDamping
- }
- if (e.noiseTexture && s) {
- var $ = b("BABYLON.ProceduralTexture");
- t.noiseTexture = $.Parse(e.noiseTexture, s, n)
- }
- if (e.particleEmitterType) {
- switch (e.particleEmitterType.type) {
- case "SphereParticleEmitter":
- l = new gf;
- break;
- case "SphereDirectedParticleEmitter":
- l = new vf;
- break;
- case "ConeEmitter":
- case "ConeParticleEmitter":
- l = new df;
- break;
- case "CylinderParticleEmitter":
- l = new pf;
- break;
- case "CylinderDirectedParticleEmitter":
- l = new ff;
- break;
- case "HemisphericParticleEmitter":
- l = new _f;
- break;
- case "PointParticleEmitter":
- l = new mf;
- break;
- case "MeshParticleEmitter":
- l = new bf;
- break;
- default:
- l = new hf
- }
- l.parse(e.particleEmitterType, s)
- } else
- (l = new hf).parse(e, s);
- t.particleEmitterType = l,
- t.startSpriteCellID = e.startSpriteCellID,
- t.endSpriteCellID = e.endSpriteCellID,
- t.spriteCellLoop = null === (r = e.spriteCellLoop) || void 0 === r || r,
- t.spriteCellWidth = e.spriteCellWidth,
- t.spriteCellHeight = e.spriteCellHeight,
- t.spriteCellChangeSpeed = e.spriteCellChangeSpeed,
- t.spriteRandomStartCell = e.spriteRandomStartCell,
- t.disposeOnStop = null !== (o = e.disposeOnStop) && void 0 !== o && o,
- t.manualEmitCount = null !== (a = e.manualEmitCount) && void 0 !== a ? a : -1
- }
- ,
- t.Parse = function(e, i, n, r, o) {
- void 0 === r && (r = !1);
- var a, s = e.name, l = null, c = null;
- if (a = i instanceof Ht ? i : i.getEngine(),
- e.customShader && a.createEffectForParticles) {
- var u = (c = e.customShader).shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join("\n") : "";
- l = a.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, u)
- }
- var h = new t(s,o || e.capacity,i,l,e.isAnimationSheetEnabled);
- if (h.customShader = c,
- h._rootUrl = n,
- e.id && (h.id = e.id),
- e.subEmitters) {
- h.subEmitters = [];
- for (var d = 0, p = e.subEmitters; d < p.length; d++) {
- for (var f = [], _ = 0, m = p[d]; _ < m.length; _++) {
- var g = m[_];
- f.push(py.Parse(g, i, n))
- }
- h.subEmitters.push(f)
- }
- }
- return t._Parse(e, h, i, n),
- e.textureMask && (h.textureMask = N.FromArray(e.textureMask)),
- e.preventAutoStart && (h.preventAutoStart = e.preventAutoStart),
- r || h.preventAutoStart || h.start(),
- h
- }
- ,
- t.BILLBOARDMODE_Y = a.PARTICLES_BILLBOARDMODE_Y,
- t.BILLBOARDMODE_ALL = a.PARTICLES_BILLBOARDMODE_ALL,
- t.BILLBOARDMODE_STRETCHED = a.PARTICLES_BILLBOARDMODE_STRETCHED,
- t
- }(Tf);
- py._ParseParticleSystem = fy.Parse;
- Pt.IncludesShadersStore.clipPlaneFragmentDeclaration2 = "#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nin float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nin float fClipDistance6;\n#endif\n";
- Pt.ShadersStore.gpuRenderParticlesPixelShader = "precision highp float;\nuniform sampler2D diffuseSampler;\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<clipPlaneFragmentDeclaration2> \n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main() {\n#include<clipPlaneFragment> \nvec4 textureColor=texture2D(diffuseSampler,vUV);\ngl_FragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;\ngl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\n#endif \n#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\ngl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);\ngl_FragColor=applyImageProcessing(gl_FragColor);\n#endif\n#endif\n}\n";
- Pt.IncludesShadersStore.clipPlaneVertexDeclaration2 = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nout float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nout float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nout float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nout float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nout float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nout float fClipDistance6;\n#endif\n";
- Pt.ShadersStore.gpuRenderParticlesVertexShader = "precision highp float;\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n#ifdef LOCAL\nuniform mat4 emitterWM;\n#endif\nattribute vec3 position;\nattribute float age;\nattribute float life;\nattribute vec3 size;\n#ifndef BILLBOARD\nattribute vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\nattribute float angle;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\nattribute vec2 offset;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vPositionW;\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nattribute vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix= mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture2D(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=(position+worldOffset)-eyePosition;\nyaxis.y=0.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(vPositionW,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=(position+worldOffset)-eyePosition;\nvPositionW=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(vPositionW,1.0));\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n#ifdef LOCAL\nvec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;\n#else\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\nvPositionW=(invView*viewPosition).xyz;\n#endif\n#else\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvPositionW=rotate(yaxis,rotatedCorner);\nvec4 viewPosition=view*vec4(vPositionW,1.0);\n#endif\ngl_Position=projection*viewPosition;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include<clipPlaneVertex>\n}";
- var _y = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = null),
- void 0 === o && (o = !1);
- var s = e.call(this, t) || this;
- if (s.layerMask = 268435455,
- s._accumulatedCount = 0,
- s._targetIndex = 0,
- s._currentRenderId = -1,
- s._currentRenderingCameraUniqueId = -1,
- s._started = !1,
- s._stopped = !1,
- s._timeDelta = 0,
- s._actualFrame = 0,
- s._rawTextureWidth = 256,
- s.onDisposeObservable = new h,
- s.onStoppedObservable = new h,
- s.forceDepthWrite = !1,
- s._preWarmDone = !1,
- s.isLocal = !1,
- s._onBeforeDrawParticlesObservable = null,
- n && "Scene" !== n.getClassName() ? (s._engine = n,
- s.defaultProjectionMatrix = P.PerspectiveFovLH(.8, 1, .1, 100, s._engine.isNDCHalfZRange)) : (s._scene = n || E.LastCreatedScene,
- s._engine = s._scene.getEngine(),
- s.uniqueId = s._scene.getUniqueId(),
- s._scene.particleSystems.push(s)),
- s._engine.getCaps().supportComputeShaders) {
- if (!b("BABYLON.ComputeShaderParticleSystem"))
- throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");
- s._platform = new (b("BABYLON.ComputeShaderParticleSystem"))(s,s._engine)
- } else {
- if (!b("BABYLON.WebGL2ParticleSystem"))
- throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");
- s._platform = new (b("BABYLON.WebGL2ParticleSystem"))(s,s._engine)
- }
- s._customWrappers = {
- 0: new Gt(s._engine)
- },
- s._customWrappers[0].effect = r,
- s._drawWrappers = {
- 0: new Gt(s._engine)
- },
- s._drawWrappers[0].drawContext && (s._drawWrappers[0].drawContext.useInstancing = !0),
- s._attachImageProcessingConfiguration(null),
- (i = null != i ? i : {}).randomTextureSize || delete i.randomTextureSize;
- var l = V({
- capacity: 5e4,
- randomTextureSize: s._engine.getCaps().maxTextureSize
- }, i)
- , c = i;
- isFinite(c) && (l.capacity = c),
- s._capacity = l.capacity,
- s._activeCount = l.capacity,
- s._currentActiveCount = 0,
- s._isAnimationSheetEnabled = o,
- s.particleEmitterType = new hf;
- for (var u = Math.min(s._engine.getCaps().maxTextureSize, l.randomTextureSize), d = [], p = 0; p < u; ++p)
- d.push(Math.random()),
- d.push(Math.random()),
- d.push(Math.random()),
- d.push(Math.random());
- for (s._randomTexture = new ao(new Float32Array(d),u,1,a.TEXTUREFORMAT_RGBA,n,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE,a.TEXTURETYPE_FLOAT),
- s._randomTexture.name = "GPUParticleSystem_random1",
- s._randomTexture.wrapU = a.TEXTURE_WRAP_ADDRESSMODE,
- s._randomTexture.wrapV = a.TEXTURE_WRAP_ADDRESSMODE,
- d = [],
- p = 0; p < u; ++p)
- d.push(Math.random()),
- d.push(Math.random()),
- d.push(Math.random()),
- d.push(Math.random());
- return s._randomTexture2 = new ao(new Float32Array(d),u,1,a.TEXTUREFORMAT_RGBA,n,!1,!1,a.TEXTURE_NEAREST_SAMPLINGMODE,a.TEXTURETYPE_FLOAT),
- s._randomTexture2.name = "GPUParticleSystem_random2",
- s._randomTexture2.wrapU = a.TEXTURE_WRAP_ADDRESSMODE,
- s._randomTexture2.wrapV = a.TEXTURE_WRAP_ADDRESSMODE,
- s._randomTextureSize = u,
- s
- }
- return U(t, e),
- Object.defineProperty(t, "IsSupported", {
- get: function() {
- if (!E.LastCreatedEngine)
- return !1;
- var e = E.LastCreatedEngine.getCaps();
- return e.supportTransformFeedbacks || e.supportComputeShaders
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getCapacity = function() {
- return this._capacity
- }
- ,
- Object.defineProperty(t.prototype, "activeParticleCount", {
- get: function() {
- return this._activeCount
- },
- set: function(e) {
- this._activeCount = Math.min(e, this._capacity)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.isReady = function() {
- if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
- return !1;
- if (this.blendMode !== fy.BLENDMODE_MULTIPLYADD) {
- if (!this._getWrapper(this.blendMode).effect.isReady())
- return !1
- } else {
- if (!this._getWrapper(fy.BLENDMODE_MULTIPLY).effect.isReady())
- return !1;
- if (!this._getWrapper(fy.BLENDMODE_ADD).effect.isReady())
- return !1
- }
- return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(),
- !1)
- }
- ,
- t.prototype.isStarted = function() {
- return this._started
- }
- ,
- t.prototype.isStopped = function() {
- return this._stopped
- }
- ,
- t.prototype.isStopping = function() {
- return !1
- }
- ,
- t.prototype.getActiveCount = function() {
- return this._currentActiveCount
- }
- ,
- t.prototype.start = function(e) {
- var t = this;
- if (void 0 === e && (e = this.startDelay),
- !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
- throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
- e ? setTimeout((function() {
- t.start(0)
- }
- ), e) : (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))
- }
- ,
- t.prototype.stop = function() {
- this._stopped || (this._stopped = !0)
- }
- ,
- t.prototype.reset = function() {
- this._releaseBuffers(),
- this._platform.releaseVertexBuffers(),
- this._currentActiveCount = 0,
- this._targetIndex = 0
- }
- ,
- t.prototype.getClassName = function() {
- return "GPUParticleSystem"
- }
- ,
- t.prototype.getCustomEffect = function(e) {
- var t, i;
- return void 0 === e && (e = 0),
- null !== (i = null === (t = this._customWrappers[e]) || void 0 === t ? void 0 : t.effect) && void 0 !== i ? i : this._customWrappers[0].effect
- }
- ,
- t.prototype._getCustomDrawWrapper = function(e) {
- var t;
- return void 0 === e && (e = 0),
- null !== (t = this._customWrappers[e]) && void 0 !== t ? t : this._customWrappers[0]
- }
- ,
- t.prototype.setCustomEffect = function(e, t) {
- void 0 === t && (t = 0),
- this._customWrappers[t] = new Gt(this._engine),
- this._customWrappers[t].effect = e
- }
- ,
- Object.defineProperty(t.prototype, "onBeforeDrawParticlesObservable", {
- get: function() {
- return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new h),
- this._onBeforeDrawParticlesObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "vertexShaderName", {
- get: function() {
- return "gpuRenderParticles"
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._removeGradientAndTexture = function(t, i, n) {
- return e.prototype._removeGradientAndTexture.call(this, t, i, n),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype.addColorGradient = function(e, t) {
- this._colorGradients || (this._colorGradients = []);
- var i = new ly(e,t);
- return this._colorGradients.push(i),
- this._refreshColorGradient(!0),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype._refreshColorGradient = function(e) {
- void 0 === e && (e = !1),
- this._colorGradients && (e && this._colorGradients.sort((function(e, t) {
- return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
- }
- )),
- this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
- this._colorGradientsTexture = null))
- }
- ,
- t.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()
- }
- ,
- t.prototype.removeColorGradient = function(e) {
- return this._removeGradientAndTexture(e, this._colorGradients, this._colorGradientsTexture),
- this._colorGradientsTexture = null,
- this
- }
- ,
- t.prototype.resetDrawCache = function() {
- var e;
- for (var t in this._drawWrappers)
- null === (e = this._drawWrappers[t].drawContext) || void 0 === e || e.reset()
- }
- ,
- t.prototype._addFactorGradient = function(e, t, i) {
- var n = new uy(t,i);
- e.push(n),
- this._releaseBuffers()
- }
- ,
- t.prototype.addSizeGradient = function(e, t) {
- return this._sizeGradients || (this._sizeGradients = []),
- this._addFactorGradient(this._sizeGradients, e, t),
- this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype.removeSizeGradient = function(e) {
- return this._removeGradientAndTexture(e, this._sizeGradients, this._sizeGradientsTexture),
- this._sizeGradientsTexture = null,
- this
- }
- ,
- t.prototype._refreshFactorGradient = function(e, t, i) {
- if (void 0 === i && (i = !1),
- e) {
- i && e.sort((function(e, t) {
- return e.gradient < t.gradient ? -1 : e.gradient > t.gradient ? 1 : 0
- }
- ));
- var n = this;
- n[t] && (n[t].dispose(),
- n[t] = null)
- }
- }
- ,
- t.prototype.addAngularSpeedGradient = function(e, t) {
- return this._angularSpeedGradients || (this._angularSpeedGradients = []),
- this._addFactorGradient(this._angularSpeedGradients, e, t),
- this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype.removeAngularSpeedGradient = function(e) {
- return this._removeGradientAndTexture(e, this._angularSpeedGradients, this._angularSpeedGradientsTexture),
- this._angularSpeedGradientsTexture = null,
- this
- }
- ,
- t.prototype.addVelocityGradient = function(e, t) {
- return this._velocityGradients || (this._velocityGradients = []),
- this._addFactorGradient(this._velocityGradients, e, t),
- this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype.removeVelocityGradient = function(e) {
- return this._removeGradientAndTexture(e, this._velocityGradients, this._velocityGradientsTexture),
- this._velocityGradientsTexture = null,
- this
- }
- ,
- t.prototype.addLimitVelocityGradient = function(e, t) {
- return this._limitVelocityGradients || (this._limitVelocityGradients = []),
- this._addFactorGradient(this._limitVelocityGradients, e, t),
- this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype.removeLimitVelocityGradient = function(e) {
- return this._removeGradientAndTexture(e, this._limitVelocityGradients, this._limitVelocityGradientsTexture),
- this._limitVelocityGradientsTexture = null,
- this
- }
- ,
- t.prototype.addDragGradient = function(e, t) {
- return this._dragGradients || (this._dragGradients = []),
- this._addFactorGradient(this._dragGradients, e, t),
- this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- t.prototype.removeDragGradient = function(e) {
- return this._removeGradientAndTexture(e, this._dragGradients, this._dragGradientsTexture),
- this._dragGradientsTexture = null,
- this
- }
- ,
- t.prototype.addEmitRateGradient = function() {
- return this
- }
- ,
- t.prototype.removeEmitRateGradient = function() {
- return this
- }
- ,
- t.prototype.addStartSizeGradient = function() {
- return this
- }
- ,
- t.prototype.removeStartSizeGradient = function() {
- return this
- }
- ,
- t.prototype.addColorRemapGradient = function() {
- return this
- }
- ,
- t.prototype.removeColorRemapGradient = function() {
- return this
- }
- ,
- t.prototype.addAlphaRemapGradient = function() {
- return this
- }
- ,
- t.prototype.removeAlphaRemapGradient = function() {
- return this
- }
- ,
- t.prototype.addRampGradient = function() {
- return this
- }
- ,
- t.prototype.removeRampGradient = function() {
- return this
- }
- ,
- t.prototype.getRampGradients = function() {
- return null
- }
- ,
- Object.defineProperty(t.prototype, "useRampGradients", {
- get: function() {
- return !1
- },
- set: function(e) {},
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.addLifeTimeGradient = function() {
- return this
- }
- ,
- t.prototype.removeLifeTimeGradient = function() {
- return this
- }
- ,
- t.prototype._reset = function() {
- this._releaseBuffers()
- }
- ,
- t.prototype._createVertexBuffers = function(e, t, i) {
- var n = {};
- n.position = t.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
- var r = 3;
- n.age = t.createVertexBuffer("age", r, 1, this._attributesStrideSize, !0),
- r += 1,
- n.size = t.createVertexBuffer("size", r, 3, this._attributesStrideSize, !0),
- r += 3,
- n.life = t.createVertexBuffer("life", r, 1, this._attributesStrideSize, !0),
- r += 1,
- r += 4,
- this.billboardMode === fy.BILLBOARDMODE_STRETCHED && (n.direction = t.createVertexBuffer("direction", r, 3, this._attributesStrideSize, !0)),
- r += 3,
- this._platform.alignDataInBuffer && (r += 1),
- this.particleEmitterType instanceof yf && (r += 3,
- this._platform.alignDataInBuffer && (r += 1)),
- this._colorGradientsTexture || (n.color = t.createVertexBuffer("color", r, 4, this._attributesStrideSize, !0),
- r += 4),
- this._isBillboardBased || (n.initialDirection = t.createVertexBuffer("initialDirection", r, 3, this._attributesStrideSize, !0),
- r += 3,
- this._platform.alignDataInBuffer && (r += 1)),
- this.noiseTexture && (n.noiseCoordinates1 = t.createVertexBuffer("noiseCoordinates1", r, 3, this._attributesStrideSize, !0),
- r += 3,
- this._platform.alignDataInBuffer && (r += 1),
- n.noiseCoordinates2 = t.createVertexBuffer("noiseCoordinates2", r, 3, this._attributesStrideSize, !0),
- r += 3,
- this._platform.alignDataInBuffer && (r += 1)),
- n.angle = t.createVertexBuffer("angle", r, 1, this._attributesStrideSize, !0),
- this._angularSpeedGradientsTexture ? r++ : r += 2,
- this._isAnimationSheetEnabled && (n.cellIndex = t.createVertexBuffer("cellIndex", r, 1, this._attributesStrideSize, !0),
- r += 1,
- this.spriteRandomStartCell && (n.cellStartOffset = t.createVertexBuffer("cellStartOffset", r, 1, this._attributesStrideSize, !0),
- r += 1)),
- n.offset = i.createVertexBuffer("offset", 0, 2),
- n.uv = i.createVertexBuffer("uv", 2, 2),
- this._platform.createVertexBuffers(e, n),
- this.resetDrawCache()
- }
- ,
- t.prototype._initialize = function(e) {
- if (void 0 === e && (e = !1),
- !this._buffer0 || e) {
- var t = this._engine
- , i = new Array;
- this._attributesStrideSize = 21,
- this._targetIndex = 0,
- this._platform.alignDataInBuffer && (this._attributesStrideSize += 1),
- this.particleEmitterType instanceof yf && (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 n = this.particleEmitterType instanceof yf, r = I.Vector3[0], o = 0, a = 0; a < this._capacity; a++)
- if (i.push(0),
- i.push(0),
- i.push(0),
- i.push(0),
- i.push(0),
- i.push(0),
- i.push(0),
- i.push(0),
- i.push(Math.random()),
- i.push(Math.random()),
- i.push(Math.random()),
- i.push(Math.random()),
- n ? (this.particleEmitterType.particleDestinationGenerator(a, null, r),
- i.push(r.x),
- i.push(r.y),
- i.push(r.z)) : (i.push(0),
- i.push(0),
- i.push(0)),
- this._platform.alignDataInBuffer && i.push(0),
- o += 16,
- n && (this.particleEmitterType.particlePositionGenerator(a, null, r),
- i.push(r.x),
- i.push(r.y),
- i.push(r.z),
- this._platform.alignDataInBuffer && i.push(0),
- o += 4),
- this._colorGradientsTexture || (i.push(0),
- i.push(0),
- i.push(0),
- i.push(0),
- o += 4),
- this.isBillboardBased || (i.push(0),
- i.push(0),
- i.push(0),
- this._platform.alignDataInBuffer && i.push(0),
- o += 4),
- this.noiseTexture && (i.push(Math.random()),
- i.push(Math.random()),
- i.push(Math.random()),
- this._platform.alignDataInBuffer && i.push(0),
- i.push(Math.random()),
- i.push(Math.random()),
- i.push(Math.random()),
- this._platform.alignDataInBuffer && i.push(0),
- o += 8),
- i.push(0),
- o += 1,
- this._angularSpeedGradientsTexture || (i.push(0),
- o += 1),
- this._isAnimationSheetEnabled && (i.push(0),
- o += 1,
- this.spriteRandomStartCell && (i.push(0),
- o += 1)),
- this._platform.alignDataInBuffer) {
- var s = 3 - (o + 3 & 3);
- for (o += s; s-- > 0; )
- i.push(0)
- }
- var l = new Float32Array([.5, .5, 1, 1, -.5, .5, 0, 1, .5, -.5, 1, 0, -.5, -.5, 0, 0])
- , c = this._platform.createParticleBuffer(i)
- , u = this._platform.createParticleBuffer(i);
- this._buffer0 = new wi(t,c,!1,this._attributesStrideSize),
- this._buffer1 = new wi(t,u,!1,this._attributesStrideSize),
- this._spriteBuffer = new wi(t,l,!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
- }
- }
- ,
- t.prototype._recreateUpdateEffect = function() {
- var e = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
- this._isBillboardBased && (e += "\n#define BILLBOARD"),
- this._colorGradientsTexture && (e += "\n#define COLORGRADIENTS"),
- this._sizeGradientsTexture && (e += "\n#define SIZEGRADIENTS"),
- this._angularSpeedGradientsTexture && (e += "\n#define ANGULARSPEEDGRADIENTS"),
- this._velocityGradientsTexture && (e += "\n#define VELOCITYGRADIENTS"),
- this._limitVelocityGradientsTexture && (e += "\n#define LIMITVELOCITYGRADIENTS"),
- this._dragGradientsTexture && (e += "\n#define DRAGGRADIENTS"),
- this.isAnimationSheetEnabled && (e += "\n#define ANIMATESHEET",
- this.spriteRandomStartCell && (e += "\n#define ANIMATESHEETRANDOMSTART")),
- this.noiseTexture && (e += "\n#define NOISE"),
- this.isLocal && (e += "\n#define LOCAL"),
- this._platform.isUpdateBufferCreated() && this._cachedUpdateDefines === e || (this._cachedUpdateDefines = e,
- this._updateBuffer = this._platform.createUpdateBuffer(e))
- }
- ,
- t.prototype._getWrapper = function(e) {
- var t = this._getCustomDrawWrapper(e);
- if (null == t ? void 0 : t.effect)
- return t;
- var i = [];
- this.fillDefines(i, e);
- var n = this._drawWrappers[e];
- n || ((n = new Gt(this._engine)).drawContext && (n.drawContext.useInstancing = !0),
- this._drawWrappers[e] = n);
- var r = i.join("\n");
- if (n.defines !== r) {
- var o = []
- , a = []
- , s = [];
- this.fillUniformsAttributesAndSamplerNames(a, o, s),
- n.setEffect(this._engine.createEffect("gpuRenderParticles", o, a, s, r), r)
- }
- return n
- }
- ,
- t._GetAttributeNamesOrOptions = function(e, t, i, n) {
- void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- void 0 === n && (n = !1);
- var r = [Bi.PositionKind, "age", "life", "size", "angle"];
- return e || r.push(Bi.ColorKind),
- t && r.push("cellIndex"),
- i || r.push("initialDirection"),
- n || r.push("direction"),
- r.push("offset", Bi.UVKind),
- r
- }
- ,
- t._GetEffectCreationOptions = function(e) {
- void 0 === e && (e = !1);
- var t = ["emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "translationPivot", "eyePosition"];
- return e && t.push("sheetInfos"),
- t
- }
- ,
- t.prototype.fillDefines = function(e, t) {
- if (void 0 === t && (t = 0),
- this._scene && (this._scene.clipPlane && e.push("#define CLIPPLANE"),
- this._scene.clipPlane2 && e.push("#define CLIPPLANE2"),
- this._scene.clipPlane3 && e.push("#define CLIPPLANE3"),
- this._scene.clipPlane4 && e.push("#define CLIPPLANE4"),
- this._scene.clipPlane5 && e.push("#define CLIPPLANE5"),
- this._scene.clipPlane6 && e.push("#define CLIPPLANE6")),
- t === fy.BLENDMODE_MULTIPLY && e.push("#define BLENDMULTIPLYMODE"),
- this.isLocal && e.push("#define LOCAL"),
- this._isBillboardBased)
- switch (e.push("#define BILLBOARD"),
- this.billboardMode) {
- case fy.BILLBOARDMODE_Y:
- e.push("#define BILLBOARDY");
- break;
- case fy.BILLBOARDMODE_STRETCHED:
- e.push("#define BILLBOARDSTRETCHED");
- break;
- case fy.BILLBOARDMODE_ALL:
- e.push("#define BILLBOARDMODE_ALL")
- }
- this._colorGradientsTexture && e.push("#define COLORGRADIENTS"),
- this.isAnimationSheetEnabled && e.push("#define ANIMATESHEET"),
- this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
- e.push("" + this._imageProcessingConfigurationDefines.toString()))
- }
- ,
- t.prototype.fillUniformsAttributesAndSamplerNames = function(e, i, n) {
- i.push.apply(i, t._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === fy.BILLBOARDMODE_STRETCHED)),
- e.push.apply(e, t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
- n.push("diffuseSampler", "colorGradientSampler"),
- this._imageProcessingConfiguration && (Ri.PrepareUniforms(e, this._imageProcessingConfigurationDefines),
- Ri.PrepareSamplers(n, this._imageProcessingConfigurationDefines))
- }
- ,
- t.prototype.animate = function(e) {
- var t;
- void 0 === e && (e = !1),
- this._timeDelta = this.updateSpeed * (e ? this.preWarmStepOffset : (null === (t = this._scene) || void 0 === t ? void 0 : t.getAnimationRatio()) || 1),
- this._actualFrame += this._timeDelta,
- this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()
- }
- ,
- t.prototype._createFactorGradientTexture = function(e, t) {
- var i = this[t];
- if (e && e.length && !i) {
- for (var n = new Float32Array(this._rawTextureWidth), r = function(t) {
- var i = t / o._rawTextureWidth;
- hy.GetCurrentGradient(i, e, (function(e, i, r) {
- n[t] = d.Lerp(e.factor1, i.factor1, r)
- }
- ))
- }, o = this, s = 0; s < this._rawTextureWidth; s++)
- r(s);
- this[t] = ao.CreateRTexture(n, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
- }
- }
- ,
- t.prototype._createSizeGradientTexture = function() {
- this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture")
- }
- ,
- t.prototype._createAngularSpeedGradientTexture = function() {
- this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture")
- }
- ,
- t.prototype._createVelocityGradientTexture = function() {
- this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture")
- }
- ,
- t.prototype._createLimitVelocityGradientTexture = function() {
- this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture")
- }
- ,
- t.prototype._createDragGradientTexture = function() {
- this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture")
- }
- ,
- t.prototype._createColorGradientTexture = function() {
- if (this._colorGradients && this._colorGradients.length && !this._colorGradientsTexture) {
- for (var e = new Uint8Array(4 * this._rawTextureWidth), t = L.Color4[0], i = function(i) {
- var r = i / n._rawTextureWidth;
- hy.GetCurrentGradient(r, n._colorGradients, (function(n, r, o) {
- N.LerpToRef(n.color1, r.color1, o, t),
- e[4 * i] = 255 * t.r,
- e[4 * i + 1] = 255 * t.g,
- e[4 * i + 2] = 255 * t.b,
- e[4 * i + 3] = 255 * t.a
- }
- ))
- }, n = this, r = 0; r < this._rawTextureWidth; r++)
- i(r);
- this._colorGradientsTexture = ao.CreateRGBATexture(e, this._rawTextureWidth, 1, this._scene, !1, !1, a.TEXTURE_NEAREST_SAMPLINGMODE)
- }
- }
- ,
- t.prototype._render = function(e, t) {
- var i, n, r = this._getWrapper(e), o = r.effect;
- this._engine.enableEffect(r);
- var s = (null === (i = this._scene) || void 0 === i ? void 0 : i.getViewMatrix()) || P.IdentityReadOnly;
- if (o.setMatrix("view", s),
- o.setMatrix("projection", null !== (n = this.defaultProjectionMatrix) && void 0 !== n ? n : this._scene.getProjectionMatrix()),
- o.setTexture("diffuseSampler", this.particleTexture),
- o.setVector2("translationPivot", this.translationPivot),
- o.setVector3("worldOffset", this.worldOffset),
- this.isLocal && o.setMatrix("emitterWM", t),
- this._colorGradientsTexture ? o.setTexture("colorGradientSampler", this._colorGradientsTexture) : o.setDirectColor4("colorDead", this.colorDead),
- this._isAnimationSheetEnabled && this.particleTexture) {
- var l = this.particleTexture.getBaseSize();
- o.setFloat3("sheetInfos", this.spriteCellWidth / l.width, this.spriteCellHeight / l.height, l.width / this.spriteCellWidth)
- }
- if (this._isBillboardBased && this._scene) {
- var c = this._scene.activeCamera;
- o.setVector3("eyePosition", c.globalPosition)
- }
- var u = o.defines;
- if (this._scene && (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) && Mr.BindClipPlane(o, this._scene),
- u.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
- var h = s.clone();
- h.invert(),
- o.setMatrix("invView", h)
- }
- switch (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(o),
- e) {
- case fy.BLENDMODE_ADD:
- this._engine.setAlphaMode(a.ALPHA_ADD);
- break;
- case fy.BLENDMODE_ONEONE:
- this._engine.setAlphaMode(a.ALPHA_ONEONE);
- break;
- case fy.BLENDMODE_STANDARD:
- this._engine.setAlphaMode(a.ALPHA_COMBINE);
- break;
- case fy.BLENDMODE_MULTIPLY:
- this._engine.setAlphaMode(a.ALPHA_MULTIPLY)
- }
- return this._platform.bindDrawBuffers(this._targetIndex, o),
- this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(o),
- this._engine.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, this._currentActiveCount),
- this._engine.setAlphaMode(a.ALPHA_DISABLE),
- this._currentActiveCount
- }
- ,
- t.prototype.render = function(e, t) {
- if (void 0 === e && (e = !1),
- void 0 === t && (t = !1),
- !this._started)
- return 0;
- if (this._createColorGradientTexture(),
- this._createSizeGradientTexture(),
- this._createAngularSpeedGradientTexture(),
- this._createVelocityGradientTexture(),
- this._createLimitVelocityGradientTexture(),
- this._createDragGradientTexture(),
- this._recreateUpdateEffect(),
- !this.isReady())
- return 0;
- if (!e && this._scene) {
- if (!this._preWarmDone && this.preWarmCycles) {
- for (var i = 0; i < this.preWarmCycles; i++)
- 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 n = 0 | this._accumulatedCount;
- this._accumulatedCount -= n,
- this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + n)
- }
- if (!this._currentActiveCount)
- return 0;
- var r;
- if (this.emitter.position)
- r = this.emitter.getWorldMatrix();
- else {
- var o = this.emitter;
- r = P.Translation(o.x, o.y, o.z)
- }
- var s = 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", r),
- this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
- var l = 0;
- e || t || (s.setState(!1),
- this.forceDepthWrite && s.setDepthWrite(!0),
- l = this.blendMode === fy.BLENDMODE_MULTIPLYADD ? this._render(fy.BLENDMODE_MULTIPLY, r) + this._render(fy.BLENDMODE_ADD, r) : this._render(this.blendMode, r),
- this._engine.setAlphaMode(a.ALPHA_DISABLE)),
- this._targetIndex++,
- 2 === this._targetIndex && (this._targetIndex = 0);
- var c = this._sourceBuffer;
- return this._sourceBuffer = this._targetBuffer,
- this._targetBuffer = c,
- l
- }
- ,
- t.prototype.rebuild = function() {
- this._initialize(!0)
- }
- ,
- t.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()
- }
- ,
- t.prototype.dispose = function(e) {
- for (var t in void 0 === e && (e = !0),
- this._drawWrappers)
- this._drawWrappers[t].dispose();
- if (this._drawWrappers = {},
- this._scene) {
- var i = this._scene.particleSystems.indexOf(this);
- i > -1 && this._scene.particleSystems.splice(i, 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),
- e && this.particleTexture && (this.particleTexture.dispose(),
- this.particleTexture = null),
- e && this.noiseTexture && (this.noiseTexture.dispose(),
- this.noiseTexture = null),
- this.onStoppedObservable.clear(),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- t.prototype.clone = function(e, i) {
- var n = V({}, this._customWrappers)
- , r = null
- , o = this._engine;
- if (o.createEffectForParticles && null != this.customShader) {
- var a = (r = this.customShader).shaderOptions.defines.length > 0 ? r.shaderOptions.defines.join("\n") : "";
- n[0] = o.createEffectForParticles(r.shaderPath.fragmentElement, r.shaderOptions.uniforms, r.shaderOptions.samplers, a, void 0, void 0, void 0, this)
- }
- var s = this.serialize()
- , l = t.Parse(s, this._scene || this._engine, this._rootUrl);
- return l.name = e,
- l.customShader = r,
- l._customWrappers = n,
- void 0 === i && (i = this.emitter),
- this.noiseTexture && (l.noiseTexture = this.noiseTexture.clone()),
- l.emitter = i,
- l
- }
- ,
- t.prototype.serialize = function(e) {
- void 0 === e && (e = !1);
- var t = {};
- return fy._Serialize(t, this, e),
- t.activeParticleCount = this.activeParticleCount,
- t.randomTextureSize = this._randomTextureSize,
- t.customShader = this.customShader,
- t
- }
- ,
- t.Parse = function(e, i, n, r, o) {
- void 0 === r && (r = !1);
- var a, s = e.name;
- a = i instanceof Ht ? i : i.getEngine();
- var l = new t(s,{
- capacity: o || e.capacity,
- randomTextureSize: e.randomTextureSize
- },i,null,e.isAnimationSheetEnabled);
- if (l._rootUrl = n,
- e.customShader && a.createEffectForParticles) {
- var c = e.customShader
- , u = c.shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join("\n") : ""
- , h = a.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, u, void 0, void 0, void 0, l);
- l.setCustomEffect(h, 0),
- l.customShader = c
- }
- return e.id && (l.id = e.id),
- e.activeParticleCount && (l.activeParticleCount = e.activeParticleCount),
- fy._Parse(e, l, i, n),
- e.preventAutoStart && (l.preventAutoStart = e.preventAutoStart),
- r || l.preventAutoStart || l.start(),
- l
- }
- ,
- t
- }(Tf)
- , my = function() {
- function e() {
- this._emitterNodeIsOwned = !0,
- this.systems = new Array
- }
- return Object.defineProperty(e.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 t = 0, i = this.systems; t < i.length; t++)
- i[t].emitter = e;
- this._emitterNode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setEmitterAsSphere = function(e, t, i) {
- this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(),
- this._emitterNodeIsOwned = !0,
- this._emitterCreationOptions = {
- kind: "Sphere",
- options: e,
- renderingGroupId: t
- };
- var n = Dl("emitterSphere", {
- diameter: e.diameter,
- segments: e.segments
- }, i);
- n.renderingGroupId = t;
- var r = new Os("emitterSphereMaterial",i);
- r.emissiveColor = e.color,
- n.material = r;
- for (var o = 0, a = this.systems; o < a.length; o++)
- a[o].emitter = n;
- this._emitterNode = n
- }
- ,
- e.prototype.start = function(e) {
- for (var t = 0, i = this.systems; t < i.length; t++) {
- var n = i[t];
- e && (n.emitter = e),
- n.start()
- }
- }
- ,
- e.prototype.dispose = function() {
- for (var e = 0, t = this.systems; e < t.length; e++)
- t[e].dispose();
- this.systems = [],
- this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
- this._emitterNode = null)
- }
- ,
- e.prototype.serialize = function(e) {
- void 0 === e && (e = !1);
- for (var t = {
- systems: []
- }, i = 0, n = this.systems; i < n.length; i++) {
- var r = n[i];
- t.systems.push(r.serialize(e))
- }
- return this._emitterNode && (t.emitter = this._emitterCreationOptions),
- t
- }
- ,
- e.Parse = function(t, i, n, r) {
- void 0 === n && (n = !1);
- var o = new e
- , a = this.BaseAssetsUrl + "/textures/";
- i = i || E.LastCreatedScene;
- for (var s = 0, l = t.systems; s < l.length; s++) {
- var c = l[s];
- o.systems.push(n ? _y.Parse(c, i, a, !0, r) : fy.Parse(c, i, a, !0, r))
- }
- if (t.emitter) {
- var u = t.emitter.options;
- "Sphere" === t.emitter.kind && o.setEmitterAsSphere({
- diameter: u.diameter,
- segments: u.segments,
- color: D.FromArray(u.color)
- }, t.emitter.renderingGroupId, i)
- }
- return o
- }
- ,
- e.BaseAssetsUrl = "https://assets.babylonjs.com/particles",
- e
- }()
- , gy = function() {
- function e() {}
- return e.CreateDefault = function(e, t, i, n) {
- var r;
- return void 0 === t && (t = 500),
- void 0 === n && (n = !1),
- (r = n ? new _y("default system",{
- capacity: t
- },i) : new fy("default system",t,i)).emitter = e,
- r.particleTexture = new io("https://www.babylonjs.com/assets/Flare.png",r.getScene()),
- r.createConeEmitter(.1, Math.PI / 4),
- r.color1 = new N(1,1,1,1),
- r.color2 = new N(1,1,1,1),
- r.colorDead = new N(1,1,1,0),
- r.minSize = .1,
- r.maxSize = .1,
- r.minEmitPower = 2,
- r.maxEmitPower = 2,
- r.updateSpeed = 1 / 60,
- r.emitRate = 30,
- r
- }
- ,
- e.CreateAsync = function(t, i, n, r) {
- void 0 === n && (n = !1),
- i || (i = E.LastCreatedScene);
- var o = {};
- return i._addPendingData(o),
- new Promise((function(a, s) {
- if (n && !_y.IsSupported)
- return i._removePendingData(o),
- s("Particle system with GPU is not supported.");
- gi.LoadFile("".concat(e.BaseAssetsUrl, "/systems/").concat(t, ".json"), (function(e) {
- i._removePendingData(o);
- var t = JSON.parse(e.toString());
- return a(my.Parse(t, i, n, r))
- }
- ), void 0, void 0, void 0, (function() {
- return i._removePendingData(o),
- s("An error occurred with the creation of your particle system. Check if your type '".concat(t, "' exists."))
- }
- ))
- }
- ))
- }
- ,
- e.ExportSet = function(e) {
- for (var t = new my, i = 0, n = e; i < n.length; i++) {
- var r = n[i];
- t.systems.push(r)
- }
- return t
- }
- ,
- e.ParseFromFileAsync = function(e, t, i, n, r, o) {
- return void 0 === n && (n = !1),
- void 0 === r && (r = ""),
- new Promise((function(a, s) {
- var l = new Ye;
- l.addEventListener("readystatechange", (function() {
- if (4 == l.readyState)
- if (200 == l.status) {
- var t = JSON.parse(l.responseText)
- , c = void 0;
- c = n ? _y.Parse(t, i, r, !1, o) : fy.Parse(t, i, r, !1, o),
- e && (c.name = e),
- a(c)
- } else
- s("Unable to load the particle system")
- }
- )),
- l.open("GET", t),
- l.send()
- }
- ))
- }
- ,
- e.CreateFromSnippetAsync = function(e, t, i, n, r) {
- var o = this;
- if (void 0 === i && (i = !1),
- void 0 === n && (n = ""),
- "_BLANK" === e) {
- var a = this.CreateDefault(null);
- return a.start(),
- Promise.resolve(a)
- }
- return new Promise((function(a, s) {
- var l = new Ye;
- l.addEventListener("readystatechange", (function() {
- if (4 == l.readyState)
- if (200 == l.status) {
- var o = JSON.parse(JSON.parse(l.responseText).jsonPayload)
- , c = JSON.parse(o.particleSystem)
- , u = void 0;
- (u = i ? _y.Parse(c, t, n, !1, r) : fy.Parse(c, t, n, !1, r)).snippetId = e,
- a(u)
- } else
- s("Unable to load the snippet " + e)
- }
- )),
- l.open("GET", o.SnippetUrl + "/" + e.replace(/#/g, "/")),
- l.send()
- }
- ))
- }
- ,
- e.BaseAssetsUrl = my.BaseAssetsUrl,
- e.SnippetUrl = "https://snippet.babylonjs.com",
- e
- }();
- o.AddParser(Wi.NAME_PARTICLESYSTEM, (function(e, t, i, n) {
- var r = o.GetIndividualParser(Wi.NAME_PARTICLESYSTEM);
- if (r && void 0 !== e.particleSystems && null !== e.particleSystems)
- for (var a = 0, s = e.particleSystems.length; a < s; a++) {
- var l = e.particleSystems[a];
- i.particleSystems.push(r(l, t, n))
- }
- }
- )),
- o.AddIndividualParser(Wi.NAME_PARTICLESYSTEM, (function(e, t, i) {
- return e.activeParticleCount ? _y.Parse(e, t, i) : fy.Parse(e, t, i)
- }
- )),
- vr.prototype.createEffectForParticles = function(e, t, i, n, r, o, a, s) {
- var l;
- void 0 === t && (t = []),
- void 0 === i && (i = []),
- void 0 === n && (n = "");
- var c = []
- , u = []
- , h = [];
- return s ? s.fillUniformsAttributesAndSamplerNames(u, c, h) : (c = fy._GetAttributeNamesOrOptions(),
- u = fy._GetEffectCreationOptions()),
- -1 === n.indexOf(" BILLBOARD") && (n += "\n#define BILLBOARD\n"),
- -1 === i.indexOf("diffuseSampler") && i.push("diffuseSampler"),
- this.createEffect({
- vertex: null !== (l = null == s ? void 0 : s.vertexShaderName) && void 0 !== l ? l : "particles",
- fragmentElement: e
- }, c, u.concat(t), h.concat(i), n, r, o, a)
- }
- ,
- Vr.prototype.getEmittedParticleSystems = function() {
- for (var e = new Array, t = 0; t < this.getScene().particleSystems.length; t++) {
- var i = this.getScene().particleSystems[t];
- i.emitter === this && e.push(i)
- }
- return e
- }
- ,
- Vr.prototype.getHierarchyEmittedParticleSystems = function() {
- var e = new Array
- , t = this.getDescendants();
- t.push(this);
- for (var i = 0; i < this.getScene().particleSystems.length; i++) {
- var n = this.getScene().particleSystems[i]
- , r = n.emitter;
- r.position && -1 !== t.indexOf(r) && e.push(n)
- }
- return e
- }
- ;
- var vy, yy = function() {
- function e(e, t, i, n, r, o, a, s, l, c) {
- void 0 === l && (l = null),
- void 0 === c && (c = null),
- this.idx = 0,
- this.id = 0,
- this.color = new N(1,1,1,1),
- this.position = x.Zero(),
- this.rotation = x.Zero(),
- this.scaling = x.One(),
- this.uvs = new R(0,0,1,1),
- this.velocity = x.Zero(),
- this.pivot = x.Zero(),
- this.translateFromPivot = !1,
- this.alive = !0,
- this.isVisible = !0,
- this._pos = 0,
- this._ind = 0,
- this.shapeId = 0,
- this.idxInShape = 0,
- this._stillInvisible = !1,
- this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1],
- this.parentId = null,
- this.materialIndex = null,
- this.props = null,
- this.cullingStrategy = Sr.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
- this._globalPosition = x.Zero(),
- this.idx = e,
- this.id = t,
- this._pos = i,
- this._ind = n,
- this._model = r,
- this.shapeId = o,
- this.idxInShape = a,
- this._sps = s,
- l && (this._modelBoundingInfo = l,
- this._boundingInfo = new sr(l.minimum,l.maximum)),
- null !== c && (this.materialIndex = c)
- }
- return e.prototype.getBoundingInfo = function() {
- return this._boundingInfo
- }
- ,
- Object.defineProperty(e.prototype, "hasBoundingInfo", {
- get: function() {
- return null !== this._boundingInfo
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.copyToRef = function(e) {
- return e.position.copyFrom(this.position),
- e.rotation.copyFrom(this.rotation),
- this.rotationQuaternion && (e.rotationQuaternion ? e.rotationQuaternion.copyFrom(this.rotationQuaternion) : e.rotationQuaternion = this.rotationQuaternion.clone()),
- e.scaling.copyFrom(this.scaling),
- this.color && (e.color ? e.color.copyFrom(this.color) : e.color = this.color.clone()),
- e.uvs.copyFrom(this.uvs),
- e.velocity.copyFrom(this.velocity),
- e.pivot.copyFrom(this.pivot),
- e.translateFromPivot = this.translateFromPivot,
- e.alive = this.alive,
- e.isVisible = this.isVisible,
- e.parentId = this.parentId,
- e.cullingStrategy = this.cullingStrategy,
- null !== this.materialIndex && (e.materialIndex = this.materialIndex),
- this
- }
- ,
- Object.defineProperty(e.prototype, "scale", {
- get: function() {
- return this.scaling
- },
- set: function(e) {
- this.scaling = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "quaternion", {
- get: function() {
- return this.rotationQuaternion
- },
- set: function(e) {
- this.rotationQuaternion = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.intersectsMesh = function(e) {
- return !(!this._boundingInfo || !e.hasBoundingInfo) && (this._sps._bSphereOnly ? ir.Intersects(this._boundingInfo.boundingSphere, e.getBoundingInfo().boundingSphere) : this._boundingInfo.intersects(e.getBoundingInfo(), !1))
- }
- ,
- e.prototype.isInFrustum = function(e) {
- return null !== this._boundingInfo && this._boundingInfo.isInFrustum(e, this.cullingStrategy)
- }
- ,
- e.prototype.getRotationMatrix = function(e) {
- var t;
- if (this.rotationQuaternion)
- t = this.rotationQuaternion;
- else {
- t = I.Quaternion[0];
- var i = this.rotation;
- C.RotationYawPitchRollToRef(i.y, i.x, i.z, t)
- }
- t.toRotationMatrix(e)
- }
- ,
- e
- }(), by = function() {
- function e(e, t, i, n, r, o, a, s, l) {
- this._indicesLength = 0,
- this.shapeId = e,
- this._shape = t,
- this._indices = i,
- this._indicesLength = i.length,
- this._shapeUV = o,
- this._shapeColors = r,
- this._normals = n,
- this._positionFunction = a,
- this._vertexFunction = s,
- this._material = l
- }
- return Object.defineProperty(e.prototype, "shapeID", {
- get: function() {
- return this.shapeId
- },
- set: function(e) {
- this.shapeId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(), Ty = function(e, t, i, n) {
- this.idx = 0,
- this.ind = 0,
- this.indicesLength = 0,
- this.sqDistance = 0,
- this.materialIndex = 0,
- this.idx = e,
- this.ind = t,
- this.indicesLength = i,
- this.materialIndex = n
- }, Ey = function() {
- function e() {
- this.position = x.Zero(),
- this.color = new N(1,1,1,1),
- this.uv = A.Zero()
- }
- return Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this.position.x
- },
- set: function(e) {
- this.position.x = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this.position.y
- },
- set: function(e) {
- this.position.y = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "z", {
- get: function() {
- return this.position.z
- },
- set: function(e) {
- this.position.z = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(), Sy = function() {
- function e(e, t, i) {
- this.particles = new Array,
- this.nbParticles = 0,
- this.billboard = !1,
- this.recomputeNormals = !1,
- this.counter = 0,
- this.vars = {},
- this._bSphereOnly = !1,
- this._bSphereRadiusFactor = 1,
- this._positions = new Array,
- this._indices = new Array,
- this._normals = new Array,
- this._colors = new Array,
- this._uvs = new Array,
- this._index = 0,
- this._updatable = !0,
- this._pickable = !1,
- this._isVisibilityBoxLocked = !1,
- this._alwaysVisible = !1,
- this._depthSort = !1,
- this._expandable = !1,
- this._shapeCounter = 0,
- this._copy = new yy(0,0,0,0,null,0,0,this),
- this._color = new N(0,0,0,0),
- this._computeParticleColor = !0,
- this._computeParticleTexture = !0,
- this._computeParticleRotation = !0,
- this._computeParticleVertex = !1,
- this._computeBoundingBox = !1,
- this._depthSortParticles = !0,
- this._mustUnrotateFixedNormals = !1,
- this._particlesIntersect = !1,
- this._needs32Bits = !1,
- this._isNotBuilt = !0,
- this._lastParticleId = 0,
- this._idxOfId = [],
- this._multimaterialEnabled = !1,
- this._useModelMaterial = !1,
- this._depthSortFunction = function(e, t) {
- return t.sqDistance - e.sqDistance
- }
- ,
- this._materialSortFunction = function(e, t) {
- return e.materialIndex - t.materialIndex
- }
- ,
- this._autoUpdateSubMeshes = !1,
- this.name = e,
- this._scene = t || E.LastCreatedScene,
- this._camera = t.activeCamera,
- this._pickable = !!i && i.isPickable,
- this._depthSort = !!i && i.enableDepthSort,
- this._multimaterialEnabled = !!i && i.enableMultiMaterial,
- this._useModelMaterial = !!i && i.useModelMaterial,
- this._multimaterialEnabled = !!this._useModelMaterial || this._multimaterialEnabled,
- this._expandable = !!i && i.expandable,
- this._particlesIntersect = !!i && i.particleIntersection,
- this._bSphereOnly = !!i && i.boundingSphereOnly,
- this._bSphereRadiusFactor = i && i.bSphereRadiusFactor ? i.bSphereRadiusFactor : 1,
- i && void 0 !== i.updatable ? this._updatable = i.updatable : this._updatable = !0,
- this._pickable && (this.pickedBySubMesh = [[]],
- this.pickedParticles = this.pickedBySubMesh[0]),
- (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []),
- this._multimaterialEnabled && (this._multimaterial = new Dr(this.name + "MultiMaterial",this._scene),
- this._materials = [],
- this._materialIndexesById = {}),
- this._tmpVertex = new Ey
- }
- return e.prototype.buildMesh = function() {
- if (!this._isNotBuilt && this.mesh)
- return this.mesh;
- if (0 === this.nbParticles && !this.mesh) {
- var e = Pd("", {
- radius: 1,
- tessellation: 3
- }, this._scene);
- this.addShape(e, 1),
- e.dispose()
- }
- if (this._indices32 = this._needs32Bits ? new Uint32Array(this._indices) : new Uint16Array(this._indices),
- this._positions32 = new Float32Array(this._positions),
- this._uvs32 = new Float32Array(this._uvs),
- this._colors32 = new Float32Array(this._colors),
- !this.mesh) {
- var t = new Vr(this.name,this._scene);
- this.mesh = t
- }
- !this._updatable && this._multimaterialEnabled && this._sortParticlesByMaterial(),
- this.recomputeNormals && $n.ComputeNormals(this._positions32, this._indices32, this._normals),
- this._normals32 = new Float32Array(this._normals),
- this._fixedNormal32 = new Float32Array(this._normals),
- this._mustUnrotateFixedNormals && this._unrotateFixedNormals();
- var i = new $n;
- if (i.indices = this._depthSort ? this._indices : this._indices32,
- i.set(this._positions32, Bi.PositionKind),
- i.set(this._normals32, Bi.NormalKind),
- this._uvs32.length > 0 && i.set(this._uvs32, Bi.UVKind),
- this._colors32.length > 0 && i.set(this._colors32, Bi.ColorKind),
- i.applyToMesh(this.mesh, this._updatable),
- this.mesh.isPickable = this._pickable,
- this._pickable)
- for (var n = 0, r = 0; r < this.nbParticles; r++)
- for (var o = this.particles[r], a = o._model._indicesLength, s = 0; s < a; s++)
- if (0 == s % 3) {
- var l = {
- idx: o.idx,
- faceId: n
- };
- this.pickedParticles[n] = l,
- n++
- }
- return this._multimaterialEnabled && this.setMultiMaterial(this._materials),
- this._expandable || (this._depthSort || this._multimaterialEnabled || (this._indices = null),
- this._positions = null,
- this._normals = null,
- this._uvs = null,
- this._colors = null,
- this._updatable || (this.particles.length = 0)),
- this._isNotBuilt = !1,
- this.recomputeNormals = !1,
- this.mesh
- }
- ,
- e.prototype.digest = function(e, t) {
- var i = t && t.facetNb || 1
- , n = t && t.number || 0
- , r = t && t.delta || 0
- , o = e.getVerticesData(Bi.PositionKind)
- , a = e.getIndices()
- , s = e.getVerticesData(Bi.UVKind)
- , l = e.getVerticesData(Bi.ColorKind)
- , c = e.getVerticesData(Bi.NormalKind)
- , u = t && t.storage ? t.storage : null
- , h = 0
- , d = a.length / 3;
- n ? (n = n > d ? d : n,
- i = Math.round(d / n),
- r = 0) : i = i > d ? d : i;
- for (var p = [], f = [], _ = [], m = [], g = [], v = x.Zero(), y = i; h < d; ) {
- h > d - (i = y + Math.floor((1 + r) * Math.random())) && (i = d - h),
- p.length = 0,
- f.length = 0,
- _.length = 0,
- m.length = 0,
- g.length = 0;
- for (var b = 0, T = 3 * h; T < 3 * (h + i); T++) {
- _.push(b);
- var E = a[T]
- , S = 3 * E;
- if (p.push(o[S], o[S + 1], o[S + 2]),
- f.push(c[S], c[S + 1], c[S + 2]),
- s) {
- var A = 2 * E;
- m.push(s[A], s[A + 1])
- }
- if (l) {
- var R = 4 * E;
- g.push(l[R], l[R + 1], l[R + 2], l[R + 3])
- }
- b++
- }
- var C = this.nbParticles
- , P = this._posToShape(p)
- , M = this._uvsToShapeUV(m)
- , I = gi.Slice(_)
- , O = gi.Slice(g)
- , D = gi.Slice(f);
- v.copyFromFloats(0, 0, 0);
- var N = void 0;
- for (N = 0; N < P.length; N++)
- v.addInPlace(P[N]);
- v.scaleInPlace(1 / P.length);
- var L = new x(1 / 0,1 / 0,1 / 0)
- , F = new x(-1 / 0,-1 / 0,-1 / 0);
- for (N = 0; N < P.length; N++)
- P[N].subtractInPlace(v),
- L.minimizeInPlaceFromFloats(P[N].x, P[N].y, P[N].z),
- F.maximizeInPlaceFromFloats(P[N].x, P[N].y, P[N].z);
- var w = void 0;
- this._particlesIntersect && (w = new sr(L,F));
- var B = null;
- this._useModelMaterial && (B = e.material ? e.material : this._setDefaultMaterial());
- var U = new by(this._shapeCounter,P,I,D,O,M,null,null,B)
- , V = this._positions.length
- , k = this._indices.length;
- this._meshBuilder(this._index, k, P, this._positions, I, this._indices, m, this._uvs, O, this._colors, D, this._normals, C, 0, null, U),
- this._addParticle(C, this._lastParticleId, V, k, U, this._shapeCounter, 0, w, u),
- this.particles[this.nbParticles].position.addInPlace(v),
- u || (this._index += P.length,
- C++,
- this.nbParticles++,
- this._lastParticleId++),
- this._shapeCounter++,
- h += i
- }
- return this._isNotBuilt = !0,
- this
- }
- ,
- e.prototype._unrotateFixedNormals = function() {
- for (var e = 0, t = 0, i = I.Vector3[0], n = I.Quaternion[0], r = I.Matrix[0], o = 0; o < this.particles.length; o++) {
- var a = this.particles[o]
- , s = a._model._shape;
- if (a.rotationQuaternion)
- a.rotationQuaternion.conjugateToRef(n);
- else {
- var l = a.rotation;
- C.RotationYawPitchRollToRef(l.y, l.x, l.z, n),
- n.conjugateInPlace()
- }
- n.toRotationMatrix(r);
- for (var c = 0; c < s.length; c++)
- t = e + 3 * c,
- x.TransformNormalFromFloatsToRef(this._normals32[t], this._normals32[t + 1], this._normals32[t + 2], r, i),
- i.toArray(this._fixedNormal32, t);
- e = t + 3
- }
- }
- ,
- e.prototype._resetCopy = function() {
- var e = this._copy;
- e.position.setAll(0),
- e.rotation.setAll(0),
- e.rotationQuaternion = null,
- e.scaling.setAll(1),
- e.uvs.copyFromFloats(0, 0, 1, 1),
- e.color = null,
- e.translateFromPivot = !1,
- e.shapeId = 0,
- e.materialIndex = null
- }
- ,
- e.prototype._meshBuilder = function(e, t, i, n, r, o, a, s, l, c, u, h, d, p, f, _) {
- var m, g = 0, v = 0, y = 0;
- this._resetCopy();
- var b = this._copy
- , T = !(!f || !f.storage);
- if (b.idx = d,
- b.idxInShape = p,
- b.shapeId = _.shapeId,
- this._useModelMaterial) {
- var E = _._material.uniqueId
- , S = this._materialIndexesById;
- Object.prototype.hasOwnProperty.call(S, E) || (S[E] = this._materials.length,
- this._materials.push(_._material));
- var A = S[E];
- b.materialIndex = A
- }
- if (f && f.positionFunction && (f.positionFunction(b, d, p),
- this._mustUnrotateFixedNormals = !0),
- T)
- return b;
- var R = I.Matrix[0]
- , C = this._tmpVertex
- , M = C.position
- , O = C.color
- , D = C.uv
- , N = I.Vector3[1]
- , L = I.Vector3[2]
- , F = I.Vector3[3];
- P.IdentityToRef(R),
- b.getRotationMatrix(R),
- b.pivot.multiplyToRef(b.scaling, F),
- b.translateFromPivot ? L.setAll(0) : L.copyFrom(F);
- var w = f && f.vertexFunction;
- for (m = 0; m < i.length; m++) {
- if (M.copyFrom(i[m]),
- b.color && O.copyFrom(b.color),
- a && D.copyFromFloats(a[g], a[g + 1]),
- w && f.vertexFunction(b, C, m),
- M.multiplyInPlace(b.scaling).subtractInPlace(F),
- x.TransformCoordinatesToRef(M, R, N),
- N.addInPlace(L).addInPlace(b.position),
- n.push(N.x, N.y, N.z),
- a) {
- var B = b.uvs;
- s.push((B.z - B.x) * D.x + B.x, (B.w - B.y) * D.y + B.y),
- g += 2
- }
- if (b.color)
- this._color.copyFrom(O);
- else {
- var U = this._color;
- l && void 0 !== l[v] ? (U.r = l[v],
- U.g = l[v + 1],
- U.b = l[v + 2],
- U.a = l[v + 3]) : (U.r = 1,
- U.g = 1,
- U.b = 1,
- U.a = 1)
- }
- c.push(this._color.r, this._color.g, this._color.b, this._color.a),
- v += 4,
- !this.recomputeNormals && u && (x.TransformNormalFromFloatsToRef(u[y], u[y + 1], u[y + 2], R, M),
- h.push(M.x, M.y, M.z),
- y += 3)
- }
- for (m = 0; m < r.length; m++) {
- var V = e + r[m];
- o.push(V),
- V > 65535 && (this._needs32Bits = !0)
- }
- if (this._depthSort || this._multimaterialEnabled) {
- var k = null !== b.materialIndex ? b.materialIndex : 0;
- this.depthSortedParticles.push(new Ty(d,t,r.length,k))
- }
- return b
- }
- ,
- e.prototype._posToShape = function(e) {
- for (var t = [], i = 0; i < e.length; i += 3)
- t.push(x.FromArray(e, i));
- return t
- }
- ,
- e.prototype._uvsToShapeUV = function(e) {
- var t = [];
- if (e)
- for (var i = 0; i < e.length; i++)
- t.push(e[i]);
- return t
- }
- ,
- e.prototype._addParticle = function(e, t, i, n, r, o, a, s, l) {
- void 0 === s && (s = null),
- void 0 === l && (l = null);
- var c = new yy(e,t,i,n,r,o,a,this,s);
- return (l || this.particles).push(c),
- c
- }
- ,
- e.prototype.addShape = function(e, t, i) {
- var n = e.getVerticesData(Bi.PositionKind)
- , r = e.getIndices()
- , o = e.getVerticesData(Bi.UVKind)
- , a = e.getVerticesData(Bi.ColorKind)
- , s = e.getVerticesData(Bi.NormalKind);
- this.recomputeNormals = !s;
- var l = gi.SliceToArray(r)
- , c = gi.SliceToArray(s)
- , u = a ? gi.SliceToArray(a) : []
- , h = i && i.storage ? i.storage : null
- , d = null;
- this._particlesIntersect && (d = e.getBoundingInfo());
- var p = this._posToShape(n)
- , f = this._uvsToShapeUV(o)
- , _ = i ? i.positionFunction : null
- , m = i ? i.vertexFunction : null
- , g = null;
- this._useModelMaterial && (g = e.material ? e.material : this._setDefaultMaterial());
- for (var v = new by(this._shapeCounter,p,l,c,u,f,_,m,g), y = 0; y < t; y++)
- this._insertNewParticle(this.nbParticles, y, v, p, r, o, a, s, d, h, i);
- return this._shapeCounter++,
- this._isNotBuilt = !0,
- this._shapeCounter - 1
- }
- ,
- e.prototype._rebuildParticle = function(e, t) {
- void 0 === t && (t = !1),
- this._resetCopy();
- var i = this._copy;
- e._model._positionFunction && e._model._positionFunction(i, e.idx, e.idxInShape);
- var n = I.Matrix[0]
- , r = I.Vector3[0]
- , o = I.Vector3[1]
- , a = I.Vector3[2]
- , s = I.Vector3[3];
- i.getRotationMatrix(n),
- e.pivot.multiplyToRef(e.scaling, s),
- i.translateFromPivot ? a.copyFromFloats(0, 0, 0) : a.copyFrom(s);
- for (var l = e._model._shape, c = 0; c < l.length; c++)
- r.copyFrom(l[c]),
- e._model._vertexFunction && e._model._vertexFunction(i, r, c),
- r.multiplyInPlace(i.scaling).subtractInPlace(s),
- x.TransformCoordinatesToRef(r, n, o),
- o.addInPlace(a).addInPlace(i.position).toArray(this._positions32, e._pos + 3 * c);
- t && (e.position.setAll(0),
- e.rotation.setAll(0),
- e.rotationQuaternion = null,
- e.scaling.setAll(1),
- e.uvs.setAll(0),
- e.pivot.setAll(0),
- e.translateFromPivot = !1,
- e.parentId = null)
- }
- ,
- e.prototype.rebuildMesh = function(e) {
- void 0 === e && (e = !1);
- for (var t = 0; t < this.particles.length; t++)
- this._rebuildParticle(this.particles[t], e);
- return this.mesh.updateVerticesData(Bi.PositionKind, this._positions32, !1, !1),
- this
- }
- ,
- e.prototype.removeParticles = function(e, t) {
- var i = t - e + 1;
- if (!this._expandable || i <= 0 || i >= this.nbParticles || !this._updatable)
- return [];
- var n = this.particles
- , r = this.nbParticles;
- if (t < r - 1)
- for (var o = t + 1, a = n[o]._pos - n[e]._pos, s = n[o]._ind - n[e]._ind, l = o; l < r; l++) {
- var c = n[l];
- c._pos -= a,
- c._ind -= s
- }
- var u = n.splice(e, i);
- this._positions.length = 0,
- this._indices.length = 0,
- this._colors.length = 0,
- this._uvs.length = 0,
- this._normals.length = 0,
- this._index = 0,
- this._idxOfId.length = 0,
- (this._depthSort || this._multimaterialEnabled) && (this.depthSortedParticles = []);
- for (var h = 0, d = n.length, p = 0; p < d; p++) {
- var f = n[p]
- , _ = f._model
- , m = _._shape
- , g = _._indices
- , v = _._normals
- , y = _._shapeColors
- , b = _._shapeUV;
- f.idx = p,
- this._idxOfId[f.id] = p,
- this._meshBuilder(this._index, h, m, this._positions, g, this._indices, b, this._uvs, y, this._colors, v, this._normals, f.idx, f.idxInShape, null, _),
- this._index += m.length,
- h += g.length
- }
- return this.nbParticles -= i,
- this._isNotBuilt = !0,
- u
- }
- ,
- e.prototype.insertParticlesFromArray = function(e) {
- if (!this._expandable)
- return this;
- for (var t = 0, i = e[0].shapeId, n = e.length, r = 0; r < n; r++) {
- var o = e[r]
- , a = o._model
- , s = a._shape
- , l = a._indices
- , c = a._shapeUV
- , u = a._shapeColors
- , h = a._normals
- , d = !h;
- this.recomputeNormals = d || this.recomputeNormals;
- var p = o.getBoundingInfo()
- , f = this._insertNewParticle(this.nbParticles, t, a, s, l, c, u, h, p, null, null);
- o.copyToRef(f),
- t++,
- i != o.shapeId && (i = o.shapeId,
- t = 0)
- }
- return this._isNotBuilt = !0,
- this
- }
- ,
- e.prototype._insertNewParticle = function(e, t, i, n, r, o, a, s, l, c, u) {
- var h = this._positions.length
- , d = this._indices.length
- , p = this._meshBuilder(this._index, d, n, this._positions, r, this._indices, o, this._uvs, a, this._colors, s, this._normals, e, t, u, i)
- , f = null;
- return this._updatable && ((f = this._addParticle(this.nbParticles, this._lastParticleId, h, d, i, this._shapeCounter, t, l, c)).position.copyFrom(p.position),
- f.rotation.copyFrom(p.rotation),
- p.rotationQuaternion && (f.rotationQuaternion ? f.rotationQuaternion.copyFrom(p.rotationQuaternion) : f.rotationQuaternion = p.rotationQuaternion.clone()),
- p.color && (f.color ? f.color.copyFrom(p.color) : f.color = p.color.clone()),
- f.scaling.copyFrom(p.scaling),
- f.uvs.copyFrom(p.uvs),
- null !== p.materialIndex && (f.materialIndex = p.materialIndex),
- this.expandable && (this._idxOfId[f.id] = f.idx)),
- c || (this._index += n.length,
- this.nbParticles++,
- this._lastParticleId++),
- f
- }
- ,
- e.prototype.setParticles = function(e, t, i) {
- if (void 0 === e && (e = 0),
- void 0 === t && (t = this.nbParticles - 1),
- void 0 === i && (i = !0),
- !this._updatable || this._isNotBuilt)
- return this;
- this.beforeUpdateParticles(e, t, i);
- var n = I.Matrix[0]
- , r = I.Matrix[1]
- , o = this.mesh
- , a = this._colors32
- , s = this._positions32
- , l = this._normals32
- , c = this._uvs32
- , u = this._indices32
- , h = this._indices
- , d = this._fixedNormal32
- , p = I.Vector3
- , f = p[5].copyFromFloats(1, 0, 0)
- , _ = p[6].copyFromFloats(0, 1, 0)
- , m = p[7].copyFromFloats(0, 0, 1)
- , g = p[8].setAll(Number.MAX_VALUE)
- , v = p[9].setAll(-Number.MAX_VALUE)
- , y = p[10].setAll(0)
- , b = this._tmpVertex
- , T = b.position
- , E = b.color
- , S = b.uv;
- if ((this.billboard || this._depthSort) && (this.mesh.computeWorldMatrix(!0),
- this.mesh._worldMatrix.invertToRef(r)),
- this.billboard) {
- var A = p[0];
- this._camera.getDirectionToRef(vn.Z, A),
- x.TransformNormalToRef(A, r, m),
- m.normalize();
- var R = this._camera.getViewMatrix(!0);
- x.TransformNormalFromFloatsToRef(R.m[1], R.m[5], R.m[9], r, _),
- x.CrossToRef(_, m, f),
- _.normalize(),
- f.normalize()
- }
- this._depthSort && x.TransformCoordinatesToRef(this._camera.globalPosition, r, y),
- P.IdentityToRef(n);
- var C = 0
- , M = 0
- , O = 0
- , D = 0
- , N = 0
- , L = 0
- , F = 0;
- if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0),
- t = t >= this.nbParticles ? this.nbParticles - 1 : t,
- this._computeBoundingBox && (0 != e || t != this.nbParticles - 1)) {
- var w = this.mesh.getBoundingInfo();
- w && (g.copyFrom(w.minimum),
- v.copyFrom(w.maximum))
- }
- var B = (M = this.particles[e]._pos) / 3 | 0;
- D = 4 * B,
- L = 2 * B;
- for (var U = e; U <= t; U++) {
- var V = this.particles[U];
- this.updateParticle(V);
- var k = V._model._shape
- , G = V._model._shapeUV
- , z = V._rotationMatrix
- , W = V.position
- , H = V.rotation
- , X = V.scaling
- , j = V._globalPosition;
- if (this._depthSort && this._depthSortParticles) {
- var Y = this.depthSortedParticles[U];
- Y.idx = V.idx,
- Y.ind = V._ind,
- Y.indicesLength = V._model._indicesLength,
- Y.sqDistance = x.DistanceSquared(V.position, y)
- }
- if (!V.alive || V._stillInvisible && !V.isVisible)
- M += 3 * (F = k.length),
- D += 4 * F,
- L += 2 * F;
- else {
- if (V.isVisible) {
- V._stillInvisible = !1;
- var K = p[12];
- if (V.pivot.multiplyToRef(X, K),
- this.billboard && (H.x = 0,
- H.y = 0),
- (this._computeParticleRotation || this.billboard) && V.getRotationMatrix(n),
- null !== V.parentId) {
- var Q = this.getParticleById(V.parentId);
- if (Q) {
- var q = Q._rotationMatrix
- , Z = Q._globalPosition
- , J = W.x * q[1] + W.y * q[4] + W.z * q[7]
- , $ = W.x * q[0] + W.y * q[3] + W.z * q[6]
- , ee = W.x * q[2] + W.y * q[5] + W.z * q[8];
- if (j.x = Z.x + $,
- j.y = Z.y + J,
- j.z = Z.z + ee,
- this._computeParticleRotation || this.billboard) {
- var te = n.m;
- z[0] = te[0] * q[0] + te[1] * q[3] + te[2] * q[6],
- z[1] = te[0] * q[1] + te[1] * q[4] + te[2] * q[7],
- z[2] = te[0] * q[2] + te[1] * q[5] + te[2] * q[8],
- z[3] = te[4] * q[0] + te[5] * q[3] + te[6] * q[6],
- z[4] = te[4] * q[1] + te[5] * q[4] + te[6] * q[7],
- z[5] = te[4] * q[2] + te[5] * q[5] + te[6] * q[8],
- z[6] = te[8] * q[0] + te[9] * q[3] + te[10] * q[6],
- z[7] = te[8] * q[1] + te[9] * q[4] + te[10] * q[7],
- z[8] = te[8] * q[2] + te[9] * q[5] + te[10] * q[8]
- }
- } else
- V.parentId = null
- } else
- j.x = W.x,
- j.y = W.y,
- j.z = W.z,
- (this._computeParticleRotation || this.billboard) && (te = n.m,
- z[0] = te[0],
- z[1] = te[1],
- z[2] = te[2],
- z[3] = te[4],
- z[4] = te[5],
- z[5] = te[6],
- z[6] = te[8],
- z[7] = te[9],
- z[8] = te[10]);
- var ie = p[11];
- for (V.translateFromPivot ? ie.setAll(0) : ie.copyFrom(K),
- F = 0; F < k.length; F++) {
- C = M + 3 * F,
- O = D + 4 * F,
- N = L + 2 * F;
- var ne = 2 * F
- , re = ne + 1;
- T.copyFrom(k[F]),
- this._computeParticleColor && V.color && E.copyFrom(V.color),
- this._computeParticleTexture && S.copyFromFloats(G[ne], G[re]),
- this._computeParticleVertex && this.updateParticleVertex(V, b, F);
- var oe = T.x * X.x - K.x
- , ae = T.y * X.y - K.y
- , se = T.z * X.z - K.z;
- $ = oe * z[0] + ae * z[3] + se * z[6],
- J = oe * z[1] + ae * z[4] + se * z[7],
- ee = oe * z[2] + ae * z[5] + se * z[8],
- $ += ie.x,
- J += ie.y,
- ee += ie.z;
- var le = s[C] = j.x + f.x * $ + _.x * J + m.x * ee
- , ce = s[C + 1] = j.y + f.y * $ + _.y * J + m.y * ee
- , ue = s[C + 2] = j.z + f.z * $ + _.z * J + m.z * ee;
- if (this._computeBoundingBox && (g.minimizeInPlaceFromFloats(le, ce, ue),
- v.maximizeInPlaceFromFloats(le, ce, ue)),
- !this._computeParticleVertex) {
- var he = d[C]
- , de = d[C + 1]
- , pe = d[C + 2]
- , fe = he * z[0] + de * z[3] + pe * z[6]
- , _e = he * z[1] + de * z[4] + pe * z[7]
- , me = he * z[2] + de * z[5] + pe * z[8];
- l[C] = f.x * fe + _.x * _e + m.x * me,
- l[C + 1] = f.y * fe + _.y * _e + m.y * me,
- l[C + 2] = f.z * fe + _.z * _e + m.z * me
- }
- if (this._computeParticleColor && V.color) {
- var ge = this._colors32;
- ge[O] = E.r,
- ge[O + 1] = E.g,
- ge[O + 2] = E.b,
- ge[O + 3] = E.a
- }
- if (this._computeParticleTexture) {
- var ve = V.uvs;
- c[N] = S.x * (ve.z - ve.x) + ve.x,
- c[N + 1] = S.y * (ve.w - ve.y) + ve.y
- }
- }
- } else
- for (V._stillInvisible = !0,
- F = 0; F < k.length; F++) {
- if (O = D + 4 * F,
- N = L + 2 * F,
- s[C = M + 3 * F] = s[C + 1] = s[C + 2] = 0,
- l[C] = l[C + 1] = l[C + 2] = 0,
- this._computeParticleColor && V.color) {
- var ye = V.color;
- a[O] = ye.r,
- a[O + 1] = ye.g,
- a[O + 2] = ye.b,
- a[O + 3] = ye.a
- }
- this._computeParticleTexture && (ve = V.uvs,
- c[N] = G[2 * F] * (ve.z - ve.x) + ve.x,
- c[N + 1] = G[2 * F + 1] * (ve.w - ve.y) + ve.y)
- }
- if (this._particlesIntersect) {
- var be = V.getBoundingInfo()
- , Te = be.boundingBox
- , Ee = be.boundingSphere
- , Se = V._modelBoundingInfo;
- if (!this._bSphereOnly) {
- var Ae = Se.boundingBox.vectors
- , xe = p[1]
- , Re = p[2];
- xe.setAll(Number.MAX_VALUE),
- Re.setAll(-Number.MAX_VALUE);
- for (var Ce = 0; Ce < 8; Ce++) {
- var Pe = Ae[Ce].x * X.x
- , Me = Ae[Ce].y * X.y
- , Ie = Ae[Ce].z * X.z
- , Oe = ($ = Pe * z[0] + Me * z[3] + Ie * z[6],
- J = Pe * z[1] + Me * z[4] + Ie * z[7],
- ee = Pe * z[2] + Me * z[5] + Ie * z[8],
- W.x + f.x * $ + _.x * J + m.x * ee)
- , De = W.y + f.y * $ + _.y * J + m.y * ee
- , Ne = W.z + f.z * $ + _.z * J + m.z * ee;
- xe.minimizeInPlaceFromFloats(Oe, De, Ne),
- Re.maximizeInPlaceFromFloats(Oe, De, Ne)
- }
- Te.reConstruct(xe, Re, o._worldMatrix)
- }
- var Le = Se.minimum.multiplyToRef(X, p[1])
- , Fe = Se.maximum.multiplyToRef(X, p[2])
- , we = Fe.addToRef(Le, p[3]).scaleInPlace(.5).addInPlace(j)
- , Be = Fe.subtractToRef(Le, p[4]).scaleInPlace(.5 * this._bSphereRadiusFactor)
- , Ue = we.subtractToRef(Be, p[1])
- , Ve = we.addToRef(Be, p[2]);
- Ee.reConstruct(Ue, Ve, o._worldMatrix)
- }
- M = C + 3,
- D = O + 4,
- L = N + 2
- }
- }
- if (i) {
- this._computeParticleColor && ((We = o.getVertexBuffer(Bi.ColorKind)) && !o.isPickable ? We.updateDirectly(a, 0) : o.updateVerticesData(Bi.ColorKind, a, !1, !1)),
- this._computeParticleTexture && ((We = o.getVertexBuffer(Bi.UVKind)) && !o.isPickable ? We.updateDirectly(c, 0) : o.updateVerticesData(Bi.UVKind, c, !1, !1));
- var ke = o.getVertexBuffer(Bi.PositionKind);
- if (ke && !o.isPickable ? ke.updateDirectly(s, 0) : o.updateVerticesData(Bi.PositionKind, s, !1, !1),
- !o.areNormalsFrozen || o.isFacetDataEnabled) {
- if (this._computeParticleVertex || o.isFacetDataEnabled) {
- var Ge = o.isFacetDataEnabled ? o.getFacetDataParameters() : null;
- $n.ComputeNormals(s, u, l, Ge);
- for (var ze = 0; ze < l.length; ze++)
- d[ze] = l[ze]
- }
- var We;
- o.areNormalsFrozen || ((We = o.getVertexBuffer(Bi.NormalKind)) && !o.isPickable ? We.updateDirectly(l, 0) : o.updateVerticesData(Bi.NormalKind, l, !1, !1))
- }
- if (this._depthSort && this._depthSortParticles) {
- var He = this.depthSortedParticles;
- He.sort(this._depthSortFunction);
- for (var Xe = He.length, je = 0, Ye = 0, Ke = 0; Ke < Xe; Ke++) {
- var Qe = He[Ke]
- , qe = Qe.indicesLength
- , Ze = Qe.ind;
- for (ze = 0; ze < qe; ze++)
- if (u[je] = h[Ze + ze],
- je++,
- this._pickable && 0 == ze % 3) {
- var Je = this.pickedParticles[Ye];
- Je.idx = Qe.idx,
- Je.faceId = Ye,
- Ye++
- }
- }
- o.updateIndices(u)
- }
- }
- return this._computeBoundingBox && (o.hasBoundingInfo ? o.getBoundingInfo().reConstruct(g, v, o._worldMatrix) : o.buildBoundingInfo(g, v, o._worldMatrix)),
- this._autoUpdateSubMeshes && this.computeSubMeshes(),
- this.afterUpdateParticles(e, t, i),
- this
- }
- ,
- e.prototype.dispose = function() {
- this.mesh.dispose(),
- this.vars = null,
- this._positions = null,
- this._indices = null,
- this._normals = null,
- this._uvs = null,
- this._colors = null,
- this._indices32 = null,
- this._positions32 = null,
- this._normals32 = null,
- this._fixedNormal32 = null,
- this._uvs32 = null,
- this._colors32 = null,
- this.pickedParticles = null,
- this.pickedBySubMesh = null,
- this._materials = null,
- this._materialIndexes = null,
- this._indicesByMaterial = null,
- this._idxOfId = null
- }
- ,
- e.prototype.pickedParticle = function(e) {
- if (e.hit) {
- var t = e.subMeshId
- , i = e.faceId - this.mesh.subMeshes[t].indexStart / 3
- , n = this.pickedBySubMesh;
- if (n[t] && n[t][i])
- return n[t][i]
- }
- return null
- }
- ,
- e.prototype.getParticleById = function(e) {
- var t = this.particles[e];
- if (t && t.id == e)
- return t;
- var i = this.particles
- , n = this._idxOfId[e];
- if (void 0 !== n)
- return i[n];
- for (var r = 0, o = this.nbParticles; r < o; ) {
- var a = i[r];
- if (a.id == e)
- return a;
- r++
- }
- return null
- }
- ,
- e.prototype.getParticlesByShapeId = function(e) {
- var t = [];
- return this.getParticlesByShapeIdToRef(e, t),
- t
- }
- ,
- e.prototype.getParticlesByShapeIdToRef = function(e, t) {
- t.length = 0;
- for (var i = 0; i < this.nbParticles; i++) {
- var n = this.particles[i];
- n.shapeId == e && t.push(n)
- }
- return this
- }
- ,
- e.prototype.computeSubMeshes = function() {
- if (!this.mesh || !this._multimaterialEnabled)
- return this;
- var e = this.depthSortedParticles;
- if (this.particles.length > 0)
- for (var t = 0; t < this.particles.length; t++) {
- var i = this.particles[t];
- i.materialIndex || (i.materialIndex = 0);
- var n = e[t];
- n.materialIndex = i.materialIndex,
- n.ind = i._ind,
- n.indicesLength = i._model._indicesLength,
- n.idx = i.idx
- }
- this._sortParticlesByMaterial();
- var r = this._indicesByMaterial
- , o = this._materialIndexes
- , a = this.mesh;
- a.subMeshes = [];
- for (var s = a.getTotalVertices(), l = 0; l < o.length; l++) {
- var c = r[l]
- , u = r[l + 1] - c
- , h = o[l];
- new hr(h,0,s,c,u,a)
- }
- return this
- }
- ,
- e.prototype._sortParticlesByMaterial = function() {
- var e = [0];
- this._indicesByMaterial = e;
- var t = [];
- this._materialIndexes = t;
- var i = this.depthSortedParticles;
- i.sort(this._materialSortFunction);
- var n = i.length
- , r = this._indices32
- , o = this._indices
- , a = 0
- , s = 0
- , l = 0
- , c = i[0].materialIndex;
- t.push(c),
- this._pickable && (this.pickedBySubMesh = [[]],
- this.pickedParticles = this.pickedBySubMesh[0]);
- for (var u = 0; u < n; u++) {
- var h = i[u]
- , d = h.indicesLength
- , p = h.ind;
- h.materialIndex !== c && (c = h.materialIndex,
- e.push(l),
- t.push(c),
- this._pickable && (a++,
- this.pickedBySubMesh[a] = [],
- s = 0));
- for (var f = 0, _ = 0; _ < d; _++) {
- if (r[l] = o[p + _],
- this._pickable && 0 == _ % 3) {
- var m = this.pickedBySubMesh[a][s];
- m ? (m.idx = h.idx,
- m.faceId = f) : this.pickedBySubMesh[a][s] = {
- idx: h.idx,
- faceId: f
- },
- s++,
- f++
- }
- l++
- }
- }
- return e.push(r.length),
- this._updatable && this.mesh.updateIndices(r),
- this
- }
- ,
- e.prototype._setMaterialIndexesById = function() {
- this._materialIndexesById = {};
- for (var e = 0; e < this._materials.length; e++) {
- var t = this._materials[e].uniqueId;
- this._materialIndexesById[t] = e
- }
- }
- ,
- e.prototype._filterUniqueMaterialId = function(e) {
- return e.filter((function(e, t, i) {
- return i.indexOf(e) === t
- }
- ))
- }
- ,
- e.prototype._setDefaultMaterial = function() {
- return this._defaultMaterial || (this._defaultMaterial = new Os(this.name + "DefaultMaterial",this._scene)),
- this._defaultMaterial
- }
- ,
- e.prototype.refreshVisibleSize = function() {
- return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(),
- this
- }
- ,
- e.prototype.setVisibilityBox = function(e) {
- var t = e / 2;
- this.mesh.buildBoundingInfo(new x(-t,-t,-t), new x(t,t,t))
- }
- ,
- Object.defineProperty(e.prototype, "isAlwaysVisible", {
- get: function() {
- return this._alwaysVisible
- },
- set: function(e) {
- this._alwaysVisible = e,
- this.mesh.alwaysSelectAsActiveMesh = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isVisibilityBoxLocked", {
- get: function() {
- return this._isVisibilityBoxLocked
- },
- set: function(e) {
- this._isVisibilityBoxLocked = e,
- this.mesh.getBoundingInfo().isLocked = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleRotation", {
- get: function() {
- return this._computeParticleRotation
- },
- set: function(e) {
- this._computeParticleRotation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleColor", {
- get: function() {
- return this._computeParticleColor
- },
- set: function(e) {
- this._computeParticleColor = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleTexture", {
- get: function() {
- return this._computeParticleTexture
- },
- set: function(e) {
- this._computeParticleTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleVertex", {
- get: function() {
- return this._computeParticleVertex
- },
- set: function(e) {
- this._computeParticleVertex = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeBoundingBox", {
- get: function() {
- return this._computeBoundingBox
- },
- set: function(e) {
- this._computeBoundingBox = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthSortParticles", {
- get: function() {
- return this._depthSortParticles
- },
- set: function(e) {
- this._depthSortParticles = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "expandable", {
- get: function() {
- return this._expandable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "multimaterialEnabled", {
- get: function() {
- return this._multimaterialEnabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useModelMaterial", {
- get: function() {
- return this._useModelMaterial
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "materials", {
- get: function() {
- return this._materials
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setMultiMaterial = function(e) {
- this._materials = this._filterUniqueMaterialId(e),
- this._setMaterialIndexesById(),
- this._multimaterial && this._multimaterial.dispose(),
- this._multimaterial = new Dr(this.name + "MultiMaterial",this._scene);
- for (var t = 0; t < this._materials.length; t++)
- this._multimaterial.subMaterials.push(this._materials[t]);
- this.computeSubMeshes(),
- this.mesh.material = this._multimaterial
- }
- ,
- Object.defineProperty(e.prototype, "multimaterial", {
- get: function() {
- return this._multimaterial
- },
- set: function(e) {
- this._multimaterial = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "autoUpdateSubMeshes", {
- get: function() {
- return this._autoUpdateSubMeshes
- },
- set: function(e) {
- this._autoUpdateSubMeshes = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initParticles = function() {}
- ,
- e.prototype.recycleParticle = function(e) {
- return e
- }
- ,
- e.prototype.updateParticle = function(e) {
- return e
- }
- ,
- e.prototype.updateParticleVertex = function(e, t, i) {
- return this
- }
- ,
- e.prototype.beforeUpdateParticles = function(e, t, i) {}
- ,
- e.prototype.afterUpdateParticles = function(e, t, i) {}
- ,
- e
- }(), Ay = function() {
- function e(e, t, i, n, r) {
- this.idx = 0,
- this.color = new N(1,1,1,1),
- this.position = x.Zero(),
- this.rotation = x.Zero(),
- this.uv = new A(0,0),
- this.velocity = x.Zero(),
- this.pivot = x.Zero(),
- this.translateFromPivot = !1,
- this._pos = 0,
- this._ind = 0,
- this.groupId = 0,
- this.idxInGroup = 0,
- this._stillInvisible = !1,
- this._rotationMatrix = [1, 0, 0, 0, 1, 0, 0, 0, 1],
- this.parentId = null,
- this._globalPosition = x.Zero(),
- this.idx = e,
- this._group = t,
- this.groupId = i,
- this.idxInGroup = n,
- this._pcs = r
- }
- return Object.defineProperty(e.prototype, "size", {
- get: function() {
- return this.size
- },
- set: function(e) {
- this.size = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "quaternion", {
- get: function() {
- return this.rotationQuaternion
- },
- set: function(e) {
- this.rotationQuaternion = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.intersectsMesh = function(e, t) {
- if (!e.hasBoundingInfo)
- return !1;
- if (t = t || !1)
- return e.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));
- var i, n, r, o, a, s;
- i = e.getBoundingInfo().boundingBox.maximumWorld.x,
- n = e.getBoundingInfo().boundingBox.minimumWorld.x,
- r = e.getBoundingInfo().boundingBox.maximumWorld.y,
- o = e.getBoundingInfo().boundingBox.minimumWorld.y,
- a = e.getBoundingInfo().boundingBox.maximumWorld.z,
- s = e.getBoundingInfo().boundingBox.minimumWorld.z;
- var l = this.position.x + this._pcs.mesh.position.x
- , c = this.position.y + this._pcs.mesh.position.y
- , u = this.position.z + this._pcs.mesh.position.z;
- return n <= l && l <= i && o <= c && c <= r && s <= u && u <= a
- }
- ,
- e.prototype.getRotationMatrix = function(e) {
- var t;
- if (this.rotationQuaternion)
- t = this.rotationQuaternion;
- else {
- t = I.Quaternion[0];
- var i = this.rotation;
- C.RotationYawPitchRollToRef(i.y, i.x, i.z, t)
- }
- t.toRotationMatrix(e)
- }
- ,
- e
- }(), xy = function() {
- function e(e, t) {
- this.groupId = e,
- this._positionFunction = t
- }
- return Object.defineProperty(e.prototype, "groupID", {
- get: function() {
- return this.groupId
- },
- set: function(e) {
- this.groupId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }();
- !function(e) {
- e[e.Color = 2] = "Color",
- e[e.UV = 1] = "UV",
- e[e.Random = 0] = "Random",
- e[e.Stated = 3] = "Stated"
- }(vy || (vy = {}));
- var Ry = function() {
- function e(e, t, i, n) {
- this.particles = new Array,
- this.nbParticles = 0,
- this.counter = 0,
- this.vars = {},
- this._promises = [],
- this._positions = new Array,
- this._indices = new Array,
- this._normals = new Array,
- this._colors = new Array,
- this._uvs = new Array,
- this._updatable = !0,
- this._isVisibilityBoxLocked = !1,
- this._alwaysVisible = !1,
- this._groups = new Array,
- this._groupCounter = 0,
- this._computeParticleColor = !0,
- this._computeParticleTexture = !0,
- this._computeParticleRotation = !0,
- this._computeBoundingBox = !1,
- this._isReady = !1,
- this.name = e,
- this._size = t,
- this._scene = i || E.LastCreatedScene,
- n && void 0 !== n.updatable ? this._updatable = n.updatable : this._updatable = !0
- }
- return e.prototype.buildMeshAsync = function(e) {
- var t = this;
- return Promise.all(this._promises).then((function() {
- return t._isReady = !0,
- t._buildMesh(e)
- }
- ))
- }
- ,
- e.prototype._buildMesh = function(e) {
- 0 === this.nbParticles && this.addPoints(1),
- this._positions32 = new Float32Array(this._positions),
- this._uvs32 = new Float32Array(this._uvs),
- this._colors32 = new Float32Array(this._colors);
- var t = new $n;
- t.set(this._positions32, Bi.PositionKind),
- this._uvs32.length > 0 && t.set(this._uvs32, Bi.UVKind);
- var i = 0;
- this._colors32.length > 0 && (i = 1,
- t.set(this._colors32, Bi.ColorKind));
- var n = new Vr(this.name,this._scene);
- t.applyToMesh(n, this._updatable),
- this.mesh = n,
- this._positions = null,
- this._uvs = null,
- this._colors = null,
- this._updatable || (this.particles.length = 0);
- var r = e;
- return r || ((r = new Os("point cloud material",this._scene)).emissiveColor = new D(i,i,i),
- r.disableLighting = !0,
- r.pointsCloud = !0,
- r.pointSize = this._size),
- n.material = r,
- new Promise((function(e) {
- return e(n)
- }
- ))
- }
- ,
- e.prototype._addParticle = function(e, t, i, n) {
- var r = new Ay(e,t,i,n,this);
- return this.particles.push(r),
- r
- }
- ,
- e.prototype._randomUnitVector = function(e) {
- e.position = new x(Math.random(),Math.random(),Math.random()),
- e.color = new N(1,1,1,1)
- }
- ,
- e.prototype._getColorIndicesForCoord = function(e, t, i, n) {
- var r = e._groupImageData
- , o = i * (4 * n) + 4 * t
- , a = [o, o + 1, o + 2, o + 3]
- , s = a[1]
- , l = a[2]
- , c = a[3]
- , u = r[a[0]]
- , h = r[s]
- , d = r[l]
- , p = r[c];
- return new N(u / 255,h / 255,d / 255,p)
- }
- ,
- e.prototype._setPointsColorOrUV = function(e, t, i, n, r, o, a) {
- i && e.updateFacetData();
- var s = 2 * e.getBoundingInfo().boundingSphere.radius
- , l = e.getVerticesData(Bi.PositionKind)
- , c = e.getIndices()
- , u = e.getVerticesData(Bi.UVKind)
- , h = e.getVerticesData(Bi.ColorKind)
- , p = x.Zero();
- e.computeWorldMatrix();
- var f = e.getWorldMatrix();
- if (!f.isIdentity()) {
- l = l.slice(0);
- for (var _ = 0; _ < l.length / 3; _++)
- x.TransformCoordinatesFromFloatsToRef(l[3 * _], l[3 * _ + 1], l[3 * _ + 2], f, p),
- l[3 * _] = p.x,
- l[3 * _ + 1] = p.y,
- l[3 * _ + 2] = p.z
- }
- var m, g, v = 0, y = 0, b = 0, T = 0, E = 0, S = 0, C = 0, P = 0, M = 0, I = 0, O = 0, L = 0, F = 0, w = x.Zero(), B = x.Zero(), U = x.Zero(), V = x.Zero(), k = x.Zero(), G = 0, z = 0, W = 0, H = 0, X = 0, j = 0, Y = A.Zero(), K = A.Zero(), Q = A.Zero(), q = A.Zero(), Z = A.Zero(), J = 0, $ = 0, ee = 0, te = 0, ie = 0, ne = 0, re = 0, oe = 0, ae = 0, se = 0, le = 0, ce = 0, ue = R.Zero(), he = R.Zero(), de = R.Zero(), pe = R.Zero(), fe = R.Zero(), _e = 0, me = 0;
- a = a || 0;
- for (var ge, ve = new R(0,0,0,0), ye = x.Zero(), be = x.Zero(), Te = x.Zero(), Ee = 0, Se = x.Zero(), Ae = 0, xe = 0, Re = new _o(x.Zero(),new x(1,0,0)), Ce = x.Zero(), Pe = 0; Pe < c.length / 3; Pe++) {
- y = c[3 * Pe],
- b = c[3 * Pe + 1],
- T = c[3 * Pe + 2],
- E = l[3 * y],
- S = l[3 * y + 1],
- C = l[3 * y + 2],
- P = l[3 * b],
- M = l[3 * b + 1],
- I = l[3 * b + 2],
- O = l[3 * T],
- L = l[3 * T + 1],
- F = l[3 * T + 2],
- w.set(E, S, C),
- B.set(P, M, I),
- U.set(O, L, F),
- B.subtractToRef(w, V),
- U.subtractToRef(B, k),
- u && (G = u[2 * y],
- z = u[2 * y + 1],
- W = u[2 * b],
- H = u[2 * b + 1],
- X = u[2 * T],
- j = u[2 * T + 1],
- Y.set(G, z),
- K.set(W, H),
- Q.set(X, j),
- K.subtractToRef(Y, q),
- Q.subtractToRef(K, Z)),
- h && n && (J = h[4 * y],
- $ = h[4 * y + 1],
- ee = h[4 * y + 2],
- te = h[4 * y + 3],
- ie = h[4 * b],
- ne = h[4 * b + 1],
- re = h[4 * b + 2],
- oe = h[4 * b + 3],
- ae = h[4 * T],
- se = h[4 * T + 1],
- le = h[4 * T + 2],
- ce = h[4 * T + 3],
- ue.set(J, $, ee, te),
- he.set(ie, ne, re, oe),
- de.set(ae, se, le, ce),
- he.subtractToRef(ue, pe),
- de.subtractToRef(he, fe));
- for (var Me = void 0, Ie = void 0, Oe = void 0, De = void 0, Ne = void 0, Le = void 0, Fe = void 0, we = void 0, Be = new D(0,0,0), Ue = new D(0,0,0), Ve = void 0, ke = void 0, Ge = 0; Ge < t._groupDensity[Pe]; Ge++)
- v = this.particles.length,
- this._addParticle(v, t, this._groupCounter, Pe + Ge),
- ke = this.particles[v],
- _e = d.RandomRange(0, 1),
- me = d.RandomRange(0, 1),
- m = w.add(V.scale(_e)).add(k.scale(_e * me)),
- i && (ye = e.getFacetNormal(Pe).normalize().scale(-1),
- be = V.clone().normalize(),
- Te = x.Cross(ye, be),
- Ee = d.RandomRange(0, 2 * Math.PI),
- Se = be.scale(Math.cos(Ee)).add(Te.scale(Math.sin(Ee))),
- Ee = d.RandomRange(.1, Math.PI / 2),
- Ce = Se.scale(Math.cos(Ee)).add(ye.scale(Math.sin(Ee))),
- Re.origin = m.add(Ce.scale(1e-5)),
- Re.direction = Ce,
- Re.length = s,
- (ge = Re.intersectsMesh(e)).hit && (xe = ge.pickedPoint.subtract(m).length(),
- Ae = d.RandomRange(0, 1) * xe,
- m.addInPlace(Ce.scale(Ae)))),
- ke.position = m.clone(),
- this._positions.push(ke.position.x, ke.position.y, ke.position.z),
- void 0 !== n ? u && (g = Y.add(q.scale(_e)).add(Z.scale(_e * me)),
- n ? r && null !== t._groupImageData ? (Me = t._groupImgWidth,
- Ie = t._groupImgHeight,
- Ve = this._getColorIndicesForCoord(t, Math.round(g.x * Me), Math.round(g.y * Ie), Me),
- ke.color = Ve,
- this._colors.push(Ve.r, Ve.g, Ve.b, Ve.a)) : h ? (ve = ue.add(pe.scale(_e)).add(fe.scale(_e * me)),
- ke.color = new N(ve.x,ve.y,ve.z,ve.w),
- this._colors.push(ve.x, ve.y, ve.z, ve.w)) : (ve = ue.set(Math.random(), Math.random(), Math.random(), 1),
- ke.color = new N(ve.x,ve.y,ve.z,ve.w),
- this._colors.push(ve.x, ve.y, ve.z, ve.w)) : (ke.uv = g.clone(),
- this._uvs.push(ke.uv.x, ke.uv.y))) : (o ? (Be.set(o.r, o.g, o.b),
- Oe = d.RandomRange(-a, a),
- De = d.RandomRange(-a, a),
- Ne = (we = Be.toHSV()).r,
- (Le = we.g + Oe) < 0 && (Le = 0),
- Le > 1 && (Le = 1),
- (Fe = we.b + De) < 0 && (Fe = 0),
- Fe > 1 && (Fe = 1),
- D.HSVtoRGBToRef(Ne, Le, Fe, Ue),
- ve.set(Ue.r, Ue.g, Ue.b, 1)) : ve = ue.set(Math.random(), Math.random(), Math.random(), 1),
- ke.color = new N(ve.x,ve.y,ve.z,ve.w),
- this._colors.push(ve.x, ve.y, ve.z, ve.w))
- }
- }
- ,
- e.prototype._colorFromTexture = function(e, t, i) {
- var n = this;
- if (null === e.material)
- return K.Warn(e.name + "has no material."),
- t._groupImageData = null,
- void this._setPointsColorOrUV(e, t, i, !0, !1);
- var r = e.material.getActiveTextures();
- if (0 === r.length)
- return K.Warn(e.name + "has no usable texture."),
- t._groupImageData = null,
- void this._setPointsColorOrUV(e, t, i, !0, !1);
- var o = e.clone();
- o.setEnabled(!1),
- this._promises.push(new Promise((function(e) {
- Zr.WhenAllReady(r, (function() {
- var a = t._textureNb;
- a < 0 && (a = 0),
- a > r.length - 1 && (a = r.length - 1);
- var s = function() {
- t._groupImgWidth = r[a].getSize().width,
- t._groupImgHeight = r[a].getSize().height,
- n._setPointsColorOrUV(o, t, i, !0, !0),
- o.dispose(),
- e()
- };
- t._groupImageData = null;
- var l = r[a].readPixels();
- l ? l.then((function(e) {
- t._groupImageData = e,
- s()
- }
- )) : s()
- }
- ))
- }
- )))
- }
- ,
- e.prototype._calculateDensity = function(e, t, i) {
- for (var n, r, o, a, s, l, c, u, h, d, p, f, _, m, g, v, y, b = new Array, T = x.Zero(), E = x.Zero(), S = x.Zero(), A = x.Zero(), R = x.Zero(), C = x.Zero(), P = new Array, M = 0, I = i.length / 3, O = 0; O < I; O++)
- n = i[3 * O],
- r = i[3 * O + 1],
- o = i[3 * O + 2],
- a = t[3 * n],
- s = t[3 * n + 1],
- l = t[3 * n + 2],
- c = t[3 * r],
- u = t[3 * r + 1],
- h = t[3 * r + 2],
- d = t[3 * o],
- p = t[3 * o + 1],
- f = t[3 * o + 2],
- T.set(a, s, l),
- E.set(c, u, h),
- S.set(d, p, f),
- E.subtractToRef(T, A),
- S.subtractToRef(E, R),
- S.subtractToRef(T, C),
- v = ((_ = A.length()) + (m = R.length()) + (g = C.length())) / 2,
- M += y = Math.sqrt(v * (v - _) * (v - m) * (v - g)),
- P[O] = y;
- var D = 0;
- for (O = 0; O < I; O++)
- b[O] = Math.floor(e * P[O] / M),
- D += b[O];
- var N = e - D
- , L = Math.floor(N / I)
- , F = N % I;
- for (L > 0 && (b = b.map((function(e) {
- return e + L
- }
- ))),
- O = 0; O < F; O++)
- b[O] += 1;
- return b
- }
- ,
- e.prototype.addPoints = function(e, t) {
- void 0 === t && (t = this._randomUnitVector);
- for (var i, n = new xy(this._groupCounter,t), r = this.nbParticles, o = 0; o < e; o++)
- i = this._addParticle(r, n, this._groupCounter, o),
- n && n._positionFunction && n._positionFunction(i, r, o),
- this._positions.push(i.position.x, i.position.y, i.position.z),
- i.color && this._colors.push(i.color.r, i.color.g, i.color.b, i.color.a),
- i.uv && this._uvs.push(i.uv.x, i.uv.y),
- r++;
- return this.nbParticles += e,
- this._groupCounter++,
- this._groupCounter
- }
- ,
- e.prototype.addSurfacePoints = function(e, t, i, n, r) {
- var o = i || vy.Random;
- (isNaN(o) || o < 0 || o > 3) && (o = vy.Random);
- var a = e.getVerticesData(Bi.PositionKind)
- , s = e.getIndices();
- this._groups.push(this._groupCounter);
- var l = new xy(this._groupCounter,null);
- switch (l._groupDensity = this._calculateDensity(t, a, s),
- o === vy.Color ? l._textureNb = n || 0 : n = n || new N(1,1,1,1),
- o) {
- case vy.Color:
- this._colorFromTexture(e, l, !1);
- break;
- case vy.UV:
- this._setPointsColorOrUV(e, l, !1, !1, !1);
- break;
- case vy.Random:
- this._setPointsColorOrUV(e, l, !1);
- break;
- case vy.Stated:
- this._setPointsColorOrUV(e, l, !1, void 0, void 0, n, r)
- }
- return this.nbParticles += t,
- this._groupCounter++,
- this._groupCounter - 1
- }
- ,
- e.prototype.addVolumePoints = function(e, t, i, n, r) {
- var o = i || vy.Random;
- (isNaN(o) || o < 0 || o > 3) && (o = vy.Random);
- var a = e.getVerticesData(Bi.PositionKind)
- , s = e.getIndices();
- this._groups.push(this._groupCounter);
- var l = new xy(this._groupCounter,null);
- switch (l._groupDensity = this._calculateDensity(t, a, s),
- o === vy.Color ? l._textureNb = n || 0 : n = n || new N(1,1,1,1),
- o) {
- case vy.Color:
- this._colorFromTexture(e, l, !0);
- break;
- case vy.UV:
- this._setPointsColorOrUV(e, l, !0, !1, !1);
- break;
- case vy.Random:
- this._setPointsColorOrUV(e, l, !0);
- break;
- case vy.Stated:
- this._setPointsColorOrUV(e, l, !0, void 0, void 0, n, r)
- }
- return this.nbParticles += t,
- this._groupCounter++,
- this._groupCounter - 1
- }
- ,
- e.prototype.setParticles = function(e, t, i) {
- if (void 0 === e && (e = 0),
- void 0 === t && (t = this.nbParticles - 1),
- void 0 === i && (i = !0),
- !this._updatable || !this._isReady)
- return this;
- this.beforeUpdateParticles(e, t, i);
- var n = I.Matrix[0]
- , r = this.mesh
- , o = this._colors32
- , a = this._positions32
- , s = this._uvs32
- , l = I.Vector3
- , c = l[5].copyFromFloats(1, 0, 0)
- , u = l[6].copyFromFloats(0, 1, 0)
- , h = l[7].copyFromFloats(0, 0, 1)
- , d = l[8].setAll(Number.MAX_VALUE)
- , p = l[9].setAll(-Number.MAX_VALUE);
- P.IdentityToRef(n);
- var f = 0;
- if (this.mesh.isFacetDataEnabled && (this._computeBoundingBox = !0),
- t = t >= this.nbParticles ? this.nbParticles - 1 : t,
- this._computeBoundingBox && (0 != e || t != this.nbParticles - 1)) {
- var _ = this.mesh.getBoundingInfo();
- _ && (d.copyFrom(_.minimum),
- p.copyFrom(_.maximum))
- }
- f = 0;
- for (var m = 0, g = 0, v = 0, y = e; y <= t; y++) {
- var b = this.particles[y];
- m = 3 * (f = b.idx),
- g = 4 * f,
- v = 2 * f,
- this.updateParticle(b);
- var T = b._rotationMatrix
- , E = b.position
- , S = b._globalPosition;
- if (this._computeParticleRotation && b.getRotationMatrix(n),
- null !== b.parentId) {
- var A = this.particles[b.parentId]
- , x = A._rotationMatrix
- , R = A._globalPosition
- , C = E.x * x[1] + E.y * x[4] + E.z * x[7]
- , M = E.x * x[0] + E.y * x[3] + E.z * x[6]
- , O = E.x * x[2] + E.y * x[5] + E.z * x[8];
- if (S.x = R.x + M,
- S.y = R.y + C,
- S.z = R.z + O,
- this._computeParticleRotation) {
- var D = n.m;
- T[0] = D[0] * x[0] + D[1] * x[3] + D[2] * x[6],
- T[1] = D[0] * x[1] + D[1] * x[4] + D[2] * x[7],
- T[2] = D[0] * x[2] + D[1] * x[5] + D[2] * x[8],
- T[3] = D[4] * x[0] + D[5] * x[3] + D[6] * x[6],
- T[4] = D[4] * x[1] + D[5] * x[4] + D[6] * x[7],
- T[5] = D[4] * x[2] + D[5] * x[5] + D[6] * x[8],
- T[6] = D[8] * x[0] + D[9] * x[3] + D[10] * x[6],
- T[7] = D[8] * x[1] + D[9] * x[4] + D[10] * x[7],
- T[8] = D[8] * x[2] + D[9] * x[5] + D[10] * x[8]
- }
- } else
- S.x = 0,
- S.y = 0,
- S.z = 0,
- this._computeParticleRotation && (D = n.m,
- T[0] = D[0],
- T[1] = D[1],
- T[2] = D[2],
- T[3] = D[4],
- T[4] = D[5],
- T[5] = D[6],
- T[6] = D[8],
- T[7] = D[9],
- T[8] = D[10]);
- var N = l[11];
- b.translateFromPivot ? N.setAll(0) : N.copyFrom(b.pivot);
- var L = l[0];
- L.copyFrom(b.position);
- var F = L.x - b.pivot.x
- , w = L.y - b.pivot.y
- , B = L.z - b.pivot.z
- , U = F * T[0] + w * T[3] + B * T[6]
- , V = F * T[1] + w * T[4] + B * T[7]
- , k = F * T[2] + w * T[5] + B * T[8];
- U += N.x,
- V += N.y,
- k += N.z;
- var G = a[m] = S.x + c.x * U + u.x * V + h.x * k
- , z = a[m + 1] = S.y + c.y * U + u.y * V + h.y * k
- , W = a[m + 2] = S.z + c.z * U + u.z * V + h.z * k;
- if (this._computeBoundingBox && (d.minimizeInPlaceFromFloats(G, z, W),
- p.maximizeInPlaceFromFloats(G, z, W)),
- this._computeParticleColor && b.color) {
- var H = b.color
- , X = this._colors32;
- X[g] = H.r,
- X[g + 1] = H.g,
- X[g + 2] = H.b,
- X[g + 3] = H.a
- }
- if (this._computeParticleTexture && b.uv) {
- var j = b.uv
- , Y = this._uvs32;
- Y[v] = j.x,
- Y[v + 1] = j.y
- }
- }
- return i && (this._computeParticleColor && r.updateVerticesData(Bi.ColorKind, o, !1, !1),
- this._computeParticleTexture && r.updateVerticesData(Bi.UVKind, s, !1, !1),
- r.updateVerticesData(Bi.PositionKind, a, !1, !1)),
- this._computeBoundingBox && (r.hasBoundingInfo ? r.getBoundingInfo().reConstruct(d, p, r._worldMatrix) : r.buildBoundingInfo(d, p, r._worldMatrix)),
- this.afterUpdateParticles(e, t, i),
- this
- }
- ,
- e.prototype.dispose = function() {
- this.mesh.dispose(),
- this.vars = null,
- this._positions = null,
- this._indices = null,
- this._normals = null,
- this._uvs = null,
- this._colors = null,
- this._indices32 = null,
- this._positions32 = null,
- this._uvs32 = null,
- this._colors32 = null
- }
- ,
- e.prototype.refreshVisibleSize = function() {
- return this._isVisibilityBoxLocked || this.mesh.refreshBoundingInfo(),
- this
- }
- ,
- e.prototype.setVisibilityBox = function(e) {
- var t = e / 2;
- this.mesh.buildBoundingInfo(new x(-t,-t,-t), new x(t,t,t))
- }
- ,
- Object.defineProperty(e.prototype, "isAlwaysVisible", {
- get: function() {
- return this._alwaysVisible
- },
- set: function(e) {
- this._alwaysVisible = e,
- this.mesh.alwaysSelectAsActiveMesh = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleRotation", {
- set: function(e) {
- this._computeParticleRotation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleColor", {
- get: function() {
- return this._computeParticleColor
- },
- set: function(e) {
- this._computeParticleColor = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeParticleTexture", {
- get: function() {
- return this._computeParticleTexture
- },
- set: function(e) {
- this._computeParticleTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeBoundingBox", {
- get: function() {
- return this._computeBoundingBox
- },
- set: function(e) {
- this._computeBoundingBox = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initParticles = function() {}
- ,
- e.prototype.recycleParticle = function(e) {
- return e
- }
- ,
- e.prototype.updateParticle = function(e) {
- return e
- }
- ,
- e.prototype.beforeUpdateParticles = function(e, t, i) {}
- ,
- e.prototype.afterUpdateParticles = function(e, t, i) {}
- ,
- e
- }();
- mn.prototype.getPhysicsEngine = function() {
- return this._physicsEngine
- }
- ,
- mn.prototype.enablePhysics = function(e, t) {
- if (void 0 === e && (e = null),
- this._physicsEngine)
- return !0;
- var i = this._getComponent(Wi.NAME_PHYSICSENGINE);
- i || (i = new My(this),
- this._addComponent(i));
- try {
- return this._physicsEngine = new R_(e,t),
- this._physicsTimeAccumulator = 0,
- !0
- } catch (e) {
- return K.Error(e.message),
- !1
- }
- }
- ,
- mn.prototype.disablePhysicsEngine = function() {
- this._physicsEngine && (this._physicsEngine.dispose(),
- this._physicsEngine = null)
- }
- ,
- mn.prototype.isPhysicsEnabled = function() {
- return void 0 !== this._physicsEngine
- }
- ,
- mn.prototype.deleteCompoundImpostor = function(e) {
- var t = e.parts[0].mesh;
- t.physicsImpostor && (t.physicsImpostor.dispose(),
- t.physicsImpostor = null)
- }
- ,
- mn.prototype._advancePhysicsEngineStep = function(e) {
- if (this._physicsEngine) {
- var t = this._physicsEngine.getSubTimeStep();
- if (t > 0)
- for (this._physicsTimeAccumulator += e; this._physicsTimeAccumulator > t; )
- this.onBeforePhysicsObservable.notifyObservers(this),
- this._physicsEngine._step(t / 1e3),
- this.onAfterPhysicsObservable.notifyObservers(this),
- this._physicsTimeAccumulator -= t;
- else
- this.onBeforePhysicsObservable.notifyObservers(this),
- this._physicsEngine._step(e / 1e3),
- this.onAfterPhysicsObservable.notifyObservers(this)
- }
- }
- ,
- Object.defineProperty(Sr.prototype, "physicsImpostor", {
- get: function() {
- return this._physicsImpostor
- },
- set: function(e) {
- var t = this;
- this._physicsImpostor !== e && (this._disposePhysicsObserver && this.onDisposeObservable.remove(this._disposePhysicsObserver),
- this._physicsImpostor = e,
- e && (this._disposePhysicsObserver = this.onDisposeObservable.add((function() {
- t.physicsImpostor && (t.physicsImpostor.dispose(),
- t.physicsImpostor = null)
- }
- ))))
- },
- enumerable: !0,
- configurable: !0
- }),
- Sr.prototype.getPhysicsImpostor = function() {
- return this.physicsImpostor
- }
- ,
- Sr.prototype.applyImpulse = function(e, t) {
- return this.physicsImpostor ? (this.physicsImpostor.applyImpulse(e, t),
- this) : this
- }
- ,
- Sr.prototype.setPhysicsLinkWith = function(e, t, i, n) {
- return this.physicsImpostor && e.physicsImpostor ? (this.physicsImpostor.createJoint(e.physicsImpostor, Ll.HingeJoint, {
- mainPivot: t,
- connectedPivot: i,
- nativeParams: n
- }),
- this) : this
- }
- ;
- var Cy, Py, My = function() {
- function e(e) {
- var t = this;
- this.name = Wi.NAME_PHYSICSENGINE,
- this.scene = e,
- this.scene.onBeforePhysicsObservable = new h,
- this.scene.onAfterPhysicsObservable = new h,
- this.scene.getDeterministicFrameTime = function() {
- return t.scene._physicsEngine ? 1e3 * t.scene._physicsEngine.getTimeStep() : 1e3 / 60
- }
- }
- return e.prototype.register = function() {}
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {
- this.scene.onBeforePhysicsObservable.clear(),
- this.scene.onAfterPhysicsObservable.clear(),
- this.scene._physicsEngine && this.scene.disablePhysicsEngine()
- }
- ,
- e
- }(), Iy = function() {
- function e(e) {
- this._scene = e,
- this._physicsEngine = this._scene.getPhysicsEngine(),
- this._physicsEngine || K.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")
- }
- return e.prototype.applyRadialExplosionImpulse = function(e, t, i, n) {
- if (!this._physicsEngine)
- return K.Warn("Physics engine not enabled. Please enable the physics before you call this method."),
- null;
- var r = this._physicsEngine.getImpostors();
- if (0 === r.length)
- return null;
- "number" == typeof t && ((t = new Fy).radius = t,
- t.strength = i || t.strength,
- t.falloff = n || t.falloff);
- var o = new Oy(this._scene,t)
- , a = Array();
- return r.forEach((function(t) {
- var i = o.getImpostorHitData(t, e);
- i && (t.applyImpulse(i.force, i.contactPoint),
- a.push({
- impostor: t,
- hitData: i
- }))
- }
- )),
- o.triggerAffectedImpostorsCallback(a),
- o.dispose(!1),
- o
- }
- ,
- e.prototype.applyRadialExplosionForce = function(e, t, i, n) {
- if (!this._physicsEngine)
- return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
- null;
- var r = this._physicsEngine.getImpostors();
- if (0 === r.length)
- return null;
- "number" == typeof t && ((t = new Fy).radius = t,
- t.strength = i || t.strength,
- t.falloff = n || t.falloff);
- var o = new Oy(this._scene,t)
- , a = Array();
- return r.forEach((function(t) {
- var i = o.getImpostorHitData(t, e);
- i && (t.applyForce(i.force, i.contactPoint),
- a.push({
- impostor: t,
- hitData: i
- }))
- }
- )),
- o.triggerAffectedImpostorsCallback(a),
- o.dispose(!1),
- o
- }
- ,
- e.prototype.gravitationalField = function(e, t, i, n) {
- if (!this._physicsEngine)
- return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
- null;
- if (0 === this._physicsEngine.getImpostors().length)
- return null;
- "number" == typeof t && ((t = new Fy).radius = t,
- t.strength = i || t.strength,
- t.falloff = n || t.falloff);
- var r = new Dy(this,this._scene,e,t);
- return r.dispose(!1),
- r
- }
- ,
- e.prototype.updraft = function(e, t, i, n, r) {
- if (!this._physicsEngine)
- return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
- null;
- if (0 === this._physicsEngine.getImpostors().length)
- return null;
- "number" == typeof t && ((t = new wy).radius = t,
- t.strength = i || t.strength,
- t.height = n || t.height,
- t.updraftMode = r || t.updraftMode);
- var o = new Ny(this._scene,e,t);
- return o.dispose(!1),
- o
- }
- ,
- e.prototype.vortex = function(e, t, i, n) {
- if (!this._physicsEngine)
- return K.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),
- null;
- if (0 === this._physicsEngine.getImpostors().length)
- return null;
- "number" == typeof t && ((t = new By).radius = t,
- t.strength = i || t.strength,
- t.height = n || t.height);
- var r = new Ly(this._scene,e,t);
- return r.dispose(!1),
- r
- }
- ,
- e
- }(), Oy = function() {
- function e(e, t) {
- this._scene = e,
- this._options = t,
- this._dataFetched = !1,
- this._options = V(V({}, new Fy), this._options)
- }
- return e.prototype.getData = function() {
- return this._dataFetched = !0,
- {
- sphere: this._sphere
- }
- }
- ,
- e.prototype.getImpostorHitData = function(e, t) {
- if (0 === e.mass)
- return null;
- if (!this._intersectsWithSphere(e, t, this._options.radius))
- return null;
- if ("Mesh" !== e.object.getClassName() && "InstancedMesh" !== e.object.getClassName())
- return null;
- var i = e.getObjectCenter().subtract(t)
- , n = new _o(t,i,this._options.radius).intersectsMesh(e.object).pickedPoint;
- if (!n)
- return null;
- var r = x.Distance(t, n);
- if (r > this._options.radius)
- return null;
- var o = this._options.falloff === Cy.Constant ? this._options.strength : this._options.strength * (1 - r / this._options.radius);
- return {
- force: i.multiplyByFloats(o, o, o),
- contactPoint: n,
- distanceFromOrigin: r
- }
- }
- ,
- e.prototype.triggerAffectedImpostorsCallback = function(e) {
- this._options.affectedImpostorsCallback && this._options.affectedImpostorsCallback(e)
- }
- ,
- e.prototype.dispose = function(e) {
- var t = this;
- void 0 === e && (e = !0),
- e ? this._sphere.dispose() : setTimeout((function() {
- t._dataFetched || t._sphere.dispose()
- }
- ), 0)
- }
- ,
- e.prototype._prepareSphere = function() {
- this._sphere || (this._sphere = Dl("radialExplosionEventSphere", this._options.sphere, this._scene),
- this._sphere.isVisible = !1)
- }
- ,
- e.prototype._intersectsWithSphere = function(e, t, i) {
- var n = e.object;
- return this._prepareSphere(),
- this._sphere.position = t,
- this._sphere.scaling = new x(2 * i,2 * i,2 * i),
- this._sphere._updateBoundingInfo(),
- this._sphere.computeWorldMatrix(!0),
- this._sphere.intersectsMesh(n, !0)
- }
- ,
- e
- }(), Dy = function() {
- function e(e, t, i, n) {
- this._physicsHelper = e,
- this._scene = t,
- this._origin = i,
- this._options = n,
- this._dataFetched = !1,
- this._options = V(V({}, new Fy), this._options),
- this._tickCallback = this._tick.bind(this),
- this._options.strength = -1 * this._options.strength
- }
- return e.prototype.getData = function() {
- return this._dataFetched = !0,
- {
- sphere: this._sphere
- }
- }
- ,
- e.prototype.enable = function() {
- this._tickCallback.call(this),
- this._scene.registerBeforeRender(this._tickCallback)
- }
- ,
- e.prototype.disable = function() {
- this._scene.unregisterBeforeRender(this._tickCallback)
- }
- ,
- e.prototype.dispose = function(e) {
- var t = this;
- void 0 === e && (e = !0),
- e ? this._sphere.dispose() : setTimeout((function() {
- t._dataFetched || t._sphere.dispose()
- }
- ), 0)
- }
- ,
- e.prototype._tick = function() {
- if (this._sphere)
- this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
- else {
- var e = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
- e && (this._sphere = e.getData().sphere.clone("radialExplosionEventSphereClone"))
- }
- }
- ,
- e
- }(), Ny = function() {
- function e(e, t, i) {
- this._scene = e,
- this._origin = t,
- this._options = i,
- this._originTop = x.Zero(),
- this._originDirection = x.Zero(),
- this._cylinderPosition = x.Zero(),
- this._dataFetched = !1,
- this._physicsEngine = this._scene.getPhysicsEngine(),
- this._options = V(V({}, new wy), this._options),
- this._origin.addToRef(new x(0,this._options.height / 2,0), this._cylinderPosition),
- this._origin.addToRef(new x(0,this._options.height,0), this._originTop),
- this._options.updraftMode === Py.Perpendicular && (this._originDirection = this._origin.subtract(this._originTop).normalize()),
- this._tickCallback = this._tick.bind(this),
- this._prepareCylinder()
- }
- return e.prototype.getData = function() {
- return this._dataFetched = !0,
- {
- cylinder: this._cylinder
- }
- }
- ,
- e.prototype.enable = function() {
- this._tickCallback.call(this),
- this._scene.registerBeforeRender(this._tickCallback)
- }
- ,
- e.prototype.disable = function() {
- this._scene.unregisterBeforeRender(this._tickCallback)
- }
- ,
- e.prototype.dispose = function(e) {
- var t = this;
- void 0 === e && (e = !0),
- this._cylinder && (e ? this._cylinder.dispose() : setTimeout((function() {
- t._dataFetched || t._cylinder.dispose()
- }
- ), 0))
- }
- ,
- e.prototype._getImpostorHitData = function(e) {
- if (0 === e.mass)
- return null;
- if (!this._intersectsWithCylinder(e))
- return null;
- var t, i = e.getObjectCenter();
- t = this._options.updraftMode === Py.Perpendicular ? this._originDirection : i.subtract(this._originTop);
- var n = x.Distance(this._origin, i)
- , r = -1 * this._options.strength;
- return {
- force: t.multiplyByFloats(r, r, r),
- contactPoint: i,
- distanceFromOrigin: n
- }
- }
- ,
- e.prototype._tick = function() {
- var e = this;
- this._physicsEngine.getImpostors().forEach((function(t) {
- var i = e._getImpostorHitData(t);
- i && t.applyForce(i.force, i.contactPoint)
- }
- ))
- }
- ,
- e.prototype._prepareCylinder = function() {
- this._cylinder || (this._cylinder = Ys("updraftEventCylinder", {
- height: this._options.height,
- diameter: 2 * this._options.radius
- }, this._scene),
- this._cylinder.isVisible = !1)
- }
- ,
- e.prototype._intersectsWithCylinder = function(e) {
- var t = e.object;
- return this._cylinder.position = this._cylinderPosition,
- this._cylinder.intersectsMesh(t, !0)
- }
- ,
- e
- }(), Ly = function() {
- function e(e, t, i) {
- this._scene = e,
- this._origin = t,
- this._options = i,
- this._originTop = x.Zero(),
- this._cylinderPosition = x.Zero(),
- this._dataFetched = !1,
- this._physicsEngine = this._scene.getPhysicsEngine(),
- this._options = V(V({}, new By), this._options),
- this._origin.addToRef(new x(0,this._options.height / 2,0), this._cylinderPosition),
- this._origin.addToRef(new x(0,this._options.height,0), this._originTop),
- this._tickCallback = this._tick.bind(this),
- this._prepareCylinder()
- }
- return e.prototype.getData = function() {
- return this._dataFetched = !0,
- {
- cylinder: this._cylinder
- }
- }
- ,
- e.prototype.enable = function() {
- this._tickCallback.call(this),
- this._scene.registerBeforeRender(this._tickCallback)
- }
- ,
- e.prototype.disable = function() {
- this._scene.unregisterBeforeRender(this._tickCallback)
- }
- ,
- e.prototype.dispose = function(e) {
- var t = this;
- void 0 === e && (e = !0),
- e ? this._cylinder.dispose() : setTimeout((function() {
- t._dataFetched || t._cylinder.dispose()
- }
- ), 0)
- }
- ,
- e.prototype._getImpostorHitData = function(e) {
- if (0 === e.mass)
- return null;
- if (!this._intersectsWithCylinder(e))
- return null;
- if ("Mesh" !== e.object.getClassName() && "InstancedMesh" !== e.object.getClassName())
- return null;
- var t = e.getObjectCenter()
- , i = new x(this._origin.x,t.y,this._origin.z)
- , n = t.subtract(i)
- , r = new _o(i,n,this._options.radius).intersectsMesh(e.object)
- , o = r.pickedPoint;
- if (!o)
- return null;
- var a, s, l, c = r.distance / this._options.radius, u = o.normalize();
- if (c > this._options.centripetalForceThreshold && (u = u.negate()),
- c > this._options.centripetalForceThreshold)
- a = u.x * this._options.centripetalForceMultiplier,
- s = u.y * this._options.updraftForceMultiplier,
- l = u.z * this._options.centripetalForceMultiplier;
- else {
- var h = x.Cross(i, t).normalize();
- a = (h.x + u.x) * this._options.centrifugalForceMultiplier,
- s = this._originTop.y * this._options.updraftForceMultiplier,
- l = (h.z + u.z) * this._options.centrifugalForceMultiplier
- }
- var d = new x(a,s,l);
- return {
- force: d = d.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength),
- contactPoint: t,
- distanceFromOrigin: c
- }
- }
- ,
- e.prototype._tick = function() {
- var e = this;
- this._physicsEngine.getImpostors().forEach((function(t) {
- var i = e._getImpostorHitData(t);
- i && t.applyForce(i.force, i.contactPoint)
- }
- ))
- }
- ,
- e.prototype._prepareCylinder = function() {
- this._cylinder || (this._cylinder = Ys("vortexEventCylinder", {
- height: this._options.height,
- diameter: 2 * this._options.radius
- }, this._scene),
- this._cylinder.isVisible = !1)
- }
- ,
- e.prototype._intersectsWithCylinder = function(e) {
- var t = e.object;
- return this._cylinder.position = this._cylinderPosition,
- this._cylinder.intersectsMesh(t, !0)
- }
- ,
- e
- }(), Fy = function() {
- this.radius = 5,
- this.strength = 10,
- this.falloff = Cy.Constant,
- this.sphere = {
- segments: 32,
- diameter: 1
- }
- }, wy = function() {
- this.radius = 5,
- this.strength = 10,
- this.height = 10,
- this.updraftMode = Py.Center
- }, By = function() {
- this.radius = 5,
- this.strength = 10,
- this.height = 10,
- this.centripetalForceThreshold = .7,
- this.centripetalForceMultiplier = 5,
- this.centrifugalForceMultiplier = .5,
- this.updraftForceMultiplier = .02
- };
- !function(e) {
- e[e.Constant = 0] = "Constant",
- e[e.Linear = 1] = "Linear"
- }(Cy || (Cy = {})),
- function(e) {
- e[e.Center = 0] = "Center",
- e[e.Perpendicular = 1] = "Perpendicular"
- }(Py || (Py = {}));
- Pt.ShadersStore.blackAndWhitePixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11)); \nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}";
- var Uy = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, "blackAndWhite", ["degree"], null, i, n, r, o, a) || this;
- return s.degree = 1,
- s.onApplyObservable.add((function(e) {
- e.setFloat("degree", s.degree)
- }
- )),
- s
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "BlackAndWhitePostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "degree", void 0),
- t
- }(Ba);
- y("BABYLON.BlackAndWhitePostProcess", Uy);
- var Vy = function() {
- function e(e, t, i, n) {
- this._name = t,
- this._singleInstance = n || !0,
- this._getPostProcesses = i,
- this._cameras = {},
- this._indicesForCamera = {},
- this._postProcesses = {}
- }
- return Object.defineProperty(e.prototype, "isSupported", {
- get: function() {
- for (var e in this._postProcesses)
- if (Object.prototype.hasOwnProperty.call(this._postProcesses, e))
- for (var t = this._postProcesses[e], i = 0; i < t.length; i++)
- if (!t[i].isSupported)
- return !1;
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._update = function() {}
- ,
- e.prototype._attachCameras = function(e) {
- var t, i = this, n = gi.MakeArray(e || this._cameras);
- if (n)
- for (var r = function(e) {
- var r = n[e];
- if (!r)
- return "continue";
- var a = r.name;
- if (t = o._singleInstance ? 0 : a,
- !o._postProcesses[t]) {
- var s = o._getPostProcesses();
- s && (o._postProcesses[t] = Array.isArray(s) ? s : [s])
- }
- o._indicesForCamera[a] || (o._indicesForCamera[a] = []),
- o._postProcesses[t].forEach((function(e) {
- var t = r.attachPostProcess(e);
- i._indicesForCamera[a].push(t)
- }
- )),
- o._cameras[a] || (o._cameras[a] = r)
- }, o = this, a = 0; a < n.length; a++)
- r(a)
- }
- ,
- e.prototype._detachCameras = function(e) {
- var t = gi.MakeArray(e || this._cameras);
- if (t)
- for (var i = function(e) {
- var i = t[e]
- , r = i.name
- , o = n._postProcesses[n._singleInstance ? 0 : r];
- o && o.forEach((function(e) {
- i.detachPostProcess(e)
- }
- )),
- n._cameras[r] && (n._cameras[r] = null)
- }, n = this, r = 0; r < t.length; r++)
- i(r)
- }
- ,
- e.prototype._enable = function(e) {
- var t = this
- , i = gi.MakeArray(e || this._cameras);
- if (i)
- for (var n = function(e) {
- for (var n = i[e], o = n.name, a = function(a) {
- void 0 !== n._postProcesses[r._indicesForCamera[o][a]] && null !== n._postProcesses[r._indicesForCamera[o][a]] || r._postProcesses[r._singleInstance ? 0 : o].forEach((function(n) {
- i[e].attachPostProcess(n, t._indicesForCamera[o][a])
- }
- ))
- }, s = 0; s < r._indicesForCamera[o].length; s++)
- a(s)
- }, r = this, o = 0; o < i.length; o++)
- n(o)
- }
- ,
- e.prototype._disable = function(e) {
- var t = gi.MakeArray(e || this._cameras);
- if (t)
- for (var i = function(e) {
- var i = t[e]
- , r = i.name;
- n._postProcesses[n._singleInstance ? 0 : r].forEach((function(e) {
- i.detachPostProcess(e)
- }
- ))
- }, n = this, r = 0; r < t.length; r++)
- i(r)
- }
- ,
- e.prototype.getPostProcesses = function(e) {
- return this._singleInstance ? this._postProcesses[0] : e ? this._postProcesses[e.name] : null
- }
- ,
- e
- }();
- Pt.ShadersStore.extractHighlightsPixelShader = "#include<helperFunctions>\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float threshold;\nuniform float exposure;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\nfloat luma=getLuminance(gl_FragColor.rgb*exposure);\ngl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;\n}";
- var ky = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === c && (c = !1);
- var u = e.call(this, t, "extractHighlights", ["threshold", "exposure"], null, i, n, r, o, s, null, l, void 0, null, c) || this;
- return u.threshold = .9,
- u._exposure = 1,
- u._inputPostProcess = null,
- u.onApplyObservable.add((function(e) {
- u.externalTextureSamplerBinding = !!u._inputPostProcess,
- u._inputPostProcess && e.setTextureFromPostProcess("textureSampler", u._inputPostProcess),
- e.setFloat("threshold", Math.pow(u.threshold, p)),
- e.setFloat("exposure", u._exposure)
- }
- )),
- u
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ExtractHighlightsPostProcess"
- }
- ,
- k([Ce()], t.prototype, "threshold", void 0),
- t
- }(Ba);
- y("BABYLON.ExtractHighlightsPostProcess", ky);
- Pt.ShadersStore.bloomMergePixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D bloomBlur;\nvarying vec2 vUV;\nuniform float bloomWeight;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec3 blurred=texture2D(bloomBlur,vUV).rgb;\ngl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); \n}\n";
- var Gy = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h, d) {
- void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === d && (d = !1);
- var p = e.call(this, t, "bloomMerge", ["bloomWeight"], ["bloomBlur"], o, s, l, c, u, null, h, void 0, null, !0) || this;
- return p.weight = 1,
- p.weight = r,
- p.externalTextureSamplerBinding = !0,
- p.onApplyObservable.add((function(e) {
- e.setTextureFromPostProcess("textureSampler", i),
- e.setTextureFromPostProcessOutput("bloomBlur", n),
- e.setFloat("bloomWeight", p.weight)
- }
- )),
- d || p.updateEffect(),
- p
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "BloomMergePostProcess"
- }
- ,
- k([Ce()], t.prototype, "weight", void 0),
- t
- }(Ba);
- y("BABYLON.BloomMergePostProcess", Gy);
- var zy = function(e) {
- function t(t, i, n, r, o, a) {
- void 0 === o && (o = 0),
- void 0 === a && (a = !1);
- var s = e.call(this, t.getEngine(), "bloom", (function() {
- return s._effects
- }
- ), !0) || this;
- return s._bloomScale = i,
- s._effects = [],
- s._downscale = new ky("highlights",1,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,a),
- s._blurX = new Fd("horizontal blur",new A(1,0),10,i,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,a),
- s._blurX.alwaysForcePOT = !0,
- s._blurX.autoClear = !1,
- s._blurY = new Fd("vertical blur",new A(0,1),10,i,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,a),
- s._blurY.alwaysForcePOT = !0,
- s._blurY.autoClear = !1,
- s.kernel = r,
- s._effects = [s._downscale, s._blurX, s._blurY],
- s._merge = new Gy("bloomMerge",s._downscale,s._blurY,n,i,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,a),
- s._merge.autoClear = !1,
- s._effects.push(s._merge),
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "threshold", {
- get: function() {
- return this._downscale.threshold
- },
- set: function(e) {
- this._downscale.threshold = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "weight", {
- get: function() {
- return this._merge.weight
- },
- set: function(e) {
- this._merge.weight = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "kernel", {
- get: function() {
- return this._blurX.kernel / this._bloomScale
- },
- set: function(e) {
- this._blurX.kernel = e * this._bloomScale,
- this._blurY.kernel = e * this._bloomScale
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.disposeEffects = function(e) {
- for (var t = 0; t < this._effects.length; t++)
- this._effects[t].dispose(e)
- }
- ,
- t.prototype._updateEffects = function() {
- for (var e = 0; e < this._effects.length; e++)
- this._effects[e].updateEffect()
- }
- ,
- t.prototype._isReady = function() {
- for (var e = 0; e < this._effects.length; e++)
- if (!this._effects[e].isReady())
- return !1;
- return !0
- }
- ,
- t
- }(Vy);
- Pt.ShadersStore.chromaticAberrationPixelShader = "uniform sampler2D textureSampler; \nuniform float chromatic_aberration;\nuniform float radialIntensity;\nuniform vec2 direction;\nuniform vec2 centerPosition;\nuniform float screen_width;\nuniform float screen_height;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);\nvec2 directionOfEffect=direction;\nif(directionOfEffect.x==0. && directionOfEffect.y==0.){\ndirectionOfEffect=normalize(centered_screen_pos);\n}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+ centered_screen_pos.y*centered_screen_pos.y;\nfloat radius=sqrt(radius2);\nvec4 original=texture2D(textureSampler,vUV);\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;\nfloat ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\noriginal.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);\ngl_FragColor=original;\n}";
- var Wy = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h) {
- void 0 === u && (u = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === h && (h = !1);
- var d = e.call(this, t, "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], [], r, o, s, l, c, null, u, void 0, null, h) || this;
- return d.aberrationAmount = 30,
- d.radialIntensity = 0,
- d.direction = new A(.707,.707),
- d.centerPosition = new A(.5,.5),
- d.screenWidth = i,
- d.screenHeight = n,
- d.onApplyObservable.add((function(e) {
- e.setFloat("chromatic_aberration", d.aberrationAmount),
- e.setFloat("screen_width", i),
- e.setFloat("screen_height", n),
- e.setFloat("radialIntensity", d.radialIntensity),
- e.setFloat2("direction", d.direction.x, d.direction.y),
- e.setFloat2("centerPosition", d.centerPosition.x, d.centerPosition.y)
- }
- )),
- d
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ChromaticAberrationPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.screenWidth,e.screenHeight,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "aberrationAmount", void 0),
- k([Ce()], t.prototype, "radialIntensity", void 0),
- k([Ce()], t.prototype, "direction", void 0),
- k([Ce()], t.prototype, "centerPosition", void 0),
- k([Ce()], t.prototype, "screenWidth", void 0),
- k([Ce()], t.prototype, "screenHeight", void 0),
- t
- }(Ba);
- y("BABYLON.ChromaticAberrationPostProcess", Wy);
- Pt.ShadersStore.circleOfConfusionPixelShader = "uniform sampler2D depthSampler;\nvarying vec2 vUV;\nuniform vec2 cameraMinMaxZ;\nuniform float focusDistance;\nuniform float cocPrecalculation;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0; \nfloat coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));\ncoc=clamp(coc,0.0,1.0);\ngl_FragColor=vec4(coc,depth,coc,1.0);\n}\n";
- var Hy = function(e) {
- function t(t, i, n, r, o, s, l, c, u) {
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = !1);
- var h = e.call(this, t, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], n, r, o, s, l, null, c, void 0, null, u) || this;
- return h.lensSize = 50,
- h.fStop = 1.4,
- h.focusDistance = 2e3,
- h.focalLength = 50,
- h._depthTexture = null,
- h._depthTexture = i,
- h.onApplyObservable.add((function(e) {
- if (h._depthTexture) {
- e.setTexture("depthSampler", h._depthTexture);
- var t = h.lensSize / h.fStop * h.focalLength / (h.focusDistance - h.focalLength);
- e.setFloat("focusDistance", h.focusDistance),
- e.setFloat("cocPrecalculation", t),
- e.setFloat2("cameraMinMaxZ", h._depthTexture.activeCamera.minZ, h._depthTexture.activeCamera.maxZ)
- } else
- K.Warn("No depth texture set on CircleOfConfusionPostProcess")
- }
- )),
- h
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "CircleOfConfusionPostProcess"
- }
- ,
- Object.defineProperty(t.prototype, "depthTexture", {
- set: function(e) {
- this._depthTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- k([Ce()], t.prototype, "lensSize", void 0),
- k([Ce()], t.prototype, "fStop", void 0),
- k([Ce()], t.prototype, "focusDistance", void 0),
- k([Ce()], t.prototype, "focalLength", void 0),
- t
- }(Ba);
- y("BABYLON.CircleOfConfusionPostProcess", Hy);
- Pt.ShadersStore.colorCorrectionPixelShader = "uniform sampler2D textureSampler; \nuniform sampler2D colorTable; \nvarying vec2 vUV;\nconst float SLICE_COUNT=16.0; \nvec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {\nfloat sliceSize=1.0/width; \nfloat slicePixelSize=sliceSize/width; \nfloat sliceInnerSize=slicePixelSize*(width-1.0); \nfloat zSlice0=min(floor(uv.z*width),width-1.0);\nfloat zSlice1=min(zSlice0+1.0,width-1.0);\nfloat xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;\nfloat s0=xOffset+(zSlice0*sliceSize);\nfloat s1=xOffset+(zSlice1*sliceSize);\nvec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));\nvec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));\nfloat zOffset=mod(uv.z*width,1.0);\nvec4 result=mix(slice0Color,slice1Color,zOffset);\nreturn result;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}";
- var Xy = function(e) {
- function t(t, i, n, r, o, a, s) {
- var l = e.call(this, t, "colorCorrection", null, ["colorTable"], n, r, o, a, s) || this;
- return l._colorTableTexture = new io(i,r.getScene(),!0,!1,io.TRILINEAR_SAMPLINGMODE),
- l._colorTableTexture.anisotropicFilteringLevel = 1,
- l._colorTableTexture.wrapU = io.CLAMP_ADDRESSMODE,
- l._colorTableTexture.wrapV = io.CLAMP_ADDRESSMODE,
- l.colorTableUrl = i,
- l.onApply = function(e) {
- e.setTexture("colorTable", l._colorTableTexture)
- }
- ,
- l
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ColorCorrectionPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.colorTableUrl,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "colorTableUrl", void 0),
- t
- }(Ba);
- y("BABYLON.ColorCorrectionPostProcess", Xy);
- Pt.ShadersStore.convolutionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}";
- var jy = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
- var u = e.call(this, t, "convolution", ["kernel", "screenSize"], null, n, r, o, s, l, null, c) || this;
- return u.kernel = i,
- u.onApply = function(e) {
- e.setFloat2("screenSize", u.width, u.height),
- e.setArray("kernel", u.kernel)
- }
- ,
- u
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ConvolutionPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType)
- }
- ), e, n, r)
- }
- ,
- t.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1],
- t.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0],
- t.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1],
- t.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0],
- t.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2],
- t.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0],
- k([Ce()], t.prototype, "kernel", void 0),
- t
- }(Ba);
- y("BABYLON.ConvolutionPostProcess", jy);
- var Yy = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h, d, p, f) {
- void 0 === c && (c = null),
- void 0 === u && (u = io.BILINEAR_SAMPLINGMODE),
- void 0 === p && (p = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === f && (f = !1);
- var _ = e.call(this, t, n, r, o, s, u = a.TEXTURE_BILINEAR_SAMPLINGMODE, h, d, p = a.TEXTURETYPE_UNSIGNED_INT, "#define DOF 1\r\n", f) || this;
- return _.direction = n,
- _.externalTextureSamplerBinding = !!c,
- _.onApplyObservable.add((function(e) {
- null != c && e.setTextureFromPostProcess("textureSampler", c),
- e.setTextureFromPostProcessOutput("circleOfConfusionSampler", l),
- i.activeCamera && e.setFloat2("cameraMinMaxZ", i.activeCamera.minZ, i.activeCamera.maxZ)
- }
- )),
- _
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DepthOfFieldBlurPostProcess"
- }
- ,
- k([Ce()], t.prototype, "direction", void 0),
- t
- }(Fd);
- y("BABYLON.DepthOfFieldBlurPostProcess", Yy);
- Pt.ShadersStore.depthOfFieldMergePixelShader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\nuniform sampler2D circleOfConfusionSampler;\nuniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\n#if BLUR_LEVEL==0\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred0=texture2D(blurStep0,vUV);\ngl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(original,blurred1,coc/0.5);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV); \nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\n}\n#endif\n#if BLUR_LEVEL==2\nif(coc<0.33){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(original,blurred2,coc/0.33);\n}else if(coc<0.66){\nvec4 blurred1=texture2D(blurStep1,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\n}\n#endif\n}\n";
- var Ky, Qy = function() {}, qy = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h, d) {
- void 0 === h && (h = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === d && (d = !1);
- var p = e.call(this, t, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], o, s, l, c, u, null, h, void 0, null, !0) || this;
- return p._blurSteps = r,
- p.externalTextureSamplerBinding = !0,
- p.onApplyObservable.add((function(e) {
- e.setTextureFromPostProcess("textureSampler", i),
- e.setTextureFromPostProcessOutput("circleOfConfusionSampler", n),
- r.forEach((function(t, i) {
- e.setTextureFromPostProcessOutput("blurStep" + (r.length - i - 1), t)
- }
- ))
- }
- )),
- d || p.updateEffect(),
- p
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DepthOfFieldMergePostProcess"
- }
- ,
- t.prototype.updateEffect = function(t, i, n, r, o, a) {
- void 0 === t && (t = null),
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- t || (t = "",
- t += "#define BLUR_LEVEL " + (this._blurSteps.length - 1) + "\n"),
- e.prototype.updateEffect.call(this, t, i, n, r, o, a)
- }
- ,
- t
- }(Ba);
- !function(e) {
- e[e.Low = 0] = "Low",
- e[e.Medium = 1] = "Medium",
- e[e.High = 2] = "High"
- }(Ky || (Ky = {}));
- var Zy = function(e) {
- function t(t, i, n, r, o) {
- void 0 === n && (n = Ky.Low),
- void 0 === r && (r = 0),
- void 0 === o && (o = !1);
- var a = e.call(this, t.getEngine(), "depth of field", (function() {
- return a._effects
- }
- ), !0) || this;
- a._effects = [],
- a._circleOfConfusion = new Hy("circleOfConfusion",i,1,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),
- a._depthOfFieldBlurY = [],
- a._depthOfFieldBlurX = [];
- var s = 1
- , l = 15;
- switch (n) {
- case Ky.High:
- s = 3,
- l = 51;
- break;
- case Ky.Medium:
- s = 2,
- l = 31;
- break;
- default:
- l = 15,
- s = 1
- }
- for (var c = l / Math.pow(2, s - 1), u = 1, h = 0; h < s; h++) {
- var d = new Yy("vertical blur",t,new A(0,1),c,u,null,a._circleOfConfusion,0 == h ? a._circleOfConfusion : null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o);
- d.autoClear = !1,
- u = .75 / Math.pow(2, h);
- var p = new Yy("horizontal blur",t,new A(1,0),c,u,null,a._circleOfConfusion,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o);
- p.autoClear = !1,
- a._depthOfFieldBlurY.push(d),
- a._depthOfFieldBlurX.push(p)
- }
- for (a._effects = [a._circleOfConfusion],
- h = 0; h < a._depthOfFieldBlurX.length; h++)
- a._effects.push(a._depthOfFieldBlurY[h]),
- a._effects.push(a._depthOfFieldBlurX[h]);
- return a._dofMerge = new qy("dofMerge",a._circleOfConfusion,a._circleOfConfusion,a._depthOfFieldBlurX,u,null,io.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),
- a._dofMerge.autoClear = !1,
- a._effects.push(a._dofMerge),
- a
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "focalLength", {
- get: function() {
- return this._circleOfConfusion.focalLength
- },
- set: function(e) {
- this._circleOfConfusion.focalLength = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fStop", {
- get: function() {
- return this._circleOfConfusion.fStop
- },
- set: function(e) {
- this._circleOfConfusion.fStop = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "focusDistance", {
- get: function() {
- return this._circleOfConfusion.focusDistance
- },
- set: function(e) {
- this._circleOfConfusion.focusDistance = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "lensSize", {
- get: function() {
- return this._circleOfConfusion.lensSize
- },
- set: function(e) {
- this._circleOfConfusion.lensSize = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "DepthOfFieldEffect"
- }
- ,
- Object.defineProperty(t.prototype, "depthTexture", {
- set: function(e) {
- this._circleOfConfusion.depthTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.disposeEffects = function(e) {
- for (var t = 0; t < this._effects.length; t++)
- this._effects[t].dispose(e)
- }
- ,
- t.prototype._updateEffects = function() {
- for (var e = 0; e < this._effects.length; e++)
- this._effects[e].updateEffect()
- }
- ,
- t.prototype._isReady = function() {
- for (var e = 0; e < this._effects.length; e++)
- if (!this._effects[e].isReady())
- return !1;
- return !0
- }
- ,
- t
- }(Vy);
- Pt.ShadersStore.displayPassPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
- var Jy = function(e) {
- function t(t, i, n, r, o, a) {
- return e.call(this, t, "displayPass", ["passSampler"], ["passSampler"], i, n, r, o, a) || this
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "DisplayPassPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- t
- }(Ba);
- y("BABYLON.DisplayPassPostProcess", Jy);
- Pt.ShadersStore.filterPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}";
- var $y = function(e) {
- function t(t, i, n, r, o, a, s) {
- var l = e.call(this, t, "filter", ["kernelMatrix"], null, n, r, o, a, s) || this;
- return l.kernelMatrix = i,
- l.onApply = function(e) {
- e.setMatrix("kernelMatrix", l.kernelMatrix)
- }
- ,
- l
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FilterPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.kernelMatrix,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ue()], t.prototype, "kernelMatrix", void 0),
- t
- }(Ba);
- y("BABYLON.FilterPostProcess", $y);
- Pt.ShadersStore.fxaaPixelShader = "uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\nreturn;\n}\n#endif\nfloat lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));\nfloat lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));\nfloat lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));\nfloat lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));\nfloat lumaNS=lumaN+lumaS;\nfloat lumaWE=lumaW+lumaE;\nfloat subpixRcpRange=1.0/range;\nfloat subpixNSWE=lumaNS+lumaWE;\nfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\nfloat edgeVert1=(-2.0*lumaM)+lumaWE;\nfloat lumaNESE=lumaNE+lumaSE;\nfloat lumaNWNE=lumaNW+lumaNE;\nfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\nfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\nfloat lumaNWSW=lumaNW+lumaSW;\nfloat lumaSWSE=lumaSW+lumaSE;\nfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\nfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\nfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\nfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\nfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\nfloat edgeVert=abs(edgeVert3)+edgeVert4;\nfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\nfloat lengthSign=texelSize.x;\nbool horzSpan=edgeHorz>=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan) \n{\nlumaS=lumaE;\n}\nif (horzSpan) \n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan) \n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN) \n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) \n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN) \n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP) \n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan) \n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN<dstP;\nfloat dst=min(dstN,dstP);\nbool goodSpan=directionN ? goodSpanN : goodSpanP;\nfloat subpixG=subpixF*subpixF;\nfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\nfloat subpixH=subpixG*fxaaQualitySubpix;\nfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\nfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\nif (!horzSpan)\n{\nposM.x+=pixelOffsetSubpix*lengthSign;\n}\nif (horzSpan)\n{\nposM.y+=pixelOffsetSubpix*lengthSign;\n}\n#ifdef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\n}\nelse\n{\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n}\n#else\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n#endif\n}";
- Pt.ShadersStore.fxaaVertexShader = "attribute vec2 position;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var eb = function(e) {
- function t(t, i, n, r, o, s, l) {
- void 0 === n && (n = null),
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
- var c = e.call(this, t, "fxaa", ["texelSize"], null, i, n, r || io.BILINEAR_SAMPLINGMODE, o, s, null, l, "fxaa", void 0, !0) || this
- , u = c._getDefines();
- return c.updateEffect(u),
- c.onApplyObservable.add((function(e) {
- var t = c.texelSize;
- e.setFloat2("texelSize", t.x, t.y)
- }
- )),
- c
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "FxaaPostProcess"
- }
- ,
- t.prototype._getDefines = function() {
- var e = this.getEngine();
- if (!e)
- return null;
- var t = e.getGlInfo();
- return t && t.renderer && t.renderer.toLowerCase().indexOf("mali") > -1 ? "#define MALI 1\n" : null
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- t
- }(Ba);
- y("BABYLON.FxaaPostProcess", eb);
- Pt.ShadersStore.grainPixelShader = "#include<helperFunctions>\nuniform sampler2D textureSampler; \nuniform float intensity;\nuniform float animatedSeed;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}";
- var tb = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === c && (c = !1);
- var u = e.call(this, t, "grain", ["intensity", "animatedSeed"], [], i, n, r, o, s, null, l, void 0, null, c) || this;
- return u.intensity = 30,
- u.animated = !1,
- u.onApplyObservable.add((function(e) {
- e.setFloat("intensity", u.intensity),
- e.setFloat("animatedSeed", u.animated ? Math.random() + 1 : 1)
- }
- )),
- u
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "GrainPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "intensity", void 0),
- k([Ce()], t.prototype, "animated", void 0),
- t
- }(Ba);
- y("BABYLON.GrainPostProcess", tb);
- Pt.ShadersStore.highlightsPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); \n}";
- var ib = function(e) {
- function t(t, i, n, r, o, s, l) {
- return void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
- e.call(this, t, "highlights", null, null, i, n, r, o, s, null, l) || this
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "HighlightsPostProcess"
- }
- ,
- t
- }(Ba);
- Pt.IncludesShadersStore.mrtFragmentDeclaration = "#if defined(WEBGL2) || defined(WEBGPU)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
- Pt.ShadersStore.geometryPixelShader = "#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#ifdef BUMP\nvarying mat4 vWorldView;\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIVITY) && (defined(HAS_SPECULAR) || defined(HAS_REFLECTIVITY))\nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef ALPHATEST\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include<bumpFragment>\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\n#endif\n#else\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\ngl_FragData[1]=vec4(normalOutput,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\n#ifdef HAS_SPECULAR\nvec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#elif HAS_REFLECTIVITY\nvec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);\n#else\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}\n";
- Pt.IncludesShadersStore.geometryVertexDeclaration = "uniform mat4 viewProjection;\nuniform mat4 view;";
- Pt.IncludesShadersStore.geometryUboDeclaration = "#include<sceneUboDeclaration>\n";
- Pt.ShadersStore.geometryVertexShader = "precision highp float;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\n#include<__decl__geometryVertex>\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;\nvarying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;\nvarying vec2 vReflectivityUV;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;\nvNormalW=normalUpdated;\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef NEED_UV\n#ifdef UV1\n#if defined(ALPHATEST) && defined(ALPHATEST_UV1)\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP_UV1\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV1\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#if defined(ALPHATEST) && defined(ALPHATEST_UV2)\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP_UV2\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV2\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include<bumpVertex>\n}\n";
- var nb = function() {
- function e(t, i) {
- void 0 === i && (i = 1),
- this._previousTransformationMatrices = {},
- this._previousBonesTransformationMatrices = {},
- this.excludedSkinnedMeshesFromVelocity = [],
- this.renderTransparentMeshes = !0,
- this._resizeObserver = null,
- this._enablePosition = !1,
- this._enableVelocity = !1,
- this._enableReflectivity = !1,
- this._positionIndex = -1,
- this._velocityIndex = -1,
- this._reflectivityIndex = -1,
- this._depthIndex = -1,
- this._normalIndex = -1,
- this._linkedWithPrePass = !1,
- this._scene = t,
- this._ratio = i,
- this._useUbo = t.getEngine().supportsUniformBuffers,
- e._SceneComponentInitialization(this._scene),
- this._createRenderTargets()
- }
- return e.prototype._linkPrePassRenderer = function(e) {
- this._linkedWithPrePass = !0,
- this._prePassRenderer = e,
- this._multiRenderTarget && (this._multiRenderTarget.onClearObservable.clear(),
- this._multiRenderTarget.onClearObservable.add((function() {}
- )))
- }
- ,
- e.prototype._unlinkPrePassRenderer = function() {
- this._linkedWithPrePass = !1,
- this._createRenderTargets()
- }
- ,
- e.prototype._resetLayout = function() {
- this._enablePosition = !1,
- this._enableReflectivity = !1,
- this._enableVelocity = !1,
- this._attachments = []
- }
- ,
- e.prototype._forceTextureType = function(t, i) {
- t === e.POSITION_TEXTURE_TYPE ? (this._positionIndex = i,
- this._enablePosition = !0) : t === e.VELOCITY_TEXTURE_TYPE ? (this._velocityIndex = i,
- this._enableVelocity = !0) : t === e.REFLECTIVITY_TEXTURE_TYPE ? (this._reflectivityIndex = i,
- this._enableReflectivity = !0) : t === e.DEPTH_TEXTURE_TYPE ? this._depthIndex = i : t === e.NORMAL_TEXTURE_TYPE && (this._normalIndex = i)
- }
- ,
- e.prototype._setAttachments = function(e) {
- this._attachments = e
- }
- ,
- e.prototype._linkInternalTexture = function(e) {
- this._multiRenderTarget.setInternalTexture(e, 0, !1)
- }
- ,
- Object.defineProperty(e.prototype, "renderList", {
- get: function() {
- return this._multiRenderTarget.renderList
- },
- set: function(e) {
- this._multiRenderTarget.renderList = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isSupported", {
- get: function() {
- return this._multiRenderTarget.isSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getTextureIndex = function(t) {
- switch (t) {
- case e.POSITION_TEXTURE_TYPE:
- return this._positionIndex;
- case e.VELOCITY_TEXTURE_TYPE:
- return this._velocityIndex;
- case e.REFLECTIVITY_TEXTURE_TYPE:
- return this._reflectivityIndex;
- default:
- return -1
- }
- }
- ,
- Object.defineProperty(e.prototype, "enablePosition", {
- get: function() {
- return this._enablePosition
- },
- set: function(e) {
- this._enablePosition = e,
- this._linkedWithPrePass || (this.dispose(),
- this._createRenderTargets())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enableVelocity", {
- get: function() {
- return this._enableVelocity
- },
- set: function(e) {
- this._enableVelocity = e,
- e || (this._previousTransformationMatrices = {}),
- this._linkedWithPrePass || (this.dispose(),
- this._createRenderTargets()),
- this._scene.needsPreviousWorldMatrices = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enableReflectivity", {
- get: function() {
- return this._enableReflectivity
- },
- set: function(e) {
- this._enableReflectivity = e,
- this._linkedWithPrePass || (this.dispose(),
- this._createRenderTargets())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ratio", {
- get: function() {
- return this._ratio
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function(e, t) {
- var i = e.getMaterial();
- if (i && i.disableDepthWrite)
- return !1;
- var n = []
- , r = [Bi.PositionKind, Bi.NormalKind]
- , o = e.getMesh();
- if (i) {
- var a = !1;
- i.needAlphaTesting() && i.getAlphaTestTexture() && (n.push("#define ALPHATEST"),
- n.push("#define ALPHATEST_UV".concat(i.getAlphaTestTexture().coordinatesIndex + 1)),
- a = !0),
- i.bumpTexture && vs.BumpTextureEnabled && (n.push("#define BUMP"),
- n.push("#define BUMP_UV".concat(i.bumpTexture.coordinatesIndex + 1)),
- a = !0),
- this._enableReflectivity && (i.specularTexture ? (n.push("#define HAS_SPECULAR"),
- n.push("#define REFLECTIVITY_UV".concat(i.specularTexture.coordinatesIndex + 1)),
- a = !0) : i.reflectivityTexture && (n.push("#define HAS_REFLECTIVITY"),
- n.push("#define REFLECTIVITY_UV".concat(i.reflectivityTexture.coordinatesIndex + 1)),
- a = !0)),
- a && (n.push("#define NEED_UV"),
- o.isVerticesDataPresent(Bi.UVKind) && (r.push(Bi.UVKind),
- n.push("#define UV1")),
- o.isVerticesDataPresent(Bi.UV2Kind) && (r.push(Bi.UV2Kind),
- n.push("#define UV2")))
- }
- this._linkedWithPrePass && (n.push("#define PREPASS"),
- -1 !== this._depthIndex && (n.push("#define DEPTH_INDEX " + this._depthIndex),
- n.push("#define PREPASS_DEPTH")),
- -1 !== this._normalIndex && (n.push("#define NORMAL_INDEX " + this._normalIndex),
- n.push("#define PREPASS_NORMAL"))),
- this._enablePosition && (n.push("#define POSITION"),
- n.push("#define POSITION_INDEX " + this._positionIndex)),
- this._enableVelocity && (n.push("#define VELOCITY"),
- n.push("#define VELOCITY_INDEX " + this._velocityIndex),
- -1 === this.excludedSkinnedMeshesFromVelocity.indexOf(o) && n.push("#define BONES_VELOCITY_ENABLED")),
- this._enableReflectivity && (n.push("#define REFLECTIVITY"),
- n.push("#define REFLECTIVITY_INDEX " + this._reflectivityIndex)),
- o.useBones && o.computeBonesUsingShaders ? (r.push(Bi.MatricesIndicesKind),
- r.push(Bi.MatricesWeightsKind),
- o.numBoneInfluencers > 4 && (r.push(Bi.MatricesIndicesExtraKind),
- r.push(Bi.MatricesWeightsExtraKind)),
- n.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers),
- n.push("#define BonesPerMesh " + (o.skeleton ? o.skeleton.bones.length + 1 : 0))) : n.push("#define NUM_BONE_INFLUENCERS 0");
- var s = o.morphTargetManager
- , l = 0;
- s && s.numInfluencers > 0 && (l = s.numInfluencers,
- n.push("#define MORPHTARGETS"),
- n.push("#define NUM_MORPH_INFLUENCERS " + l),
- s.isUsingTextureForTargets && n.push("#define MORPHTARGETS_TEXTURE"),
- Mr.PrepareAttributesForMorphTargetsInfluencers(r, o, l)),
- t && (n.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(r, this._enableVelocity),
- e.getRenderingMesh().hasThinInstances && n.push("#define THIN_INSTANCES")),
- this._linkedWithPrePass ? n.push("#define RENDER_TARGET_COUNT " + this._attachments.length) : n.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
- var c = e._getDrawWrapper(void 0, !0)
- , u = c.defines
- , h = n.join("\n");
- return u !== h && c.setEffect(this._scene.getEngine().createEffect("geometry", {
- attributes: r,
- uniformsNames: ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorld", "previousViewProjection", "mPreviousBones", "bumpMatrix", "reflectivityMatrix", "vTangentSpaceParams", "vBumpInfos", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices"],
- samplers: ["diffuseSampler", "bumpSampler", "reflectivitySampler", "morphTargets"],
- defines: h,
- onCompiled: null,
- fallbacks: null,
- onError: null,
- uniformBuffersNames: ["Scene"],
- indexParameters: {
- buffersCount: this._multiRenderTarget.textures.length - 1,
- maxSimultaneousMorphTargets: l
- }
- }, this._scene.getEngine()), h),
- c.effect.isReady()
- }
- ,
- e.prototype.getGBuffer = function() {
- return this._multiRenderTarget
- }
- ,
- Object.defineProperty(e.prototype, "samples", {
- get: function() {
- return this._multiRenderTarget.samples
- },
- set: function(e) {
- this._multiRenderTarget.samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),
- this._resizeObserver = null),
- this.getGBuffer().dispose()
- }
- ,
- e.prototype._assignRenderTargetIndices = function() {
- var e = []
- , t = 2;
- return e.push("gBuffer_Depth", "gBuffer_Normal"),
- this._enablePosition && (this._positionIndex = t,
- t++,
- e.push("gBuffer_Position")),
- this._enableVelocity && (this._velocityIndex = t,
- t++,
- e.push("gBuffer_Velocity")),
- this._enableReflectivity && (this._reflectivityIndex = t,
- t++,
- e.push("gBuffer_Reflectivity")),
- [t, e]
- }
- ,
- e.prototype._createRenderTargets = function() {
- var e = this
- , t = this._scene.getEngine()
- , i = this._assignRenderTargetIndices()
- , n = i[0]
- , r = i[1]
- , o = a.TEXTURETYPE_UNSIGNED_BYTE;
- if (t._caps.textureFloat && t._caps.textureFloatLinearFiltering ? o = a.TEXTURETYPE_FLOAT : t._caps.textureHalfFloat && t._caps.textureHalfFloatLinearFiltering && (o = a.TEXTURETYPE_HALF_FLOAT),
- this._multiRenderTarget = new pm("gBuffer",{
- width: t.getRenderWidth() * this._ratio,
- height: t.getRenderHeight() * this._ratio
- },n,this._scene,{
- generateMipMaps: !1,
- generateDepthTexture: !0,
- defaultType: o
- },r.concat("gBuffer_DepthBuffer")),
- this.isSupported) {
- this._multiRenderTarget.wrapU = io.CLAMP_ADDRESSMODE,
- this._multiRenderTarget.wrapV = io.CLAMP_ADDRESSMODE,
- this._multiRenderTarget.refreshRate = 1,
- this._multiRenderTarget.renderParticles = !1,
- this._multiRenderTarget.renderList = null,
- this._multiRenderTarget.onClearObservable.add((function(e) {
- e.clear(new N(0,0,0,0), !0, !0, !0)
- }
- )),
- this._resizeObserver = t.onResizeObservable.add((function() {
- e._multiRenderTarget && e._multiRenderTarget.resize({
- width: t.getRenderWidth() * e._ratio,
- height: t.getRenderHeight() * e._ratio
- })
- }
- ));
- var s = function(t) {
- var i = t.getRenderingMesh()
- , n = t.getEffectiveMesh()
- , r = e._scene
- , o = r.getEngine()
- , a = t.getMaterial();
- if (a) {
- if (n._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- e._enableVelocity && !e._previousTransformationMatrices[n.uniqueId] && (e._previousTransformationMatrices[n.uniqueId] = {
- world: P.Identity(),
- viewProjection: r.getTransformMatrix()
- },
- i.skeleton)) {
- var s = i.skeleton.getTransformMatrices(i);
- e._previousBonesTransformationMatrices[i.uniqueId] = e._copyBonesTransformationMatrices(s, new Float32Array(s.length))
- }
- var l = i._getInstancesRenderList(t._id, !!t.getReplacementMesh());
- if (!l.mustReturn) {
- var c = o.getCaps().instancedArrays && (null !== l.visibleInstances[t._id] || i.hasThinInstances)
- , u = n.getWorldMatrix();
- if (e.isReady(t, c)) {
- var h = t._getDrawWrapper();
- if (!h)
- return;
- var d = h.effect;
- if (o.enableEffect(h),
- c || i._bind(t, d, a.fillMode),
- e._useUbo ? (Mr.BindSceneUniformBuffer(d, e._scene.getSceneUniformBuffer()),
- e._scene.finalizeSceneUbo()) : (d.setMatrix("viewProjection", r.getTransformMatrix()),
- d.setMatrix("view", r.getViewMatrix())),
- a) {
- var p = void 0
- , f = i._instanceDataStorage;
- if (f.isFrozen || !a.backFaceCulling && null === i.overrideMaterialSideOrientation)
- p = f.sideOrientation;
- else {
- var _ = n._getWorldMatrixDeterminant();
- null === (p = i.overrideMaterialSideOrientation) && (p = a.sideOrientation),
- _ < 0 && (p = p === Or.ClockWiseSideOrientation ? Or.CounterClockWiseSideOrientation : Or.ClockWiseSideOrientation)
- }
- if (a._preBind(h, p),
- a.needAlphaTesting()) {
- var m = a.getAlphaTestTexture();
- m && (d.setTexture("diffuseSampler", m),
- d.setMatrix("diffuseMatrix", m.getTextureMatrix()))
- }
- a.bumpTexture && r.getEngine().getCaps().standardDerivatives && vs.BumpTextureEnabled && (d.setFloat3("vBumpInfos", a.bumpTexture.coordinatesIndex, 1 / a.bumpTexture.level, a.parallaxScaleBias),
- d.setMatrix("bumpMatrix", a.bumpTexture.getTextureMatrix()),
- d.setTexture("bumpSampler", a.bumpTexture),
- d.setFloat2("vTangentSpaceParams", a.invertNormalMapX ? -1 : 1, a.invertNormalMapY ? -1 : 1)),
- e._enableReflectivity && (a.specularTexture ? (d.setMatrix("reflectivityMatrix", a.specularTexture.getTextureMatrix()),
- d.setTexture("reflectivitySampler", a.specularTexture)) : a.reflectivityTexture && (d.setMatrix("reflectivityMatrix", a.reflectivityTexture.getTextureMatrix()),
- d.setTexture("reflectivitySampler", a.reflectivityTexture)))
- }
- i.useBones && i.computeBonesUsingShaders && i.skeleton && (d.setMatrices("mBones", i.skeleton.getTransformMatrices(i)),
- e._enableVelocity && d.setMatrices("mPreviousBones", e._previousBonesTransformationMatrices[i.uniqueId])),
- Mr.BindMorphTargetParameters(i, d),
- i.morphTargetManager && i.morphTargetManager.isUsingTextureForTargets && i.morphTargetManager._bind(d),
- e._enableVelocity && (d.setMatrix("previousWorld", e._previousTransformationMatrices[n.uniqueId].world),
- d.setMatrix("previousViewProjection", e._previousTransformationMatrices[n.uniqueId].viewProjection)),
- c && i.hasThinInstances && d.setMatrix("world", u),
- i._processRendering(n, t, d, a.fillMode, l, c, (function(e, t) {
- e || d.setMatrix("world", t)
- }
- ))
- }
- e._enableVelocity && (e._previousTransformationMatrices[n.uniqueId].world = u.clone(),
- e._previousTransformationMatrices[n.uniqueId].viewProjection = e._scene.getTransformMatrix().clone(),
- i.skeleton && e._copyBonesTransformationMatrices(i.skeleton.getTransformMatrices(i), e._previousBonesTransformationMatrices[n.uniqueId]))
- }
- }
- };
- this._multiRenderTarget.customIsReadyFunction = function(i, n) {
- if (!i.isReady(!1))
- return !1;
- if (0 === n && i.subMeshes)
- for (var r = 0; r < i.subMeshes.length; ++r) {
- var o = i.subMeshes[r]
- , a = o.getMaterial()
- , s = o.getRenderingMesh();
- if (a) {
- var l = s._getInstancesRenderList(o._id, !!o.getReplacementMesh())
- , c = t.getCaps().instancedArrays && (null !== l.visibleInstances[o._id] || s.hasThinInstances);
- if (!e.isReady(o, c))
- return !1
- }
- }
- return !0
- }
- ,
- this._multiRenderTarget.customRenderFunction = function(i, n, r, o) {
- var a;
- if (e._linkedWithPrePass) {
- if (!e._prePassRenderer.enabled)
- return;
- e._scene.getEngine().bindAttachments(e._attachments)
- }
- if (o.length) {
- for (t.setColorWrite(!1),
- a = 0; a < o.length; a++)
- s(o.data[a]);
- t.setColorWrite(!0)
- }
- for (a = 0; a < i.length; a++)
- s(i.data[a]);
- for (t.setDepthWrite(!1),
- a = 0; a < n.length; a++)
- s(n.data[a]);
- if (e.renderTransparentMeshes)
- for (a = 0; a < r.length; a++)
- s(r.data[a]);
- t.setDepthWrite(!0)
- }
- }
- }
- ,
- e.prototype._copyBonesTransformationMatrices = function(e, t) {
- for (var i = 0; i < e.length; i++)
- t[i] = e[i];
- return t
- }
- ,
- e.DEPTH_TEXTURE_TYPE = 0,
- e.NORMAL_TEXTURE_TYPE = 1,
- e.POSITION_TEXTURE_TYPE = 2,
- e.VELOCITY_TEXTURE_TYPE = 3,
- e.REFLECTIVITY_TEXTURE_TYPE = 4,
- e._SceneComponentInitialization = function(e) {
- throw be("GeometryBufferRendererSceneComponent")
- }
- ,
- e
- }()
- , rb = function() {
- this.enabled = !1,
- this.name = "motionBlur",
- this.texturesRequired = [a.PREPASS_VELOCITY_TEXTURE_TYPE]
- };
- Object.defineProperty(mn.prototype, "geometryBufferRenderer", {
- get: function() {
- return this._geometryBufferRenderer
- },
- set: function(e) {
- e && e.isSupported && (this._geometryBufferRenderer = e)
- },
- enumerable: !0,
- configurable: !0
- }),
- mn.prototype.enableGeometryBufferRenderer = function(e) {
- return void 0 === e && (e = 1),
- this._geometryBufferRenderer || (this._geometryBufferRenderer = new nb(this,e),
- this._geometryBufferRenderer.isSupported || (this._geometryBufferRenderer = null)),
- this._geometryBufferRenderer
- }
- ,
- mn.prototype.disableGeometryBufferRenderer = function() {
- this._geometryBufferRenderer && (this._geometryBufferRenderer.dispose(),
- this._geometryBufferRenderer = null)
- }
- ;
- var ob = function() {
- function e(e) {
- this.name = Wi.NAME_GEOMETRYBUFFERRENDERER,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {}
- ,
- e.prototype._gatherRenderTargets = function(e) {
- this.scene._geometryBufferRenderer && e.push(this.scene._geometryBufferRenderer.getGBuffer())
- }
- ,
- e
- }();
- nb._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_GEOMETRYBUFFERRENDERER);
- t || (t = new ob(e),
- e._addComponent(t))
- }
- ;
- Pt.ShadersStore.motionBlurPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\n#ifdef OBJECT_BASED\nuniform sampler2D velocitySampler;\n#else\nuniform sampler2D depthSampler;\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\n#ifdef OBJECT_BASED\nvec2 texelSize=1.0/screenSize;\nvec4 velocityColor=texture2D(velocitySampler,vUV);\nvelocityColor.rg=velocityColor.rg*2.0-vec2(1.0);\nvec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.0))*velocityColor.a;\nvelocity*=motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint samplesCount=int(clamp(speed,1.0,SAMPLES));\nvelocity=normalize(velocity)*texelSize;\nfloat hlim=float(-samplesCount)*0.5+0.5;\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i)\n{\nif (i>=samplesCount)\nbreak;\nvec2 offset=vUV+velocity*(hlim+float(i));\nresult+=texture2D(textureSampler,offset);\n}\ngl_FragColor=result/float(samplesCount);\ngl_FragColor.a=1.0;\n#else\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n#endif\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
- var ab = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h) {
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = !1),
- void 0 === h && (h = !1);
- var d = e.call(this, t, "motionBlur", ["motionStrength", "motionScale", "screenSize", "inverseViewProjection", "prevViewProjection"], ["velocitySampler"], n, r, o, s, l, "#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED", c, void 0, null, u) || this;
- return d.motionStrength = 1,
- d._motionBlurSamples = 32,
- d._isObjectBased = !0,
- d._forceGeometryBuffer = !1,
- d._invViewProjection = null,
- d._previousViewProjection = null,
- d._forceGeometryBuffer = h,
- d._forceGeometryBuffer ? (i.enableGeometryBufferRenderer(),
- d._geometryBufferRenderer && (d._geometryBufferRenderer.enableVelocity = !0)) : (i.enablePrePassRenderer(),
- d._prePassRenderer && (d._prePassRenderer.markAsDirty(),
- d._prePassEffectConfiguration = new rb)),
- d._applyMode(),
- d
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "motionBlurSamples", {
- get: function() {
- return this._motionBlurSamples
- },
- set: function(e) {
- this._motionBlurSamples = e,
- this._updateEffect()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "isObjectBased", {
- get: function() {
- return this._isObjectBased
- },
- set: function(e) {
- this._isObjectBased !== e && (this._isObjectBased = e,
- this._applyMode())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_geometryBufferRenderer", {
- get: function() {
- return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_prePassRenderer", {
- get: function() {
- return this._forceGeometryBuffer ? null : this._scene.prePassRenderer
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "MotionBlurPostProcess"
- }
- ,
- t.prototype.excludeSkinnedMesh = function(e) {
- if (e.skeleton) {
- var t = void 0;
- if (this._geometryBufferRenderer)
- t = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
- else {
- if (!this._prePassRenderer)
- return;
- t = this._prePassRenderer.excludedSkinnedMesh
- }
- t.push(e)
- }
- }
- ,
- t.prototype.removeExcludedSkinnedMesh = function(e) {
- if (e.skeleton) {
- var t = void 0;
- if (this._geometryBufferRenderer)
- t = this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;
- else {
- if (!this._prePassRenderer)
- return;
- t = this._prePassRenderer.excludedSkinnedMesh
- }
- var i = t.indexOf(e);
- -1 !== i && t.splice(i, 1)
- }
- }
- ,
- t.prototype.dispose = function(t) {
- this._geometryBufferRenderer && (this._geometryBufferRenderer._previousTransformationMatrices = {},
- this._geometryBufferRenderer._previousBonesTransformationMatrices = {},
- this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity = []),
- e.prototype.dispose.call(this, t)
- }
- ,
- t.prototype._applyMode = function() {
- var e = this;
- if (!this._geometryBufferRenderer && !this._prePassRenderer)
- return K.Warn("Multiple Render Target support needed to compute object based motion blur"),
- this.updateEffect();
- this._updateEffect(),
- this._invViewProjection = null,
- this._previousViewProjection = null,
- this.isObjectBased ? (this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = a.PREPASS_VELOCITY_TEXTURE_TYPE),
- this.onApply = function(t) {
- return e._onApplyObjectBased(t)
- }
- ) : (this._invViewProjection = P.Identity(),
- this._previousViewProjection = P.Identity(),
- this._prePassRenderer && this._prePassEffectConfiguration && (this._prePassEffectConfiguration.texturesRequired[0] = a.PREPASS_DEPTH_TEXTURE_TYPE),
- this.onApply = function(t) {
- return e._onApplyScreenBased(t)
- }
- )
- }
- ,
- t.prototype._onApplyObjectBased = function(e) {
- if (e.setVector2("screenSize", new A(this.width,this.height)),
- e.setFloat("motionScale", this._scene.getAnimationRatio()),
- e.setFloat("motionStrength", this.motionStrength),
- this._geometryBufferRenderer) {
- var t = this._geometryBufferRenderer.getTextureIndex(nb.VELOCITY_TEXTURE_TYPE);
- e.setTexture("velocitySampler", this._geometryBufferRenderer.getGBuffer().textures[t])
- } else
- this._prePassRenderer && (t = this._prePassRenderer.getIndex(a.PREPASS_VELOCITY_TEXTURE_TYPE),
- e.setTexture("velocitySampler", this._prePassRenderer.getRenderTarget().textures[t]))
- }
- ,
- t.prototype._onApplyScreenBased = function(e) {
- var t = this._scene.getProjectionMatrix().multiply(this._scene.getViewMatrix());
- if (t.invertToRef(this._invViewProjection),
- e.setMatrix("inverseViewProjection", this._invViewProjection),
- e.setMatrix("prevViewProjection", this._previousViewProjection),
- this._previousViewProjection = t,
- e.setVector2("screenSize", new A(this.width,this.height)),
- e.setFloat("motionScale", this._scene.getAnimationRatio()),
- e.setFloat("motionStrength", this.motionStrength),
- this._geometryBufferRenderer) {
- var i = this._geometryBufferRenderer.getTextureIndex(nb.DEPTH_TEXTURE_TYPE);
- e.setTexture("depthSampler", this._geometryBufferRenderer.getGBuffer().textures[i])
- } else
- this._prePassRenderer && (i = this._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE),
- e.setTexture("depthSampler", this._prePassRenderer.getRenderTarget().textures[i]))
- }
- ,
- t.prototype._updateEffect = function() {
- if (this._geometryBufferRenderer || this._prePassRenderer) {
- var e = ["#define GEOMETRY_SUPPORTED", "#define SAMPLES " + this._motionBlurSamples.toFixed(1), this._isObjectBased ? "#define OBJECT_BASED" : "#define SCREEN_BASED"];
- this.updateEffect(e.join("\n"))
- }
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "motionStrength", void 0),
- k([Ce()], t.prototype, "motionBlurSamples", null),
- k([Ce()], t.prototype, "isObjectBased", null),
- t
- }(Ba);
- y("BABYLON.MotionBlurPostProcess", ab);
- Pt.ShadersStore.refractionPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}";
- var sb = function(e) {
- function t(t, i, n, r, o, a, s, l, c, u) {
- var h = e.call(this, t, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], a, s, l, c, u) || this;
- return h._ownRefractionTexture = !0,
- h.color = n,
- h.depth = r,
- h.colorLevel = o,
- h.refractionTextureUrl = i,
- h.onActivateObservable.add((function(e) {
- h._refTexture = h._refTexture || new io(i,e.getScene())
- }
- )),
- h.onApplyObservable.add((function(e) {
- e.setColor3("baseColor", h.color),
- e.setFloat("depth", h.depth),
- e.setFloat("colorLevel", h.colorLevel),
- e.setTexture("refractionSampler", h._refTexture)
- }
- )),
- h
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "refractionTexture", {
- get: function() {
- return this._refTexture
- },
- set: function(e) {
- this._refTexture && this._ownRefractionTexture && this._refTexture.dispose(),
- this._refTexture = e,
- this._ownRefractionTexture = !1
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "RefractionPostProcess"
- }
- ,
- t.prototype.dispose = function(t) {
- this._refTexture && this._ownRefractionTexture && (this._refTexture.dispose(),
- this._refTexture = null),
- e.prototype.dispose.call(this, t)
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.refractionTextureUrl,e.color,e.depth,e.colorLevel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "color", void 0),
- k([Ce()], t.prototype, "depth", void 0),
- k([Ce()], t.prototype, "colorLevel", void 0),
- k([Ce()], t.prototype, "refractionTextureUrl", void 0),
- t
- }(Ba);
- y("BABYLON.RefractionPostProcess", sb);
- Pt.ShadersStore.sharpenPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 sharpnessAmounts;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 color=texture2D(textureSampler,vUV);\nvec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;\ngl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);\n}";
- var lb = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === c && (c = !1);
- var u = e.call(this, t, "sharpen", ["sharpnessAmounts", "screenSize"], null, i, n, r, o, s, null, l, void 0, null, c) || this;
- return u.colorAmount = 1,
- u.edgeAmount = .3,
- u.onApply = function(e) {
- e.setFloat2("screenSize", u.width, u.height),
- e.setFloat2("sharpnessAmounts", u.edgeAmount, u.colorAmount)
- }
- ,
- u
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "SharpenPostProcess"
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "colorAmount", void 0),
- k([Ce()], t.prototype, "edgeAmount", void 0),
- t
- }(Ba);
- y("BABYLON.SharpenPostProcess", lb);
- var cb = function() {
- function e(e, t) {
- this._engine = e,
- this._name = t,
- this._renderEffects = {},
- this._renderEffectsForIsolatedPass = new Array,
- this._cameras = []
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return this._name
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameras", {
- get: function() {
- return this._cameras
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "PostProcessRenderPipeline"
- }
- ,
- Object.defineProperty(e.prototype, "isSupported", {
- get: function() {
- for (var e in this._renderEffects)
- if (Object.prototype.hasOwnProperty.call(this._renderEffects, e) && !this._renderEffects[e].isSupported)
- return !1;
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addEffect = function(e) {
- this._renderEffects[e._name] = e
- }
- ,
- e.prototype._rebuild = function() {}
- ,
- e.prototype._enableEffect = function(e, t) {
- var i = this._renderEffects[e];
- i && i._enable(gi.MakeArray(t || this._cameras))
- }
- ,
- e.prototype._disableEffect = function(e, t) {
- var i = this._renderEffects[e];
- i && i._disable(gi.MakeArray(t || this._cameras))
- }
- ,
- e.prototype._attachCameras = function(e, t) {
- var i = gi.MakeArray(e || this._cameras);
- if (i) {
- var n, r = [];
- for (n = 0; n < i.length; n++) {
- var o = i[n];
- if (o) {
- var a = o.name;
- -1 === this._cameras.indexOf(o) ? this._cameras[a] = o : t && r.push(n)
- }
- }
- for (n = 0; n < r.length; n++)
- i.splice(r[n], 1);
- for (var s in this._renderEffects)
- Object.prototype.hasOwnProperty.call(this._renderEffects, s) && this._renderEffects[s]._attachCameras(i)
- }
- }
- ,
- e.prototype._detachCameras = function(e) {
- var t = gi.MakeArray(e || this._cameras);
- if (t) {
- for (var i in this._renderEffects)
- Object.prototype.hasOwnProperty.call(this._renderEffects, i) && this._renderEffects[i]._detachCameras(t);
- for (var n = 0; n < t.length; n++)
- this._cameras.splice(this._cameras.indexOf(t[n]), 1)
- }
- }
- ,
- e.prototype._update = function() {
- for (var e in this._renderEffects)
- Object.prototype.hasOwnProperty.call(this._renderEffects, e) && this._renderEffects[e]._update();
- for (var t = 0; t < this._cameras.length; t++)
- if (this._cameras[t]) {
- var i = this._cameras[t].name;
- this._renderEffectsForIsolatedPass[i] && this._renderEffectsForIsolatedPass[i]._update()
- }
- }
- ,
- e.prototype._reset = function() {
- this._renderEffects = {},
- this._renderEffectsForIsolatedPass = new Array
- }
- ,
- e.prototype._enableMSAAOnFirstPostProcess = function(e) {
- if (!this._engine._features.supportMSAA)
- return !1;
- var t = Object.keys(this._renderEffects);
- if (t.length > 0) {
- var i = this._renderEffects[t[0]].getPostProcesses();
- i && (i[0].samples = e)
- }
- return !0
- }
- ,
- e.prototype.setPrePassRenderer = function(e) {
- return !1
- }
- ,
- e.prototype.dispose = function() {}
- ,
- k([Ce()], e.prototype, "_name", void 0),
- e
- }()
- , ub = function() {
- function e() {
- this._renderPipelines = {}
- }
- return Object.defineProperty(e.prototype, "supportedPipelines", {
- get: function() {
- var e = [];
- for (var t in this._renderPipelines)
- if (Object.prototype.hasOwnProperty.call(this._renderPipelines, t)) {
- var i = this._renderPipelines[t];
- i.isSupported && e.push(i)
- }
- return e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addPipeline = function(e) {
- this._renderPipelines[e._name] = e
- }
- ,
- e.prototype.attachCamerasToRenderPipeline = function(e, t, i) {
- void 0 === i && (i = !1);
- var n = this._renderPipelines[e];
- n && n._attachCameras(t, i)
- }
- ,
- e.prototype.detachCamerasFromRenderPipeline = function(e, t) {
- var i = this._renderPipelines[e];
- i && i._detachCameras(t)
- }
- ,
- e.prototype.enableEffectInPipeline = function(e, t, i) {
- var n = this._renderPipelines[e];
- n && n._enableEffect(t, i)
- }
- ,
- e.prototype.disableEffectInPipeline = function(e, t, i) {
- var n = this._renderPipelines[e];
- n && n._disableEffect(t, i)
- }
- ,
- e.prototype.update = function() {
- for (var e in this._renderPipelines)
- if (Object.prototype.hasOwnProperty.call(this._renderPipelines, e)) {
- var t = this._renderPipelines[e];
- t.isSupported ? t._update() : (t.dispose(),
- delete this._renderPipelines[e])
- }
- }
- ,
- e.prototype._rebuild = function() {
- for (var e in this._renderPipelines)
- Object.prototype.hasOwnProperty.call(this._renderPipelines, e) && this._renderPipelines[e]._rebuild()
- }
- ,
- e.prototype.dispose = function() {
- for (var e in this._renderPipelines)
- Object.prototype.hasOwnProperty.call(this._renderPipelines, e) && this._renderPipelines[e].dispose()
- }
- ,
- e
- }();
- Object.defineProperty(mn.prototype, "postProcessRenderPipelineManager", {
- get: function() {
- if (!this._postProcessRenderPipelineManager) {
- var e = this._getComponent(Wi.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
- e || (e = new hb(this),
- this._addComponent(e)),
- this._postProcessRenderPipelineManager = new ub
- }
- return this._postProcessRenderPipelineManager
- },
- enumerable: !0,
- configurable: !0
- });
- var hb = function() {
- function e(e) {
- this.name = Wi.NAME_POSTPROCESSRENDERPIPELINEMANAGER,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets)
- }
- ,
- e.prototype.rebuild = function() {
- this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild()
- }
- ,
- e.prototype.dispose = function() {
- this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose()
- }
- ,
- e.prototype._gatherRenderTargets = function() {
- this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update()
- }
- ,
- e
- }()
- , db = function(e) {
- function t(t, i, n, r, o) {
- void 0 === t && (t = ""),
- void 0 === i && (i = !0),
- void 0 === n && (n = E.LastCreatedScene),
- void 0 === o && (o = !0);
- var s = e.call(this, n.getEngine(), t) || this;
- s._camerasToBeAttached = [],
- s.SharpenPostProcessId = "SharpenPostProcessEffect",
- s.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect",
- s.FxaaPostProcessId = "FxaaPostProcessEffect",
- s.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect",
- s.GrainPostProcessId = "GrainPostProcessEffect",
- s._glowLayer = null,
- s.animations = [],
- s._imageProcessingConfigurationObserver = null,
- s._sharpenEnabled = !1,
- s._bloomEnabled = !1,
- s._depthOfFieldEnabled = !1,
- s._depthOfFieldBlurLevel = Ky.Low,
- s._fxaaEnabled = !1,
- s._imageProcessingEnabled = !0,
- s._bloomScale = .5,
- s._chromaticAberrationEnabled = !1,
- s._grainEnabled = !1,
- s._buildAllowed = !0,
- s.onBuildObservable = new h,
- s._resizeObserver = null,
- s._hardwareScaleLevel = 1,
- s._bloomKernel = 64,
- s._bloomWeight = .15,
- s._bloomThreshold = .9,
- s._samples = 1,
- s._hasCleared = !1,
- s._prevPostProcess = null,
- s._prevPrevPostProcess = null,
- s._depthOfFieldSceneObserver = null,
- s._cameras = r || n.cameras,
- s._cameras = s._cameras.slice(),
- s._camerasToBeAttached = s._cameras.slice(),
- s._buildAllowed = o,
- s._scene = n;
- var l = s._scene.getEngine().getCaps();
- s._hdr = i && (l.textureHalfFloatRender || l.textureFloatRender),
- s._hdr ? l.textureHalfFloatRender ? s._defaultPipelineTextureType = a.TEXTURETYPE_HALF_FLOAT : l.textureFloatRender && (s._defaultPipelineTextureType = a.TEXTURETYPE_FLOAT) : s._defaultPipelineTextureType = a.TEXTURETYPE_UNSIGNED_INT,
- n.postProcessRenderPipelineManager.addPipeline(s);
- var c = s._scene.getEngine();
- return s.sharpen = new lb("sharpen",1,null,io.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),
- s._sharpenEffect = new Vy(c,s.SharpenPostProcessId,(function() {
- return s.sharpen
- }
- ),!0),
- s.depthOfField = new Zy(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),
- s.bloom = new zy(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),
- s.chromaticAberration = new Wy("ChromaticAberration",c.getRenderWidth(),c.getRenderHeight(),1,null,io.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),
- s._chromaticAberrationEffect = new Vy(c,s.ChromaticAberrationPostProcessId,(function() {
- return s.chromaticAberration
- }
- ),!0),
- s.grain = new tb("Grain",1,null,io.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),
- s._grainEffect = new Vy(c,s.GrainPostProcessId,(function() {
- return s.grain
- }
- ),!0),
- s._resizeObserver = c.onResizeObservable.add((function() {
- s._hardwareScaleLevel = c.getHardwareScalingLevel(),
- s.bloomKernel = s._bloomKernel
- }
- )),
- s._imageProcessingConfigurationObserver = s._scene.imageProcessingConfiguration.onUpdateParameters.add((function() {
- s.bloom._downscale._exposure = s._scene.imageProcessingConfiguration.exposure,
- s.imageProcessingEnabled !== s._scene.imageProcessingConfiguration.isEnabled && (s._imageProcessingEnabled = s._scene.imageProcessingConfiguration.isEnabled,
- s._buildPipeline())
- }
- )),
- s._buildPipeline(),
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "sharpenEnabled", {
- get: function() {
- return this._sharpenEnabled
- },
- set: function(e) {
- this._sharpenEnabled !== e && (this._sharpenEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bloomKernel", {
- get: function() {
- return this._bloomKernel
- },
- set: function(e) {
- this._bloomKernel = e,
- this.bloom.kernel = e / this._hardwareScaleLevel
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bloomWeight", {
- get: function() {
- return this._bloomWeight
- },
- set: function(e) {
- this._bloomWeight !== e && (this.bloom.weight = e,
- this._bloomWeight = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bloomThreshold", {
- get: function() {
- return this._bloomThreshold
- },
- set: function(e) {
- this._bloomThreshold !== e && (this.bloom.threshold = e,
- this._bloomThreshold = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bloomScale", {
- get: function() {
- return this._bloomScale
- },
- set: function(e) {
- this._bloomScale !== e && (this._bloomScale = e,
- this._rebuildBloom(),
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "bloomEnabled", {
- get: function() {
- return this._bloomEnabled
- },
- set: function(e) {
- this._bloomEnabled !== e && (this._bloomEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._rebuildBloom = function() {
- var e = this.bloom;
- this.bloom = new zy(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),
- this.bloom.threshold = e.threshold;
- for (var t = 0; t < this._cameras.length; t++)
- e.disposeEffects(this._cameras[t])
- }
- ,
- Object.defineProperty(t.prototype, "depthOfFieldEnabled", {
- get: function() {
- return this._depthOfFieldEnabled
- },
- set: function(e) {
- this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "depthOfFieldBlurLevel", {
- get: function() {
- return this._depthOfFieldBlurLevel
- },
- set: function(e) {
- if (this._depthOfFieldBlurLevel !== e) {
- this._depthOfFieldBlurLevel = e;
- var t = this.depthOfField;
- this.depthOfField = new Zy(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),
- this.depthOfField.focalLength = t.focalLength,
- this.depthOfField.focusDistance = t.focusDistance,
- this.depthOfField.fStop = t.fStop,
- this.depthOfField.lensSize = t.lensSize;
- for (var i = 0; i < this._cameras.length; i++)
- t.disposeEffects(this._cameras[i]);
- this._buildPipeline()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fxaaEnabled", {
- get: function() {
- return this._fxaaEnabled
- },
- set: function(e) {
- this._fxaaEnabled !== e && (this._fxaaEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(e) {
- this._samples !== e && (this._samples = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "imageProcessingEnabled", {
- get: function() {
- return this._imageProcessingEnabled
- },
- set: function(e) {
- this._imageProcessingEnabled !== e && (this._scene.imageProcessingConfiguration.isEnabled = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "glowLayerEnabled", {
- get: function() {
- return null != this._glowLayer
- },
- set: function(e) {
- e && !this._glowLayer ? this._glowLayer = new qf("",this._scene) : !e && this._glowLayer && (this._glowLayer.dispose(),
- this._glowLayer = null)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "glowLayer", {
- get: function() {
- return this._glowLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "chromaticAberrationEnabled", {
- get: function() {
- return this._chromaticAberrationEnabled
- },
- set: function(e) {
- this._chromaticAberrationEnabled !== e && (this._chromaticAberrationEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "grainEnabled", {
- get: function() {
- return this._grainEnabled
- },
- set: function(e) {
- this._grainEnabled !== e && (this._grainEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "DefaultRenderingPipeline"
- }
- ,
- t.prototype.prepare = function() {
- var e = this._buildAllowed;
- this._buildAllowed = !0,
- this._buildPipeline(),
- this._buildAllowed = e
- }
- ,
- t.prototype._setAutoClearAndTextureSharing = function(e, t) {
- void 0 === t && (t = !1),
- this._hasCleared ? e.autoClear = !1 : (e.autoClear = !0,
- this._scene.autoClear = !1,
- this._hasCleared = !0),
- t || (this._prevPrevPostProcess ? e.shareOutputWith(this._prevPrevPostProcess) : e.useOwnOutput(),
- this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess),
- this._prevPostProcess = e)
- }
- ,
- t.prototype._buildPipeline = function() {
- var e = this;
- if (this._buildAllowed) {
- this._scene.autoClear = !0;
- var t = this._scene.getEngine();
- if (this._disposePostProcesses(),
- null !== this._cameras && (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 i = 0, n = this._cameras; i < n.length; i++) {
- var r = n[i];
- (o = this._scene.enableDepthRenderer(r)).useOnlyInActiveCamera = !0
- }
- this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add((function(t) {
- e._cameras.indexOf(t.activeCamera) > -1 && (e.depthOfField.depthTexture = t.enableDepthRenderer(t.activeCamera).getDepthMap())
- }
- ))
- } else {
- this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
- var o = this._scene.enableDepthRenderer(this._cameras[0]);
- this.depthOfField.depthTexture = o.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 Fs("imageProcessing",1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),
- this._hdr ? (this.addEffect(new Vy(t,this.ImageProcessingPostProcessId,(function() {
- return e.imageProcessing
- }
- ),!0)),
- this._setAutoClearAndTextureSharing(this.imageProcessing)) : this._scene.imageProcessingConfiguration.applyByPostProcess = !1,
- this.cameras && 0 !== this.cameras.length || (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 eb("fxaa",1,null,io.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),
- this.addEffect(new Vy(t,this.FxaaPostProcessId,(function() {
- return e.fxaa
- }
- ),!0)),
- this._setAutoClearAndTextureSharing(this.fxaa, !0)),
- null !== this._cameras && 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 && K.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),
- this.onBuildObservable.notifyObservers(this)
- }
- }
- ,
- t.prototype._disposePostProcesses = function(e) {
- void 0 === e && (e = !1);
- for (var t = 0; t < this._cameras.length; t++) {
- var i = this._cameras[t];
- this.imageProcessing && this.imageProcessing.dispose(i),
- this.fxaa && this.fxaa.dispose(i),
- e && (this.sharpen && this.sharpen.dispose(i),
- this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),
- this.depthOfField.disposeEffects(i)),
- this.bloom && this.bloom.disposeEffects(i),
- this.chromaticAberration && this.chromaticAberration.dispose(i),
- this.grain && this.grain.dispose(i),
- this._glowLayer && this._glowLayer.dispose())
- }
- this.imageProcessing = null,
- this.fxaa = null,
- e && (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)
- }
- ,
- t.prototype.addCamera = function(e) {
- this._camerasToBeAttached.push(e),
- this._buildPipeline()
- }
- ,
- t.prototype.removeCamera = function(e) {
- var t = this._camerasToBeAttached.indexOf(e);
- this._camerasToBeAttached.splice(t, 1),
- this._buildPipeline()
- }
- ,
- t.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),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.customType = "DefaultRenderingPipeline",
- e
- }
- ,
- t.Parse = function(e, i, n) {
- return Ge.Parse((function() {
- return new t(e._name,e._name._hdr,i)
- }
- ), e, i, n)
- }
- ,
- k([Ce()], t.prototype, "sharpenEnabled", null),
- k([Ce()], t.prototype, "bloomKernel", null),
- k([Ce()], t.prototype, "_bloomWeight", void 0),
- k([Ce()], t.prototype, "_bloomThreshold", void 0),
- k([Ce()], t.prototype, "_hdr", void 0),
- k([Ce()], t.prototype, "bloomWeight", null),
- k([Ce()], t.prototype, "bloomThreshold", null),
- k([Ce()], t.prototype, "bloomScale", null),
- k([Ce()], t.prototype, "bloomEnabled", null),
- k([Ce()], t.prototype, "depthOfFieldEnabled", null),
- k([Ce()], t.prototype, "depthOfFieldBlurLevel", null),
- k([Ce()], t.prototype, "fxaaEnabled", null),
- k([Ce()], t.prototype, "samples", null),
- k([Ce()], t.prototype, "imageProcessingEnabled", null),
- k([Ce()], t.prototype, "glowLayerEnabled", null),
- k([Ce()], t.prototype, "chromaticAberrationEnabled", null),
- k([Ce()], t.prototype, "grainEnabled", null),
- t
- }(cb);
- y("BABYLON.DefaultRenderingPipeline", db);
- Pt.ShadersStore.lensHighlightsPixelShader = "uniform sampler2D textureSampler; \nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\nvarying vec2 vUV;\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\nif (gain==-1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n}";
- Pt.ShadersStore.depthOfFieldPixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\nuniform float near;\nuniform float far;\nvarying vec2 vUV;\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion==0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\nfloat sampleScreen(inout vec4 color,in vec2 offset,in float weight) {\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\nreturn col;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\nif (dof_enabled==false || coc<0.07) { coc=0.0; }\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\nfloat blur_amount=max(edge_blur_amount,coc);\nif (blur_amount==0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\ngl_FragColor=getBlurColor(blur_amount*1.7);\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n";
- var pb = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = 1);
- var a = e.call(this, n.getEngine(), t) || this;
- return a.LensChromaticAberrationEffect = "LensChromaticAberrationEffect",
- a.HighlightsEnhancingEffect = "HighlightsEnhancingEffect",
- a.LensDepthOfFieldEffect = "LensDepthOfFieldEffect",
- a._pentagonBokehIsEnabled = !1,
- a._scene = n,
- a._depthTexture = n.enableDepthRenderer().getDepthMap(),
- i.grain_texture ? a._grainTexture = i.grain_texture : a._createGrainTexture(),
- a._edgeBlur = i.edge_blur ? i.edge_blur : 0,
- a._grainAmount = i.grain_amount ? i.grain_amount : 0,
- a._chromaticAberration = i.chromatic_aberration ? i.chromatic_aberration : 0,
- a._distortion = i.distortion ? i.distortion : 0,
- a._highlightsGain = void 0 !== i.dof_gain ? i.dof_gain : -1,
- a._highlightsThreshold = i.dof_threshold ? i.dof_threshold : 1,
- a._dofDistance = void 0 !== i.dof_focus_distance ? i.dof_focus_distance : -1,
- a._dofAperture = i.dof_aperture ? i.dof_aperture : 1,
- a._dofDarken = i.dof_darken ? i.dof_darken : 0,
- a._dofPentagon = void 0 === i.dof_pentagon || i.dof_pentagon,
- a._blurNoise = void 0 === i.blur_noise || i.blur_noise,
- a._createChromaticAberrationPostProcess(r),
- a._createHighlightsPostProcess(r),
- a._createDepthOfFieldPostProcess(r / 4),
- a.addEffect(new Vy(n.getEngine(),a.LensChromaticAberrationEffect,(function() {
- return a._chromaticAberrationPostProcess
- }
- ),!0)),
- a.addEffect(new Vy(n.getEngine(),a.HighlightsEnhancingEffect,(function() {
- return a._highlightsPostProcess
- }
- ),!0)),
- a.addEffect(new Vy(n.getEngine(),a.LensDepthOfFieldEffect,(function() {
- return a._depthOfFieldPostProcess
- }
- ),!0)),
- -1 === a._highlightsGain && a._disableEffect(a.HighlightsEnhancingEffect, null),
- n.postProcessRenderPipelineManager.addPipeline(a),
- o && n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, o),
- a
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "LensRenderingPipeline"
- }
- ,
- Object.defineProperty(t.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "edgeBlur", {
- get: function() {
- return this._edgeBlur
- },
- set: function(e) {
- this.setEdgeBlur(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "grainAmount", {
- get: function() {
- return this._grainAmount
- },
- set: function(e) {
- this.setGrainAmount(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "chromaticAberration", {
- get: function() {
- return this._chromaticAberration
- },
- set: function(e) {
- this.setChromaticAberration(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dofAperture", {
- get: function() {
- return this._dofAperture
- },
- set: function(e) {
- this.setAperture(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "edgeDistortion", {
- get: function() {
- return this._distortion
- },
- set: function(e) {
- this.setEdgeDistortion(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "dofDistortion", {
- get: function() {
- return this._dofDistance
- },
- set: function(e) {
- this.setFocusDistance(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "darkenOutOfFocus", {
- get: function() {
- return this._dofDarken
- },
- set: function(e) {
- this.setDarkenOutOfFocus(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "blurNoise", {
- get: function() {
- return this._blurNoise
- },
- set: function(e) {
- this._blurNoise = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "pentagonBokeh", {
- get: function() {
- return this._pentagonBokehIsEnabled
- },
- set: function(e) {
- e ? this.enablePentagonBokeh() : this.disablePentagonBokeh()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "highlightsGain", {
- get: function() {
- return this._highlightsGain
- },
- set: function(e) {
- this.setHighlightsGain(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "highlightsThreshold", {
- get: function() {
- return this._highlightsThreshold
- },
- set: function(e) {
- this.setHighlightsThreshold(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.setEdgeBlur = function(e) {
- this._edgeBlur = e
- }
- ,
- t.prototype.disableEdgeBlur = function() {
- this._edgeBlur = 0
- }
- ,
- t.prototype.setGrainAmount = function(e) {
- this._grainAmount = e
- }
- ,
- t.prototype.disableGrain = function() {
- this._grainAmount = 0
- }
- ,
- t.prototype.setChromaticAberration = function(e) {
- this._chromaticAberration = e
- }
- ,
- t.prototype.disableChromaticAberration = function() {
- this._chromaticAberration = 0
- }
- ,
- t.prototype.setEdgeDistortion = function(e) {
- this._distortion = e
- }
- ,
- t.prototype.disableEdgeDistortion = function() {
- this._distortion = 0
- }
- ,
- t.prototype.setFocusDistance = function(e) {
- this._dofDistance = e
- }
- ,
- t.prototype.disableDepthOfField = function() {
- this._dofDistance = -1
- }
- ,
- t.prototype.setAperture = function(e) {
- this._dofAperture = e
- }
- ,
- t.prototype.setDarkenOutOfFocus = function(e) {
- this._dofDarken = e
- }
- ,
- t.prototype.enablePentagonBokeh = function() {
- this._highlightsPostProcess.updateEffect("#define PENTAGON\n"),
- this._pentagonBokehIsEnabled = !0
- }
- ,
- t.prototype.disablePentagonBokeh = function() {
- this._pentagonBokehIsEnabled = !1,
- this._highlightsPostProcess.updateEffect()
- }
- ,
- t.prototype.enableNoiseBlur = function() {
- this._blurNoise = !0
- }
- ,
- t.prototype.disableNoiseBlur = function() {
- this._blurNoise = !1
- }
- ,
- t.prototype.setHighlightsGain = function(e) {
- this._highlightsGain = e
- }
- ,
- t.prototype.setHighlightsThreshold = function(e) {
- -1 === this._highlightsGain && (this._highlightsGain = 1),
- this._highlightsThreshold = e
- }
- ,
- t.prototype.disableHighlights = function() {
- this._highlightsGain = -1
- }
- ,
- t.prototype.dispose = function(e) {
- void 0 === e && (e = !1),
- this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras),
- this._chromaticAberrationPostProcess = null,
- this._highlightsPostProcess = null,
- this._depthOfFieldPostProcess = null,
- this._grainTexture.dispose(),
- e && this._scene.disableDepthRenderer()
- }
- ,
- t.prototype._createChromaticAberrationPostProcess = function(e) {
- var t = this;
- this._chromaticAberrationPostProcess = new Ba("LensChromaticAberration","chromaticAberration",["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"],[],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),
- this._chromaticAberrationPostProcess.onApply = function(e) {
- e.setFloat("chromatic_aberration", t._chromaticAberration),
- e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()),
- e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()),
- e.setFloat("radialIntensity", 1),
- e.setFloat2("direction", 17, 17),
- e.setFloat2("centerPosition", .5, .5)
- }
- }
- ,
- t.prototype._createHighlightsPostProcess = function(e) {
- var t = this;
- this._highlightsPostProcess = new Ba("LensHighlights","lensHighlights",["gain", "threshold", "screen_width", "screen_height"],[],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon ? "#define PENTAGON\n" : ""),
- this._highlightsPostProcess.externalTextureSamplerBinding = !0,
- this._highlightsPostProcess.onApply = function(e) {
- e.setFloat("gain", t._highlightsGain),
- e.setFloat("threshold", t._highlightsThreshold),
- e.setTextureFromPostProcess("textureSampler", t._chromaticAberrationPostProcess),
- e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()),
- e.setFloat("screen_height", t._scene.getEngine().getRenderHeight())
- }
- }
- ,
- t.prototype._createDepthOfFieldPostProcess = function(e) {
- var t = this;
- this._depthOfFieldPostProcess = new Ba("LensDepthOfField","depthOfField",["grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled", "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"],["depthSampler", "grainSampler", "highlightsSampler"],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),
- this._depthOfFieldPostProcess.externalTextureSamplerBinding = !0,
- this._depthOfFieldPostProcess.onApply = function(e) {
- e.setTexture("depthSampler", t._depthTexture),
- e.setTexture("grainSampler", t._grainTexture),
- e.setTextureFromPostProcess("textureSampler", t._highlightsPostProcess),
- e.setTextureFromPostProcess("highlightsSampler", t._depthOfFieldPostProcess),
- e.setFloat("grain_amount", t._grainAmount),
- e.setBool("blur_noise", t._blurNoise),
- e.setFloat("screen_width", t._scene.getEngine().getRenderWidth()),
- e.setFloat("screen_height", t._scene.getEngine().getRenderHeight()),
- e.setFloat("distortion", t._distortion),
- e.setBool("dof_enabled", -1 !== t._dofDistance),
- e.setFloat("screen_distance", 1 / (.1 - 1 / t._dofDistance)),
- e.setFloat("aperture", t._dofAperture),
- e.setFloat("darken", t._dofDarken),
- e.setFloat("edge_blur", t._edgeBlur),
- e.setBool("highlights", -1 !== t._highlightsGain),
- t._scene.activeCamera && (e.setFloat("near", t._scene.activeCamera.minZ),
- e.setFloat("far", t._scene.activeCamera.maxZ))
- }
- }
- ,
- t.prototype._createGrainTexture = function() {
- this._grainTexture = new Ds("LensNoiseTexture",512,this._scene,!1,io.BILINEAR_SAMPLINGMODE),
- this._grainTexture.wrapU = io.WRAP_ADDRESSMODE,
- this._grainTexture.wrapV = io.WRAP_ADDRESSMODE;
- for (var e, t = this._grainTexture.getContext(), i = 0; i < 512; i++)
- for (var n = 0; n < 512; n++)
- e = Math.floor(255 * (.42,
- .58,
- Math.random() * (.58 - .42) + .42)),
- t.fillStyle = "rgb(" + e + ", " + e + ", " + e + ")",
- t.fillRect(i, n, 1, 1);
- this._grainTexture.update(!1)
- }
- ,
- t
- }(cb)
- , fb = function() {
- this.enabled = !1,
- this.name = "ssao2",
- this.texturesRequired = [a.PREPASS_NORMAL_TEXTURE_TYPE, a.PREPASS_DEPTH_TEXTURE_TYPE]
- };
- Pt.ShadersStore.ssao2PixelShader = "precision highp float;\nuniform sampler2D textureSampler;\nuniform float near;\nuniform float far;\nuniform float radius;\nfloat scales[16]=float[16](\n0.1,\n0.11406250000000001,\n0.131640625,\n0.15625,\n0.187890625,\n0.2265625,\n0.272265625,\n0.325,\n0.384765625,\n0.4515625,\n0.525390625,\n0.60625,\n0.694140625,\n0.7890625,\n0.891015625,\n1.0\n);\nvarying vec2 vUV;\nfloat perspectiveDepthToViewZ(in float invClipZ,in float near,in float far ) {\nreturn ( near*far )/( ( far-near )*invClipZ-far );\n}\nfloat viewZToPerspectiveDepth( in float viewZ,in float near,in float far ) {\nreturn ( near*far/viewZ+far)/( far-near );\n}\nfloat viewZToOrthographicDepth( in float viewZ,in float near,in float far ) {\nreturn ( viewZ+near )/( near-far );\n}\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D normalSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float base;\nuniform float xViewport;\nuniform float yViewport;\nuniform mat3 depthProjection;\nuniform float maxZ;\nuniform float minZAspect;\nuniform vec2 texelSize;\nuniform mat4 projection;\nvoid main()\n{\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat depthSign=depth/abs(depth);\ndepth=depth*depthSign;\nvec3 normal=texture2D(normalSampler,vUV).rgb;\nfloat occlusion=0.0;\nfloat correctedRadius=min(radius,minZAspect*depth/near);\nvec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);\nvec3 vDepthFactor=depthProjection*vec3(1.0,1.0,depth);\nvec3 origin=vViewRay*vDepthFactor;\nvec3 rvec=random*2.0-1.0;\nrvec.z=0.0;\nfloat dotProduct=dot(rvec,normal);\nrvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\nvec3 bitangent=cross(normal,tangent);\nmat3 tbn=mat3(tangent,bitangent,normal);\nfloat difference;\nfor (int i=0; i<SAMPLES; ++i) {\nvec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];\nsamplePosition=samplePosition*correctedRadius+origin;\nvec4 offset=vec4(samplePosition,1.0);\noffset=projection*offset;\noffset.xyz/=offset.w;\noffset.xy=offset.xy*0.5+0.5;\nif (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {\ncontinue;\n}\nfloat sampleDepth=abs(texture2D(depthSampler,offset.xy).r);\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+= weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+= weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i<SAMPLES; ++i)\n{\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\nvec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);\n#else\nvec2 direction=vec2(0.0,1.0);\nvec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);\n#endif\nvec2 samplePos=vUV+sampleOffset;\nfloat sampleDepth=abs(texture2D(depthSampler,samplePos).r);\nfloat weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30000.0);\nresult+=texture2D(textureSampler,samplePos).r*weight;\nweightSum+=weight;\n}\nresult/=weightSum;\ngl_FragColor.rgb=vec3(result);\ngl_FragColor.a=1.0;\n#else\nvec4 color;\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#else\nvec2 direction=vec2(0.0,1.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#endif\ngl_FragColor.rgb=vec3(color.r);\ngl_FragColor.a=1.0;\n#endif\n}\n#endif\n";
- Pt.ShadersStore.ssaoCombinePixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nuniform vec4 viewport;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
- var _b = function(e) {
- function t(t, i, n, r, o, s) {
- void 0 === o && (o = !1),
- void 0 === s && (s = a.TEXTURETYPE_UNSIGNED_INT);
- var l = e.call(this, i.getEngine(), t) || this;
- if (l.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect",
- l.SSAORenderEffect = "SSAORenderEffect",
- l.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect",
- l.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect",
- l.SSAOCombineRenderEffect = "SSAOCombineRenderEffect",
- l.totalStrength = 1,
- l.maxZ = 100,
- l.minZAspect = .2,
- l._samples = 8,
- l._textureSamples = 1,
- l._forceGeometryBuffer = !1,
- l._expensiveBlur = !0,
- l.radius = 2,
- l.base = 0,
- l._bits = new Uint32Array(1),
- l._scene = i,
- l._ratio = n,
- l._forceGeometryBuffer = o,
- !l.isSupported)
- return K.Error("The current engine does not support SSAO 2."),
- l;
- var c = l._ratio.ssaoRatio || n
- , u = l._ratio.blurRatio || n;
- return l._forceGeometryBuffer ? i.enableGeometryBufferRenderer() : i.enablePrePassRenderer(),
- l._createRandomTexture(),
- l._originalColorPostProcess = new Ua("SSAOOriginalSceneColor",1,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),void 0,s),
- l._originalColorPostProcess.samples = l.textureSamples,
- l._createSSAOPostProcess(1, s),
- l._createBlurPostProcess(c, u, s),
- l._createSSAOCombinePostProcess(u, s),
- l.addEffect(new Vy(i.getEngine(),l.SSAOOriginalSceneColorEffect,(function() {
- return l._originalColorPostProcess
- }
- ),!0)),
- l.addEffect(new Vy(i.getEngine(),l.SSAORenderEffect,(function() {
- return l._ssaoPostProcess
- }
- ),!0)),
- l.addEffect(new Vy(i.getEngine(),l.SSAOBlurHRenderEffect,(function() {
- return l._blurHPostProcess
- }
- ),!0)),
- l.addEffect(new Vy(i.getEngine(),l.SSAOBlurVRenderEffect,(function() {
- return l._blurVPostProcess
- }
- ),!0)),
- l.addEffect(new Vy(i.getEngine(),l.SSAOCombineRenderEffect,(function() {
- return l._ssaoCombinePostProcess
- }
- ),!0)),
- i.postProcessRenderPipelineManager.addPipeline(l),
- r && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, r),
- l
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(e) {
- this._samples = e,
- this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),
- this._sampleSphere = this._generateHemisphere()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "textureSamples", {
- get: function() {
- return this._textureSamples
- },
- set: function(e) {
- this._textureSamples = e,
- this._prePassRenderer ? this._prePassRenderer.samples = e : this._originalColorPostProcess.samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_geometryBufferRenderer", {
- get: function() {
- return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_prePassRenderer", {
- get: function() {
- return this._forceGeometryBuffer ? null : this._scene.prePassRenderer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "expensiveBlur", {
- get: function() {
- return this._expensiveBlur
- },
- set: function(e) {
- this._blurHPostProcess.updateEffect("#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE " + (e ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]),
- this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (e ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]),
- this._expensiveBlur = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "IsSupported", {
- get: function() {
- var e = E.LastCreatedEngine;
- return !!e && e._features.supportSSAO2
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "SSAO2RenderingPipeline"
- }
- ,
- t.prototype.dispose = function(t) {
- void 0 === t && (t = !1);
- for (var i = 0; i < this._scene.cameras.length; i++) {
- var n = this._scene.cameras[i];
- this._originalColorPostProcess.dispose(n),
- this._ssaoPostProcess.dispose(n),
- this._blurHPostProcess.dispose(n),
- this._blurVPostProcess.dispose(n),
- this._ssaoCombinePostProcess.dispose(n)
- }
- this._randomTexture.dispose(),
- t && this._scene.disableGeometryBufferRenderer(),
- this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype._createBlurPostProcess = function(e, t, i) {
- var n = this;
- this._samplerOffsets = [];
- for (var r = this.expensiveBlur, o = -8; o < 8; o++)
- this._samplerOffsets.push(2 * o + .5);
- this._blurHPostProcess = new Ba("BlurH","ssao2",["outSize", "samplerOffsets", "near", "far", "radius"],["depthSampler"],e,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE " + (r ? "1" : "0") + "\n",i),
- this._blurHPostProcess.onApply = function(e) {
- n._scene.activeCamera && (e.setFloat("outSize", n._ssaoCombinePostProcess.width > 0 ? n._ssaoCombinePostProcess.width : n._originalColorPostProcess.width),
- e.setFloat("near", n._scene.activeCamera.minZ),
- e.setFloat("far", n._scene.activeCamera.maxZ),
- e.setFloat("radius", n.radius),
- n._geometryBufferRenderer ? e.setTexture("depthSampler", n._geometryBufferRenderer.getGBuffer().textures[0]) : n._prePassRenderer && e.setTexture("depthSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
- e.setArray("samplerOffsets", n._samplerOffsets))
- }
- ,
- this._blurVPostProcess = new Ba("BlurV","ssao2",["outSize", "samplerOffsets", "near", "far", "radius"],["depthSampler"],t,null,io.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE " + (r ? "1" : "0") + "\n",i),
- this._blurVPostProcess.onApply = function(e) {
- n._scene.activeCamera && (e.setFloat("outSize", n._ssaoCombinePostProcess.height > 0 ? n._ssaoCombinePostProcess.height : n._originalColorPostProcess.height),
- e.setFloat("near", n._scene.activeCamera.minZ),
- e.setFloat("far", n._scene.activeCamera.maxZ),
- e.setFloat("radius", n.radius),
- n._geometryBufferRenderer ? e.setTexture("depthSampler", n._geometryBufferRenderer.getGBuffer().textures[0]) : n._prePassRenderer && e.setTexture("depthSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
- e.setArray("samplerOffsets", n._samplerOffsets))
- }
- ,
- this._blurHPostProcess.samples = this.textureSamples,
- this._blurVPostProcess.samples = this.textureSamples
- }
- ,
- t.prototype._rebuild = function() {
- e.prototype._rebuild.call(this)
- }
- ,
- t.prototype._radicalInverse_VdC = function(e) {
- return this._bits[0] = e,
- this._bits[0] = (this._bits[0] << 16 | this._bits[0] >> 16) >>> 0,
- this._bits[0] = (1431655765 & this._bits[0]) << 1 | (2863311530 & this._bits[0]) >>> 1 >>> 0,
- this._bits[0] = (858993459 & this._bits[0]) << 2 | (3435973836 & this._bits[0]) >>> 2 >>> 0,
- this._bits[0] = (252645135 & this._bits[0]) << 4 | (4042322160 & this._bits[0]) >>> 4 >>> 0,
- this._bits[0] = (16711935 & this._bits[0]) << 8 | (4278255360 & this._bits[0]) >>> 8 >>> 0,
- 2.3283064365386963e-10 * this._bits[0]
- }
- ,
- t.prototype._hammersley = function(e, t) {
- return [e / t, this._radicalInverse_VdC(e)]
- }
- ,
- t.prototype._hemisphereSample_uniform = function(e, t) {
- var i = 2 * t * Math.PI
- , n = 1 - (.85 * e + .15)
- , r = Math.sqrt(1 - n * n);
- return new x(Math.cos(i) * r,Math.sin(i) * r,n)
- }
- ,
- t.prototype._generateHemisphere = function() {
- for (var e, t = this.samples, i = [], n = 0; n < t; ) {
- if (t < 16)
- e = this._hemisphereSample_uniform(Math.random(), Math.random());
- else {
- var r = this._hammersley(n, t);
- e = this._hemisphereSample_uniform(r[0], r[1])
- }
- i.push(e.x, e.y, e.z),
- n++
- }
- return i
- }
- ,
- t.prototype._getDefinesForSSAO = function() {
- return "#define SAMPLES " + this.samples + "\n#define SSAO"
- }
- ,
- t.prototype._createSSAOPostProcess = function(e, i) {
- var n = this;
- this._sampleSphere = this._generateHemisphere();
- var r = this._getDefinesForSSAO();
- this._ssaoPostProcess = new Ba("ssao2","ssao2",["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "base", "range", "projection", "near", "far", "texelSize", "xViewport", "yViewport", "maxZ", "minZAspect", "depthProjection"],["randomSampler", "depthSampler", "normalSampler"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r,i),
- this._ssaoPostProcess.onApply = function(e) {
- var i, r, o, s;
- if (n._scene.activeCamera) {
- if (e.setArray3("sampleSphere", n._sampleSphere),
- e.setFloat("randTextureTiles", 32),
- e.setFloat("samplesFactor", 1 / n.samples),
- e.setFloat("totalStrength", n.totalStrength),
- e.setFloat2("texelSize", 1 / n._ssaoPostProcess.width, 1 / n._ssaoPostProcess.height),
- e.setFloat("radius", n.radius),
- e.setFloat("maxZ", n.maxZ),
- e.setFloat("minZAspect", n.minZAspect),
- e.setFloat("base", n.base),
- e.setFloat("near", n._scene.activeCamera.minZ),
- e.setFloat("far", n._scene.activeCamera.maxZ),
- n._scene.activeCamera.mode === Rr.PERSPECTIVE_CAMERA)
- e.setMatrix3x3("depthProjection", t.PERSPECTIVE_DEPTH_PROJECTION),
- e.setFloat("xViewport", Math.tan(n._scene.activeCamera.fov / 2) * n._scene.getEngine().getAspectRatio(n._scene.activeCamera, !0)),
- e.setFloat("yViewport", Math.tan(n._scene.activeCamera.fov / 2));
- else {
- var l = n._scene.getEngine().getRenderWidth() / 2
- , c = n._scene.getEngine().getRenderHeight() / 2
- , u = null !== (i = n._scene.activeCamera.orthoLeft) && void 0 !== i ? i : -l
- , h = null !== (r = n._scene.activeCamera.orthoRight) && void 0 !== r ? r : l
- , d = null !== (o = n._scene.activeCamera.orthoBottom) && void 0 !== o ? o : -c
- , p = null !== (s = n._scene.activeCamera.orthoTop) && void 0 !== s ? s : c;
- e.setMatrix3x3("depthProjection", t.ORTHO_DEPTH_PROJECTION),
- e.setFloat("xViewport", .5 * (h - u)),
- e.setFloat("yViewport", .5 * (p - d))
- }
- e.setMatrix("projection", n._scene.getProjectionMatrix()),
- n._geometryBufferRenderer ? (e.setTexture("depthSampler", n._geometryBufferRenderer.getGBuffer().textures[0]),
- e.setTexture("normalSampler", n._geometryBufferRenderer.getGBuffer().textures[1])) : n._prePassRenderer && (e.setTexture("depthSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
- e.setTexture("normalSampler", n._prePassRenderer.getRenderTarget().textures[n._prePassRenderer.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE)])),
- e.setTexture("randomSampler", n._randomTexture)
- }
- }
- ,
- this._ssaoPostProcess.samples = this.textureSamples
- }
- ,
- t.prototype._createSSAOCombinePostProcess = function(e, t) {
- var i = this;
- this._ssaoCombinePostProcess = new Ba("ssaoCombine","ssaoCombine",[],["originalColor", "viewport"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,void 0,t),
- this._ssaoCombinePostProcess.onApply = function(e) {
- var t = i._scene.activeCamera.viewport;
- e.setVector4("viewport", I.Vector4[0].copyFromFloats(t.x, t.y, t.width, t.height)),
- e.setTextureFromPostProcessOutput("originalColor", i._originalColorPostProcess)
- }
- ,
- this._ssaoCombinePostProcess.samples = this.textureSamples,
- this._forceGeometryBuffer || (this._ssaoCombinePostProcess._prePassEffectConfiguration = new fb)
- }
- ,
- t.prototype._createRandomTexture = function() {
- this._randomTexture = new Ds("SSAORandomTexture",128,this._scene,!1,io.TRILINEAR_SAMPLINGMODE),
- this._randomTexture.wrapU = io.WRAP_ADDRESSMODE,
- this._randomTexture.wrapV = io.WRAP_ADDRESSMODE;
- for (var e = this._randomTexture.getContext(), t = function(e, t) {
- return Math.random() * (t - e) + e
- }, i = x.Zero(), n = 0; n < 128; n++)
- for (var r = 0; r < 128; r++)
- i.x = t(0, 1),
- i.y = t(0, 1),
- i.z = 0,
- i.normalize(),
- i.scaleInPlace(255),
- i.x = Math.floor(i.x),
- i.y = Math.floor(i.y),
- e.fillStyle = "rgb(" + i.x + ", " + i.y + ", " + i.z + ")",
- e.fillRect(n, r, 1, 1);
- this._randomTexture.update(!1)
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return e.customType = "SSAO2RenderingPipeline",
- e
- }
- ,
- t.Parse = function(e, i, n) {
- return Ge.Parse((function() {
- return new t(e._name,i,e._ratio)
- }
- ), e, i, n)
- }
- ,
- t.ORTHO_DEPTH_PROJECTION = [1, 0, 0, 0, 1, 0, 0, 0, 1],
- t.PERSPECTIVE_DEPTH_PROJECTION = [0, 0, 0, 0, 0, 0, 1, 1, 1],
- k([Ce()], t.prototype, "totalStrength", void 0),
- k([Ce()], t.prototype, "maxZ", void 0),
- k([Ce()], t.prototype, "minZAspect", void 0),
- k([Ce("samples")], t.prototype, "_samples", void 0),
- k([Ce("textureSamples")], t.prototype, "_textureSamples", void 0),
- k([Ce()], t.prototype, "_ratio", void 0),
- k([Ce("expensiveBlur")], t.prototype, "_expensiveBlur", void 0),
- k([Ce()], t.prototype, "radius", void 0),
- k([Ce()], t.prototype, "base", void 0),
- t
- }(cb);
- y("BABYLON.SSAO2RenderingPipeline", _b);
- Pt.ShadersStore.ssaoPixelShader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i<SAMPLES; i++)\n{\nray=radiusDepth*reflect(sampleSphere[i],random);\nhemiRay=position+sign(dot(ray,normal))*ray;\nocclusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;\ndifference=depth-occlusionDepth;\nocclusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));\n}\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor.r=result;\ngl_FragColor.g=result;\ngl_FragColor.b=result;\ngl_FragColor.a=1.0;\n}\n#endif\n";
- var mb = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, i.getEngine(), t) || this;
- o.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect",
- o.SSAORenderEffect = "SSAORenderEffect",
- o.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect",
- o.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect",
- o.SSAOCombineRenderEffect = "SSAOCombineRenderEffect",
- o.totalStrength = 1,
- o.radius = 1e-4,
- o.area = .0075,
- o.fallOff = 1e-6,
- o.base = .5,
- o._firstUpdate = !0,
- o._scene = i,
- o._createRandomTexture(),
- o._depthTexture = i.enableDepthRenderer().getDepthMap();
- var a = n.ssaoRatio || n
- , s = n.combineRatio || n;
- return o._originalColorPostProcess = new Ua("SSAOOriginalSceneColor",s,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),
- o._createSSAOPostProcess(a),
- o._createBlurPostProcess(a),
- o._createSSAOCombinePostProcess(s),
- o.addEffect(new Vy(i.getEngine(),o.SSAOOriginalSceneColorEffect,(function() {
- return o._originalColorPostProcess
- }
- ),!0)),
- o.addEffect(new Vy(i.getEngine(),o.SSAORenderEffect,(function() {
- return o._ssaoPostProcess
- }
- ),!0)),
- o.addEffect(new Vy(i.getEngine(),o.SSAOBlurHRenderEffect,(function() {
- return o._blurHPostProcess
- }
- ),!0)),
- o.addEffect(new Vy(i.getEngine(),o.SSAOBlurVRenderEffect,(function() {
- return o._blurVPostProcess
- }
- ),!0)),
- o.addEffect(new Vy(i.getEngine(),o.SSAOCombineRenderEffect,(function() {
- return o._ssaoCombinePostProcess
- }
- ),!0)),
- i.postProcessRenderPipelineManager.addPipeline(o),
- r && i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t, r),
- o
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "SSAORenderingPipeline"
- }
- ,
- t.prototype.dispose = function(t) {
- void 0 === t && (t = !1);
- for (var i = 0; i < this._scene.cameras.length; i++) {
- var n = this._scene.cameras[i];
- this._originalColorPostProcess.dispose(n),
- this._ssaoPostProcess.dispose(n),
- this._blurHPostProcess.dispose(n),
- this._blurVPostProcess.dispose(n),
- this._ssaoCombinePostProcess.dispose(n)
- }
- this._randomTexture.dispose(),
- t && this._scene.disableDepthRenderer(),
- this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype._createBlurPostProcess = function(e) {
- var t = this;
- this._blurHPostProcess = new Fd("BlurH",new A(1,0),16,e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),
- this._blurVPostProcess = new Fd("BlurV",new A(0,1),16,e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),
- this._blurHPostProcess.onActivateObservable.add((function() {
- var e = t._blurHPostProcess.width / t._scene.getEngine().getRenderWidth();
- t._blurHPostProcess.kernel = 16 * e
- }
- )),
- this._blurVPostProcess.onActivateObservable.add((function() {
- var e = t._blurVPostProcess.height / t._scene.getEngine().getRenderHeight();
- t._blurVPostProcess.kernel = 16 * e
- }
- ))
- }
- ,
- t.prototype._rebuild = function() {
- this._firstUpdate = !0,
- e.prototype._rebuild.call(this)
- }
- ,
- t.prototype._createSSAOPostProcess = function(e) {
- var t = this
- , i = [.5381, .1856, -.4319, .1379, .2486, .443, .3371, .5679, -.0057, -.6999, -.0451, -.0019, .0689, -.1598, -.8547, .056, .0069, -.1843, -.0146, .1402, .0762, .01, -.1924, -.0344, -.3577, -.5301, -.4358, -.3169, .1063, .0158, .0103, -.5869, .0046, -.0897, -.494, .3287, .7119, -.0154, -.0918, -.0533, .0596, -.5411, .0352, -.0631, .546, -.4776, .2847, -.0271];
- this._ssaoPostProcess = new Ba("ssao","ssao",["sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius", "area", "fallOff", "base", "range", "viewport"],["randomSampler"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES 16\n#define SSAO"),
- this._ssaoPostProcess.externalTextureSamplerBinding = !0,
- this._ssaoPostProcess.onApply = function(e) {
- t._firstUpdate && (e.setArray3("sampleSphere", i),
- e.setFloat("samplesFactor", .0625),
- e.setFloat("randTextureTiles", 4)),
- e.setFloat("totalStrength", t.totalStrength),
- e.setFloat("radius", t.radius),
- e.setFloat("area", t.area),
- e.setFloat("fallOff", t.fallOff),
- e.setFloat("base", t.base),
- e.setTexture("textureSampler", t._depthTexture),
- e.setTexture("randomSampler", t._randomTexture)
- }
- }
- ,
- t.prototype._createSSAOCombinePostProcess = function(e) {
- var t = this;
- this._ssaoCombinePostProcess = new Ba("ssaoCombine","ssaoCombine",[],["originalColor", "viewport"],e,null,io.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),
- this._ssaoCombinePostProcess.onApply = function(e) {
- e.setVector4("viewport", I.Vector4[0].copyFromFloats(0, 0, 1, 1)),
- e.setTextureFromPostProcess("originalColor", t._originalColorPostProcess)
- }
- }
- ,
- t.prototype._createRandomTexture = function() {
- this._randomTexture = new Ds("SSAORandomTexture",512,this._scene,!1,io.TRILINEAR_SAMPLINGMODE),
- this._randomTexture.wrapU = io.WRAP_ADDRESSMODE,
- this._randomTexture.wrapV = io.WRAP_ADDRESSMODE;
- for (var e = this._randomTexture.getContext(), t = function(e, t) {
- return Math.random() * (t - e) + e
- }, i = x.Zero(), n = 0; n < 512; n++)
- for (var r = 0; r < 512; r++)
- i.x = Math.floor(255 * t(-1, 1)),
- i.y = Math.floor(255 * t(-1, 1)),
- i.z = Math.floor(255 * t(-1, 1)),
- e.fillStyle = "rgb(" + i.x + ", " + i.y + ", " + i.z + ")",
- e.fillRect(n, r, 1, 1);
- this._randomTexture.update(!1)
- }
- ,
- k([Ce()], t.prototype, "totalStrength", void 0),
- k([Ce()], t.prototype, "radius", void 0),
- k([Ce()], t.prototype, "area", void 0),
- k([Ce()], t.prototype, "fallOff", void 0),
- k([Ce()], t.prototype, "base", void 0),
- t
- }(cb)
- , gb = function() {
- this.enabled = !1,
- this.name = "screenSpaceReflections",
- this.texturesRequired = [a.PREPASS_NORMAL_TEXTURE_TYPE, a.PREPASS_REFLECTIVITY_TEXTURE_TYPE, a.PREPASS_POSITION_TEXTURE_TYPE]
- };
- Pt.ShadersStore.screenSpaceReflectionPixelShader = "uniform sampler2D textureSampler;\n#ifdef SSR_SUPPORTED\nuniform sampler2D reflectivitySampler;\nuniform sampler2D normalSampler;\nuniform sampler2D positionSampler;\n#endif\nuniform mat4 view;\nuniform mat4 projection;\nuniform float stepSize;\nuniform float strength;\nuniform float threshold;\nuniform float roughnessFactor;\nuniform float reflectionSpecularFalloffExponent;\nvarying vec2 vUV;\n#ifdef SSR_SUPPORTED\nstruct ReflectionInfo {\nvec3 color;\nvec4 coords;\n};\n/**\n* According to specular,see https:\n*/\nvec3 fresnelSchlick(float cosTheta,vec3 F0)\n{\nreturn F0+(1.0-F0)*pow(1.0-cosTheta,5.0);\n}\n/**\n* Once the pixel's coordinates has been found,let's adjust (smooth) a little bit\n* by sampling multiple reflection pixels.\n*/\nReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\ninfo.color=vec3(0.0);\nvec4 projectedCoord;\nfloat sampledDepth;\nfor(int i=0; i<SMOOTH_STEPS; i++)\n{\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\nsampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;\nfloat depth=sampledDepth-hitCoord.z;\ndir*=0.5;\nif(depth>0.0)\nhitCoord-=dir;\nelse\nhitCoord+=dir;\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\n}\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,1.0);\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.color/=float(SMOOTH_STEPS+1);\nreturn info;\n}\n/**\n* Tests the given world position (hitCoord) according to the given reflection vector (dir)\n* until it finds a collision (means that depth is enough close to say \"it's the pixel to sample!\").\n*/\nReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\nvec4 projectedCoord;\nfloat sampledDepth;\ndir*=stepSize;\nfor(int i=0; i<REFLECTION_SAMPLES; i++)\n{\nhitCoord+=dir;\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\nsampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;\nfloat depth=sampledDepth-hitCoord.z;\n#ifdef RIGHT_HANDED_SCENE\ndepth*=-1.0;\n#endif\nif(((depth-dir.z)<threshold) && depth<=0.0)\n{\n#ifdef ENABLE_SMOOTH_REFLECTIONS\nreturn smoothReflectionInfo(dir,hitCoord);\n#else\ninfo.color=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,0.0);\nreturn info;\n#endif\n}\n}\ninfo.color=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,0.0);\nreturn info;\n}\nvec3 hash(vec3 a)\n{\na=fract(a*0.8);\na+=dot(a,a.yxz+19.19);\nreturn fract((a.xxy+a.yxx)*a.zyx);\n}\n#endif\nvoid main()\n{\n#ifdef SSR_SUPPORTED\nvec4 albedoFull=texture2D(textureSampler,vUV);\nvec3 albedo=albedoFull.rgb;\nfloat spec=texture2D(reflectivitySampler,vUV).r;\nif (spec==0.0) {\ngl_FragColor=albedoFull;\nreturn;\n}\nvec3 normal=(texture2D(normalSampler,vUV)).xyz;\nvec3 position=(view*texture2D(positionSampler,vUV)).xyz;\nvec3 reflected=normalize(reflect(normalize(position),normalize(normal)));\nfloat roughness=1.0-texture2D(reflectivitySampler,vUV).a;\nvec3 jitt=mix(vec3(0.0),hash(position),roughness)*roughnessFactor;\nReflectionInfo info=getReflectionInfo(jitt+reflected,position);\nvec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-info.coords.xy));\nfloat screenEdgefactor=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);\nvec3 F0=vec3(0.04);\nF0 =mix(F0,albedo,spec);\nvec3 fresnel=fresnelSchlick(max(dot(normalize(normal),normalize(position)),0.0),F0);\n#ifdef RIGHT_HANDED_SCENE\nreflected.z*=-1.0;\n#endif\nfloat reflectionMultiplier=clamp(pow(spec*strength,reflectionSpecularFalloffExponent)*screenEdgefactor*reflected.z,0.0,0.9);\nfloat albedoMultiplier=1.0-reflectionMultiplier;\nvec3 SSR=info.color*fresnel;\ngl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFull.a);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";
- var vb = function(e) {
- function t(t, i, n, r, o, s, l, c, u, h) {
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = !1),
- void 0 === h && (h = !1);
- var d = e.call(this, t, "screenSpaceReflection", ["projection", "view", "threshold", "reflectionSpecularFalloffExponent", "strength", "stepSize", "roughnessFactor"], ["textureSampler", "normalSampler", "positionSampler", "reflectivitySampler"], n, r, o, s, l, "#define SSR_SUPPORTED\n#define REFLECTION_SAMPLES 64\n#define SMOOTH_STEPS 5\n", c, void 0, null, u) || this;
- if (d.threshold = 1.2,
- d.strength = 1,
- d.reflectionSpecularFalloffExponent = 3,
- d.step = 1,
- d.roughnessFactor = .2,
- d._forceGeometryBuffer = !1,
- d._enableSmoothReflections = !1,
- d._reflectionSamples = 64,
- d._smoothSteps = 5,
- d._forceGeometryBuffer = h,
- d._forceGeometryBuffer) {
- var p = i.enableGeometryBufferRenderer();
- p && p.isSupported && (p.enablePosition = !0,
- p.enableReflectivity = !0)
- } else {
- var f = i.enablePrePassRenderer();
- null == f || f.markAsDirty(),
- d._prePassEffectConfiguration = new gb
- }
- return d._updateEffectDefines(),
- d.onApply = function(e) {
- var t = d._geometryBufferRenderer
- , n = d._prePassRenderer;
- if (n || t) {
- if (t) {
- var r = t.getTextureIndex(nb.POSITION_TEXTURE_TYPE)
- , o = t.getTextureIndex(nb.REFLECTIVITY_TEXTURE_TYPE);
- e.setTexture("normalSampler", t.getGBuffer().textures[1]),
- e.setTexture("positionSampler", t.getGBuffer().textures[r]),
- e.setTexture("reflectivitySampler", t.getGBuffer().textures[o])
- } else if (n) {
- r = n.getIndex(a.PREPASS_POSITION_TEXTURE_TYPE),
- o = n.getIndex(a.PREPASS_REFLECTIVITY_TEXTURE_TYPE);
- var s = n.getIndex(a.PREPASS_NORMAL_TEXTURE_TYPE);
- e.setTexture("normalSampler", n.getRenderTarget().textures[s]),
- e.setTexture("positionSampler", n.getRenderTarget().textures[r]),
- e.setTexture("reflectivitySampler", n.getRenderTarget().textures[o])
- }
- var l = i.activeCamera;
- if (l) {
- var c = l.getViewMatrix(!0)
- , u = l.getProjectionMatrix(!0);
- e.setMatrix("projection", u),
- e.setMatrix("view", c),
- e.setFloat("threshold", d.threshold),
- e.setFloat("reflectionSpecularFalloffExponent", d.reflectionSpecularFalloffExponent),
- e.setFloat("strength", d.strength),
- e.setFloat("stepSize", d.step),
- e.setFloat("roughnessFactor", d.roughnessFactor)
- }
- }
- }
- ,
- d._isSceneRightHanded = i.useRightHandedSystem,
- d
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "_geometryBufferRenderer", {
- get: function() {
- return this._forceGeometryBuffer ? this._scene.geometryBufferRenderer : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "_prePassRenderer", {
- get: function() {
- return this._forceGeometryBuffer ? null : this._scene.prePassRenderer
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "ScreenSpaceReflectionPostProcess"
- }
- ,
- Object.defineProperty(t.prototype, "enableSmoothReflections", {
- get: function() {
- return this._enableSmoothReflections
- },
- set: function(e) {
- e !== this._enableSmoothReflections && (this._enableSmoothReflections = e,
- this._updateEffectDefines())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "reflectionSamples", {
- get: function() {
- return this._reflectionSamples
- },
- set: function(e) {
- e !== this._reflectionSamples && (this._reflectionSamples = e,
- this._updateEffectDefines())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "smoothSteps", {
- get: function() {
- return this._smoothSteps
- },
- set: function(e) {
- e !== this._smoothSteps && (this._smoothSteps = e,
- this._updateEffectDefines())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._updateEffectDefines = function() {
- var e = [];
- (this._geometryBufferRenderer || this._prePassRenderer) && e.push("#define SSR_SUPPORTED"),
- this._enableSmoothReflections && e.push("#define ENABLE_SMOOTH_REFLECTIONS"),
- this._isSceneRightHanded && e.push("#define RIGHT_HANDED_SCENE"),
- e.push("#define REFLECTION_SAMPLES " + (this._reflectionSamples >> 0)),
- e.push("#define SMOOTH_STEPS " + (this._smoothSteps >> 0)),
- this.updateEffect(e.join("\n"))
- }
- ,
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "threshold", void 0),
- k([Ce()], t.prototype, "strength", void 0),
- k([Ce()], t.prototype, "reflectionSpecularFalloffExponent", void 0),
- k([Ce()], t.prototype, "step", void 0),
- k([Ce()], t.prototype, "roughnessFactor", void 0),
- k([Ce()], t.prototype, "enableSmoothReflections", null),
- k([Ce()], t.prototype, "reflectionSamples", null),
- k([Ce()], t.prototype, "smoothSteps", null),
- t
- }(Ba);
- y("BABYLON.ScreenSpaceReflectionPostProcess", vb);
- Pt.ShadersStore.standardPixelShader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric= (worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\n#include<packingFunctions>\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV/*lensFlareCoords*/);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";
- var yb = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = null);
- var s = e.call(this, i.getEngine(), t) || this;
- return s.downSampleX4PostProcess = null,
- s.brightPassPostProcess = null,
- s.blurHPostProcesses = [],
- s.blurVPostProcesses = [],
- s.textureAdderPostProcess = null,
- s.volumetricLightPostProcess = null,
- s.volumetricLightSmoothXPostProcess = null,
- s.volumetricLightSmoothYPostProcess = null,
- s.volumetricLightMergePostProces = null,
- s.volumetricLightFinalPostProcess = null,
- s.luminancePostProcess = null,
- s.luminanceDownSamplePostProcesses = [],
- s.hdrPostProcess = null,
- s.textureAdderFinalPostProcess = null,
- s.lensFlareFinalPostProcess = null,
- s.hdrFinalPostProcess = null,
- s.lensFlarePostProcess = null,
- s.lensFlareComposePostProcess = null,
- s.motionBlurPostProcess = null,
- s.depthOfFieldPostProcess = null,
- s.fxaaPostProcess = null,
- s.screenSpaceReflectionPostProcess = null,
- s.brightThreshold = 1,
- s.blurWidth = 512,
- s.horizontalBlur = !1,
- s.lensTexture = null,
- s.volumetricLightCoefficient = .2,
- s.volumetricLightPower = 4,
- s.volumetricLightBlurScale = 64,
- s.sourceLight = null,
- s.hdrMinimumLuminance = 1,
- s.hdrDecreaseRate = .5,
- s.hdrIncreaseRate = .5,
- s.lensColorTexture = null,
- s.lensFlareStrength = 20,
- s.lensFlareGhostDispersal = 1.4,
- s.lensFlareHaloWidth = .7,
- s.lensFlareDistortionStrength = 16,
- s.lensFlareBlurWidth = 512,
- s.lensStarTexture = null,
- s.lensFlareDirtTexture = null,
- s.depthOfFieldDistance = 10,
- s.depthOfFieldBlurWidth = 64,
- s.animations = [],
- s._currentDepthOfFieldSource = null,
- s._fixedExposure = 1,
- s._currentExposure = 1,
- s._hdrAutoExposure = !1,
- s._hdrCurrentLuminance = 1,
- s._motionStrength = 1,
- s._isObjectBasedMotionBlur = !1,
- s._camerasToBeAttached = [],
- s._bloomEnabled = !1,
- s._depthOfFieldEnabled = !1,
- s._vlsEnabled = !1,
- s._lensFlareEnabled = !1,
- s._hdrEnabled = !1,
- s._motionBlurEnabled = !1,
- s._fxaaEnabled = !1,
- s._screenSpaceReflectionsEnabled = !1,
- s._motionBlurSamples = 64,
- s._volumetricLightStepsCount = 50,
- s._samples = 1,
- s._cameras = o || i.cameras,
- s._cameras = s._cameras.slice(),
- s._camerasToBeAttached = s._cameras.slice(),
- s._scene = i,
- s._basePostProcess = r,
- s._ratio = n,
- s._floatTextureType = i.getEngine().getCaps().textureFloatRender ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT,
- i.postProcessRenderPipelineManager.addPipeline(s),
- s._buildPipeline(),
- s
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "exposure", {
- get: function() {
- return this._fixedExposure
- },
- set: function(e) {
- this._fixedExposure = e,
- this._currentExposure = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "hdrAutoExposure", {
- get: function() {
- return this._hdrAutoExposure
- },
- set: function(e) {
- if (this._hdrAutoExposure = e,
- this.hdrPostProcess) {
- var t = ["#define HDR"];
- e && t.push("#define AUTO_EXPOSURE"),
- this.hdrPostProcess.updateEffect(t.join("\n"))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "motionStrength", {
- get: function() {
- return this._motionStrength
- },
- set: function(e) {
- this._motionStrength = e,
- this._isObjectBasedMotionBlur && this.motionBlurPostProcess && (this.motionBlurPostProcess.motionStrength = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "objectBasedMotionBlur", {
- get: function() {
- return this._isObjectBasedMotionBlur
- },
- set: function(e) {
- var t = this._isObjectBasedMotionBlur !== e;
- this._isObjectBasedMotionBlur = e,
- t && this._buildPipeline()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "BloomEnabled", {
- get: function() {
- return this._bloomEnabled
- },
- set: function(e) {
- this._bloomEnabled !== e && (this._bloomEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "DepthOfFieldEnabled", {
- get: function() {
- return this._depthOfFieldEnabled
- },
- set: function(e) {
- this._depthOfFieldEnabled !== e && (this._depthOfFieldEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "LensFlareEnabled", {
- get: function() {
- return this._lensFlareEnabled
- },
- set: function(e) {
- this._lensFlareEnabled !== e && (this._lensFlareEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "HDREnabled", {
- get: function() {
- return this._hdrEnabled
- },
- set: function(e) {
- this._hdrEnabled !== e && (this._hdrEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "VLSEnabled", {
- get: function() {
- return this._vlsEnabled
- },
- set: function(e) {
- if (this._vlsEnabled !== e) {
- if (e && !this._scene.enableGeometryBufferRenderer())
- return void K.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
- this._vlsEnabled = e,
- this._buildPipeline()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "MotionBlurEnabled", {
- get: function() {
- return this._motionBlurEnabled
- },
- set: function(e) {
- this._motionBlurEnabled !== e && (this._motionBlurEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "fxaaEnabled", {
- get: function() {
- return this._fxaaEnabled
- },
- set: function(e) {
- this._fxaaEnabled !== e && (this._fxaaEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "screenSpaceReflectionsEnabled", {
- get: function() {
- return this._screenSpaceReflectionsEnabled
- },
- set: function(e) {
- this._screenSpaceReflectionsEnabled !== e && (this._screenSpaceReflectionsEnabled = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "volumetricLightStepsCount", {
- get: function() {
- return this._volumetricLightStepsCount
- },
- set: function(e) {
- this.volumetricLightPostProcess && this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + e.toFixed(1)),
- this._volumetricLightStepsCount = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "motionBlurSamples", {
- get: function() {
- return this._motionBlurSamples
- },
- set: function(e) {
- this.motionBlurPostProcess && (this._isObjectBasedMotionBlur ? this.motionBlurPostProcess.motionBlurSamples = e : this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + e.toFixed(1))),
- this._motionBlurSamples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(e) {
- this._samples !== e && (this._samples = e,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._buildPipeline = function() {
- var e = this
- , t = this._ratio
- , i = this._scene;
- this._disposePostProcesses(),
- null !== this._cameras && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
- this._cameras = this._camerasToBeAttached.slice()),
- this._reset(),
- this._screenSpaceReflectionsEnabled && (this.screenSpaceReflectionPostProcess = new vb("HDRPass",i,t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),
- this.screenSpaceReflectionPostProcess.onApplyObservable.add((function() {
- e._currentDepthOfFieldSource = e.screenSpaceReflectionPostProcess
- }
- )),
- this.addEffect(new Vy(i.getEngine(),"HDRScreenSpaceReflections",(function() {
- return e.screenSpaceReflectionPostProcess
- }
- ),!0))),
- this._basePostProcess ? this.originalPostProcess = this._basePostProcess : this.originalPostProcess = new Ba("HDRPass","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),
- this.originalPostProcess.autoClear = !this.screenSpaceReflectionPostProcess,
- this.originalPostProcess.onApplyObservable.add((function() {
- e._currentDepthOfFieldSource = e.originalPostProcess
- }
- )),
- this.addEffect(new Vy(i.getEngine(),"HDRPassPostProcess",(function() {
- return e.originalPostProcess
- }
- ),!0)),
- this._bloomEnabled && (this._createDownSampleX4PostProcess(i, t / 4),
- this._createBrightPassPostProcess(i, t / 4),
- this._createBlurPostProcesses(i, t / 4, 1),
- this._createTextureAdderPostProcess(i, t),
- this.textureAdderFinalPostProcess = new Ba("HDRDepthOfFieldSource","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(i.getEngine(),"HDRBaseDepthOfFieldSource",(function() {
- return e.textureAdderFinalPostProcess
- }
- ),!0))),
- this._vlsEnabled && (this._createVolumetricLightPostProcess(i, t),
- this.volumetricLightFinalPostProcess = new Ba("HDRVLSFinal","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(i.getEngine(),"HDRVLSFinal",(function() {
- return e.volumetricLightFinalPostProcess
- }
- ),!0))),
- this._lensFlareEnabled && (this._createLensFlarePostProcess(i, t),
- this.lensFlareFinalPostProcess = new Ba("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function() {
- return e.lensFlareFinalPostProcess
- }
- ),!0))),
- this._hdrEnabled && (this._createLuminancePostProcesses(i, this._floatTextureType),
- this._createHdrPostProcess(i, t),
- this.hdrFinalPostProcess = new Ba("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(i.getEngine(),"HDRPostHDReDepthOfFieldSource",(function() {
- return e.hdrFinalPostProcess
- }
- ),!0))),
- this._depthOfFieldEnabled && (this._createBlurPostProcesses(i, t / 2, 3, "depthOfFieldBlurWidth"),
- this._createDepthOfFieldPostProcess(i, t)),
- this._motionBlurEnabled && this._createMotionBlurPostProcess(i, t),
- this._fxaaEnabled && (this.fxaaPostProcess = new eb("fxaa",1,null,io.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(i.getEngine(),"HDRFxaa",(function() {
- return e.fxaaPostProcess
- }
- ),!0))),
- null !== this._cameras && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras),
- !this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1 && K.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")
- }
- ,
- t.prototype._createDownSampleX4PostProcess = function(e, t) {
- var i = this
- , n = new Array(32);
- this.downSampleX4PostProcess = new Ba("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),
- this.downSampleX4PostProcess.onApply = function(e) {
- for (var t = 0, r = i.downSampleX4PostProcess.width, o = i.downSampleX4PostProcess.height, a = -2; a < 2; a++)
- for (var s = -2; s < 2; s++)
- n[t] = (a + .5) * (1 / r),
- n[t + 1] = (s + .5) * (1 / o),
- t += 2;
- e.setArray2("dsOffsets", n)
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRDownSampleX4",(function() {
- return i.downSampleX4PostProcess
- }
- ),!0))
- }
- ,
- t.prototype._createBrightPassPostProcess = function(e, t) {
- var i = this
- , n = new Array(8);
- this.brightPassPostProcess = new Ba("HDRBrightPass","standard",["dsOffsets", "brightThreshold"],[],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),
- this.brightPassPostProcess.onApply = function(e) {
- var t = 1 / i.brightPassPostProcess.width
- , r = 1 / i.brightPassPostProcess.height;
- n[0] = -.5 * t,
- n[1] = .5 * r,
- n[2] = .5 * t,
- n[3] = .5 * r,
- n[4] = -.5 * t,
- n[5] = -.5 * r,
- n[6] = .5 * t,
- n[7] = -.5 * r,
- e.setArray2("dsOffsets", n),
- e.setFloat("brightThreshold", i.brightThreshold)
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRBrightPass",(function() {
- return i.brightPassPostProcess
- }
- ),!0))
- }
- ,
- t.prototype._createBlurPostProcesses = function(e, t, i, n) {
- var r = this;
- void 0 === n && (n = "blurWidth");
- var o = e.getEngine()
- , a = new Fd("HDRBlurH_" + i,new A(1,0),this[n],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType)
- , s = new Fd("HDRBlurV_" + i,new A(0,1),this[n],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);
- a.onActivateObservable.add((function() {
- var e = a.width / o.getRenderWidth();
- a.kernel = r[n] * e
- }
- )),
- s.onActivateObservable.add((function() {
- var e = s.height / o.getRenderHeight();
- s.kernel = r.horizontalBlur ? 64 * e : r[n] * e
- }
- )),
- this.addEffect(new Vy(e.getEngine(),"HDRBlurH" + i,(function() {
- return a
- }
- ),!0)),
- this.addEffect(new Vy(e.getEngine(),"HDRBlurV" + i,(function() {
- return s
- }
- ),!0)),
- this.blurHPostProcesses.push(a),
- this.blurVPostProcesses.push(s)
- }
- ,
- t.prototype._createTextureAdderPostProcess = function(e, t) {
- var i = this;
- this.textureAdderPostProcess = new Ba("HDRTextureAdder","standard",["exposure"],["otherSampler", "lensSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),
- this.textureAdderPostProcess.onApply = function(e) {
- e.setTextureFromPostProcess("otherSampler", i._vlsEnabled ? i._currentDepthOfFieldSource : i.originalPostProcess),
- e.setTexture("lensSampler", i.lensTexture),
- e.setFloat("exposure", i._currentExposure),
- i._currentDepthOfFieldSource = i.textureAdderFinalPostProcess
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRTextureAdder",(function() {
- return i.textureAdderPostProcess
- }
- ),!0))
- }
- ,
- t.prototype._createVolumetricLightPostProcess = function(e, t) {
- var i = this
- , n = e.enableGeometryBufferRenderer();
- n.enablePosition = !0;
- var r = n.getGBuffer();
- this.volumetricLightPostProcess = new Ba("HDRVLS","standard",["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"],["shadowMapSampler", "positionSampler"],t / 8,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS " + this._volumetricLightStepsCount.toFixed(1));
- var o = A.Zero();
- this.volumetricLightPostProcess.onApply = function(e) {
- if (i.sourceLight && i.sourceLight.getShadowGenerator() && i._scene.activeCamera) {
- var t = i.sourceLight.getShadowGenerator();
- e.setTexture("shadowMapSampler", t.getShadowMap()),
- e.setTexture("positionSampler", r.textures[2]),
- e.setColor3("sunColor", i.sourceLight.diffuse),
- e.setVector3("sunDirection", i.sourceLight.getShadowDirection()),
- e.setVector3("cameraPosition", i._scene.activeCamera.globalPosition),
- e.setMatrix("shadowViewProjection", t.getTransformMatrix()),
- e.setFloat("scatteringCoefficient", i.volumetricLightCoefficient),
- e.setFloat("scatteringPower", i.volumetricLightPower),
- o.x = i.sourceLight.getDepthMinZ(i._scene.activeCamera),
- o.y = i.sourceLight.getDepthMaxZ(i._scene.activeCamera),
- e.setVector2("depthValues", o)
- }
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRVLS",(function() {
- return i.volumetricLightPostProcess
- }
- ),!0)),
- this._createBlurPostProcesses(e, t / 4, 0, "volumetricLightBlurScale"),
- this.volumetricLightMergePostProces = new Ba("HDRVLSMerge","standard",[],["originalSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),
- this.volumetricLightMergePostProces.onApply = function(e) {
- e.setTextureFromPostProcess("originalSampler", i._bloomEnabled ? i.textureAdderFinalPostProcess : i.originalPostProcess),
- i._currentDepthOfFieldSource = i.volumetricLightFinalPostProcess
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRVLSMerge",(function() {
- return i.volumetricLightMergePostProces
- }
- ),!0))
- }
- ,
- t.prototype._createLuminancePostProcesses = function(e, i) {
- var n = this
- , r = Math.pow(3, t.LuminanceSteps);
- this.luminancePostProcess = new Ba("HDRLuminance","standard",["lumOffsets"],[],{
- width: r,
- height: r
- },null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",i);
- var o = [];
- this.luminancePostProcess.onApply = function(e) {
- var t = 1 / n.luminancePostProcess.width
- , i = 1 / n.luminancePostProcess.height;
- o[0] = -.5 * t,
- o[1] = .5 * i,
- o[2] = .5 * t,
- o[3] = .5 * i,
- o[4] = -.5 * t,
- o[5] = -.5 * i,
- o[6] = .5 * t,
- o[7] = -.5 * i,
- e.setArray2("lumOffsets", o)
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRLuminance",(function() {
- return n.luminancePostProcess
- }
- ),!0));
- for (var a = t.LuminanceSteps - 1; a >= 0; a--) {
- r = Math.pow(3, a);
- var s = "#define LUMINANCE_DOWN_SAMPLE\n";
- 0 === a && (s += "#define FINAL_DOWN_SAMPLER");
- var l = new Ba("HDRLuminanceDownSample" + a,"standard",["dsOffsets", "halfDestPixelSize"],[],{
- width: r,
- height: r
- },null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,s,i);
- this.luminanceDownSamplePostProcesses.push(l)
- }
- var c = this.luminancePostProcess;
- this.luminanceDownSamplePostProcesses.forEach((function(t, i) {
- var r = new Array(18);
- t.onApply = function(e) {
- if (c) {
- for (var o = 0, a = -1; a < 2; a++)
- for (var s = -1; s < 2; s++)
- r[o] = a / c.width,
- r[o + 1] = s / c.height,
- o += 2;
- e.setArray2("dsOffsets", r),
- e.setFloat("halfDestPixelSize", .5 / c.width),
- c = i === n.luminanceDownSamplePostProcesses.length - 1 ? n.luminancePostProcess : t
- }
- }
- ,
- i === n.luminanceDownSamplePostProcesses.length - 1 && (t.onAfterRender = function() {
- var t = e.getEngine().readPixels(0, 0, 1, 1)
- , i = new R(1 / 16581375,1 / 65025,1 / 255,1);
- t.then((function(e) {
- var t = new Uint8Array(e.buffer);
- n._hdrCurrentLuminance = (t[0] * i.x + t[1] * i.y + t[2] * i.z + t[3] * i.w) / 100
- }
- ))
- }
- ),
- n.addEffect(new Vy(e.getEngine(),"HDRLuminanceDownSample" + i,(function() {
- return t
- }
- ),!0))
- }
- ))
- }
- ,
- t.prototype._createHdrPostProcess = function(e, t) {
- var i = this
- , n = ["#define HDR"];
- this._hdrAutoExposure && n.push("#define AUTO_EXPOSURE"),
- this.hdrPostProcess = new Ba("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n.join("\n"),a.TEXTURETYPE_UNSIGNED_INT);
- var r = 1
- , o = 0
- , s = 0;
- this.hdrPostProcess.onApply = function(t) {
- if (t.setTextureFromPostProcess("textureAdderSampler", i._currentDepthOfFieldSource),
- o += e.getEngine().getDeltaTime(),
- r < 0)
- r = i._hdrCurrentLuminance;
- else {
- var n = (s - o) / 1e3;
- i._hdrCurrentLuminance < r + i.hdrDecreaseRate * n ? r += i.hdrDecreaseRate * n : i._hdrCurrentLuminance > r - i.hdrIncreaseRate * n ? r -= i.hdrIncreaseRate * n : r = i._hdrCurrentLuminance
- }
- i.hdrAutoExposure ? i._currentExposure = i._fixedExposure / r : (r = d.Clamp(r, i.hdrMinimumLuminance, 1e20),
- t.setFloat("averageLuminance", r)),
- s = o,
- i._currentDepthOfFieldSource = i.hdrFinalPostProcess
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDR",(function() {
- return i.hdrPostProcess
- }
- ),!0))
- }
- ,
- t.prototype._createLensFlarePostProcess = function(e, t) {
- var i = this;
- this.lensFlarePostProcess = new Ba("HDRLensFlare","standard",["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"],["lensColorSampler"],t / 2,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(e.getEngine(),"HDRLensFlare",(function() {
- return i.lensFlarePostProcess
- }
- ),!0)),
- this._createBlurPostProcesses(e, t / 4, 2, "lensFlareBlurWidth"),
- this.lensFlareComposePostProcess = new Ba("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler", "lensDirtSampler", "lensStarSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",a.TEXTURETYPE_UNSIGNED_INT),
- this.addEffect(new Vy(e.getEngine(),"HDRLensFlareCompose",(function() {
- return i.lensFlareComposePostProcess
- }
- ),!0));
- var n = new A(0,0);
- this.lensFlarePostProcess.externalTextureSamplerBinding = !0,
- this.lensFlarePostProcess.onApply = function(e) {
- e.setTextureFromPostProcess("textureSampler", i._bloomEnabled ? i.blurHPostProcesses[0] : i.originalPostProcess),
- e.setTexture("lensColorSampler", i.lensColorTexture),
- e.setFloat("strength", i.lensFlareStrength),
- e.setFloat("ghostDispersal", i.lensFlareGhostDispersal),
- e.setFloat("haloWidth", i.lensFlareHaloWidth),
- n.x = i.lensFlarePostProcess.width,
- n.y = i.lensFlarePostProcess.height,
- e.setVector2("resolution", n),
- e.setFloat("distortionStrength", i.lensFlareDistortionStrength)
- }
- ;
- var r = P.FromValues(2, 0, -1, 0, 0, 2, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1)
- , o = P.FromValues(.5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1, 0, 0, 0, 0, 1);
- this.lensFlareComposePostProcess.onApply = function(e) {
- if (i._scene.activeCamera) {
- e.setTextureFromPostProcess("otherSampler", i.lensFlarePostProcess),
- e.setTexture("lensDirtSampler", i.lensFlareDirtTexture),
- e.setTexture("lensStarSampler", i.lensStarTexture);
- var t = i._scene.activeCamera.getViewMatrix().getRow(0)
- , n = i._scene.activeCamera.getViewMatrix().getRow(2)
- , a = x.Dot(t.toVector3(), new x(1,0,0)) + x.Dot(n.toVector3(), new x(0,0,1));
- a *= 4;
- var s = P.FromValues(.5 * Math.cos(a), -Math.sin(a), 0, 0, Math.sin(a), .5 * Math.cos(a), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
- , l = o.multiply(s).multiply(r);
- e.setMatrix("lensStarMatrix", l),
- i._currentDepthOfFieldSource = i.lensFlareFinalPostProcess
- }
- }
- }
- ,
- t.prototype._createDepthOfFieldPostProcess = function(e, t) {
- var i = this;
- this.depthOfFieldPostProcess = new Ba("HDRDepthOfField","standard",["distance"],["otherSampler", "depthSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",a.TEXTURETYPE_UNSIGNED_INT),
- this.depthOfFieldPostProcess.onApply = function(e) {
- e.setTextureFromPostProcess("otherSampler", i._currentDepthOfFieldSource),
- e.setTexture("depthSampler", i._getDepthTexture()),
- e.setFloat("distance", i.depthOfFieldDistance)
- }
- ,
- this.addEffect(new Vy(e.getEngine(),"HDRDepthOfField",(function() {
- return i.depthOfFieldPostProcess
- }
- ),!0))
- }
- ,
- t.prototype._createMotionBlurPostProcess = function(e, t) {
- var i = this;
- if (this._isObjectBasedMotionBlur) {
- var n = new ab("HDRMotionBlur",e,t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,a.TEXTURETYPE_UNSIGNED_INT);
- n.motionStrength = this.motionStrength,
- n.motionBlurSamples = this.motionBlurSamples,
- this.motionBlurPostProcess = n
- } else {
- this.motionBlurPostProcess = new Ba("HDRMotionBlur","standard",["inverseViewProjection", "prevViewProjection", "screenSize", "motionScale", "motionStrength"],["depthSampler"],t,null,io.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + this.motionBlurSamples.toFixed(1),a.TEXTURETYPE_UNSIGNED_INT);
- var r = 0
- , o = P.Identity()
- , s = P.Identity()
- , l = P.Identity()
- , c = A.Zero();
- this.motionBlurPostProcess.onApply = function(t) {
- (l = e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),
- t.setMatrix("inverseViewProjection", s),
- t.setMatrix("prevViewProjection", o),
- o = l,
- c.x = i.motionBlurPostProcess.width,
- c.y = i.motionBlurPostProcess.height,
- t.setVector2("screenSize", c),
- r = e.getEngine().getFps() / 60,
- t.setFloat("motionScale", r),
- t.setFloat("motionStrength", i.motionStrength),
- t.setTexture("depthSampler", i._getDepthTexture())
- }
- }
- this.addEffect(new Vy(e.getEngine(),"HDRMotionBlur",(function() {
- return i.motionBlurPostProcess
- }
- ),!0))
- }
- ,
- t.prototype._getDepthTexture = function() {
- return this._scene.getEngine().getCaps().drawBuffersExtension ? this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0] : this._scene.enableDepthRenderer().getDepthMap()
- }
- ,
- t.prototype._disposePostProcesses = function() {
- for (var e = 0; e < this._cameras.length; e++) {
- var t = this._cameras[e];
- this.originalPostProcess && this.originalPostProcess.dispose(t),
- this.screenSpaceReflectionPostProcess && this.screenSpaceReflectionPostProcess.dispose(t),
- this.downSampleX4PostProcess && this.downSampleX4PostProcess.dispose(t),
- this.brightPassPostProcess && this.brightPassPostProcess.dispose(t),
- this.textureAdderPostProcess && this.textureAdderPostProcess.dispose(t),
- this.volumetricLightPostProcess && this.volumetricLightPostProcess.dispose(t),
- this.volumetricLightSmoothXPostProcess && this.volumetricLightSmoothXPostProcess.dispose(t),
- this.volumetricLightSmoothYPostProcess && this.volumetricLightSmoothYPostProcess.dispose(t),
- this.volumetricLightMergePostProces && this.volumetricLightMergePostProces.dispose(t),
- this.volumetricLightFinalPostProcess && this.volumetricLightFinalPostProcess.dispose(t),
- this.lensFlarePostProcess && this.lensFlarePostProcess.dispose(t),
- this.lensFlareComposePostProcess && this.lensFlareComposePostProcess.dispose(t);
- for (var i = 0; i < this.luminanceDownSamplePostProcesses.length; i++)
- this.luminanceDownSamplePostProcesses[i].dispose(t);
- for (this.luminancePostProcess && this.luminancePostProcess.dispose(t),
- this.hdrPostProcess && this.hdrPostProcess.dispose(t),
- this.hdrFinalPostProcess && this.hdrFinalPostProcess.dispose(t),
- this.depthOfFieldPostProcess && this.depthOfFieldPostProcess.dispose(t),
- this.motionBlurPostProcess && this.motionBlurPostProcess.dispose(t),
- this.fxaaPostProcess && this.fxaaPostProcess.dispose(t),
- i = 0; i < this.blurHPostProcesses.length; i++)
- this.blurHPostProcesses[i].dispose(t);
- for (i = 0; i < this.blurVPostProcesses.length; i++)
- this.blurVPostProcesses[i].dispose(t)
- }
- this.originalPostProcess = null,
- this.downSampleX4PostProcess = null,
- this.brightPassPostProcess = null,
- this.textureAdderPostProcess = null,
- this.textureAdderFinalPostProcess = null,
- this.volumetricLightPostProcess = null,
- this.volumetricLightSmoothXPostProcess = null,
- this.volumetricLightSmoothYPostProcess = null,
- this.volumetricLightMergePostProces = null,
- this.volumetricLightFinalPostProcess = null,
- this.lensFlarePostProcess = null,
- this.lensFlareComposePostProcess = null,
- this.luminancePostProcess = null,
- this.hdrPostProcess = null,
- this.hdrFinalPostProcess = null,
- this.depthOfFieldPostProcess = null,
- this.motionBlurPostProcess = null,
- this.fxaaPostProcess = null,
- this.screenSpaceReflectionPostProcess = null,
- this.luminanceDownSamplePostProcesses = [],
- this.blurHPostProcesses = [],
- this.blurVPostProcesses = []
- }
- ,
- t.prototype.dispose = function() {
- this._disposePostProcesses(),
- this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype.serialize = function() {
- var e = Ge.Serialize(this);
- return this.sourceLight && (e.sourceLightId = this.sourceLight.id),
- this.screenSpaceReflectionPostProcess && (e.screenSpaceReflectionPostProcess = Ge.Serialize(this.screenSpaceReflectionPostProcess)),
- e.customType = "StandardRenderingPipeline",
- e
- }
- ,
- t.Parse = function(e, i, n) {
- var r = Ge.Parse((function() {
- return new t(e._name,i,e._ratio)
- }
- ), e, i, n);
- return e.sourceLightId && (r.sourceLight = i.getLightById(e.sourceLightId)),
- e.screenSpaceReflectionPostProcess && Ge.Parse((function() {
- return r.screenSpaceReflectionPostProcess
- }
- ), e.screenSpaceReflectionPostProcess, i, n),
- r
- }
- ,
- t.LuminanceSteps = 6,
- k([Ce()], t.prototype, "brightThreshold", void 0),
- k([Ce()], t.prototype, "blurWidth", void 0),
- k([Ce()], t.prototype, "horizontalBlur", void 0),
- k([Ce()], t.prototype, "exposure", null),
- k([Pe("lensTexture")], t.prototype, "lensTexture", void 0),
- k([Ce()], t.prototype, "volumetricLightCoefficient", void 0),
- k([Ce()], t.prototype, "volumetricLightPower", void 0),
- k([Ce()], t.prototype, "volumetricLightBlurScale", void 0),
- k([Ce()], t.prototype, "hdrMinimumLuminance", void 0),
- k([Ce()], t.prototype, "hdrDecreaseRate", void 0),
- k([Ce()], t.prototype, "hdrIncreaseRate", void 0),
- k([Ce()], t.prototype, "hdrAutoExposure", null),
- k([Pe("lensColorTexture")], t.prototype, "lensColorTexture", void 0),
- k([Ce()], t.prototype, "lensFlareStrength", void 0),
- k([Ce()], t.prototype, "lensFlareGhostDispersal", void 0),
- k([Ce()], t.prototype, "lensFlareHaloWidth", void 0),
- k([Ce()], t.prototype, "lensFlareDistortionStrength", void 0),
- k([Ce()], t.prototype, "lensFlareBlurWidth", void 0),
- k([Pe("lensStarTexture")], t.prototype, "lensStarTexture", void 0),
- k([Pe("lensFlareDirtTexture")], t.prototype, "lensFlareDirtTexture", void 0),
- k([Ce()], t.prototype, "depthOfFieldDistance", void 0),
- k([Ce()], t.prototype, "depthOfFieldBlurWidth", void 0),
- k([Ce()], t.prototype, "motionStrength", null),
- k([Ce()], t.prototype, "objectBasedMotionBlur", null),
- k([Ce()], t.prototype, "_ratio", void 0),
- k([Ce()], t.prototype, "BloomEnabled", null),
- k([Ce()], t.prototype, "DepthOfFieldEnabled", null),
- k([Ce()], t.prototype, "LensFlareEnabled", null),
- k([Ce()], t.prototype, "HDREnabled", null),
- k([Ce()], t.prototype, "VLSEnabled", null),
- k([Ce()], t.prototype, "MotionBlurEnabled", null),
- k([Ce()], t.prototype, "fxaaEnabled", null),
- k([Ce()], t.prototype, "screenSpaceReflectionsEnabled", null),
- k([Ce()], t.prototype, "volumetricLightStepsCount", null),
- k([Ce()], t.prototype, "motionBlurSamples", null),
- k([Ce()], t.prototype, "samples", null),
- t
- }(cb);
- y("BABYLON.StandardRenderingPipeline", yb);
- var bb;
- Pt.ShadersStore.tonemapPixelShader = "varying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;\nconst float B=0.50;\nconst float C=0.10;\nconst float D=0.20;\nconst float E=0.02;\nconst float F=0.30;\nconst float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{\nreturn dot(c,vec3(0.22,0.707,0.071));\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb); \nfloat lumTm=lum*_ExposureAdjustment;\nfloat scale=lumTm/(1.0+lumTm); \ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nconst float ExposureBias=2.0;\nvec3 x=ExposureBias*colour;\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\nx=vec3(W,W,W);\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\ncolour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour= vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);\n}",
- function(e) {
- e[e.Hable = 0] = "Hable",
- e[e.Reinhard = 1] = "Reinhard",
- e[e.HejiDawson = 2] = "HejiDawson",
- e[e.Photographic = 3] = "Photographic"
- }(bb || (bb = {}));
- var Tb = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === o && (o = a.TEXTURE_BILINEAR_SAMPLINGMODE),
- void 0 === l && (l = a.TEXTURETYPE_UNSIGNED_INT);
- var u = e.call(this, t, "tonemap", ["_ExposureAdjustment"], null, 1, r, o, s, c, null, l) || this;
- u._operator = i,
- u.exposureAdjustment = n;
- var h = "#define ";
- return u._operator === bb.Hable ? h += "HABLE_TONEMAPPING" : u._operator === bb.Reinhard ? h += "REINHARD_TONEMAPPING" : u._operator === bb.HejiDawson ? h += "OPTIMIZED_HEJIDAWSON_TONEMAPPING" : u._operator === bb.Photographic && (h += "PHOTOGRAPHIC_TONEMAPPING"),
- u.updateEffect(h),
- u.onApply = function(e) {
- e.setFloat("_ExposureAdjustment", u.exposureAdjustment)
- }
- ,
- u
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "TonemapPostProcess"
- }
- ,
- t
- }(Ba);
- Pt.ShadersStore.volumetricLightScatteringPixelShader = "uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i<NUM_SAMPLES; i++) {\ntc-=deltaTexCoord;\nvec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;\ndataSample*=illuminationDecay*weight;\ncolor+=dataSample;\nilluminationDecay*=decay;\n}\nvec4 realColor=texture2D(textureSampler,vUV);\ngl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";
- Pt.ShadersStore.volumetricLightScatteringPassVertexShader = "attribute vec3 position;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";
- Pt.ShadersStore.volumetricLightScatteringPassPixelShader = "#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#if defined(ALPHATEST)\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\nif (diffuseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\n}\n";
- var Eb = function(e) {
- function t(i, n, r, o, a, s, l, c, u) {
- void 0 === a && (a = 100),
- void 0 === s && (s = io.BILINEAR_SAMPLINGMODE);
- var h, d = this;
- return (d = e.call(this, i, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], n.postProcessRatio || n, r, s, l, c, "#define NUM_SAMPLES " + a) || this)._screenCoordinates = A.Zero(),
- d.customMeshPosition = x.Zero(),
- d.useCustomMeshPosition = !1,
- d.invert = !0,
- d.excludedMeshes = new Array,
- d.exposure = .3,
- d.decay = .96815,
- d.weight = .58767,
- d.density = .926,
- l = (u = null !== (h = null == r ? void 0 : r.getScene()) && void 0 !== h ? h : u).getEngine(),
- d._viewPort = new xr(0,0,1,1).toGlobal(l.getRenderWidth(), l.getRenderHeight()),
- d.mesh = null != o ? o : t.CreateDefaultMesh("VolumetricLightScatteringMesh", u),
- d._volumetricLightScatteringPass = new Gt(l),
- d._createPass(u, n.passRatio || n),
- d.onActivate = function(e) {
- d.isSupported || d.dispose(e),
- d.onActivate = null
- }
- ,
- d.onApplyObservable.add((function(e) {
- d._updateMeshScreenCoordinates(u),
- e.setTexture("lightScatteringSampler", d._volumetricLightScatteringRTT),
- e.setFloat("exposure", d.exposure),
- e.setFloat("decay", d.decay),
- e.setFloat("weight", d.weight),
- e.setFloat("density", d.density),
- e.setVector2("meshPositionOnScreen", d._screenCoordinates)
- }
- )),
- d
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "useDiffuseColor", {
- get: function() {
- return K.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),
- !1
- },
- set: function(e) {
- K.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "VolumetricLightScatteringPostProcess"
- }
- ,
- t.prototype._isReady = function(e, t) {
- var i = e.getMesh();
- if (i === this.mesh && i.material)
- return i.material.isReady(i);
- var n = []
- , r = [Bi.PositionKind]
- , o = e.getMaterial();
- o && (o.needAlphaTesting() && n.push("#define ALPHATEST"),
- i.isVerticesDataPresent(Bi.UVKind) && (r.push(Bi.UVKind),
- n.push("#define UV1")),
- i.isVerticesDataPresent(Bi.UV2Kind) && (r.push(Bi.UV2Kind),
- n.push("#define UV2"))),
- i.useBones && i.computeBonesUsingShaders ? (r.push(Bi.MatricesIndicesKind),
- r.push(Bi.MatricesWeightsKind),
- n.push("#define NUM_BONE_INFLUENCERS " + i.numBoneInfluencers),
- n.push("#define BonesPerMesh " + (i.skeleton ? i.skeleton.bones.length + 1 : 0))) : n.push("#define NUM_BONE_INFLUENCERS 0"),
- t && (n.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(r),
- e.getRenderingMesh().hasThinInstances && n.push("#define THIN_INSTANCES"));
- var a = n.join("\n");
- return this._cachedDefines !== a && (this._cachedDefines = a,
- this._volumetricLightScatteringPass.effect = i.getScene().getEngine().createEffect("volumetricLightScatteringPass", r, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], a, void 0, void 0, void 0, {
- maxSimultaneousMorphTargets: i.numBoneInfluencers
- })),
- this._volumetricLightScatteringPass.effect.isReady()
- }
- ,
- t.prototype.setCustomMeshPosition = function(e) {
- this.customMeshPosition = e
- }
- ,
- t.prototype.getCustomMeshPosition = function() {
- return this.customMeshPosition
- }
- ,
- t.prototype.dispose = function(t) {
- var i = t.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
- -1 !== i && t.getScene().customRenderTargets.splice(i, 1),
- this._volumetricLightScatteringRTT.dispose(),
- e.prototype.dispose.call(this, t)
- }
- ,
- t.prototype.getPass = function() {
- return this._volumetricLightScatteringRTT
- }
- ,
- t.prototype._meshExcluded = function(e) {
- return this.excludedMeshes.length > 0 && -1 !== this.excludedMeshes.indexOf(e)
- }
- ,
- t.prototype._createPass = function(e, t) {
- var i = this
- , n = e.getEngine();
- this._volumetricLightScatteringRTT = new ns("volumetricLightScatteringMap",{
- width: n.getRenderWidth() * t,
- height: n.getRenderHeight() * t
- },e,!1,!0,a.TEXTURETYPE_UNSIGNED_INT),
- this._volumetricLightScatteringRTT.wrapU = io.CLAMP_ADDRESSMODE,
- this._volumetricLightScatteringRTT.wrapV = io.CLAMP_ADDRESSMODE,
- this._volumetricLightScatteringRTT.renderList = null,
- this._volumetricLightScatteringRTT.renderParticles = !1,
- this._volumetricLightScatteringRTT.ignoreCameraViewport = !0;
- var r = this.getCamera();
- r ? r.customRenderTargets.push(this._volumetricLightScatteringRTT) : e.customRenderTargets.push(this._volumetricLightScatteringRTT);
- var o, s = function(e) {
- var t = e.getRenderingMesh()
- , n = e.getEffectiveMesh();
- if (!i._meshExcluded(t)) {
- n._internalAbstractMeshDataInfo._isActiveIntermediate = !1;
- var r = e.getMaterial();
- if (r) {
- var o = t.getScene()
- , a = o.getEngine();
- a.setState(r.backFaceCulling, void 0, void 0, void 0, r.cullBackFaces);
- var s = t._getInstancesRenderList(e._id, !!e.getReplacementMesh());
- if (!s.mustReturn) {
- var l = a.getCaps().instancedArrays && (null !== s.visibleInstances[e._id] || t.hasThinInstances);
- if (i._isReady(e, l)) {
- var c = i._volumetricLightScatteringPass;
- t === i.mesh && (c = e.effect ? e._drawWrapper : r._getDrawWrapper());
- var u = c.effect;
- if (a.enableEffect(c),
- l || t._bind(e, u, r.fillMode),
- t === i.mesh)
- r.bind(n.getWorldMatrix(), t);
- else {
- if (u.setMatrix("viewProjection", o.getTransformMatrix()),
- r && r.needAlphaTesting()) {
- var h = r.getAlphaTestTexture();
- u.setTexture("diffuseSampler", h),
- h && u.setMatrix("diffuseMatrix", h.getTextureMatrix())
- }
- t.useBones && t.computeBonesUsingShaders && t.skeleton && u.setMatrices("mBones", t.skeleton.getTransformMatrices(t))
- }
- t._processRendering(n, e, u, Or.TriangleFillMode, s, l, (function(e, t) {
- return u.setMatrix("world", t)
- }
- ))
- }
- }
- }
- }
- }, l = new N(0,0,0,1);
- this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function() {
- o = e.clearColor,
- e.clearColor = l
- }
- )),
- this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function() {
- e.clearColor = o
- }
- )),
- this._volumetricLightScatteringRTT.customIsReadyFunction = function(e, t) {
- if (!e.isReady(!1))
- return !1;
- if (0 === t && e.subMeshes)
- for (var r = 0; r < e.subMeshes.length; ++r) {
- var o = e.subMeshes[r]
- , a = o.getMaterial()
- , s = o.getRenderingMesh();
- if (a) {
- var l = s._getInstancesRenderList(o._id, !!o.getReplacementMesh())
- , c = n.getCaps().instancedArrays && (null !== l.visibleInstances[o._id] || s.hasThinInstances);
- if (!i._isReady(o, c))
- return !1
- }
- }
- return !0
- }
- ,
- this._volumetricLightScatteringRTT.customRenderFunction = function(t, i, n, r) {
- var o, l = e.getEngine();
- if (r.length) {
- for (l.setColorWrite(!1),
- o = 0; o < r.length; o++)
- s(r.data[o]);
- l.setColorWrite(!0)
- }
- for (o = 0; o < t.length; o++)
- s(t.data[o]);
- for (o = 0; o < i.length; o++)
- s(i.data[o]);
- if (n.length) {
- for (o = 0; o < n.length; o++) {
- var c = n.data[o]
- , u = c.getBoundingInfo();
- u && e.activeCamera && (c._alphaIndex = c.getMesh().alphaIndex,
- c._distanceToCamera = u.boundingSphere.centerWorld.subtract(e.activeCamera.position).length())
- }
- var h = n.data.slice(0, n.length);
- for (h.sort((function(e, t) {
- return e._alphaIndex > t._alphaIndex ? 1 : e._alphaIndex < t._alphaIndex ? -1 : e._distanceToCamera < t._distanceToCamera ? 1 : e._distanceToCamera > t._distanceToCamera ? -1 : 0
- }
- )),
- l.setAlphaMode(a.ALPHA_COMBINE),
- o = 0; o < h.length; o++)
- s(h[o]);
- l.setAlphaMode(a.ALPHA_DISABLE)
- }
- }
- }
- ,
- t.prototype._updateMeshScreenCoordinates = function(e) {
- var t, i = e.getTransformMatrix();
- t = this.useCustomMeshPosition ? this.customMeshPosition : this.attachedNode ? this.attachedNode.position : this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
- var n = x.Project(t, P.Identity(), i, this._viewPort);
- this._screenCoordinates.x = n.x / this._viewPort.width,
- this._screenCoordinates.y = n.y / this._viewPort.height,
- this.invert && (this._screenCoordinates.y = 1 - this._screenCoordinates.y)
- }
- ,
- t.CreateDefaultMesh = function(e, t) {
- var i = vo(e, {
- size: 1
- }, t);
- i.billboardMode = Sr.BILLBOARDMODE_ALL;
- var n = new Os(e + "Material",t);
- return n.emissiveColor = new D(1,1,1),
- i.material = n,
- i
- }
- ,
- k([De()], t.prototype, "customMeshPosition", void 0),
- k([Ce()], t.prototype, "useCustomMeshPosition", void 0),
- k([Ce()], t.prototype, "invert", void 0),
- k([Ne()], t.prototype, "mesh", void 0),
- k([Ce()], t.prototype, "excludedMeshes", void 0),
- k([Ce()], t.prototype, "exposure", void 0),
- k([Ce()], t.prototype, "decay", void 0),
- k([Ce()], t.prototype, "weight", void 0),
- k([Ce()], t.prototype, "density", void 0),
- t
- }(Ba);
- y("BABYLON.VolumetricLightScatteringPostProcess", Eb);
- Pt.ShadersStore.screenSpaceCurvaturePixelShader = "precision highp float;\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D normalSampler;\nuniform float curvature_ridge;\nuniform float curvature_valley;\n#ifndef CURVATURE_OFFSET\n#define CURVATURE_OFFSET 1\n#endif\nfloat curvature_soft_clamp(float curvature,float control)\n{\nif (curvature<0.5/control)\nreturn curvature*(1.0-curvature*control);\nreturn 0.25/control;\n}\nfloat calculate_curvature(ivec2 texel,float ridge,float valley)\n{\nvec2 normal_up =texelFetch(normalSampler,texel+ivec2(0, CURVATURE_OFFSET),0).rb;\nvec2 normal_down =texelFetch(normalSampler,texel+ivec2(0,-CURVATURE_OFFSET),0).rb;\nvec2 normal_left =texelFetch(normalSampler,texel+ivec2(-CURVATURE_OFFSET,0),0).rb;\nvec2 normal_right=texelFetch(normalSampler,texel+ivec2( CURVATURE_OFFSET,0),0).rb;\nfloat normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));\nif (normal_diff<0.0)\nreturn -2.0*curvature_soft_clamp(-normal_diff,valley);\nreturn 2.0*curvature_soft_clamp(normal_diff,ridge);\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nivec2 texel=ivec2(gl_FragCoord.xy);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);\nbaseColor.rgb*=curvature+1.0;\ngl_FragColor=baseColor;\n}";
- var Sb = function(e) {
- function t(t, i, n, r, o, s, l, c, u) {
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT),
- void 0 === u && (u = !1);
- var h = e.call(this, t, "screenSpaceCurvature", ["curvature_ridge", "curvature_valley"], ["textureSampler", "normalSampler"], n, r, o, s, l, void 0, c, void 0, null, u) || this;
- return h.ridge = 1,
- h.valley = 1,
- h._geometryBufferRenderer = i.enableGeometryBufferRenderer(),
- h._geometryBufferRenderer ? h.onApply = function(e) {
- e.setFloat("curvature_ridge", .5 / Math.max(h.ridge * h.ridge, 1e-4)),
- e.setFloat("curvature_valley", .7 / Math.max(h.valley * h.valley, 1e-4));
- var t = h._geometryBufferRenderer.getGBuffer().textures[1];
- e.setTexture("normalSampler", t)
- }
- : K.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."),
- h
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "ScreenSpaceCurvaturePostProcess"
- }
- ,
- Object.defineProperty(t, "IsSupported", {
- get: function() {
- var e = E.LastCreatedEngine;
- return !!e && e.getCaps().drawBuffersExtension
- },
- enumerable: !1,
- configurable: !0
- }),
- t._Parse = function(e, i, n, r) {
- return Ge.Parse((function() {
- return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)
- }
- ), e, n, r)
- }
- ,
- k([Ce()], t.prototype, "ridge", void 0),
- k([Ce()], t.prototype, "valley", void 0),
- t
- }(Ba);
- y("BABYLON.ScreenSpaceCurvaturePostProcess", Sb);
- Pt.IncludesShadersStore.boundingBoxRendererFragmentDeclaration = "uniform vec4 color;\n";
- Pt.IncludesShadersStore.boundingBoxRendererUboDeclaration = "layout(std140,column_major) uniform;\nuniform BoundingBoxRenderer {\nvec4 color;\nmat4 world;\nmat4 viewProjection;\nmat4 viewProjectionR;\n};\n";
- Pt.ShadersStore.boundingBoxRendererPixelShader = "#include<__decl__boundingBoxRendererFragment>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.IncludesShadersStore.boundingBoxRendererVertexDeclaration = "uniform mat4 world;\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n";
- Pt.ShadersStore.boundingBoxRendererVertexShader = "attribute vec3 position;\n#include<__decl__boundingBoxRendererVertex>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR==0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n",
- Object.defineProperty(mn.prototype, "forceShowBoundingBoxes", {
- get: function() {
- return this._forceShowBoundingBoxes || !1
- },
- set: function(e) {
- this._forceShowBoundingBoxes = e,
- e && this.getBoundingBoxRenderer()
- },
- enumerable: !0,
- configurable: !0
- }),
- mn.prototype.getBoundingBoxRenderer = function() {
- return this._boundingBoxRenderer || (this._boundingBoxRenderer = new Ab(this)),
- this._boundingBoxRenderer
- }
- ,
- Object.defineProperty(Sr.prototype, "showBoundingBox", {
- get: function() {
- return this._showBoundingBox || !1
- },
- set: function(e) {
- this._showBoundingBox = e,
- e && this.getScene().getBoundingBoxRenderer()
- },
- enumerable: !0,
- configurable: !0
- });
- var Ab = function() {
- function e(e) {
- this.name = Wi.NAME_BOUNDINGBOXRENDERER,
- this.frontColor = new D(1,1,1),
- this.backColor = new D(.1,.1,.1),
- this.showBackLines = !0,
- this.onBeforeBoxRenderingObservable = new h,
- this.onAfterBoxRenderingObservable = new h,
- this.onResourcesReadyObservable = new h,
- this.enabled = !0,
- this.renderList = new bi(32),
- this._vertexBuffers = {},
- this._fillIndexBuffer = null,
- this._fillIndexData = null,
- this.scene = e,
- e._addComponent(this),
- this._uniformBufferFront = new Fi(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront"),
- this._buildUniformLayout(this._uniformBufferFront),
- this._uniformBufferBack = new Fi(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack"),
- this._buildUniformLayout(this._uniformBufferBack)
- }
- return e.prototype._buildUniformLayout = function(e) {
- e.addUniform("color", 4),
- e.addUniform("world", 16),
- e.addUniform("viewProjection", 16),
- e.addUniform("viewProjectionR", 16),
- e.create()
- }
- ,
- e.prototype.register = function() {
- this.scene._beforeEvaluateActiveMeshStage.registerStep(Wi.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset),
- this.scene._preActiveMeshStage.registerStep(Wi.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh),
- this.scene._evaluateSubMeshStage.registerStep(Wi.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh),
- this.scene._afterRenderingGroupDrawStage.registerStep(Wi.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render)
- }
- ,
- e.prototype._evaluateSubMesh = function(e, t) {
- if (e.showSubMeshesBoundingBox) {
- var i = t.getBoundingInfo();
- null != i && (i.boundingBox._tag = e.renderingGroupId,
- this.renderList.push(i.boundingBox))
- }
- }
- ,
- e.prototype._preActiveMesh = function(e) {
- if (e.showBoundingBox || this.scene.forceShowBoundingBoxes) {
- var t = e.getBoundingInfo();
- t.boundingBox._tag = e.renderingGroupId,
- this.renderList.push(t.boundingBox)
- }
- }
- ,
- e.prototype._prepareResources = function() {
- if (!this._colorShader) {
- this._colorShader = new jl("colorShader",this.scene,"boundingBoxRenderer",{
- attributes: [Bi.PositionKind],
- uniforms: ["world", "viewProjection", "color"],
- uniformBuffers: ["BoundingBoxRenderer"]
- },!1),
- this._colorShader.reservedDataStore = {
- hidden: !0
- },
- this._colorShaderForOcclusionQuery = new jl("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{
- attributes: [Bi.PositionKind],
- uniforms: ["world", "viewProjection", "color"],
- uniformBuffers: ["BoundingBoxRenderer"]
- },!0),
- this._colorShaderForOcclusionQuery.reservedDataStore = {
- hidden: !0
- };
- var e = this.scene.getEngine()
- , t = Pl({
- size: 1
- });
- this._vertexBuffers[Bi.PositionKind] = new Bi(e,t.positions,Bi.PositionKind,!1),
- this._createIndexBuffer(),
- this._fillIndexData = t.indices,
- this.onResourcesReadyObservable.notifyObservers(this)
- }
- }
- ,
- e.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])
- }
- ,
- e.prototype.rebuild = function() {
- var e = this._vertexBuffers[Bi.PositionKind];
- e && e._rebuild(),
- this._createIndexBuffer()
- }
- ,
- e.prototype.reset = function() {
- this.renderList.reset()
- }
- ,
- e.prototype.render = function(e) {
- var t, i;
- if (0 !== this.renderList.length && this.enabled && (this._prepareResources(),
- this._colorShader.isReady())) {
- var n = this.scene.getEngine();
- n.setDepthWrite(!1);
- for (var r = this.frontColor.toColor4(), o = this.backColor.toColor4(), a = this.scene.getTransformMatrix(), s = 0; s < this.renderList.length; s++) {
- var l = this.renderList.data[s];
- if (l._tag === e) {
- this._createWrappersForBoundingBox(l),
- this.onBeforeBoxRenderingObservable.notifyObservers(l);
- var c = l.minimum
- , u = l.maximum.subtract(c)
- , h = c.add(u.scale(.5))
- , d = P.Scaling(u.x, u.y, u.z).multiply(P.Translation(h.x, h.y, h.z)).multiply(l.getWorldMatrix())
- , p = n.useReverseDepthBuffer;
- if (this.showBackLines) {
- var f = null !== (t = l._drawWrapperBack) && void 0 !== t ? t : this._colorShader._getDrawWrapper();
- this._colorShader._preBind(f),
- n.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
- p ? n.setDepthFunctionToLessOrEqual() : n.setDepthFunctionToGreaterOrEqual(),
- this._uniformBufferBack.bindToEffect(f.effect, "BoundingBoxRenderer"),
- this._uniformBufferBack.updateDirectColor4("color", o),
- this._uniformBufferBack.updateMatrix("world", d),
- this._uniformBufferBack.updateMatrix("viewProjection", a),
- this._uniformBufferBack.update(),
- n.drawElementsType(Or.LineListDrawMode, 0, 24)
- }
- var _ = null !== (i = l._drawWrapperFront) && void 0 !== i ? i : this._colorShader._getDrawWrapper();
- this._colorShader._preBind(_),
- n.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
- p ? n.setDepthFunctionToGreater() : n.setDepthFunctionToLess(),
- this._uniformBufferFront.bindToEffect(_.effect, "BoundingBoxRenderer"),
- this._uniformBufferFront.updateDirectColor4("color", r),
- this._uniformBufferFront.updateMatrix("world", d),
- this._uniformBufferFront.updateMatrix("viewProjection", a),
- this._uniformBufferFront.update(),
- n.drawElementsType(Or.LineListDrawMode, 0, 24),
- this.onAfterBoxRenderingObservable.notifyObservers(l)
- }
- }
- this._colorShader.unbind(),
- n.setDepthFunctionToLessOrEqual(),
- n.setDepthWrite(!0)
- }
- }
- ,
- e.prototype._createWrappersForBoundingBox = function(e) {
- if (!e._drawWrapperFront) {
- var t = this.scene.getEngine();
- e._drawWrapperFront = new Gt(t),
- e._drawWrapperBack = new Gt(t),
- e._drawWrapperFront.setEffect(this._colorShader.getEffect()),
- e._drawWrapperBack.setEffect(this._colorShader.getEffect())
- }
- }
- ,
- e.prototype.renderOcclusionBoundingBox = function(e) {
- var t = this.scene.getEngine();
- void 0 === this._renderPassIdForOcclusionQuery && (this._renderPassIdForOcclusionQuery = t.createRenderPassId("Render pass for occlusion query"));
- var i = t.currentRenderPassId;
- t.currentRenderPassId = this._renderPassIdForOcclusionQuery,
- this._prepareResources();
- var n = e.subMeshes[0];
- if (this._colorShaderForOcclusionQuery.isReady(e, void 0, n) && e.hasBoundingInfo) {
- this._fillIndexBuffer || (this._fillIndexBuffer = t.createIndexBuffer(this._fillIndexData));
- var r = t.useReverseDepthBuffer;
- t.setDepthWrite(!1),
- t.setColorWrite(!1);
- var o = e.getBoundingInfo().boundingBox
- , a = o.minimum
- , s = o.maximum.subtract(a)
- , l = a.add(s.scale(.5))
- , c = P.Scaling(s.x, s.y, s.z).multiply(P.Translation(l.x, l.y, l.z)).multiply(o.getWorldMatrix())
- , u = n._drawWrapper;
- this._colorShaderForOcclusionQuery._preBind(u),
- t.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, u.effect),
- r ? t.setDepthFunctionToGreater() : t.setDepthFunctionToLess(),
- this.scene.resetCachedMaterial(),
- this._uniformBufferFront.bindToEffect(u.effect, "BoundingBoxRenderer"),
- this._uniformBufferFront.updateMatrix("world", c),
- this._uniformBufferFront.updateMatrix("viewProjection", this.scene.getTransformMatrix()),
- this._uniformBufferFront.update(),
- t.drawElementsType(Or.TriangleFillMode, 0, 36),
- this._colorShaderForOcclusionQuery.unbind(),
- t.setDepthFunctionToLessOrEqual(),
- t.setDepthWrite(!0),
- t.setColorWrite(!0),
- t.currentRenderPassId = i
- } else
- t.currentRenderPassId = i
- }
- ,
- e.prototype.dispose = function() {
- if (void 0 !== this._renderPassIdForOcclusionQuery && (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[Bi.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[Bi.PositionKind] = null),
- this.scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),
- this._fillIndexBuffer = null)
- }
- }
- ,
- e
- }();
- mn.prototype.enableDepthRenderer = function(e, t, i) {
- if (void 0 === t && (t = !1),
- void 0 === i && (i = !1),
- !(e = e || this.activeCamera))
- throw "No camera available to enable depth renderer";
- if (this._depthRenderer || (this._depthRenderer = {}),
- !this._depthRenderer[e.id]) {
- var n, r = !!this.getEngine().getCaps().textureFloatRender;
- n = !this.getEngine().getCaps().textureHalfFloatRender || i && r ? r ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE : a.TEXTURETYPE_HALF_FLOAT,
- this._depthRenderer[e.id] = new o_(this,n,e,t)
- }
- return this._depthRenderer[e.id]
- }
- ,
- mn.prototype.disableDepthRenderer = function(e) {
- (e = e || this.activeCamera) && this._depthRenderer && this._depthRenderer[e.id] && this._depthRenderer[e.id].dispose()
- }
- ;
- var xb = function() {
- function e(e) {
- this.name = Wi.NAME_DEPTHRENDERER,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._gatherRenderTargetsStage.registerStep(Wi.STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets),
- this.scene._gatherActiveCameraRenderTargetsStage.registerStep(Wi.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {
- for (var e in this.scene._depthRenderer)
- this.scene._depthRenderer[e].dispose()
- }
- ,
- e.prototype._gatherRenderTargets = function(e) {
- if (this.scene._depthRenderer)
- for (var t in this.scene._depthRenderer) {
- var i = this.scene._depthRenderer[t];
- i.enabled && !i.useOnlyInActiveCamera && e.push(i.getDepthMap())
- }
- }
- ,
- e.prototype._gatherActiveCameraRenderTargets = function(e) {
- if (this.scene._depthRenderer)
- for (var t in this.scene._depthRenderer) {
- var i = this.scene._depthRenderer[t];
- i.enabled && i.useOnlyInActiveCamera && this.scene.activeCamera.id === t && e.push(i.getDepthMap())
- }
- }
- ,
- e
- }();
- o_._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_DEPTHRENDERER);
- t || (t = new xb(e),
- e._addComponent(t))
- }
- ;
- Pt.ShadersStore.oitFinalPixelShader = "precision highp float;\nuniform sampler2D uFrontColor;\nuniform sampler2D uBackColor;\nvoid main() {\nivec2 fragCoord=ivec2(gl_FragCoord.xy);\nvec4 frontColor=texelFetch(uFrontColor,fragCoord,0);\nvec4 backColor=texelFetch(uBackColor,fragCoord,0);\nfloat alphaMultiplier=1.0-frontColor.a;\nglFragColor=vec4(\nfrontColor.rgb+alphaMultiplier*backColor.rgb,\nfrontColor.a+backColor.a\n);\n}";
- Pt.ShadersStore.oitBackBlendPixelShader = "precision highp float;\nuniform sampler2D uBackColor;\nvoid main() {\nglFragColor=texelFetch(uBackColor,ivec2(gl_FragCoord.xy),0);\nif (glFragColor.a==0.0) { \ndiscard;\n}\n}";
- var Rb = function() {
- this.enabled = !0,
- this.name = "depthPeeling",
- this.texturesRequired = [a.PREPASS_COLOR_TEXTURE_TYPE]
- }
- , Cb = function() {
- function e(t, i) {
- if (void 0 === i && (i = 5),
- this._thinTextures = [],
- this._currentPingPongState = 0,
- this._layoutCacheFormat = [[!0], [!0, !0], [!0, !0, !0]],
- this._layoutCache = [],
- this._candidateSubMeshes = new bi(10),
- this._excludedSubMeshes = new bi(10),
- this._colorCache = [new N(e._DEPTH_CLEAR_VALUE,e._DEPTH_CLEAR_VALUE,0,0), new N(-e._MIN_DEPTH,e._MAX_DEPTH,0,0), new N(0,0,0,0)],
- this._scene = t,
- this._engine = t.getEngine(),
- this._passCount = i,
- t.enablePrePassRenderer()) {
- for (var n = 0; n < this._layoutCacheFormat.length; ++n)
- this._layoutCache[n] = this._engine.buildTextureLayout(this._layoutCacheFormat[n]);
- this._renderPassIds = [],
- this.useRenderPasses = !1,
- this._prePassEffectConfiguration = new Rb,
- this._createTextures(),
- this._createEffects()
- } else
- K.Warn("Depth peeling for order independant transparency could not enable PrePass, aborting.")
- }
- return Object.defineProperty(e.prototype, "passCount", {
- get: function() {
- return this._passCount
- },
- set: function(e) {
- this._passCount !== e && (this._passCount = e,
- this._createRenderPassIds())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useRenderPasses", {
- get: function() {
- return this._useRenderPasses
- },
- set: function(e) {
- this._useRenderPasses !== e && (this._useRenderPasses = e,
- this._createRenderPassIds())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createRenderPassIds = function() {
- if (this._releaseRenderPassIds(),
- this._useRenderPasses)
- for (var e = 0; e < this._passCount + 1; ++e)
- this._renderPassIds[e] || (this._renderPassIds[e] = this._engine.createRenderPassId("DepthPeelingRenderer - pass #".concat(e)))
- }
- ,
- e.prototype._releaseRenderPassIds = function() {
- for (var e = 0; e < this._renderPassIds.length; ++e)
- this._engine.releaseRenderPassId(this._renderPassIds[e]);
- this._renderPassIds = []
- }
- ,
- e.prototype._createTextures = function() {
- var e = {
- width: this._engine.getRenderWidth(),
- height: this._engine.getRenderHeight()
- };
- this._depthMrts = [new pm("depthPeelingDepth0",e,1,this._scene), new pm("depthPeelingDepth1",e,1,this._scene)],
- this._colorMrts = [new pm("depthPeelingColor0",e,1,this._scene,{
- generateDepthBuffer: !1
- }), new pm("depthPeelingColor1",e,1,this._scene,{
- generateDepthBuffer: !1
- })],
- this._blendBackMrt = new pm("depthPeelingBack",e,1,this._scene,{
- generateDepthBuffer: !1
- });
- for (var t = [{
- format: a.TEXTUREFORMAT_RG,
- samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE,
- type: this._engine.getCaps().textureFloatLinearFiltering ? a.TEXTURETYPE_FLOAT : a.TEXTURETYPE_HALF_FLOAT
- }, {
- format: a.TEXTUREFORMAT_RGBA,
- samplingMode: a.TEXTURE_NEAREST_SAMPLINGMODE,
- type: a.TEXTURETYPE_HALF_FLOAT
- }], i = 0; i < 2; i++) {
- var n = this._engine._createInternalTexture(e, t[0], !1)
- , r = this._engine._createInternalTexture(e, t[1], !1)
- , o = this._engine._createInternalTexture(e, t[1], !1);
- this._depthMrts[i].setInternalTexture(n, 0),
- this._depthMrts[i].setInternalTexture(r, 1),
- this._depthMrts[i].setInternalTexture(o, 2),
- this._colorMrts[i].setInternalTexture(r, 0),
- this._colorMrts[i].setInternalTexture(o, 1),
- this._thinTextures.push(new qr(n), new qr(r), new qr(o))
- }
- }
- ,
- e.prototype._disposeTextures = function() {
- for (var e = 0; e < this._thinTextures.length; e++)
- 6 !== e && this._thinTextures[e].dispose();
- for (e = 0; e < 2; e++)
- this._depthMrts[e].dispose(!0),
- this._colorMrts[e].dispose(!0),
- this._blendBackMrt.dispose(!0);
- this._thinTextures = [],
- this._colorMrts = [],
- this._depthMrts = []
- }
- ,
- e.prototype._updateTextures = function() {
- return this._depthMrts[0].getSize().width === this._engine.getRenderWidth() && this._depthMrts[0].getSize().height === this._engine.getRenderHeight() || (this._disposeTextures(),
- this._createTextures()),
- this._updateTextureReferences()
- }
- ,
- e.prototype._updateTextureReferences = function() {
- var e, t = this._scene.prePassRenderer;
- if (!t)
- return !1;
- var i = t.getIndex(a.PREPASS_COLOR_TEXTURE_TYPE)
- , n = (null === (e = t.defaultRT.textures) || void 0 === e ? void 0 : e.length) ? t.defaultRT.textures[i].getInternalTexture() : null;
- return !!n && (this._blendBackTexture !== n && (this._blendBackTexture = n,
- this._blendBackMrt.setInternalTexture(this._blendBackTexture, 0),
- this._thinTextures[6] && this._thinTextures[6].dispose(),
- this._thinTextures[6] = new qr(this._blendBackTexture),
- t.defaultRT.renderTarget._shareDepth(this._depthMrts[0].renderTarget)),
- !0)
- }
- ,
- e.prototype._createEffects = function() {
- this._blendBackEffectWrapper = new b_({
- fragmentShader: "oitBackBlend",
- useShaderStore: !0,
- engine: this._engine,
- samplerNames: ["uBackColor"],
- uniformNames: []
- }),
- this._blendBackEffectWrapperPingPong = new b_({
- fragmentShader: "oitBackBlend",
- useShaderStore: !0,
- engine: this._engine,
- samplerNames: ["uBackColor"],
- uniformNames: []
- }),
- this._finalEffectWrapper = new b_({
- fragmentShader: "oitFinal",
- useShaderStore: !0,
- engine: this._engine,
- samplerNames: ["uFrontColor", "uBackColor"],
- uniformNames: []
- }),
- this._effectRenderer = new y_(this._engine)
- }
- ,
- e.prototype.setPrePassRenderer = function(e) {
- e.addEffectConfiguration(this._prePassEffectConfiguration)
- }
- ,
- e.prototype.bind = function(e) {
- e.setTexture("oitDepthSampler", this._thinTextures[3 * this._currentPingPongState]),
- e.setTexture("oitFrontColorSampler", this._thinTextures[3 * this._currentPingPongState + 1])
- }
- ,
- e.prototype._renderSubMeshes = function(e) {
- var t;
- this._useRenderPasses && (t = {});
- for (var i = 0; i < e.length; i++) {
- var n = e.data[i].getMaterial()
- , r = !0
- , o = !1
- , a = e.data[i]
- , s = void 0
- , l = !1;
- if (this._useRenderPasses && (l = !(s = a._getDrawWrapper())),
- n && (r = n.allowShaderHotSwapping,
- o = n.backFaceCulling,
- n.allowShaderHotSwapping = !1,
- n.backFaceCulling = !1),
- a.render(!1),
- l && (s = a._getDrawWrapper()).materialContext) {
- var c = t[s.materialContext.uniqueId];
- c || (c = t[s.materialContext.uniqueId] = this._engine.createMaterialContext()),
- a._getDrawWrapper().materialContext = c
- }
- n && (n.allowShaderHotSwapping = r,
- n.backFaceCulling = o)
- }
- }
- ,
- e.prototype._finalCompose = function(e) {
- this._engine.restoreDefaultFramebuffer(),
- this._engine.setAlphaMode(a.ALPHA_DISABLE),
- this._engine.applyStates(),
- this._engine.enableEffect(this._finalEffectWrapper._drawWrapper),
- this._finalEffectWrapper.effect.setTexture("uFrontColor", this._thinTextures[3 * e + 1]),
- this._finalEffectWrapper.effect.setTexture("uBackColor", this._thinTextures[6]),
- this._effectRenderer.render(this._finalEffectWrapper)
- }
- ,
- e.prototype.render = function(e) {
- if (this._candidateSubMeshes.length = 0,
- this._excludedSubMeshes.length = 0,
- !(this._blendBackEffectWrapper.effect.isReady() && this._blendBackEffectWrapperPingPong.effect.isReady() && this._finalEffectWrapper.effect.isReady() && this._updateTextures()))
- return this._excludedSubMeshes;
- for (var t = 0; t < e.length; t++) {
- var i = e.data[t].getMaterial();
- !i || i.fillMode !== Or.TriangleFanDrawMode && i.fillMode !== Or.TriangleFillMode && i.fillMode !== Or.TriangleStripDrawMode ? this._excludedSubMeshes.push(e.data[t]) : this._candidateSubMeshes.push(e.data[t])
- }
- if (!this._candidateSubMeshes.length)
- return this._finalCompose(1),
- this._excludedSubMeshes;
- var n = this._engine.currentRenderPassId;
- this._scene.prePassRenderer._enabled = !1,
- this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[0]),
- this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),
- this._engine.bindAttachments(this._layoutCache[0]),
- this._engine.clear(this._colorCache[0], !0, !1, !1),
- this._engine.bindFramebuffer(this._depthMrts[1].renderTarget),
- this._engine.bindAttachments(this._layoutCache[0]),
- this._engine.clear(this._colorCache[1], !0, !1, !1),
- this._engine.bindFramebuffer(this._colorMrts[0].renderTarget),
- this._engine.bindAttachments(this._layoutCache[1]),
- this._engine.clear(this._colorCache[2], !0, !1, !1),
- this._engine.bindFramebuffer(this._colorMrts[1].renderTarget),
- this._engine.bindAttachments(this._layoutCache[1]),
- this._engine.clear(this._colorCache[2], !0, !1, !1),
- this._engine.bindFramebuffer(this._depthMrts[0].renderTarget),
- this._engine.bindAttachments(this._layoutCache[0]),
- this._engine.setAlphaMode(a.ALPHA_ONEONE_ONEONE),
- this._engine.setAlphaEquation(a.ALPHA_EQUATION_MAX),
- this._engine.depthCullingState.depthMask = !1,
- this._engine.depthCullingState.depthTest = !0,
- this._engine.applyStates(),
- this._currentPingPongState = 1,
- this._renderSubMeshes(this._candidateSubMeshes),
- this._scene.resetCachedMaterial();
- var r = 0
- , o = 0;
- for (t = 0; t < this._passCount; t++) {
- o = 1 - (r = t % 2),
- this._currentPingPongState = r,
- this._useRenderPasses && (this._engine.currentRenderPassId = this._renderPassIds[t + 1]),
- this._engine.bindFramebuffer(this._depthMrts[o].renderTarget),
- this._engine.bindAttachments(this._layoutCache[0]),
- this._engine.clear(this._colorCache[0], !0, !1, !1),
- this._engine.bindFramebuffer(this._colorMrts[o].renderTarget),
- this._engine.bindAttachments(this._layoutCache[1]),
- this._engine.clear(this._colorCache[2], !0, !1, !1),
- this._engine.bindFramebuffer(this._depthMrts[o].renderTarget),
- this._engine.bindAttachments(this._layoutCache[2]),
- this._engine.setAlphaMode(a.ALPHA_ONEONE_ONEONE),
- this._engine.setAlphaEquation(a.ALPHA_EQUATION_MAX),
- this._engine.depthCullingState.depthTest = !1,
- this._engine.applyStates(),
- this._renderSubMeshes(this._candidateSubMeshes),
- this._scene.resetCachedMaterial(),
- this._engine.bindFramebuffer(this._blendBackMrt.renderTarget),
- this._engine.bindAttachments(this._layoutCache[0]),
- this._engine.setAlphaEquation(a.ALPHA_EQUATION_ADD),
- this._engine.setAlphaMode(a.ALPHA_LAYER_ACCUMULATE),
- this._engine.applyStates();
- var s = 0 !== o && this._useRenderPasses ? this._blendBackEffectWrapperPingPong : this._blendBackEffectWrapper;
- this._engine.enableEffect(s._drawWrapper),
- s.effect.setTexture("uBackColor", this._thinTextures[3 * o + 2]),
- this._effectRenderer.render(s)
- }
- return this._engine.currentRenderPassId = n,
- this._finalCompose(o),
- this._scene.prePassRenderer._enabled = !0,
- this._engine.depthCullingState.depthMask = !0,
- this._engine.depthCullingState.depthTest = !0,
- this._excludedSubMeshes
- }
- ,
- e.prototype.dispose = function() {
- this._disposeTextures(),
- this._blendBackEffectWrapper.dispose(),
- this._finalEffectWrapper.dispose(),
- this._effectRenderer.dispose(),
- this._releaseRenderPassIds()
- }
- ,
- e._DEPTH_CLEAR_VALUE = -99999,
- e._MIN_DEPTH = 0,
- e._MAX_DEPTH = 1,
- e
- }();
- Object.defineProperty(mn.prototype, "depthPeelingRenderer", {
- get: function() {
- if (!this._depthPeelingRenderer) {
- var e = this._getComponent(Wi.NAME_DEPTHPEELINGRENDERER);
- e || (e = new Pb(this),
- this._addComponent(e))
- }
- return this._depthPeelingRenderer
- },
- set: function(e) {
- this._depthPeelingRenderer = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(mn.prototype, "useOrderIndependentTransparency", {
- get: function() {
- return this._useOrderIndependentTransparency
- },
- set: function(e) {
- var t;
- this._useOrderIndependentTransparency !== e && (this._useOrderIndependentTransparency = e,
- this.markAllMaterialsAsDirty(a.MATERIAL_AllDirtyFlag),
- null === (t = this.prePassRenderer) || void 0 === t || t.markAsDirty())
- },
- enumerable: !0,
- configurable: !0
- });
- var Pb = function() {
- function e(e) {
- this.name = Wi.NAME_DEPTHPEELINGRENDERER,
- this.scene = e,
- e.depthPeelingRenderer = new Cb(e)
- }
- return e.prototype.register = function() {}
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {
- var e;
- null === (e = this.scene.depthPeelingRenderer) || void 0 === e || e.dispose(),
- this.scene.depthPeelingRenderer = null
- }
- ,
- e
- }();
- Pt.ShadersStore.linePixelShader = "#include<clipPlaneFragmentDeclaration>\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.lineVertexShader = "#include<instancesDeclaration>\n#include<clipPlaneVertexDeclaration>\nattribute vec3 position;\nattribute vec4 normal;\nuniform mat4 viewProjection;\nuniform float width;\nuniform float aspectRatio;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\nmat4 worldViewProjection=viewProjection*finalWorld;\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<clipPlaneVertex>\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}",
- Sr.prototype.disableEdgesRendering = function() {
- return this._edgesRenderer && (this._edgesRenderer.dispose(),
- this._edgesRenderer = null),
- this
- }
- ,
- Sr.prototype.enableEdgesRendering = function(e, t, i) {
- return void 0 === e && (e = .95),
- void 0 === t && (t = !1),
- this.disableEdgesRendering(),
- this._edgesRenderer = new Ib(this,e,t,!0,i),
- this
- }
- ,
- Object.defineProperty(Sr.prototype, "edgesRenderer", {
- get: function() {
- return this._edgesRenderer
- },
- enumerable: !0,
- configurable: !0
- }),
- Yl.prototype.enableEdgesRendering = function(e, t) {
- return void 0 === e && (e = .95),
- void 0 === t && (t = !1),
- this.disableEdgesRendering(),
- this._edgesRenderer = new Ob(this,e,t),
- this
- }
- ,
- Kl.prototype.enableEdgesRendering = function(e, t) {
- return void 0 === e && (e = .95),
- void 0 === t && (t = !1),
- Yl.prototype.enableEdgesRendering.apply(this, arguments),
- this
- }
- ;
- var Mb = function() {
- this.edges = new Array,
- this.edgesConnectedCount = 0
- }
- , Ib = function() {
- function e(e, t, i, n, r) {
- void 0 === t && (t = .95),
- void 0 === i && (i = !1),
- void 0 === n && (n = !0);
- var o, a = this;
- this.edgesWidthScalerForOrthographic = 1e3,
- this.edgesWidthScalerForPerspective = 50,
- this._linesPositions = new Array,
- this._linesNormals = new Array,
- this._linesIndices = new Array,
- this._buffers = {},
- this._buffersForInstances = {},
- this._checkVerticesInsteadOfIndices = !1,
- this.isEnabled = !0,
- this.customInstances = new bi(32),
- this._source = e,
- this._checkVerticesInsteadOfIndices = i,
- this._options = null != r ? r : null,
- this._epsilon = t,
- this._source.getScene().getEngine().isWebGPU && (this._drawWrapper = new Gt(e.getEngine())),
- this._prepareRessources(),
- n && (null === (o = null == r ? void 0 : r.useAlternateEdgeFinder) || void 0 === o || o ? this._generateEdgesLinesAlternate() : this._generateEdgesLines()),
- this._meshRebuildObserver = this._source.onRebuildObservable.add((function() {
- a._rebuild()
- }
- )),
- this._meshDisposeObserver = this._source.onDisposeObservable.add((function() {
- a.dispose()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "linesPositions", {
- get: function() {
- return this._linesPositions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "linesNormals", {
- get: function() {
- return this._linesNormals
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "linesIndices", {
- get: function() {
- return this._linesIndices
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lineShader", {
- get: function() {
- return this._lineShader
- },
- set: function(e) {
- this._lineShader = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e._GetShader = function(e) {
- if (!e._edgeRenderLineShader) {
- var t = new jl("lineShader",e,"line",{
- attributes: ["position", "normal"],
- uniforms: ["world", "viewProjection", "color", "width", "aspectRatio"]
- },!1);
- t.disableDepthWrite = !0,
- t.backFaceCulling = !1,
- t.checkReadyOnEveryCall = e.getEngine().isWebGPU,
- e._edgeRenderLineShader = t
- }
- return e._edgeRenderLineShader
- }
- ,
- e.prototype._prepareRessources = function() {
- this._lineShader || (this._lineShader = e._GetShader(this._source.getScene()))
- }
- ,
- e.prototype._rebuild = function() {
- var e = this._buffers[Bi.PositionKind];
- e && e._rebuild(),
- (e = this._buffers[Bi.NormalKind]) && e._rebuild();
- var t = this._source.getScene().getEngine();
- this._ib = t.createIndexBuffer(this._linesIndices)
- }
- ,
- e.prototype.dispose = function() {
- var e;
- this._source.onRebuildObservable.remove(this._meshRebuildObserver),
- this._source.onDisposeObservable.remove(this._meshDisposeObserver);
- var t = this._buffers[Bi.PositionKind];
- t && (t.dispose(),
- this._buffers[Bi.PositionKind] = null),
- (t = this._buffers[Bi.NormalKind]) && (t.dispose(),
- this._buffers[Bi.NormalKind] = null),
- this._ib && this._source.getScene().getEngine()._releaseBuffer(this._ib),
- this._lineShader.dispose(),
- null === (e = this._drawWrapper) || void 0 === e || e.dispose()
- }
- ,
- e.prototype._processEdgeForAdjacencies = function(e, t, i, n, r) {
- return e === i && t === n || e === n && t === i ? 0 : e === n && t === r || e === r && t === n ? 1 : e === r && t === i || e === i && t === r ? 2 : -1
- }
- ,
- e.prototype._processEdgeForAdjacenciesWithVertices = function(e, t, i, n, r) {
- var o = 1e-10;
- return e.equalsWithEpsilon(i, o) && t.equalsWithEpsilon(n, o) || e.equalsWithEpsilon(n, o) && t.equalsWithEpsilon(i, o) ? 0 : e.equalsWithEpsilon(n, o) && t.equalsWithEpsilon(r, o) || e.equalsWithEpsilon(r, o) && t.equalsWithEpsilon(n, o) ? 1 : e.equalsWithEpsilon(r, o) && t.equalsWithEpsilon(i, o) || e.equalsWithEpsilon(i, o) && t.equalsWithEpsilon(r, o) ? 2 : -1
- }
- ,
- e.prototype._checkEdge = function(e, t, i, n, r) {
- (void 0 === t || x.Dot(i[e], i[t]) < this._epsilon) && this.createLine(n, r, this._linesPositions.length / 3)
- }
- ,
- e.prototype.createLine = function(e, t, i) {
- this._linesPositions.push(e.x, e.y, e.z, e.x, e.y, e.z, t.x, t.y, t.z, t.x, t.y, t.z),
- this._linesNormals.push(t.x, t.y, t.z, -1, t.x, t.y, t.z, 1, e.x, e.y, e.z, -1, e.x, e.y, e.z, 1),
- this._linesIndices.push(i, i + 1, i + 2, i, i + 2, i + 3)
- }
- ,
- e.prototype._tessellateTriangle = function(e, t, i, n) {
- var r = function(e, t, i) {
- i >= 0 && t.push(i);
- for (var n = 0; n < e.length; ++n)
- t.push(e[n][0])
- }
- , o = 0;
- e[1].length >= e[0].length && e[1].length >= e[2].length ? o = 1 : e[2].length >= e[0].length && e[2].length >= e[1].length && (o = 2);
- for (var a = 0; a < 3; ++a)
- a === o ? e[a].sort((function(e, t) {
- return e[1] < t[1] ? -1 : e[1] > t[1] ? 1 : 0
- }
- )) : e[a].sort((function(e, t) {
- return e[1] > t[1] ? -1 : e[1] < t[1] ? 1 : 0
- }
- ));
- var s = []
- , l = [];
- r(e[o], s, -1);
- for (var c = s.length, u = o + 2; u >= o + 1; --u)
- r(e[u % 3], l, u !== o + 2 ? n[i[t + (u + 1) % 3]] : -1);
- var h = l.length;
- i.push(n[i[t + o]], s[0], l[0]),
- i.push(n[i[t + (o + 1) % 3]], l[h - 1], s[c - 1]);
- for (var d = c <= h, p = d ? c : h, f = d ? h : c, _ = d ? c - 1 : h - 1, m = d ? 0 : 1, g = c + h - 2, v = 0, y = 0, b = d ? s : l, T = d ? l : s, E = 0; g-- > 0; ) {
- m ? i.push(b[v], T[y]) : i.push(T[y], b[v]);
- var S = void 0;
- (E += p) >= f && v < _ ? (S = b[++v],
- E -= f) : S = T[++y],
- i.push(S)
- }
- i[t + 0] = i[i.length - 3],
- i[t + 1] = i[i.length - 2],
- i[t + 2] = i[i.length - 1],
- i.length = i.length - 3
- }
- ,
- e.prototype._generateEdgesLinesAlternate = function() {
- var e, t, i, n, r, o, a, s, l, c, u = this._source.getVerticesData(Bi.PositionKind), h = this._source.getIndices();
- if (h && u) {
- Array.isArray(h) || (h = gi.SliceToArray(h));
- var d = null === (t = null === (e = this._options) || void 0 === e ? void 0 : e.useFastVertexMerger) || void 0 === t || t
- , p = d ? Math.round(-Math.log(null !== (n = null === (i = this._options) || void 0 === i ? void 0 : i.epsilonVertexMerge) && void 0 !== n ? n : 1e-6) / Math.log(10)) : null !== (o = null === (r = this._options) || void 0 === r ? void 0 : r.epsilonVertexMerge) && void 0 !== o ? o : 1e-6
- , f = []
- , _ = [];
- if (d)
- for (var m = {}, g = 0; g < u.length; g += 3) {
- var v = u[g + 0]
- , y = u[g + 1]
- , b = u[g + 2];
- if (void 0 !== m[ie = v.toFixed(p) + "|" + y.toFixed(p) + "|" + b.toFixed(p)])
- f.push(m[ie]);
- else {
- var T = g / 3;
- m[ie] = T,
- f.push(T),
- _.push(T)
- }
- }
- else
- for (g = 0; g < u.length; g += 3) {
- v = u[g + 0],
- y = u[g + 1],
- b = u[g + 2];
- for (var E = !1, S = 0; S < g && !E; S += 3) {
- var A = u[S + 0]
- , R = u[S + 1]
- , C = u[S + 2];
- if (Math.abs(v - A) < p && Math.abs(y - R) < p && Math.abs(b - C) < p) {
- f.push(S / 3),
- E = !0;
- break
- }
- }
- E || (f.push(g / 3),
- _.push(g / 3))
- }
- if (null === (a = this._options) || void 0 === a ? void 0 : a.applyTessellation) {
- for (var P = null !== (l = null === (s = this._options) || void 0 === s ? void 0 : s.epsilonVertexAligned) && void 0 !== l ? l : 1e-6, M = [], O = 0; O < h.length; O += 3)
- for (var D = void 0, N = 0; N < 3; ++N) {
- var L = f[h[O + N]]
- , F = f[h[O + (N + 1) % 3]]
- , w = f[h[O + (N + 2) % 3]];
- if (L !== F)
- for (var B = u[3 * L + 0], U = u[3 * L + 1], V = u[3 * L + 2], k = u[3 * F + 0], G = u[3 * F + 1], z = u[3 * F + 2], W = Math.sqrt((k - B) * (k - B) + (G - U) * (G - U) + (z - V) * (z - V)), H = 0; H < _.length - 1; H++) {
- var X = _[H];
- if (X !== L && X !== F && X !== w) {
- var j = u[3 * X + 0]
- , Y = u[3 * X + 1]
- , K = u[3 * X + 2]
- , Q = Math.sqrt((j - B) * (j - B) + (Y - U) * (Y - U) + (K - V) * (K - V))
- , q = Math.sqrt((j - k) * (j - k) + (Y - G) * (Y - G) + (K - z) * (K - z));
- Math.abs(Q + q - W) < P && (D || (D = {
- index: O,
- edgesPoints: [[], [], []]
- },
- M.push(D)),
- D.edgesPoints[N].push([X, Q]))
- }
- }
- }
- for (var Z = 0; Z < M.length; ++Z) {
- var J = M[Z];
- this._tessellateTriangle(J.edgesPoints, J.index, h, f)
- }
- M = null
- }
- var $ = {};
- for (O = 0; O < h.length; O += 3) {
- var ee = void 0;
- for (N = 0; N < 3; ++N)
- if (L = f[h[O + N]],
- F = f[h[O + (N + 1) % 3]],
- w = f[h[O + (N + 2) % 3]],
- L !== F && (L !== w && F !== w || !(null === (c = this._options) || void 0 === c ? void 0 : c.removeDegeneratedTriangles))) {
- if (I.Vector3[0].copyFromFloats(u[3 * L + 0], u[3 * L + 1], u[3 * L + 2]),
- I.Vector3[1].copyFromFloats(u[3 * F + 0], u[3 * F + 1], u[3 * F + 2]),
- I.Vector3[2].copyFromFloats(u[3 * w + 0], u[3 * w + 1], u[3 * w + 2]),
- ee || (I.Vector3[1].subtractToRef(I.Vector3[0], I.Vector3[3]),
- I.Vector3[2].subtractToRef(I.Vector3[1], I.Vector3[4]),
- (ee = x.Cross(I.Vector3[3], I.Vector3[4])).normalize()),
- L > F) {
- var te = L;
- L = F,
- F = te
- }
- (ne = $[ie = L + "_" + F]) ? ne.done || (x.Dot(ee, ne.normal) < this._epsilon && this.createLine(I.Vector3[0], I.Vector3[1], this._linesPositions.length / 3),
- ne.done = !0) : $[ie] = {
- normal: ee,
- done: !1,
- index: O,
- i: N
- }
- }
- }
- for (var ie in $) {
- var ne;
- (ne = $[ie]).done || (L = f[h[ne.index + ne.i]],
- F = f[h[ne.index + (ne.i + 1) % 3]],
- I.Vector3[0].copyFromFloats(u[3 * L + 0], u[3 * L + 1], u[3 * L + 2]),
- I.Vector3[1].copyFromFloats(u[3 * F + 0], u[3 * F + 1], u[3 * F + 2]),
- this.createLine(I.Vector3[0], I.Vector3[1], this._linesPositions.length / 3))
- }
- var re = this._source.getScene().getEngine();
- this._buffers[Bi.PositionKind] = new Bi(re,this._linesPositions,Bi.PositionKind,!1),
- this._buffers[Bi.NormalKind] = new Bi(re,this._linesNormals,Bi.NormalKind,!1,!1,4),
- this._buffersForInstances[Bi.PositionKind] = this._buffers[Bi.PositionKind],
- this._buffersForInstances[Bi.NormalKind] = this._buffers[Bi.NormalKind],
- this._ib = re.createIndexBuffer(this._linesIndices),
- this._indicesCount = this._linesIndices.length
- }
- }
- ,
- e.prototype._generateEdgesLines = function() {
- var e = this._source.getVerticesData(Bi.PositionKind)
- , t = this._source.getIndices();
- if (t && e) {
- var i, n, r = new Array, o = new Array;
- for (i = 0; i < t.length; i += 3) {
- n = new Mb;
- var a = t[i]
- , s = t[i + 1]
- , l = t[i + 2];
- n.p0 = new x(e[3 * a],e[3 * a + 1],e[3 * a + 2]),
- n.p1 = new x(e[3 * s],e[3 * s + 1],e[3 * s + 2]),
- n.p2 = new x(e[3 * l],e[3 * l + 1],e[3 * l + 2]);
- var c = x.Cross(n.p1.subtract(n.p0), n.p2.subtract(n.p1));
- c.normalize(),
- o.push(c),
- r.push(n)
- }
- for (i = 0; i < r.length; i++) {
- n = r[i];
- for (var u = i + 1; u < r.length; u++) {
- var h = r[u];
- if (3 === n.edgesConnectedCount)
- break;
- if (3 !== h.edgesConnectedCount)
- for (var d = t[3 * u], p = t[3 * u + 1], f = t[3 * u + 2], _ = 0; _ < 3; _++) {
- var m = 0;
- if (void 0 === n.edges[_]) {
- switch (_) {
- case 0:
- m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(n.p0, n.p1, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i], t[3 * i + 1], d, p, f);
- break;
- case 1:
- m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(n.p1, n.p2, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i + 1], t[3 * i + 2], d, p, f);
- break;
- case 2:
- m = this._checkVerticesInsteadOfIndices ? this._processEdgeForAdjacenciesWithVertices(n.p2, n.p0, h.p0, h.p1, h.p2) : this._processEdgeForAdjacencies(t[3 * i + 2], t[3 * i], d, p, f)
- }
- if (-1 !== m && (n.edges[_] = u,
- h.edges[m] = i,
- n.edgesConnectedCount++,
- h.edgesConnectedCount++,
- 3 === n.edgesConnectedCount))
- break
- }
- }
- }
- }
- for (i = 0; i < r.length; i++) {
- var g = r[i];
- this._checkEdge(i, g.edges[0], o, g.p0, g.p1),
- this._checkEdge(i, g.edges[1], o, g.p1, g.p2),
- this._checkEdge(i, g.edges[2], o, g.p2, g.p0)
- }
- var v = this._source.getScene().getEngine();
- this._buffers[Bi.PositionKind] = new Bi(v,this._linesPositions,Bi.PositionKind,!1),
- this._buffers[Bi.NormalKind] = new Bi(v,this._linesNormals,Bi.NormalKind,!1,!1,4),
- this._buffersForInstances[Bi.PositionKind] = this._buffers[Bi.PositionKind],
- this._buffersForInstances[Bi.NormalKind] = this._buffers[Bi.NormalKind],
- this._ib = v.createIndexBuffer(this._linesIndices),
- this._indicesCount = this._linesIndices.length
- }
- }
- ,
- e.prototype.isReady = function() {
- return this._lineShader.isReady(this._source, this._source.hasInstances && this.customInstances.length > 0 || this._source.hasThinInstances)
- }
- ,
- e.prototype.render = function() {
- var e = this._source.getScene()
- , t = this._lineShader._getDrawWrapper();
- if (this._drawWrapper && this._lineShader._setDrawWrapper(this._drawWrapper),
- this.isReady() && e.activeCamera) {
- var i = this._source.hasInstances && this.customInstances.length > 0
- , n = i || this._source.hasThinInstances
- , r = 0;
- if (n)
- if (this._buffersForInstances.world0 = this._source.getVertexBuffer("world0"),
- this._buffersForInstances.world1 = this._source.getVertexBuffer("world1"),
- this._buffersForInstances.world2 = this._source.getVertexBuffer("world2"),
- this._buffersForInstances.world3 = this._source.getVertexBuffer("world3"),
- i) {
- var o = this._source._instanceDataStorage;
- if (r = this.customInstances.length,
- !o.instancesData)
- return void (this._source.getScene()._activeMeshesFrozen || this.customInstances.reset());
- if (!o.isFrozen) {
- for (var s = 0, l = 0; l < r; ++l)
- this.customInstances.data[l].copyToArray(o.instancesData, s),
- s += 16;
- o.instancesBuffer.updateDirectly(o.instancesData, 0, r)
- }
- } else
- r = this._source.thinInstanceCount;
- var c = e.getEngine();
- this._lineShader._preBind(),
- 1 !== this._source.edgesColor.a ? c.setAlphaMode(a.ALPHA_COMBINE) : c.setAlphaMode(a.ALPHA_DISABLE),
- c.bindBuffers(n ? this._buffersForInstances : this._buffers, this._ib, this._lineShader.getEffect()),
- e.resetCachedMaterial(),
- this._lineShader.setColor4("color", this._source.edgesColor),
- e.activeCamera.mode === Rr.ORTHOGRAPHIC_CAMERA ? this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic) : this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective),
- this._lineShader.setFloat("aspectRatio", c.getAspectRatio(e.activeCamera)),
- this._lineShader.bind(this._source.getWorldMatrix()),
- c.drawElementsType(Or.TriangleFillMode, 0, this._indicesCount, r),
- this._lineShader.unbind(),
- n && c.unbindInstanceAttributes(),
- this._source.getScene()._activeMeshesFrozen || this.customInstances.reset(),
- this._lineShader._setDrawWrapper(t)
- } else
- this._lineShader._setDrawWrapper(t)
- }
- ,
- e
- }()
- , Ob = function(e) {
- function t(t, i, n) {
- void 0 === i && (i = .95),
- void 0 === n && (n = !1);
- var r = e.call(this, t, i, n, !1) || this;
- return r._generateEdgesLines(),
- r
- }
- return U(t, e),
- t.prototype._generateEdgesLines = function() {
- var e = this._source.getVerticesData(Bi.PositionKind)
- , t = this._source.getIndices();
- if (t && e) {
- for (var i = I.Vector3[0], n = I.Vector3[1], r = t.length - 1, o = 0, a = 0; o < r; o += 2,
- a += 4)
- x.FromArrayToRef(e, 3 * t[o], i),
- x.FromArrayToRef(e, 3 * t[o + 1], n),
- this.createLine(i, n, a);
- var s = this._source.getScene().getEngine();
- this._buffers[Bi.PositionKind] = new Bi(s,this._linesPositions,Bi.PositionKind,!1),
- this._buffers[Bi.NormalKind] = new Bi(s,this._linesNormals,Bi.NormalKind,!1,!1,4),
- this._ib = s.createIndexBuffer(this._linesIndices),
- this._indicesCount = this._linesIndices.length
- }
- }
- ,
- t
- }(Ib)
- , Db = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, n, r, o, a) || this;
- return s._beforeCompositionPostProcesses = [],
- s._internalTextureDirty = !1,
- s.enabled = !1,
- s.renderTargetTexture = null,
- s.renderTargetTexture = i,
- s
- }
- return U(t, e),
- t.prototype._createCompositionEffect = function() {
- this.imageProcessingPostProcess = new Fs("prePassComposition",1,null,void 0,this._engine),
- this.imageProcessingPostProcess._updateParameters()
- }
- ,
- t.prototype._checkSize = function() {
- var e = this._engine.getRenderWidth(!0)
- , t = this._engine.getRenderHeight(!0)
- , i = this.getRenderWidth()
- , n = this.getRenderHeight();
- i === e && n === t || (this.resize({
- width: e,
- height: t
- }),
- this._internalTextureDirty = !0)
- }
- ,
- t.prototype.updateCount = function(t, i, n) {
- e.prototype.updateCount.call(this, t, i, n),
- this._internalTextureDirty = !0
- }
- ,
- t.prototype._resetPostProcessChain = function() {
- this._beforeCompositionPostProcesses = []
- }
- ,
- t.prototype.dispose = function() {
- var t = this._scene;
- if (e.prototype.dispose.call(this),
- t && t.prePassRenderer) {
- var i = t.prePassRenderer.renderTargets.indexOf(this);
- -1 !== i && t.prePassRenderer.renderTargets.splice(i, 1)
- }
- this.imageProcessingPostProcess && this.imageProcessingPostProcess.dispose(),
- this.renderTargetTexture && (this.renderTargetTexture._prePassRenderTarget = null),
- this._outputPostProcess && (this._outputPostProcess.autoClear = !0,
- this._outputPostProcess.restoreDefaultInputTexture())
- }
- ,
- t
- }(pm)
- , Nb = function() {
- function e(t) {
- this.excludedSkinnedMesh = [],
- this.excludedMaterials = [],
- this.mrtCount = 0,
- this._mrtFormats = [],
- this._mrtLayout = [],
- this._mrtNames = [],
- this._textureIndices = [],
- this._isDirty = !0,
- this._effectConfigurations = [],
- this.doNotUseGeometryRendererFallback = !0,
- this.renderTargets = [],
- this._clearColor = new N(0,0,0,0),
- this._enabled = !1,
- this._needsCompositionForThisPass = !1,
- this.disableGammaTransform = !1,
- this._scene = t,
- this._engine = t.getEngine(),
- e._SceneComponentInitialization(this._scene),
- this.defaultRT = this._createRenderTarget("sceneprePassRT", null),
- this._currentTarget = this.defaultRT
- }
- return e.prototype.getIndex = function(e) {
- return this._textureIndices[e]
- }
- ,
- Object.defineProperty(e.prototype, "samples", {
- get: function() {
- return this.defaultRT.samples
- },
- set: function(e) {
- this.defaultRT.samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getRenderTarget = function() {
- return this._currentTarget
- }
- ,
- e.prototype._setRenderTarget = function(e) {
- this._currentTarget = e || this.defaultRT,
- this._engine.currentRenderPassId = this._currentTarget.renderPassId
- }
- ,
- Object.defineProperty(e.prototype, "currentRTisSceneRT", {
- get: function() {
- return this._currentTarget === this.defaultRT
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._refreshGeometryBufferRendererLink = function() {
- if (this.doNotUseGeometryRendererFallback)
- this._geometryBuffer && this._geometryBuffer._unlinkPrePassRenderer(),
- this._geometryBuffer = null,
- this._scene.disableGeometryBufferRenderer();
- else {
- if (this._geometryBuffer = this._scene.enableGeometryBufferRenderer(),
- !this._geometryBuffer)
- return void (this.doNotUseGeometryRendererFallback = !0);
- this._geometryBuffer._linkPrePassRenderer(this)
- }
- }
- ,
- Object.defineProperty(e.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createRenderTarget = function(e, t) {
- var i = new Db(e,t,{
- width: this._engine.getRenderWidth(),
- height: this._engine.getRenderHeight()
- },0,this._scene,{
- generateMipMaps: !1,
- generateStencilBuffer: this._engine.isStencilEnable,
- defaultType: a.TEXTURETYPE_UNSIGNED_INT,
- types: [],
- drawOnlyOnFirstAttachmentByDefault: !0
- });
- return this.renderTargets.push(i),
- i
- }
- ,
- Object.defineProperty(e.prototype, "isSupported", {
- get: function() {
- return this._scene.getEngine().getCaps().drawBuffersExtension
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.bindAttachmentsForEffect = function(e, t) {
- var i = t.getMaterial()
- , n = i && i.isPrePassCapable
- , r = i && -1 !== this.excludedMaterials.indexOf(i);
- this.enabled && this._currentTarget.enabled && (e._multiTarget && n && !r ? this._engine.bindAttachments(this._multiRenderAttachments) : (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment(),
- this._geometryBuffer && this.currentRTisSceneRT && !r && this._geometryBuffer.renderList.push(t.getRenderingMesh())))
- }
- ,
- e.prototype._reinitializeAttachments = function() {
- for (var e = [], t = [!1], i = [!0], n = 0; n < this.mrtCount; n++)
- e.push(!0),
- n > 0 && (t.push(!0),
- i.push(!1));
- this._multiRenderAttachments = this._engine.buildTextureLayout(e),
- this._clearAttachments = this._engine.buildTextureLayout(t),
- this._defaultAttachments = this._engine.buildTextureLayout(i)
- }
- ,
- e.prototype._resetLayout = function() {
- for (var t = 0; t < e._TextureFormats.length; t++)
- this._textureIndices[e._TextureFormats[t].type] = -1;
- this._textureIndices[a.PREPASS_COLOR_TEXTURE_TYPE] = 0,
- this._mrtLayout = [a.PREPASS_COLOR_TEXTURE_TYPE],
- this._mrtFormats = [e._TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].format],
- this._mrtNames = [e._TextureFormats[a.PREPASS_COLOR_TEXTURE_TYPE].name],
- this.mrtCount = 1
- }
- ,
- e.prototype._updateGeometryBufferLayout = function() {
- if (this._refreshGeometryBufferRendererLink(),
- this._geometryBuffer) {
- this._geometryBuffer._resetLayout();
- for (var e = [], t = 0; t < this._mrtLayout.length; t++)
- e.push(!1);
- this._geometryBuffer._linkInternalTexture(this.defaultRT.getInternalTexture());
- var i = [{
- prePassConstant: a.PREPASS_DEPTH_TEXTURE_TYPE,
- geometryBufferConstant: nb.DEPTH_TEXTURE_TYPE
- }, {
- prePassConstant: a.PREPASS_NORMAL_TEXTURE_TYPE,
- geometryBufferConstant: nb.NORMAL_TEXTURE_TYPE
- }, {
- prePassConstant: a.PREPASS_POSITION_TEXTURE_TYPE,
- geometryBufferConstant: nb.POSITION_TEXTURE_TYPE
- }, {
- prePassConstant: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
- geometryBufferConstant: nb.REFLECTIVITY_TEXTURE_TYPE
- }, {
- prePassConstant: a.PREPASS_VELOCITY_TEXTURE_TYPE,
- geometryBufferConstant: nb.VELOCITY_TEXTURE_TYPE
- }];
- for (t = 0; t < i.length; t++) {
- var n = this._mrtLayout.indexOf(i[t].prePassConstant);
- -1 !== n && (this._geometryBuffer._forceTextureType(i[t].geometryBufferConstant, n),
- e[n] = !0)
- }
- this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(e))
- }
- }
- ,
- e.prototype.restoreAttachments = function() {
- this.enabled && this._currentTarget.enabled && this._defaultAttachments && (this._engine._currentRenderTarget ? this._engine.bindAttachments(this._defaultAttachments) : this._engine.restoreSingleAttachment())
- }
- ,
- e.prototype._beforeDraw = function(e, t, i) {
- this._isDirty && this._update(),
- this._enabled && this._currentTarget.enabled && (this._geometryBuffer && (this._geometryBuffer.renderList = []),
- this._setupOutputForThisPass(this._currentTarget, e))
- }
- ,
- e.prototype._prepareFrame = function(e, t, i) {
- e.renderTargetTexture ? e.renderTargetTexture._prepareFrame(this._scene, t, i, e.renderTargetTexture.useCameraPostProcesses) : this._postProcessesSourceForThisPass.length ? this._scene.postProcessManager._prepareFrame() : this._engine.restoreDefaultFramebuffer()
- }
- ,
- e.prototype._renderPostProcesses = function(e, t) {
- var i, n = this._postProcessesSourceForThisPass[0], r = n ? n.inputTexture : e.renderTargetTexture ? e.renderTargetTexture.renderTarget : null, o = this._currentTarget._beforeCompositionPostProcesses;
- this._needsCompositionForThisPass && (o = o.concat([this._currentTarget.imageProcessingPostProcess])),
- o.length && (this._scene.postProcessManager._prepareFrame(null === (i = this._currentTarget.renderTarget) || void 0 === i ? void 0 : i.texture, o),
- this._scene.postProcessManager.directRender(o, r, !1, t))
- }
- ,
- e.prototype._afterDraw = function(e, t) {
- this._enabled && this._currentTarget.enabled && (this._prepareFrame(this._currentTarget, e, t),
- this._renderPostProcesses(this._currentTarget, e))
- }
- ,
- e.prototype._clear = function() {
- this._enabled && this._currentTarget.enabled && (this._bindFrameBuffer(this._currentTarget),
- this._engine.bindAttachments(this._clearAttachments),
- this._engine.clear(this._clearColor, !0, !1, !1),
- this._engine.bindAttachments(this._defaultAttachments))
- }
- ,
- e.prototype._bindFrameBuffer = function(e) {
- if (this._enabled && this._currentTarget.enabled) {
- this._currentTarget._checkSize();
- var t = this._currentTarget.renderTarget;
- t && this._engine.bindFramebuffer(t)
- }
- }
- ,
- e.prototype._setEnabled = function(e) {
- this._enabled = e
- }
- ,
- e.prototype._setRenderTargetEnabled = function(e, t) {
- e.enabled = t,
- t || this._unlinkInternalTexture(e)
- }
- ,
- e.prototype.addEffectConfiguration = function(e) {
- for (var t = 0; t < this._effectConfigurations.length; t++)
- if (this._effectConfigurations[t].name === e.name)
- return this._effectConfigurations[t];
- return this._effectConfigurations.push(e),
- e
- }
- ,
- e.prototype._enable = function() {
- for (var e = this.mrtCount, t = 0; t < this._effectConfigurations.length; t++)
- this._effectConfigurations[t].enabled && this._enableTextures(this._effectConfigurations[t].texturesRequired);
- for (t = 0; t < this.renderTargets.length; t++) {
- this.mrtCount === e && this.renderTargets[t].count === this.mrtCount || this.renderTargets[t].updateCount(this.mrtCount, {
- types: this._mrtFormats
- }, this._mrtNames.concat("prePass_DepthBuffer")),
- this.renderTargets[t]._resetPostProcessChain();
- for (var i = 0; i < this._effectConfigurations.length; i++)
- this._effectConfigurations[i].enabled && (!this._effectConfigurations[i].postProcess && this._effectConfigurations[i].createPostProcess && this._effectConfigurations[i].createPostProcess(),
- this._effectConfigurations[i].postProcess && this.renderTargets[t]._beforeCompositionPostProcesses.push(this._effectConfigurations[i].postProcess))
- }
- this._reinitializeAttachments(),
- this._setEnabled(!0),
- this._updateGeometryBufferLayout()
- }
- ,
- e.prototype._disable = function() {
- this._setEnabled(!1);
- for (var e = 0; e < this.renderTargets.length; e++)
- this._setRenderTargetEnabled(this.renderTargets[e], !1);
- for (this._resetLayout(),
- e = 0; e < this._effectConfigurations.length; e++)
- this._effectConfigurations[e].enabled = !1
- }
- ,
- e.prototype._getPostProcessesSource = function(e, t) {
- if (t)
- return t._postProcesses;
- if (e.renderTargetTexture) {
- if (e.renderTargetTexture.useCameraPostProcesses) {
- var i = e.renderTargetTexture.activeCamera ? e.renderTargetTexture.activeCamera : this._scene.activeCamera;
- return i ? i._postProcesses : []
- }
- return e.renderTargetTexture.postProcesses ? e.renderTargetTexture.postProcesses : []
- }
- return this._scene.activeCamera ? this._scene.activeCamera._postProcesses : []
- }
- ,
- e.prototype._setupOutputForThisPass = function(e, t) {
- var i = t && this._scene.activeCameras && !!this._scene.activeCameras.length && 0 !== this._scene.activeCameras.indexOf(t);
- this._postProcessesSourceForThisPass = this._getPostProcessesSource(e, t),
- this._postProcessesSourceForThisPass = this._postProcessesSourceForThisPass.filter((function(e) {
- return null != e
- }
- )),
- this._scene.autoClear = !0;
- var n = this._hasImageProcessing(this._postProcessesSourceForThisPass);
- this._needsCompositionForThisPass = !n && !this.disableGammaTransform && this._needsImageProcessing() && !i;
- var r = this._getFirstPostProcess(this._postProcessesSourceForThisPass)
- , o = e._beforeCompositionPostProcesses && e._beforeCompositionPostProcesses[0]
- , a = null;
- this._scene.imageProcessingConfiguration.applyByPostProcess = this._needsCompositionForThisPass || n,
- this._needsCompositionForThisPass && !e.imageProcessingPostProcess && e._createCompositionEffect(),
- o ? a = o : this._needsCompositionForThisPass ? a = e.imageProcessingPostProcess : r && (a = r),
- this._bindFrameBuffer(e),
- this._linkInternalTexture(e, a)
- }
- ,
- e.prototype._linkInternalTexture = function(e, t) {
- t && (t.autoClear = !1,
- t.inputTexture = e.renderTarget),
- e._outputPostProcess !== t && (e._outputPostProcess && this._unlinkInternalTexture(e),
- e._outputPostProcess = t),
- e._internalTextureDirty && (this._updateGeometryBufferLayout(),
- e._internalTextureDirty = !1)
- }
- ,
- e.prototype._unlinkInternalTexture = function(e) {
- e._outputPostProcess && (e._outputPostProcess.autoClear = !0,
- e._outputPostProcess.restoreDefaultInputTexture(),
- e._outputPostProcess = null)
- }
- ,
- e.prototype._needsImageProcessing = function() {
- for (var e = 0; e < this._effectConfigurations.length; e++)
- if (this._effectConfigurations[e].enabled && this._effectConfigurations[e].needsImageProcessing)
- return !0;
- return !1
- }
- ,
- e.prototype._hasImageProcessing = function(e) {
- var t, i = !1;
- if (e)
- for (var n = 0; n < e.length; n++)
- if ("ImageProcessingPostProcess" === (null === (t = e[n]) || void 0 === t ? void 0 : t.getClassName())) {
- i = !0;
- break
- }
- return i
- }
- ,
- e.prototype._getFirstPostProcess = function(e) {
- for (var t = 0; t < e.length; t++)
- if (null !== e[t])
- return e[t];
- return null
- }
- ,
- e.prototype.markAsDirty = function() {
- this._isDirty = !0
- }
- ,
- e.prototype._enableTextures = function(t) {
- this._scene.needsPreviousWorldMatrices = !1;
- for (var i = 0; i < t.length; i++) {
- var n = t[i];
- -1 === this._textureIndices[n] && (this._textureIndices[n] = this._mrtLayout.length,
- this._mrtLayout.push(n),
- this._mrtFormats.push(e._TextureFormats[n].format),
- this._mrtNames.push(e._TextureFormats[n].name),
- this.mrtCount++),
- n === a.PREPASS_VELOCITY_TEXTURE_TYPE && (this._scene.needsPreviousWorldMatrices = !0)
- }
- }
- ,
- e.prototype._update = function() {
- this._disable();
- var e, t = !1;
- this._scene.imageProcessingConfiguration.applyByPostProcess = !1,
- this._scene._depthPeelingRenderer && this._scene.useOrderIndependentTransparency && (this._scene._depthPeelingRenderer.setPrePassRenderer(this),
- t = !0);
- for (var i = 0; i < this._scene.materials.length; i++)
- this._scene.materials[i].setPrePassRenderer(this) && (t = !0);
- for (t && this._setRenderTargetEnabled(this.defaultRT, !0),
- i = 0; i < this.renderTargets.length; i++) {
- if (this.renderTargets[i].renderTargetTexture)
- e = this._getPostProcessesSource(this.renderTargets[i]);
- else {
- var n = this._scene.activeCamera;
- if (!n)
- continue;
- e = n._postProcesses
- }
- if (e && (e = e.filter((function(e) {
- return null != e
- }
- )))) {
- for (var r = 0; r < e.length; r++)
- e[r].setPrePassRenderer(this) && (this._setRenderTargetEnabled(this.renderTargets[i], !0),
- t = !0);
- this._hasImageProcessing(e) && (this._scene.imageProcessingConfiguration.applyByPostProcess = !0)
- }
- }
- this._markAllMaterialsAsPrePassDirty(),
- this._isDirty = !1,
- t && this._enable()
- }
- ,
- e.prototype._markAllMaterialsAsPrePassDirty = function() {
- for (var e = this._scene.materials, t = 0; t < e.length; t++)
- e[t].markAsDirty(Or.PrePassDirtyFlag)
- }
- ,
- e.prototype.dispose = function() {
- for (var e = this.renderTargets.length - 1; e >= 0; e--)
- this.renderTargets[e].dispose();
- for (e = 0; e < this._effectConfigurations.length; e++)
- this._effectConfigurations[e].dispose && this._effectConfigurations[e].dispose()
- }
- ,
- e._SceneComponentInitialization = function(e) {
- throw be("PrePassRendererSceneComponent")
- }
- ,
- e._TextureFormats = [{
- type: a.PREPASS_IRRADIANCE_TEXTURE_TYPE,
- format: a.TEXTURETYPE_HALF_FLOAT,
- name: "prePass_Irradiance"
- }, {
- type: a.PREPASS_POSITION_TEXTURE_TYPE,
- format: a.TEXTURETYPE_HALF_FLOAT,
- name: "prePass_Position"
- }, {
- type: a.PREPASS_VELOCITY_TEXTURE_TYPE,
- format: a.TEXTURETYPE_UNSIGNED_INT,
- name: "prePass_Velocity"
- }, {
- type: a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,
- format: a.TEXTURETYPE_UNSIGNED_INT,
- name: "prePass_Reflectivity"
- }, {
- type: a.PREPASS_COLOR_TEXTURE_TYPE,
- format: a.TEXTURETYPE_HALF_FLOAT,
- name: "prePass_Color"
- }, {
- type: a.PREPASS_DEPTH_TEXTURE_TYPE,
- format: a.TEXTURETYPE_HALF_FLOAT,
- name: "prePass_Depth"
- }, {
- type: a.PREPASS_NORMAL_TEXTURE_TYPE,
- format: a.TEXTURETYPE_HALF_FLOAT,
- name: "prePass_Normal"
- }, {
- type: a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,
- format: a.TEXTURETYPE_UNSIGNED_INT,
- name: "prePass_Albedo"
- }],
- e
- }();
- Object.defineProperty(mn.prototype, "prePassRenderer", {
- get: function() {
- return this._prePassRenderer
- },
- set: function(e) {
- e && e.isSupported && (this._prePassRenderer = e)
- },
- enumerable: !0,
- configurable: !0
- }),
- mn.prototype.enablePrePassRenderer = function() {
- return this._prePassRenderer || (this._prePassRenderer = new Nb(this),
- this._prePassRenderer.isSupported || (this._prePassRenderer = null,
- K.Error("PrePassRenderer needs WebGL 2 support.\nMaybe you tried to use the following features that need the PrePassRenderer :\n + Subsurface Scattering"))),
- this._prePassRenderer
- }
- ,
- mn.prototype.disablePrePassRenderer = function() {
- this._prePassRenderer && (this._prePassRenderer.dispose(),
- this._prePassRenderer = null)
- }
- ;
- var Lb = function() {
- function e(e) {
- this.name = Wi.NAME_PREPASSRENDERER,
- this.scene = e
- }
- return e.prototype.register = function() {
- this.scene._beforeCameraDrawStage.registerStep(Wi.STEP_BEFORECAMERADRAW_PREPASS, this, this._beforeCameraDraw),
- this.scene._afterCameraDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterCameraDraw),
- this.scene._beforeRenderTargetDrawStage.registerStep(Wi.STEP_BEFORERENDERTARGETDRAW_PREPASS, this, this._beforeRenderTargetDraw),
- this.scene._afterRenderTargetDrawStage.registerStep(Wi.STEP_AFTERCAMERADRAW_PREPASS, this, this._afterRenderTargetDraw),
- this.scene._beforeClearStage.registerStep(Wi.STEP_BEFORECLEARSTAGE_PREPASS, this, this._beforeClearStage),
- this.scene._beforeRenderTargetClearStage.registerStep(Wi.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS, this, this._beforeRenderTargetClearStage),
- this.scene._beforeRenderingMeshStage.registerStep(Wi.STEP_BEFORERENDERINGMESH_PREPASS, this, this._beforeRenderingMeshStage),
- this.scene._afterRenderingMeshStage.registerStep(Wi.STEP_AFTERRENDERINGMESH_PREPASS, this, this._afterRenderingMeshStage)
- }
- ,
- e.prototype._beforeRenderTargetDraw = function(e, t, i) {
- this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(e._prePassRenderTarget),
- this.scene.prePassRenderer._beforeDraw(void 0, t, i))
- }
- ,
- e.prototype._afterRenderTargetDraw = function(e, t, i) {
- this.scene.prePassRenderer && this.scene.prePassRenderer._afterDraw(t, i)
- }
- ,
- e.prototype._beforeRenderTargetClearStage = function(e) {
- this.scene.prePassRenderer && (e._prePassRenderTarget || (e._prePassRenderTarget = this.scene.prePassRenderer._createRenderTarget(e.name + "_prePassRTT", e)),
- this.scene.prePassRenderer._setRenderTarget(e._prePassRenderTarget),
- this.scene.prePassRenderer._clear())
- }
- ,
- e.prototype._beforeCameraDraw = function(e) {
- this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null),
- this.scene.prePassRenderer._beforeDraw(e))
- }
- ,
- e.prototype._afterCameraDraw = function() {
- this.scene.prePassRenderer && this.scene.prePassRenderer._afterDraw()
- }
- ,
- e.prototype._beforeClearStage = function() {
- this.scene.prePassRenderer && (this.scene.prePassRenderer._setRenderTarget(null),
- this.scene.prePassRenderer._clear())
- }
- ,
- e.prototype._beforeRenderingMeshStage = function(e, t, i, n) {
- if (n) {
- var r = e.getScene();
- r.prePassRenderer && r.prePassRenderer.bindAttachmentsForEffect(n, t)
- }
- }
- ,
- e.prototype._afterRenderingMeshStage = function(e) {
- var t = e.getScene();
- t.prePassRenderer && t.prePassRenderer.restoreAttachments()
- }
- ,
- e.prototype.rebuild = function() {
- this.scene.disablePrePassRenderer(),
- this.scene.enablePrePassRenderer()
- }
- ,
- e.prototype.dispose = function() {
- this.scene.disablePrePassRenderer()
- }
- ,
- e
- }();
- Nb._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_PREPASSRENDERER);
- t || (t = new Lb(e),
- e._addComponent(t))
- }
- ;
- Pt.IncludesShadersStore.fibonacci = "#define rcp(x) 1./x\n#define GOLDEN_RATIO 1.618033988749895\n#define TWO_PI 6.2831855\nvec2 Golden2dSeq(int i,float n)\n{\nreturn vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));\n}\nvec2 SampleDiskGolden(int i,int sampleCount)\n{\nvec2 f=Golden2dSeq(i,float(sampleCount));\nreturn vec2(sqrt(f.x),TWO_PI*f.y);\n}";
- Pt.IncludesShadersStore.diffusionProfile = "uniform vec3 diffusionS[5];\nuniform float diffusionD[5];\nuniform float filterRadii[5];";
- Pt.ShadersStore.subSurfaceScatteringPixelShader = "#include<fibonacci>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<diffusionProfile>\nvarying vec2 vUV;\nuniform vec2 texelSize;\nuniform sampler2D textureSampler;\nuniform sampler2D irradianceSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D albedoSampler;\nuniform vec2 viewportSize;\nuniform float metersPerUnit;\nconst float LOG2_E=1.4426950408889634;\nconst float SSS_PIXELS_PER_SAMPLE=4.;\nconst int _SssSampleBudget=40;\n#define rcp(x) 1./x\n#define Sq(x) x*x\n#define SSS_BILATERAL_FILTER true\nvec3 EvalBurleyDiffusionProfile(float r,vec3 S)\n{\nvec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S); \nvec3 expSum=exp_13*(1.+exp_13*exp_13); \nreturn (S*rcp(8.*PI))*expSum; \n}\nvec2 SampleBurleyDiffusionProfile(float u,float rcpS)\n{\nu=1.-u; \nfloat g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));\nfloat n=exp2(log2(g)*(-1.0/3.0)); \nfloat p=(g*n)*n; \nfloat c=1.+p+n; \nfloat d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u); \nfloat x=(3./LOG2_E)*log2(c)-d; \nfloat rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));\nfloat r=x*rcpS;\nfloat rcpPdf=(8.*PI*rcpS)*rcpExp; \nreturn vec2(r,rcpPdf);\n}\nvec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)\n{\n#ifndef SSS_BILATERAL_FILTER\nz=0.;\n#endif\nfloat r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));\nfloat area=rcpPdf;\n#if SSS_CLAMP_ARTIFACT\nreturn clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);\n#else\nreturn EvalBurleyDiffusionProfile(r,S)*area;\n#endif\n}\nvoid EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,\nfloat phase,inout vec3 totalIrradiance,inout vec3 totalWeight)\n{\nfloat scale =rcp(float(n));\nfloat offset=rcp(float(n))*0.5;\nfloat sinPhase,cosPhase;\nsinPhase=sin(phase);\ncosPhase=cos(phase);\nvec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);\nfloat r=bdp.x;\nfloat rcpPdf=bdp.y;\nfloat phi=SampleDiskGolden(i,n).y;\nfloat sinPhi,cosPhi;\nsinPhi=sin(phi);\ncosPhi=cos(phi);\nfloat sinPsi=cosPhase*sinPhi+sinPhase*cosPhi; \nfloat cosPsi=cosPhase*cosPhi-sinPhase*sinPhi; \nvec2 vec=r*vec2(cosPsi,sinPsi);\nvec2 position; \nfloat xy2;\nposition=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;\nxy2 =r*r;\nvec4 textureSample=texture2D(irradianceSampler,position);\nfloat viewZ=texture2D(depthSampler,position).r;\nvec3 irradiance =textureSample.rgb;\nif (testLightingForSSS(textureSample.a))\n{\nfloat relZ=viewZ-centerPosVS.z;\nvec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);\ntotalIrradiance+=weight*irradiance;\ntotalWeight +=weight;\n}\nelse\n{\n}\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{\nvec4 irradianceAndDiffusionProfile =texture2D(irradianceSampler,vUV);\nvec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;\nint diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));\nfloat centerDepth =0.;\nvec4 inputColor=texture2D(textureSampler,vUV);\nbool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);\nif (passedStencilTest)\n{\ncenterDepth=texture2D(depthSampler,vUV).r;\n}\nif (!passedStencilTest) { \ngl_FragColor=inputColor;\nreturn;\n}\nfloat distScale =1.;\nvec3 S =diffusionS[diffusionProfileIndex];\nfloat d =diffusionD[diffusionProfileIndex];\nfloat filterRadius=filterRadii[diffusionProfileIndex];\nvec2 centerPosNDC=vUV;\nvec2 cornerPosNDC=vUV+0.5*texelSize;\nvec3 centerPosVS =vec3(centerPosNDC*viewportSize,1.0)*centerDepth; \nvec3 cornerPosVS =vec3(cornerPosNDC*viewportSize,1.0)*centerDepth; \nfloat mmPerUnit =1000.*(metersPerUnit*rcp(distScale));\nfloat unitsPerMm=rcp(mmPerUnit);\nfloat unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);\nfloat pixelsPerMm =rcp(unitsPerPixel)*unitsPerMm;\nfloat filterArea =PI*Sq(filterRadius*pixelsPerMm);\nint sampleCount =int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));\nint sampleBudget=_SssSampleBudget;\nint texturingMode=0;\nvec3 albedo =texture2D(albedoSampler,vUV).rgb;\nif (distScale==0. || sampleCount<1)\n{\n#ifdef DEBUG_SSS_SAMPLES\nvec3 green=vec3(0.,1.,0.);\ngl_FragColor=vec4(green,1.0);\nreturn;\n#endif\ngl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);\nreturn;\n}\n#ifdef DEBUG_SSS_SAMPLES\nvec3 red =vec3(1.,0.,0.);\nvec3 blue=vec3(0.,0.,1.);\ngl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);\nreturn;\n#endif\nfloat phase=0.;\nint n=min(sampleCount,sampleBudget);\nvec3 centerWeight =vec3(0.); \nvec3 totalIrradiance=vec3(0.);\nvec3 totalWeight =vec3(0.);\nfor (int i=0; i<n; i++)\n{\nEvaluateSample(i,n,S,d,centerPosVS,mmPerUnit,pixelsPerMm,\nphase,totalIrradiance,totalWeight);\n}\ntotalWeight=max(totalWeight,HALF_MIN);\ngl_FragColor=vec4(inputColor.rgb+albedo*max(totalIrradiance/totalWeight,vec3(0.0)),1.);\n}";
- var Fb = function(e) {
- function t(t, i, n, r, o, s, l, c) {
- void 0 === r && (r = null),
- void 0 === c && (c = a.TEXTURETYPE_UNSIGNED_INT);
- var u = e.call(this, t, "subSurfaceScattering", ["texelSize", "viewportSize", "metersPerUnit"], ["diffusionS", "diffusionD", "filterRadii", "irradianceSampler", "depthSampler", "albedoSampler"], n, r, o || io.BILINEAR_SAMPLINGMODE, s, l, null, c, "postprocess", void 0, !0) || this;
- return u._scene = i,
- u.updateEffect(),
- u.onApplyObservable.add((function(e) {
- if (i.prePassRenderer && i.subSurfaceConfiguration) {
- var t = u.texelSize;
- e.setFloat("metersPerUnit", i.subSurfaceConfiguration.metersPerUnit),
- e.setFloat2("texelSize", t.x, t.y),
- e.setTexture("irradianceSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(a.PREPASS_IRRADIANCE_TEXTURE_TYPE)]),
- e.setTexture("depthSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(a.PREPASS_DEPTH_TEXTURE_TYPE)]),
- e.setTexture("albedoSampler", i.prePassRenderer.getRenderTarget().textures[i.prePassRenderer.getIndex(a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE)]),
- e.setFloat2("viewportSize", Math.tan(i.activeCamera.fov / 2) * i.getEngine().getAspectRatio(i.activeCamera, !0), Math.tan(i.activeCamera.fov / 2)),
- e.setArray3("diffusionS", i.subSurfaceConfiguration.ssDiffusionS),
- e.setArray("diffusionD", i.subSurfaceConfiguration.ssDiffusionD),
- e.setArray("filterRadii", i.subSurfaceConfiguration.ssFilterRadii)
- } else
- K.Error("PrePass and subsurface configuration needs to be enabled for subsurface scattering.")
- }
- )),
- u
- }
- return U(t, e),
- t.prototype.getClassName = function() {
- return "SubSurfaceScatteringPostProcess"
- }
- ,
- t
- }(Ba)
- , wb = function() {
- function e(t) {
- this._ssDiffusionS = [],
- this._ssFilterRadii = [],
- this._ssDiffusionD = [],
- this.enabled = !1,
- this.needsImageProcessing = !0,
- this.name = Wi.NAME_SUBSURFACE,
- this.ssDiffusionProfileColors = [],
- this.metersPerUnit = 1,
- this.texturesRequired = [a.PREPASS_DEPTH_TEXTURE_TYPE, a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE, a.PREPASS_COLOR_TEXTURE_TYPE, a.PREPASS_IRRADIANCE_TEXTURE_TYPE],
- this.addDiffusionProfile(new D(1,1,1)),
- this._scene = t,
- e._SceneComponentInitialization(this._scene)
- }
- return Object.defineProperty(e.prototype, "ssDiffusionS", {
- get: function() {
- return this._ssDiffusionS
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ssDiffusionD", {
- get: function() {
- return this._ssDiffusionD
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ssFilterRadii", {
- get: function() {
- return this._ssFilterRadii
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addDiffusionProfile = function(e) {
- if (this.ssDiffusionD.length >= 5)
- return K.Error("You already reached the maximum number of diffusion profiles."),
- 0;
- for (var t = 0; t < this._ssDiffusionS.length / 3; t++)
- if (this._ssDiffusionS[3 * t] === e.r && this._ssDiffusionS[3 * t + 1] === e.g && this._ssDiffusionS[3 * t + 2] === e.b)
- return t;
- return this._ssDiffusionS.push(e.r, e.b, e.g),
- this._ssDiffusionD.push(Math.max(Math.max(e.r, e.b), e.g)),
- this._ssFilterRadii.push(this.getDiffusionProfileParameters(e)),
- this.ssDiffusionProfileColors.push(e),
- this._ssDiffusionD.length - 1
- }
- ,
- e.prototype.createPostProcess = function() {
- return this.postProcess = new Fb("subSurfaceScattering",this._scene,1,null,void 0,this._scene.getEngine()),
- this.postProcess.autoClear = !1,
- this.postProcess
- }
- ,
- e.prototype.clearAllDiffusionProfiles = function() {
- this._ssDiffusionD = [],
- this._ssDiffusionS = [],
- this._ssFilterRadii = [],
- this.ssDiffusionProfileColors = []
- }
- ,
- e.prototype.dispose = function() {
- this.clearAllDiffusionProfiles(),
- this.postProcess && this.postProcess.dispose()
- }
- ,
- e.prototype.getDiffusionProfileParameters = function(e) {
- var t = Math.max(e.r, e.g, e.b);
- return this._sampleBurleyDiffusionProfile(.997, t)
- }
- ,
- e.prototype._sampleBurleyDiffusionProfile = function(e, t) {
- var i = 1 + 4 * (e = 1 - e) * (2 * e + Math.sqrt(1 + 4 * e * e))
- , n = Math.pow(i, -1 / 3)
- , r = 1 + i * n * n + n;
- return 3 * Math.log(r / (4 * e)) * t
- }
- ,
- e._SceneComponentInitialization = function(e) {
- throw be("SubSurfaceSceneComponent")
- }
- ,
- e
- }();
- o.AddParser(Wi.NAME_SUBSURFACE, (function(e, t) {
- if (void 0 !== e.ssDiffusionProfileColors && null !== e.ssDiffusionProfileColors && (t.enableSubSurfaceForPrePass(),
- t.subSurfaceConfiguration))
- for (var i = 0, n = e.ssDiffusionProfileColors.length; i < n; i++) {
- var r = e.ssDiffusionProfileColors[i];
- t.subSurfaceConfiguration.addDiffusionProfile(new D(r.r,r.g,r.b))
- }
- }
- )),
- Object.defineProperty(mn.prototype, "subSurfaceConfiguration", {
- get: function() {
- return this._subSurfaceConfiguration
- },
- set: function(e) {
- e && this.enablePrePassRenderer() && (this._subSurfaceConfiguration = e)
- },
- enumerable: !0,
- configurable: !0
- }),
- mn.prototype.enableSubSurfaceForPrePass = function() {
- if (this._subSurfaceConfiguration)
- return this._subSurfaceConfiguration;
- var e = this.enablePrePassRenderer();
- return e ? (this._subSurfaceConfiguration = new wb(this),
- e.addEffectConfiguration(this._subSurfaceConfiguration),
- this._subSurfaceConfiguration) : null
- }
- ,
- mn.prototype.disableSubSurfaceForPrePass = function() {
- this._subSurfaceConfiguration && (this._subSurfaceConfiguration.dispose(),
- this._subSurfaceConfiguration = null)
- }
- ;
- var Bb = function() {
- function e(e) {
- this.name = Wi.NAME_PREPASSRENDERER,
- this.scene = e
- }
- return e.prototype.register = function() {}
- ,
- e.prototype.serialize = function(e) {
- if (this.scene.subSurfaceConfiguration) {
- var t = this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;
- e.ssDiffusionProfileColors = [];
- for (var i = 0; i < t.length; i++)
- e.ssDiffusionProfileColors.push({
- r: t[i].r,
- g: t[i].g,
- b: t[i].b
- })
- }
- }
- ,
- e.prototype.addFromContainer = function() {}
- ,
- e.prototype.removeFromContainer = function() {
- this.scene.prePassRenderer && this.scene.subSurfaceConfiguration && this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles()
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {}
- ,
- e
- }();
- wb._SceneComponentInitialization = function(e) {
- var t = e._getComponent(Wi.NAME_SUBSURFACE);
- t || (t = new Bb(e),
- e._addComponent(t))
- }
- ;
- Pt.ShadersStore.outlinePixelShader = "#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include<logDepthFragment>\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.outlineVertexShader = "attribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<clipPlaneVertexDeclaration>\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertexGlobal>\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\nvec3 offsetPosition=positionUpdated+(normalUpdated*offset);\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(offsetPosition,1.0);\ngl_Position=viewProjection*worldPos;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<clipPlaneVertex>\n#include<logDepthVertex>\n}\n",
- mn.prototype.getOutlineRenderer = function() {
- return this._outlineRenderer || (this._outlineRenderer = new Ub(this)),
- this._outlineRenderer
- }
- ,
- Object.defineProperty(Vr.prototype, "renderOutline", {
- get: function() {
- return this._renderOutline
- },
- set: function(e) {
- e && this.getScene().getOutlineRenderer(),
- this._renderOutline = e
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(Vr.prototype, "renderOverlay", {
- get: function() {
- return this._renderOverlay
- },
- set: function(e) {
- e && this.getScene().getOutlineRenderer(),
- this._renderOverlay = e
- },
- enumerable: !0,
- configurable: !0
- });
- var Ub = function() {
- function e(e) {
- this.name = Wi.NAME_OUTLINERENDERER,
- this.zOffset = 1,
- this.zOffsetUnits = 4,
- this.scene = e,
- this._engine = e.getEngine(),
- this.scene._addComponent(this),
- this._passIdForDrawWrapper = [];
- for (var t = 0; t < 4; ++t)
- this._passIdForDrawWrapper[t] = this._engine.createRenderPassId("Outline Renderer (".concat(t, ")"))
- }
- return e.prototype.register = function() {
- this.scene._beforeRenderingMeshStage.registerStep(Wi.STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh),
- this.scene._afterRenderingMeshStage.registerStep(Wi.STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {
- for (var e = 0; e < this._passIdForDrawWrapper.length; ++e)
- this._engine.releaseRenderPassId(this._passIdForDrawWrapper[e])
- }
- ,
- e.prototype.render = function(e, t, i, n) {
- void 0 === i && (i = !1),
- n = null != n ? n : this._passIdForDrawWrapper[0];
- var r = this.scene
- , o = r.getEngine()
- , a = o.getCaps().instancedArrays && (null !== t.visibleInstances[e._id] && void 0 !== t.visibleInstances[e._id] || e.getRenderingMesh().hasThinInstances);
- if (this.isReady(e, a, n)) {
- var s = e.getMesh()
- , l = s._internalAbstractMeshDataInfo._actAsRegularMesh ? s : null
- , c = e.getRenderingMesh()
- , u = l || c
- , h = e.getMaterial();
- if (h && r.activeCamera) {
- var d = e._getDrawWrapper(n)
- , p = Gt.GetEffect(d);
- if (o.enableEffect(d),
- h.useLogarithmicDepth && p.setFloat("logarithmicDepthConstant", 2 / (Math.log(r.activeCamera.maxZ + 1) / Math.LN2)),
- p.setFloat("offset", i ? 0 : c.outlineWidth),
- p.setColor4("color", i ? c.overlayColor : c.outlineColor, i ? c.overlayAlpha : h.alpha),
- p.setMatrix("viewProjection", r.getTransformMatrix()),
- p.setMatrix("world", u.getWorldMatrix()),
- c.useBones && c.computeBonesUsingShaders && c.skeleton && p.setMatrices("mBones", c.skeleton.getTransformMatrices(c)),
- c.morphTargetManager && c.morphTargetManager.isUsingTextureForTargets && c.morphTargetManager._bind(p),
- Mr.BindMorphTargetParameters(c, p),
- a || c._bind(e, p, h.fillMode),
- h && h.needAlphaTesting()) {
- var f = h.getAlphaTestTexture();
- f && (p.setTexture("diffuseSampler", f),
- p.setMatrix("diffuseMatrix", f.getTextureMatrix()))
- }
- Mr.BindClipPlane(p, r),
- o.setZOffset(-this.zOffset),
- o.setZOffsetUnits(-this.zOffsetUnits),
- c._processRendering(u, e, p, h.fillMode, t, a, (function(e, t) {
- p.setMatrix("world", t)
- }
- )),
- o.setZOffset(0),
- o.setZOffsetUnits(0)
- }
- }
- }
- ,
- e.prototype.isReady = function(e, t, i) {
- i = null != i ? i : this._passIdForDrawWrapper[0];
- var n = []
- , r = [Bi.PositionKind, Bi.NormalKind]
- , o = e.getMesh()
- , a = e.getMaterial()
- , s = o.getScene();
- a && (a.needAlphaTesting() && (n.push("#define ALPHATEST"),
- o.isVerticesDataPresent(Bi.UVKind) && (r.push(Bi.UVKind),
- n.push("#define UV1")),
- o.isVerticesDataPresent(Bi.UV2Kind) && (r.push(Bi.UV2Kind),
- n.push("#define UV2"))),
- a.useLogarithmicDepth && n.push("#define LOGARITHMICDEPTH")),
- o.useBones && o.computeBonesUsingShaders ? (r.push(Bi.MatricesIndicesKind),
- r.push(Bi.MatricesWeightsKind),
- o.numBoneInfluencers > 4 && (r.push(Bi.MatricesIndicesExtraKind),
- r.push(Bi.MatricesWeightsExtraKind)),
- n.push("#define NUM_BONE_INFLUENCERS " + o.numBoneInfluencers),
- n.push("#define BonesPerMesh " + (o.skeleton ? o.skeleton.bones.length + 1 : 0))) : n.push("#define NUM_BONE_INFLUENCERS 0");
- var l = o.morphTargetManager
- , c = 0;
- l && l.numInfluencers > 0 && (c = l.numInfluencers,
- n.push("#define MORPHTARGETS"),
- n.push("#define NUM_MORPH_INFLUENCERS " + c),
- l.isUsingTextureForTargets && n.push("#define MORPHTARGETS_TEXTURE"),
- Mr.PrepareAttributesForMorphTargetsInfluencers(r, o, c)),
- t && (n.push("#define INSTANCES"),
- Mr.PushAttributesForInstances(r),
- e.getRenderingMesh().hasThinInstances && n.push("#define THIN_INSTANCES")),
- s.clipPlane && n.push("#define CLIPPLANE"),
- s.clipPlane2 && n.push("#define CLIPPLANE2"),
- s.clipPlane3 && n.push("#define CLIPPLANE3"),
- s.clipPlane4 && n.push("#define CLIPPLANE4"),
- s.clipPlane5 && n.push("#define CLIPPLANE5"),
- s.clipPlane6 && n.push("#define CLIPPLANE6");
- var u = e._getDrawWrapper(i, !0)
- , h = u.defines
- , d = n.join("\n");
- return h !== d && u.setEffect(this.scene.getEngine().createEffect("outline", r, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant", "morphTargetInfluences", "morphTargetTextureInfo", "morphTargetTextureIndices", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6"], ["diffuseSampler", "morphTargets"], d, void 0, void 0, void 0, {
- maxSimultaneousMorphTargets: c
- }), d),
- u.effect.isReady()
- }
- ,
- e.prototype._beforeRenderingMesh = function(t, i, n) {
- if (this._savedDepthWrite = this._engine.getDepthWrite(),
- t.renderOutline) {
- var r = i.getMaterial();
- r && r.needAlphaBlendingForMesh(t) && (this._engine.cacheStencilState(),
- this._engine.setDepthWrite(!1),
- this._engine.setColorWrite(!1),
- this._engine.setStencilBuffer(!0),
- this._engine.setStencilOperationPass(a.REPLACE),
- this._engine.setStencilFunction(a.ALWAYS),
- this._engine.setStencilMask(e._StencilReference),
- this._engine.setStencilFunctionReference(e._StencilReference),
- this._engine.stencilStateComposer.useStencilGlobalOnly = !0,
- this.render(i, n, !0, this._passIdForDrawWrapper[1]),
- this._engine.setColorWrite(!0),
- this._engine.setStencilFunction(a.NOTEQUAL)),
- this._engine.setDepthWrite(!1),
- this.render(i, n, !1, this._passIdForDrawWrapper[0]),
- this._engine.setDepthWrite(this._savedDepthWrite),
- r && r.needAlphaBlendingForMesh(t) && (this._engine.stencilStateComposer.useStencilGlobalOnly = !1,
- this._engine.restoreStencilState())
- }
- }
- ,
- e.prototype._afterRenderingMesh = function(e, t, i) {
- if (e.renderOverlay) {
- var n = this._engine.getAlphaMode()
- , r = this._engine.alphaState.alphaBlend;
- this._engine.setAlphaMode(a.ALPHA_COMBINE),
- this.render(t, i, !0, this._passIdForDrawWrapper[3]),
- this._engine.setAlphaMode(n),
- this._engine.setDepthWrite(this._savedDepthWrite),
- this._engine.alphaState.alphaBlend = r
- }
- e.renderOutline && this._savedDepthWrite && (this._engine.setDepthWrite(!0),
- this._engine.setColorWrite(!1),
- this.render(t, i, !1, this._passIdForDrawWrapper[2]),
- this._engine.setColorWrite(!0))
- }
- ,
- e._StencilReference = 4,
- e
- }()
- , Vb = function(e) {
- function t(t, i) {
- var n = e.call(this) || this;
- return n.name = t,
- n.animations = new Array,
- n.isPickable = !1,
- n.useAlphaForPicking = !1,
- n.onDisposeObservable = new h,
- n._onAnimationEnd = null,
- n._endAnimation = function() {
- n._onAnimationEnd && n._onAnimationEnd(),
- n.disposeWhenFinishedAnimating && n.dispose()
- }
- ,
- n.color = new N(1,1,1,1),
- n.position = x.Zero(),
- n._manager = i,
- n._manager.sprites.push(n),
- n.uniqueId = n._manager.scene.getUniqueId(),
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "size", {
- get: function() {
- return this.width
- },
- set: function(e) {
- this.width = e,
- this.height = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "manager", {
- get: function() {
- return this._manager
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getClassName = function() {
- return "Sprite"
- }
- ,
- Object.defineProperty(t.prototype, "fromIndex", {
- get: function() {
- return this._fromIndex
- },
- set: function(e) {
- this.playAnimation(e, this._toIndex, this._loopAnimation, this._delay, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "toIndex", {
- get: function() {
- return this._toIndex
- },
- set: function(e) {
- this.playAnimation(this._fromIndex, e, this._loopAnimation, this._delay, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "loopAnimation", {
- get: function() {
- return this._loopAnimation
- },
- set: function(e) {
- this.playAnimation(this._fromIndex, this._toIndex, e, this._delay, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "delay", {
- get: function() {
- return Math.max(this._delay, 1)
- },
- set: function(e) {
- this.playAnimation(this._fromIndex, this._toIndex, this._loopAnimation, e, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.playAnimation = function(t, i, n, r, o) {
- void 0 === o && (o = null),
- this._onAnimationEnd = o,
- e.prototype.playAnimation.call(this, t, i, n, r, this._endAnimation)
- }
- ,
- t.prototype.dispose = function() {
- for (var e = 0; e < this._manager.sprites.length; e++)
- this._manager.sprites[e] == this && this._manager.sprites.splice(e, 1);
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- t.prototype.serialize = function() {
- var e = {};
- return e.name = this.name,
- e.position = this.position.asArray(),
- e.color = this.color.asArray(),
- e.width = this.width,
- e.height = this.height,
- e.angle = this.angle,
- e.cellIndex = this.cellIndex,
- e.cellRef = this.cellRef,
- e.invertU = this.invertU,
- e.invertV = this.invertV,
- e.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating,
- e.isPickable = this.isPickable,
- e.isVisible = this.isVisible,
- e.useAlphaForPicking = this.useAlphaForPicking,
- e.animationStarted = this.animationStarted,
- e.fromIndex = this.fromIndex,
- e.toIndex = this.toIndex,
- e.loopAnimation = this.loopAnimation,
- e.delay = this.delay,
- e
- }
- ,
- t.Parse = function(e, i) {
- var n = new t(e.name,i);
- return n.position = x.FromArray(e.position),
- n.color = N.FromArray(e.color),
- n.width = e.width,
- n.height = e.height,
- n.angle = e.angle,
- n.cellIndex = e.cellIndex,
- n.cellRef = e.cellRef,
- n.invertU = e.invertU,
- n.invertV = e.invertV,
- n.disposeWhenFinishedAnimating = e.disposeWhenFinishedAnimating,
- n.isPickable = e.isPickable,
- n.isVisible = e.isVisible,
- n.useAlphaForPicking = e.useAlphaForPicking,
- n.fromIndex = e.fromIndex,
- n.toIndex = e.toIndex,
- n.loopAnimation = e.loopAnimation,
- n.delay = e.delay,
- e.animationStarted && n.playAnimation(n.fromIndex, n.toIndex, n.loopAnimation, n.delay),
- n
- }
- ,
- t
- }(function() {
- function e() {
- 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(e.prototype, "animationStarted", {
- get: function() {
- return this._animationStarted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fromIndex", {
- get: function() {
- return this._fromIndex
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "toIndex", {
- get: function() {
- return this._toIndex
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "loopAnimation", {
- get: function() {
- return this._loopAnimation
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "delay", {
- get: function() {
- return Math.max(this._delay, 1)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.playAnimation = function(e, t, i, n, r) {
- this._fromIndex = e,
- this._toIndex = t,
- this._loopAnimation = i,
- this._delay = n || 1,
- this._animationStarted = !0,
- this._onBaseAnimationEnd = r,
- e < t ? this._direction = 1 : (this._direction = -1,
- this._toIndex = e,
- this._fromIndex = t),
- this.cellIndex = e,
- this._time = 0
- }
- ,
- e.prototype.stopAnimation = function() {
- this._animationStarted = !1
- }
- ,
- e.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()))))
- }
- ,
- e
- }());
- mn.prototype._internalPickSprites = function(e, t, i, n) {
- if (!Ui)
- return null;
- var r = null;
- if (!n) {
- if (!this.activeCamera)
- return null;
- n = this.activeCamera
- }
- if (this.spriteManagers.length > 0)
- for (var o = 0; o < this.spriteManagers.length; o++) {
- var a = this.spriteManagers[o];
- if (a.isPickable) {
- var s = a.intersects(e, n, t, i);
- if (s && s.hit && (i || null == r || !(s.distance >= r.distance)) && (r = s,
- i))
- break
- }
- }
- return r || new Ui
- }
- ,
- mn.prototype._internalMultiPickSprites = function(e, t, i) {
- if (!Ui)
- return null;
- var n = new Array;
- if (!i) {
- if (!this.activeCamera)
- return null;
- i = this.activeCamera
- }
- if (this.spriteManagers.length > 0)
- for (var r = 0; r < this.spriteManagers.length; r++) {
- var o = this.spriteManagers[r];
- if (o.isPickable) {
- var a = o.multiIntersects(e, i, t);
- null !== a && (n = n.concat(a))
- }
- }
- return n
- }
- ,
- mn.prototype.pickSprite = function(e, t, i, n, r) {
- if (!this._tempSpritePickingRay)
- return null;
- this.createPickingRayInCameraSpaceToRef(e, t, this._tempSpritePickingRay, r);
- var o = this._internalPickSprites(this._tempSpritePickingRay, i, n, r);
- return o && (o.ray = this.createPickingRayInCameraSpace(e, t, r)),
- o
- }
- ,
- mn.prototype.pickSpriteWithRay = function(e, t, i, n) {
- if (!this._tempSpritePickingRay)
- return null;
- if (!n) {
- if (!this.activeCamera)
- return null;
- n = this.activeCamera
- }
- _o.TransformToRef(e, n.getViewMatrix(), this._tempSpritePickingRay);
- var r = this._internalPickSprites(this._tempSpritePickingRay, t, i, n);
- return r && (r.ray = e),
- r
- }
- ,
- mn.prototype.multiPickSprite = function(e, t, i, n) {
- return this.createPickingRayInCameraSpaceToRef(e, t, this._tempSpritePickingRay, n),
- this._internalMultiPickSprites(this._tempSpritePickingRay, i, n)
- }
- ,
- mn.prototype.multiPickSpriteWithRay = function(e, t, i) {
- if (!this._tempSpritePickingRay)
- return null;
- if (!i) {
- if (!this.activeCamera)
- return null;
- i = this.activeCamera
- }
- return _o.TransformToRef(e, i.getViewMatrix(), this._tempSpritePickingRay),
- this._internalMultiPickSprites(this._tempSpritePickingRay, t, i)
- }
- ,
- mn.prototype.setPointerOverSprite = function(e) {
- this._pointerOverSprite !== e && (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(a.ACTION_OnPointerOutTrigger, w.CreateNewFromSprite(this._pointerOverSprite, this)),
- this._pointerOverSprite = e,
- this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(a.ACTION_OnPointerOverTrigger, w.CreateNewFromSprite(this._pointerOverSprite, this)))
- }
- ,
- mn.prototype.getPointerOverSprite = function() {
- return this._pointerOverSprite
- }
- ;
- var kb = function() {
- function e(e) {
- this.name = Wi.NAME_SPRITE,
- this.scene = e,
- this.scene.spriteManagers = new Array,
- this.scene._tempSpritePickingRay = _o ? _o.Zero() : null,
- this.scene.onBeforeSpritesRenderingObservable = new h,
- this.scene.onAfterSpritesRenderingObservable = new h,
- this._spritePredicate = function(e) {
- return !!e.actionManager && e.isPickable && e.actionManager.hasPointerTriggers
- }
- }
- return e.prototype.register = function() {
- this.scene._pointerMoveStage.registerStep(Wi.STEP_POINTERMOVE_SPRITE, this, this._pointerMove),
- this.scene._pointerDownStage.registerStep(Wi.STEP_POINTERDOWN_SPRITE, this, this._pointerDown),
- this.scene._pointerUpStage.registerStep(Wi.STEP_POINTERUP_SPRITE, this, this._pointerUp)
- }
- ,
- e.prototype.rebuild = function() {}
- ,
- e.prototype.dispose = function() {
- this.scene.onBeforeSpritesRenderingObservable.clear(),
- this.scene.onAfterSpritesRenderingObservable.clear();
- for (var e = this.scene.spriteManagers; e.length; )
- e[0].dispose()
- }
- ,
- e.prototype._pickSpriteButKeepRay = function(e, t, i, n, r) {
- var o = this.scene.pickSprite(t, i, this._spritePredicate, n, r);
- return o && (o.ray = e ? e.ray : null),
- o
- }
- ,
- e.prototype._pointerMove = function(e, t, i, n, r) {
- var o = this.scene;
- return n ? o.setPointerOverSprite(null) : (i = this._pickSpriteButKeepRay(i, e, t, !1, o.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite ? (o.setPointerOverSprite(i.pickedSprite),
- !o.doNotHandleCursors && r && (o._pointerOverSprite && o._pointerOverSprite.actionManager && o._pointerOverSprite.actionManager.hoverCursor ? r.style.cursor = o._pointerOverSprite.actionManager.hoverCursor : r.style.cursor = o.hoverCursor)) : o.setPointerOverSprite(null),
- i
- }
- ,
- e.prototype._pointerDown = function(e, t, i, n) {
- var r = this.scene;
- if (r._pickedDownSprite = null,
- r.spriteManagers.length > 0 && (i = r.pickSprite(e, t, this._spritePredicate, !1, r.cameraToUseForPointers || void 0)) && i.hit && i.pickedSprite && i.pickedSprite.actionManager) {
- switch (r._pickedDownSprite = i.pickedSprite,
- n.button) {
- case 0:
- i.pickedSprite.actionManager.processTrigger(a.ACTION_OnLeftPickTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n));
- break;
- case 1:
- i.pickedSprite.actionManager.processTrigger(a.ACTION_OnCenterPickTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n));
- break;
- case 2:
- i.pickedSprite.actionManager.processTrigger(a.ACTION_OnRightPickTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n))
- }
- i.pickedSprite.actionManager && i.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickDownTrigger, w.CreateNewFromSprite(i.pickedSprite, r, n))
- }
- return i
- }
- ,
- e.prototype._pointerUp = function(e, t, i, n) {
- var r = this.scene;
- if (r.spriteManagers.length > 0) {
- var o = r.pickSprite(e, t, this._spritePredicate, !1, r.cameraToUseForPointers || void 0);
- o && (o.hit && o.pickedSprite && o.pickedSprite.actionManager && (o.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickUpTrigger, w.CreateNewFromSprite(o.pickedSprite, r, n)),
- o.pickedSprite.actionManager && (this.scene._inputManager._isPointerSwiping() || o.pickedSprite.actionManager.processTrigger(a.ACTION_OnPickTrigger, w.CreateNewFromSprite(o.pickedSprite, r, n)))),
- r._pickedDownSprite && r._pickedDownSprite.actionManager && r._pickedDownSprite !== o.pickedSprite && r._pickedDownSprite.actionManager.processTrigger(a.ACTION_OnPickOutTrigger, w.CreateNewFromSprite(r._pickedDownSprite, r, n)))
- }
- return i
- }
- ,
- e
- }();
- Pt.IncludesShadersStore.imageProcessingCompatibility = "#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif\n";
- Pt.ShadersStore.spritesPixelShader = "uniform bool alphaTest;\nvarying vec4 vColor;\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
- Pt.ShadersStore.spritesVertexShader = "attribute vec4 position;\nattribute vec2 options;\nattribute vec2 offsets;\nattribute vec2 inverts;\nattribute vec4 cellInfo;\nattribute vec4 color;\nuniform mat4 view;\nuniform mat4 projection;\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=offsets.xy;\ncornerPos=vec2(offset.x-0.5,offset.y -0.5)*size;\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \nvColor=color;\nvec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));\nvec2 uvPlace=cellInfo.xy;\nvec2 uvSize=cellInfo.zw;\nvUV.x=uvPlace.x+uvSize.x*uvOffset.x;\nvUV.y=uvPlace.y+uvSize.y*uvOffset.y;\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}";
- var Gb = function() {
- function e(e, t, i, n) {
- void 0 === i && (i = .01),
- void 0 === n && (n = null),
- this.blendMode = a.ALPHA_COMBINE,
- this.autoResetAlpha = !0,
- this.disableDepthWrite = !1,
- this.fogEnabled = !0,
- this._useVAO = !1,
- this._useInstancing = !1,
- this._vertexBuffers = {},
- this._capacity = t,
- this._epsilon = i,
- this._engine = e,
- this._useInstancing = e.getCaps().instancedArrays,
- this._useVAO = e.getCaps().vertexArrayObject && !e.disableVertexArrayObjects,
- this._scene = n,
- this._drawWrapperBase = new Gt(e),
- this._drawWrapperFog = new Gt(e),
- this._drawWrapperDepth = new Gt(e,!1),
- this._drawWrapperFogDepth = new Gt(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(t * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
- this._buffer = new wi(e,this._vertexData,!0,this._vertexBufferSize);
- var r, o = this._buffer.createVertexBuffer(Bi.PositionKind, 0, 4, this._vertexBufferSize, this._useInstancing), s = this._buffer.createVertexBuffer("options", 4, 2, this._vertexBufferSize, this._useInstancing), l = 6;
- if (this._useInstancing) {
- var c = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
- this._spriteBuffer = new wi(e,c,!1,2),
- r = this._spriteBuffer.createVertexBuffer("offsets", 0, 2)
- } else
- r = this._buffer.createVertexBuffer("offsets", l, 2, this._vertexBufferSize, this._useInstancing),
- l += 2;
- var u = this._buffer.createVertexBuffer("inverts", l, 2, this._vertexBufferSize, this._useInstancing)
- , h = this._buffer.createVertexBuffer("cellInfo", l + 2, 4, this._vertexBufferSize, this._useInstancing)
- , d = this._buffer.createVertexBuffer(Bi.ColorKind, l + 6, 4, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers[Bi.PositionKind] = o,
- this._vertexBuffers.options = s,
- this._vertexBuffers.offsets = r,
- this._vertexBuffers.inverts = u,
- this._vertexBuffers.cellInfo = h,
- this._vertexBuffers[Bi.ColorKind] = d,
- this._drawWrapperBase.effect = this._engine.createEffect("sprites", [Bi.PositionKind, "options", "offsets", "inverts", "cellInfo", Bi.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", [Bi.PositionKind, "options", "offsets", "inverts", "cellInfo", Bi.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(e.prototype, "capacity", {
- get: function() {
- return this._capacity
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.render = function(e, t, i, n, r) {
- if (void 0 === r && (r = null),
- this.texture && this.texture.isReady() && e.length) {
- var o = this._drawWrapperBase
- , s = this._drawWrapperDepth
- , l = !1;
- this.fogEnabled && this._scene && this._scene.fogEnabled && 0 !== this._scene.fogMode && (o = this._drawWrapperFog,
- s = this._drawWrapperFogDepth,
- l = !0);
- var c = o.effect;
- if (c.isReady()) {
- for (var u = this._engine, h = !(!this._scene || !this._scene.useRightHandedSystem), d = this.texture.getBaseSize(), p = Math.min(this._capacity, e.length), f = 0, _ = !0, m = 0; m < p; m++) {
- var g = e[m];
- g && g.isVisible && (_ = !1,
- g._animate(t),
- this._appendSpriteVertex(f++, g, 0, 0, d, h, r),
- this._useInstancing || (this._appendSpriteVertex(f++, g, 1, 0, d, h, r),
- this._appendSpriteVertex(f++, g, 1, 1, d, h, r),
- this._appendSpriteVertex(f++, g, 0, 1, d, h, r)))
- }
- if (!_) {
- this._buffer.update(this._vertexData);
- var v = !!u.depthCullingState.cull
- , y = u.depthCullingState.zOffset
- , b = u.depthCullingState.zOffsetUnits;
- if (u.setState(v, y, !1, !1, void 0, void 0, b),
- u.enableEffect(o),
- c.setTexture("diffuseSampler", this.texture),
- c.setMatrix("view", i),
- c.setMatrix("projection", n),
- l) {
- var T = this._scene;
- c.setFloat4("vFogInfos", T.fogMode, T.fogStart, T.fogEnd, T.fogDensity),
- c.setColor3("vFogColor", T.fogColor)
- }
- this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = u.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, c)),
- u.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : u.bindBuffers(this._vertexBuffers, this._indexBuffer, c),
- u.depthCullingState.depthFunc = u.useReverseDepthBuffer ? a.GEQUAL : a.LEQUAL,
- this.disableDepthWrite || (c.setBool("alphaTest", !0),
- u.setColorWrite(!1),
- u.enableEffect(s),
- this._useInstancing ? u.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(a.MATERIAL_TriangleFillMode, 0, f / 4 * 6),
- u.enableEffect(o),
- u.setColorWrite(!0),
- c.setBool("alphaTest", !1)),
- u.setAlphaMode(this.blendMode),
- this._useInstancing ? u.drawArraysType(a.MATERIAL_TriangleStripDrawMode, 0, 4, f) : u.drawElementsType(a.MATERIAL_TriangleFillMode, 0, f / 4 * 6),
- this.autoResetAlpha && u.setAlphaMode(a.ALPHA_DISABLE),
- h && this._scene.getEngine().setState(v, y, !1, !0, void 0, void 0, b),
- u.unbindInstanceAttributes()
- }
- }
- }
- }
- ,
- e.prototype._appendSpriteVertex = function(e, t, i, n, r, o, a) {
- var s = e * this._vertexBufferSize;
- if (0 === i ? i = this._epsilon : 1 === i && (i = 1 - this._epsilon),
- 0 === n ? n = this._epsilon : 1 === n && (n = 1 - this._epsilon),
- a)
- a(t, r);
- else {
- t.cellIndex || (t.cellIndex = 0);
- var l = r.width / this.cellWidth
- , c = t.cellIndex / l >> 0;
- t._xOffset = (t.cellIndex - c * l) * this.cellWidth / r.width,
- t._yOffset = c * this.cellHeight / r.height,
- t._xSize = this.cellWidth,
- t._ySize = this.cellHeight
- }
- this._vertexData[s] = t.position.x,
- this._vertexData[s + 1] = t.position.y,
- this._vertexData[s + 2] = t.position.z,
- this._vertexData[s + 3] = t.angle,
- this._vertexData[s + 4] = t.width,
- this._vertexData[s + 5] = t.height,
- this._useInstancing ? s -= 2 : (this._vertexData[s + 6] = i,
- this._vertexData[s + 7] = n),
- this._vertexData[s + 8] = o ? t.invertU ? 0 : 1 : t.invertU ? 1 : 0,
- this._vertexData[s + 9] = t.invertV ? 1 : 0,
- this._vertexData[s + 10] = t._xOffset,
- this._vertexData[s + 11] = t._yOffset,
- this._vertexData[s + 12] = t._xSize / r.width,
- this._vertexData[s + 13] = t._ySize / r.height,
- this._vertexData[s + 14] = t.color.r,
- this._vertexData[s + 15] = t.color.g,
- this._vertexData[s + 16] = t.color.b,
- this._vertexData[s + 17] = t.color.a
- }
- ,
- e.prototype._buildIndexBuffer = function() {
- for (var e = [], t = 0, i = 0; i < this._capacity; i++)
- e.push(t),
- e.push(t + 1),
- e.push(t + 2),
- e.push(t),
- e.push(t + 2),
- e.push(t + 3),
- t += 4;
- this._indexBuffer = this._engine.createIndexBuffer(e)
- }
- ,
- e.prototype.rebuild = function() {
- var e;
- for (var t in this._indexBuffer && this._buildIndexBuffer(),
- this._useVAO && (this._vertexArrayObject = void 0),
- this._buffer._rebuild(),
- this._vertexBuffers)
- this._vertexBuffers[t]._rebuild();
- null === (e = this._spriteBuffer) || void 0 === e || e._rebuild()
- }
- ,
- e.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()
- }
- ,
- e
- }()
- , zb = function() {
- function e(e, t, i, n, r, o, a, s, l) {
- void 0 === o && (o = .01),
- void 0 === a && (a = io.TRILINEAR_SAMPLINGMODE),
- void 0 === s && (s = !1),
- void 0 === l && (l = null);
- var c = this;
- this.name = e,
- this.sprites = new Array,
- this.renderingGroupId = 0,
- this.layerMask = 268435455,
- this.isPickable = !1,
- this.onDisposeObservable = new h,
- this._disableDepthWrite = !1,
- this._packedAndReady = !1,
- this._customUpdate = function(e, t) {
- e.cellRef || (e.cellIndex = 0);
- var i = e.cellIndex;
- "number" == typeof i && isFinite(i) && Math.floor(i) === i && (e.cellRef = c._spriteMap[e.cellIndex]),
- e._xOffset = c._cellData[e.cellRef].frame.x / t.width,
- e._yOffset = c._cellData[e.cellRef].frame.y / t.height,
- e._xSize = c._cellData[e.cellRef].frame.w,
- e._ySize = c._cellData[e.cellRef].frame.h
- }
- ,
- r || (r = E.LastCreatedScene),
- r._getComponent(Wi.NAME_SPRITE) || r._addComponent(new kb(r)),
- this._fromPacked = s,
- this._scene = r;
- var u = this._scene.getEngine();
- if (this._spriteRenderer = new Gb(u,i,o,r),
- n.width && n.height)
- this.cellWidth = n.width,
- this.cellHeight = n.height;
- else {
- if (void 0 === n)
- return void (this._spriteRenderer = null);
- this.cellWidth = n,
- this.cellHeight = n
- }
- this._scene.spriteManagers.push(this),
- this.uniqueId = this.scene.getUniqueId(),
- t && (this.texture = new io(t,r,!0,!1,a)),
- this._fromPacked && this._makePacked(t, l)
- }
- return Object.defineProperty(e.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "children", {
- get: function() {
- return this.sprites
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "capacity", {
- get: function() {
- return this._spriteRenderer.capacity
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "texture", {
- get: function() {
- return this._spriteRenderer.texture
- },
- set: function(e) {
- e.wrapU = io.CLAMP_ADDRESSMODE,
- e.wrapV = io.CLAMP_ADDRESSMODE,
- this._spriteRenderer.texture = e,
- this._textureContent = null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cellWidth", {
- get: function() {
- return this._spriteRenderer.cellWidth
- },
- set: function(e) {
- this._spriteRenderer.cellWidth = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cellHeight", {
- get: function() {
- return this._spriteRenderer.cellHeight
- },
- set: function(e) {
- this._spriteRenderer.cellHeight = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fogEnabled", {
- get: function() {
- return this._spriteRenderer.fogEnabled
- },
- set: function(e) {
- this._spriteRenderer.fogEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blendMode", {
- get: function() {
- return this._spriteRenderer.blendMode
- },
- set: function(e) {
- this._spriteRenderer.blendMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "disableDepthWrite", {
- get: function() {
- return this._disableDepthWrite
- },
- set: function(e) {
- this._disableDepthWrite = e,
- this._spriteRenderer.disableDepthWrite = e
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "SpriteManager"
- }
- ,
- e.prototype._makePacked = function(e, t) {
- var i = this;
- if (null !== t)
- try {
- var n = void 0;
- if ((n = "string" == typeof t ? JSON.parse(t) : t).frames.length) {
- for (var r = {}, o = 0; o < n.frames.length; o++) {
- var a = n.frames[o];
- if ("string" != typeof Object.keys(a)[0])
- throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter.");
- r[a[Object.keys(a)[0]]] = a
- }
- n.frames = r
- }
- var s = Reflect.ownKeys(n.frames);
- this._spriteMap = s,
- this._packedAndReady = !0,
- this._cellData = n.frames
- } catch (e) {
- throw this._fromPacked = !1,
- this._packedAndReady = !1,
- new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")
- }
- else {
- var l = /\./g
- , c = void 0;
- do {
- c = l.lastIndex,
- l.test(e)
- } while (l.lastIndex > 0);
- var u = e.substring(0, c - 1) + ".json";
- gi.LoadFile(u, (function(e) {
- try {
- var t = JSON.parse(e)
- , n = Reflect.ownKeys(t.frames);
- i._spriteMap = n,
- i._packedAndReady = !0,
- i._cellData = t.frames
- } catch (e) {
- throw i._fromPacked = !1,
- i._packedAndReady = !1,
- new Error("Invalid JSON format. Please check documentation for format specifications.")
- }
- }
- ), void 0, void 0, !1, (function() {
- K.Error("JSON ERROR: Unable to load JSON file."),
- i._fromPacked = !1,
- i._packedAndReady = !1
- }
- ))
- }
- }
- ,
- e.prototype._checkTextureAlpha = function(e, t, i, n, r) {
- if (!e.useAlphaForPicking || !this.texture)
- return !0;
- var o = this.texture.getSize();
- this._textureContent || (this._textureContent = new Uint8Array(o.width * o.height * 4),
- this.texture.readPixels(0, 0, this._textureContent));
- var a = I.Vector3[0];
- a.copyFrom(t.direction),
- a.normalize(),
- a.scaleInPlace(i),
- a.addInPlace(t.origin);
- var s = (a.x - n.x) / (r.x - n.x) - .5
- , l = 1 - (a.y - n.y) / (r.y - n.y) - .5
- , c = e.angle
- , u = s * Math.cos(c) - l * Math.sin(c) + .5
- , h = s * Math.sin(c) + l * Math.cos(c) + .5
- , d = e._xOffset * o.width + u * e._xSize | 0
- , p = e._yOffset * o.height + h * e._ySize | 0;
- return this._textureContent[4 * (d + p * o.width) + 3] > .5
- }
- ,
- e.prototype.intersects = function(e, t, i, n) {
- for (var r = Math.min(this.capacity, this.sprites.length), o = x.Zero(), a = x.Zero(), s = Number.MAX_VALUE, l = null, c = I.Vector3[0], u = I.Vector3[1], h = t.getViewMatrix(), d = e, p = e, f = 0; f < r; f++) {
- var _ = this.sprites[f];
- if (_) {
- if (i) {
- if (!i(_))
- continue
- } else if (!_.isPickable)
- continue;
- if (x.TransformCoordinatesToRef(_.position, h, u),
- _.angle ? (P.TranslationToRef(-u.x, -u.y, 0, I.Matrix[1]),
- P.TranslationToRef(u.x, u.y, 0, I.Matrix[2]),
- P.RotationZToRef(_.angle, I.Matrix[3]),
- I.Matrix[1].multiplyToRef(I.Matrix[3], I.Matrix[4]),
- I.Matrix[4].multiplyToRef(I.Matrix[2], I.Matrix[0]),
- d = e.clone(),
- x.TransformCoordinatesToRef(e.origin, I.Matrix[0], d.origin),
- x.TransformNormalToRef(e.direction, I.Matrix[0], d.direction)) : d = e,
- o.copyFromFloats(u.x - _.width / 2, u.y - _.height / 2, u.z),
- a.copyFromFloats(u.x + _.width / 2, u.y + _.height / 2, u.z),
- d.intersectsBoxMinMax(o, a)) {
- var m = x.Distance(u, d.origin);
- if (s > m) {
- if (!this._checkTextureAlpha(_, d, m, o, a))
- continue;
- if (p = d,
- s = m,
- l = _,
- n)
- break
- }
- }
- }
- }
- if (l) {
- var g = new Ui;
- h.invertToRef(I.Matrix[0]),
- g.hit = !0,
- g.pickedSprite = l,
- g.distance = s;
- var v = I.Vector3[2];
- return v.copyFrom(p.direction),
- v.normalize(),
- v.scaleInPlace(s),
- p.origin.addToRef(v, c),
- g.pickedPoint = x.TransformCoordinates(c, I.Matrix[0]),
- g
- }
- return null
- }
- ,
- e.prototype.multiIntersects = function(e, t, i) {
- for (var n, r = Math.min(this.capacity, this.sprites.length), o = x.Zero(), a = x.Zero(), s = [], l = I.Vector3[0].copyFromFloats(0, 0, 0), c = I.Vector3[1].copyFromFloats(0, 0, 0), u = t.getViewMatrix(), h = 0; h < r; h++) {
- var d = this.sprites[h];
- if (d) {
- if (i) {
- if (!i(d))
- continue
- } else if (!d.isPickable)
- continue;
- if (x.TransformCoordinatesToRef(d.position, u, c),
- o.copyFromFloats(c.x - d.width / 2, c.y - d.height / 2, c.z),
- a.copyFromFloats(c.x + d.width / 2, c.y + d.height / 2, c.z),
- e.intersectsBoxMinMax(o, a)) {
- if (n = x.Distance(c, e.origin),
- !this._checkTextureAlpha(d, e, n, o, a))
- continue;
- var p = new Ui;
- s.push(p),
- u.invertToRef(I.Matrix[0]),
- p.hit = !0,
- p.pickedSprite = d,
- p.distance = n;
- var f = I.Vector3[2];
- f.copyFrom(e.direction),
- f.normalize(),
- f.scaleInPlace(n),
- e.origin.addToRef(f, l),
- p.pickedPoint = x.TransformCoordinates(l, I.Matrix[0])
- }
- }
- }
- return s
- }
- ,
- e.prototype.render = function() {
- if (!this._fromPacked || this._packedAndReady && this._spriteMap && this._cellData) {
- var e = this._scene.getEngine().getDeltaTime();
- 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())
- }
- }
- ,
- e.prototype.rebuild = function() {
- var e;
- null === (e = this._spriteRenderer) || void 0 === e || e.rebuild()
- }
- ,
- e.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()
- }
- ,
- e.prototype.serialize = function(e) {
- void 0 === e && (e = !1);
- var t = {};
- t.name = this.name,
- t.capacity = this.capacity,
- t.cellWidth = this.cellWidth,
- t.cellHeight = this.cellHeight,
- this.texture && (e ? t.texture = this.texture.serialize() : (t.textureUrl = this.texture.name,
- t.invertY = this.texture._invertY)),
- t.sprites = [];
- for (var i = 0, n = this.sprites; i < n.length; i++) {
- var r = n[i];
- t.sprites.push(r.serialize())
- }
- return t
- }
- ,
- e.Parse = function(t, i, n) {
- var r = new e(t.name,"",t.capacity,{
- width: t.cellWidth,
- height: t.cellHeight
- },i);
- t.texture ? r.texture = io.Parse(t.texture, i, n) : t.textureName && (r.texture = new io(n + t.textureUrl,i,!1,void 0 === t.invertY || t.invertY));
- for (var o = 0, a = t.sprites; o < a.length; o++) {
- var s = a[o];
- Vb.Parse(s, r)
- }
- return r
- }
- ,
- e.ParseFromFileAsync = function(t, i, n, r) {
- return void 0 === r && (r = ""),
- new Promise((function(o, a) {
- var s = new Ye;
- s.addEventListener("readystatechange", (function() {
- if (4 == s.readyState)
- if (200 == s.status) {
- var i = JSON.parse(s.responseText)
- , l = e.Parse(i, n || E.LastCreatedScene, r);
- t && (l.name = t),
- o(l)
- } else
- a("Unable to load the sprite manager")
- }
- )),
- s.open("GET", i),
- s.send()
- }
- ))
- }
- ,
- e.CreateFromSnippetAsync = function(t, i, n) {
- var r = this;
- return void 0 === n && (n = ""),
- "_BLANK" === t ? Promise.resolve(new e("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,i)) : new Promise((function(o, a) {
- var s = new Ye;
- s.addEventListener("readystatechange", (function() {
- if (4 == s.readyState)
- if (200 == s.status) {
- var r = JSON.parse(JSON.parse(s.responseText).jsonPayload)
- , l = JSON.parse(r.spriteManager)
- , c = e.Parse(l, i || E.LastCreatedScene, n);
- c.snippetId = t,
- o(c)
- } else
- a("Unable to load the snippet " + t)
- }
- )),
- s.open("GET", r.SnippetUrl + "/" + t.replace(/#/g, "/")),
- s.send()
- }
- ))
- }
- ,
- e.SnippetUrl = "https://snippet.babylonjs.com",
- e
- }();
- Pt.ShadersStore.spriteMapPixelShader = "precision highp float;\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nuniform float time;\nuniform float spriteCount;\nuniform sampler2D spriteSheet;\nuniform vec2 spriteMapSize;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform sampler2D frameMap;\nuniform sampler2D tileMaps[LAYERS];\nuniform sampler2D animationMap;\nuniform vec3 colorMul;\nfloat mt;\nconst float fdStep=1./4.;\nconst float aFrameSteps=1./MAX_ANIMATION_FRAMES;\nmat4 getFrameData(float frameID){\nfloat fX=frameID/spriteCount;\nreturn mat4(\ntexture2D(frameMap,vec2(fX,0.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*1.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*2.),0.),\nvec4(0.)\n);\n}\nvoid main(){\nvec4 color=vec4(0.);\nvec2 tileUV=fract(tUV);\n#ifdef FLIPU\ntileUV.y=1.0-tileUV.y;\n#endif\nvec2 tileID=floor(tUV);\nvec2 sheetUnits=1./spriteMapSize;\nfloat spriteUnits=1./spriteCount;\nvec2 stageUnits=1./stageSize;\nfor(int i=0; i<LAYERS; i++) {\nfloat frameID;\n#define LAYER_ID_SWITCH\nvec4 animationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.); \nif(animationData.y>0.) {\nmt=mod(time*animationData.z,1.0);\nfor(float f=0.; f<MAX_ANIMATION_FRAMES; f++){\nif(animationData.y>mt){\nframeID=animationData.x;\nbreak;\n}\nanimationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.); \n}\n}\nmat4 frameData=getFrameData(frameID+0.5);\nvec2 frameSize=(frameData[0].wz)/spriteMapSize;\nvec2 offset=frameData[0].xy*sheetUnits;\nvec2 ratio=frameData[2].xy/frameData[0].wz;\nif (frameData[2].z==1.){\ntileUV.xy=tileUV.yx;\n}\nif (i==0){\ncolor=texture2D(spriteSheet,tileUV*frameSize+offset);\n} else {\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\nfloat alpha=min(color.a+nc.a,1.0);\nvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\ncolor=vec4(mixed,alpha);\n}\n}\ncolor.xyz*=colorMul;\ngl_FragColor=color;\n}";
- Pt.ShadersStore.spriteMapVertexShader = "precision highp float;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nvarying vec2 stageUnits;\nvarying vec2 levelUnits;\nvarying vec2 tileID;\nuniform float time;\nuniform mat4 worldViewProjection;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform vec2 spriteMapSize;\nuniform float stageScale;\nvoid main() {\nvec4 p=vec4( position,1. );\nvPosition=p.xyz;\nvUV=uv;\ntUV=uv*stageSize; \ngl_Position=worldViewProjection*p;\n}";
- var Wb, Hb = function() {
- function e(e, t, i, n, r) {
- var o = this;
- this.name = e,
- this.sprites = [],
- this.atlasJSON = t,
- this.sprites = this.atlasJSON.frames,
- this.spriteSheet = i,
- this.options = n,
- n.stageSize = n.stageSize || new A(1,1),
- n.outputSize = n.outputSize || n.stageSize,
- n.outputPosition = n.outputPosition || x.Zero(),
- n.outputRotation = n.outputRotation || x.Zero(),
- n.layerCount = n.layerCount || 1,
- n.maxAnimationFrames = n.maxAnimationFrames || 0,
- n.baseTile = n.baseTile || 0,
- n.flipU = n.flipU || !1,
- n.colorMultiply = n.colorMultiply || new x(1,1,1),
- this._scene = r,
- this._frameMap = this._createFrameBuffer(),
- this._tileMaps = new Array;
- for (var a = 0; a < n.layerCount; a++)
- this._tileMaps.push(this._createTileBuffer(null, a));
- this._animationMap = this._createTileAnimationBuffer(null);
- var s = [];
- s.push("#define LAYERS " + n.layerCount),
- n.flipU && s.push("#define FLIPU"),
- s.push("#define MAX_ANIMATION_FRAMES ".concat(n.maxAnimationFrames, ".0"));
- var l, c = Mt.ShadersStore.spriteMapPixelShader;
- if (r.getEngine()._features.supportSwitchCaseInShader) {
- for (l = "switch(i) {",
- a = 0; a < n.layerCount; a++)
- l += "case " + a + " : frameID = texture(tileMaps[" + a + "], (tileID + 0.5) / stageSize, 0.).x;",
- l += "break;";
- l += "}"
- } else {
- l = "";
- for (a = 0; a < n.layerCount; a++)
- l += "if (".concat(a, " == i) { frameID = texture2D(tileMaps[").concat(a, "], (tileID + 0.5) / stageSize, 0.).x; }")
- }
- Mt.ShadersStore["spriteMap" + this.name + "PixelShader"] = c.replace("#define LAYER_ID_SWITCH", l),
- this._material = new jl("spriteMap:" + this.name,this._scene,{
- vertex: "spriteMap",
- fragment: "spriteMap" + this.name
- },{
- defines: s,
- attributes: ["position", "normal", "uv"],
- uniforms: ["worldViewProjection", "time", "stageSize", "outputSize", "spriteMapSize", "spriteCount", "time", "colorMul", "mousePosition", "curTile", "flipU"],
- samplers: ["spriteSheet", "frameMap", "tileMaps", "animationMap"],
- needAlphaBlending: !0
- }),
- this._time = 0,
- this._material.setFloat("spriteCount", this.spriteCount),
- this._material.setVector2("stageSize", n.stageSize),
- this._material.setVector2("outputSize", n.outputSize),
- this._material.setTexture("spriteSheet", this.spriteSheet),
- this._material.setVector2("spriteMapSize", new A(1,1)),
- this._material.setVector3("colorMul", n.colorMultiply);
- var u = 0
- , h = function() {
- o.spriteSheet && o.spriteSheet.isReady() && o.spriteSheet._texture ? o._material.setVector2("spriteMapSize", new A(o.spriteSheet._texture.baseWidth || 1,o.spriteSheet._texture.baseHeight || 1)) : u < 100 && setTimeout((function() {
- u++,
- h()
- }
- ), 100)
- };
- h(),
- this._material.setVector3("colorMul", n.colorMultiply),
- this._material.setTexture("frameMap", this._frameMap),
- this._material.setTextureArray("tileMaps", this._tileMaps),
- this._material.setTexture("animationMap", this._animationMap),
- this._material.setFloat("time", this._time),
- this._output = vo(e + ":output", {
- size: 1,
- updatable: !0
- }, r),
- this._output.scaling.x = n.outputSize.x,
- this._output.scaling.y = n.outputSize.y,
- this.position = n.outputPosition,
- this.rotation = n.outputRotation,
- this._scene.onBeforeRenderObservable.add((function() {
- o._time += o._scene.getEngine().getDeltaTime(),
- o._material.setFloat("time", o._time)
- }
- )),
- this._output.material = this._material
- }
- return Object.defineProperty(e.prototype, "spriteCount", {
- get: function() {
- return this.sprites.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._output.position
- },
- set: function(e) {
- this._output.position = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotation", {
- get: function() {
- return this._output.rotation
- },
- set: function(e) {
- this._output.rotation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "animationMap", {
- get: function() {
- return this._animationMap
- },
- set: function(e) {
- var t = e._texture._bufferView
- , i = this._createTileAnimationBuffer(t);
- this._animationMap.dispose(),
- this._animationMap = i,
- this._material.setTexture("animationMap", this._animationMap)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getTileID = function() {
- var e = this.getMousePosition();
- return e.multiplyInPlace(this.options.stageSize || A.Zero()),
- e.x = Math.floor(e.x),
- e.y = Math.floor(e.y),
- e
- }
- ,
- e.prototype.getMousePosition = function() {
- var e = this._output
- , t = this._scene.pick(this._scene.pointerX, this._scene.pointerY, (function(t) {
- return t === e
- }
- ));
- return t && t.hit && t.getTextureCoordinates && t.getTextureCoordinates() || new A(-1,-1)
- }
- ,
- e.prototype._createFrameBuffer = function() {
- for (var e = new Array, t = 0; t < this.spriteCount; t++)
- e.push(0, 0, 0, 0),
- e.push(0, 0, 0, 0),
- e.push(0, 0, 0, 0),
- e.push(0, 0, 0, 0);
- for (t = 0; t < this.spriteCount; t++) {
- var i = this.sprites[t].frame
- , n = this.sprites[t].spriteSourceSize
- , r = this.sprites[t].sourceSize
- , o = this.sprites[t].rotated ? 1 : 0
- , a = this.sprites[t].trimmed ? 1 : 0;
- e[4 * t] = i.x,
- e[4 * t + 1] = i.y,
- e[4 * t + 2] = i.w,
- e[4 * t + 3] = i.h,
- e[4 * t + 4 * this.spriteCount] = n.x,
- e[4 * t + 1 + 4 * this.spriteCount] = n.y,
- e[4 * t + 3 + 4 * this.spriteCount] = n.h,
- e[4 * t + 8 * this.spriteCount] = r.w,
- e[4 * t + 1 + 8 * this.spriteCount] = r.h,
- e[4 * t + 2 + 8 * this.spriteCount] = o,
- e[4 * t + 3 + 8 * this.spriteCount] = a
- }
- var s = new Float32Array(e);
- return ao.CreateRGBATexture(s, this.spriteCount, 4, this._scene, !1, !1, io.NEAREST_NEAREST, vr.TEXTURETYPE_FLOAT)
- }
- ,
- e.prototype._createTileBuffer = function(e, t) {
- void 0 === t && (t = 0);
- var i = new Array
- , n = this.options.stageSize.y || 0
- , r = this.options.stageSize.x || 0;
- if (e)
- i = e;
- else {
- var o = this.options.baseTile;
- 0 != t && (o = 0);
- for (var a = 0; a < n; a++)
- for (var s = 0; s < 4 * r; s += 4)
- i.push(o, 0, 0, 0)
- }
- var l = new Float32Array(i);
- return ao.CreateRGBATexture(l, r, n, this._scene, !1, !1, io.NEAREST_NEAREST, vr.TEXTURETYPE_FLOAT)
- }
- ,
- e.prototype.changeTiles = function(e, t, i) {
- void 0 === e && (e = 0),
- void 0 === i && (i = 0);
- var n = this._tileMaps[e]._texture._bufferView;
- if (null !== n) {
- var r = new Array;
- t instanceof A ? r.push(t) : r = t;
- for (var o = this.options.stageSize.x || 0, a = 0; a < r.length; a++) {
- var s = r[a];
- s.x = Math.floor(s.x),
- s.y = Math.floor(s.y),
- n[4 * s.x + s.y * (4 * o)] = i
- }
- var l = this._createTileBuffer(n);
- this._tileMaps[e].dispose(),
- this._tileMaps[e] = l,
- this._material.setTextureArray("tileMap", this._tileMaps)
- }
- }
- ,
- e.prototype._createTileAnimationBuffer = function(e) {
- var t, i = new Array;
- if (e)
- t = e;
- else {
- for (var n = 0; n < this.spriteCount; n++) {
- i.push(0, 0, 0, 0);
- for (var r = 1; r < (this.options.maxAnimationFrames || 4); )
- i.push(0, 0, 0, 0),
- r++
- }
- t = new Float32Array(i)
- }
- return ao.CreateRGBATexture(t, this.spriteCount, this.options.maxAnimationFrames || 4, this._scene, !1, !1, io.NEAREST_NEAREST, vr.TEXTURETYPE_FLOAT)
- }
- ,
- e.prototype.addAnimationToTile = function(e, t, i, n, r) {
- void 0 === e && (e = 0),
- void 0 === t && (t = 0),
- void 0 === i && (i = 0),
- void 0 === n && (n = 0),
- void 0 === r && (r = 1);
- var o = this._animationMap._texture._bufferView
- , a = 4 * e + 4 * this.spriteCount * t;
- if (o) {
- o[a] = i,
- o[a + 1] = n,
- o[a + 2] = r;
- var s = this._createTileAnimationBuffer(o);
- this._animationMap.dispose(),
- this._animationMap = s,
- this._material.setTexture("animationMap", this._animationMap)
- }
- }
- ,
- e.prototype.saveTileMaps = function() {
- for (var e = "", t = 0; t < this._tileMaps.length; t++)
- t > 0 && (e += "\n\r"),
- e += this._tileMaps[t]._texture._bufferView.toString();
- var i = document.createElement("a");
- i.href = "data:octet/stream;charset=utf-8," + encodeURI(e),
- i.target = "_blank",
- i.download = this.name + ".tilemaps",
- i.click(),
- i.remove()
- }
- ,
- e.prototype.loadTileMaps = function(e) {
- var t = this
- , i = new XMLHttpRequest;
- i.open("GET", e);
- var n = this.options.layerCount || 0;
- i.onload = function() {
- for (var e = i.response.split("\n\r"), r = 0; r < n; r++) {
- var o = e[r].split(",").map(Number)
- , a = t._createTileBuffer(o);
- t._tileMaps[r].dispose(),
- t._tileMaps[r] = a
- }
- t._material.setTextureArray("tileMap", t._tileMaps)
- }
- ,
- i.send()
- }
- ,
- e.prototype.dispose = function() {
- this._output.dispose(),
- this._material.dispose(),
- this._animationMap.dispose(),
- this._tileMaps.forEach((function(e) {
- e.dispose()
- }
- )),
- this._frameMap.dispose()
- }
- ,
- e
- }(), Xb = function(e) {
- function t(t, i, n, r, o, a, s) {
- void 0 === o && (o = null),
- void 0 === a && (a = .01),
- void 0 === s && (s = io.TRILINEAR_SAMPLINGMODE);
- var l = e.call(this, t, i, n, 64, r, a, s, !0, o) || this;
- return l.name = t,
- l
- }
- return U(t, e),
- t
- }(zb);
- !function(e) {
- e[e.INIT = 0] = "INIT",
- e[e.RUNNING = 1] = "RUNNING",
- e[e.DONE = 2] = "DONE",
- e[e.ERROR = 3] = "ERROR"
- }(Wb || (Wb = {}));
- var jb = function() {
- function e(e) {
- this.name = e,
- this._isCompleted = !1,
- this._taskState = Wb.INIT
- }
- return Object.defineProperty(e.prototype, "isCompleted", {
- get: function() {
- return this._isCompleted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "taskState", {
- get: function() {
- return this._taskState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "errorObject", {
- get: function() {
- return this._errorObject
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._setErrorObject = function(e, t) {
- this._errorObject || (this._errorObject = {
- message: e,
- exception: t
- })
- }
- ,
- e.prototype.run = function(e, t, i) {
- var n = this;
- this._taskState = Wb.RUNNING,
- this.runTask(e, (function() {
- n._onDoneCallback(t, i)
- }
- ), (function(e, t) {
- n._onErrorCallback(i, e, t)
- }
- ))
- }
- ,
- e.prototype.runTask = function(e, t, i) {
- throw new Error("runTask is not implemented")
- }
- ,
- e.prototype.reset = function() {
- this._taskState = Wb.INIT
- }
- ,
- e.prototype._onErrorCallback = function(e, t, i) {
- this._taskState = Wb.ERROR,
- this._errorObject = {
- message: t,
- exception: i
- },
- this.onError && this.onError(this, t, i),
- e()
- }
- ,
- e.prototype._onDoneCallback = function(e, t) {
- try {
- this._taskState = Wb.DONE,
- this._isCompleted = !0,
- this.onSuccess && this.onSuccess(this),
- e()
- } catch (e) {
- this._onErrorCallback(t, "Task is done, error executing success callback(s)", e)
- }
- }
- ,
- e
- }()
- , Yb = function(e, t, i) {
- this.remainingCount = e,
- this.totalCount = t,
- this.task = i
- }
- , Kb = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t) || this;
- return o.name = t,
- o.meshesNames = i,
- o.rootUrl = n,
- o.sceneFilename = r,
- o
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- var n = this;
- od.LoadAssetContainer(this.rootUrl, this.sceneFilename, e, (function(e) {
- n.loadedContainer = e,
- n.loadedMeshes = e.meshes,
- n.loadedParticleSystems = e.particleSystems,
- n.loadedSkeletons = e.skeletons,
- n.loadedAnimationGroups = e.animationGroups,
- t()
- }
- ), null, (function(e, t, n) {
- i(t, n)
- }
- ))
- }
- ,
- t
- }(jb)
- , Qb = function(e) {
- function t(t, i, n, r) {
- var o = e.call(this, t) || this;
- return o.name = t,
- o.meshesNames = i,
- o.rootUrl = n,
- o.sceneFilename = r,
- o
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- var n = this;
- od.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, e, (function(e, i, r, o) {
- n.loadedMeshes = e,
- n.loadedParticleSystems = i,
- n.loadedSkeletons = r,
- n.loadedAnimationGroups = o,
- t()
- }
- ), null, (function(e, t, n) {
- i(t, n)
- }
- ))
- }
- ,
- t
- }(jb)
- , qb = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.name = t,
- n.url = i,
- n
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- var n = this;
- e._loadFile(this.url, (function(e) {
- n.text = e,
- t()
- }
- ), void 0, !1, !1, (function(e, t) {
- e && i(e.status + " " + e.statusText, t)
- }
- ))
- }
- ,
- t
- }(jb)
- , Zb = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.name = t,
- n.url = i,
- n
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- var n = this;
- e._loadFile(this.url, (function(e) {
- n.data = e,
- t()
- }
- ), void 0, !0, !0, (function(e, t) {
- e && i(e.status + " " + e.statusText, t)
- }
- ))
- }
- ,
- t
- }(jb)
- , Jb = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.name = t,
- n.url = i,
- n
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- var n = this
- , r = new Image;
- gi.SetCorsBehavior(this.url, r),
- r.onload = function() {
- n.image = r,
- t()
- }
- ,
- r.onerror = function(e) {
- i("Error loading image", e)
- }
- ,
- r.src = this.url
- }
- ,
- t
- }(jb)
- , $b = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = !0),
- void 0 === o && (o = io.TRILINEAR_SAMPLINGMODE);
- var a = e.call(this, t) || this;
- return a.name = t,
- a.url = i,
- a.noMipmap = n,
- a.invertY = r,
- a.samplingMode = o,
- a
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- this.texture = new io(this.url,e,this.noMipmap,this.invertY,this.samplingMode,(function() {
- t()
- }
- ),(function(e, t) {
- i(e, t)
- }
- ))
- }
- ,
- t
- }(jb)
- , eT = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t) || this;
- return s.name = t,
- s.url = i,
- s.extensions = n,
- s.noMipmap = r,
- s.files = o,
- s.prefiltered = a,
- s
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- this.texture = new Bd(this.url,e,this.extensions,this.noMipmap,this.files,(function() {
- t()
- }
- ),(function(e, t) {
- i(e, t)
- }
- ),void 0,this.prefiltered)
- }
- ,
- t
- }(jb)
- , tT = function(e) {
- function t(t, i, n, r, o, a, s) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !0),
- void 0 === a && (a = !1),
- void 0 === s && (s = !1);
- var l = e.call(this, t) || this;
- return l.name = t,
- l.url = i,
- l.size = n,
- l.noMipmap = r,
- l.generateHarmonics = o,
- l.gammaSpace = a,
- l.reserved = s,
- l
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- this.texture = new E_(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,(function() {
- t()
- }
- ),(function(e, t) {
- i(e, t)
- }
- ))
- }
- ,
- t
- }(jb)
- , iT = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !0);
- var a = e.call(this, t) || this;
- return a.name = t,
- a.url = i,
- a.size = n,
- a.noMipmap = r,
- a.gammaSpace = o,
- a
- }
- return U(t, e),
- t.prototype.runTask = function(e, t, i) {
- this.texture = new K_(this.url,e,this.size,this.noMipmap,this.gammaSpace,(function() {
- t()
- }
- ),(function(e, t) {
- i(e, t)
- }
- ))
- }
- ,
- t
- }(jb)
- , nT = function() {
- function e(e) {
- this._isLoading = !1,
- this._tasks = new Array,
- this._waitingTasksCount = 0,
- this._totalTasksCount = 0,
- this.onTaskSuccessObservable = new h,
- this.onTaskErrorObservable = new h,
- this.onTasksDoneObservable = new h,
- this.onProgressObservable = new h,
- this.useDefaultLoadingScreen = !0,
- this.autoHideLoadingUI = !0,
- this._scene = e || E.LastCreatedScene
- }
- return e.prototype.addContainerTask = function(e, t, i, n) {
- var r = new Kb(e,t,i,n);
- return this._tasks.push(r),
- r
- }
- ,
- e.prototype.addMeshTask = function(e, t, i, n) {
- var r = new Qb(e,t,i,n);
- return this._tasks.push(r),
- r
- }
- ,
- e.prototype.addTextFileTask = function(e, t) {
- var i = new qb(e,t);
- return this._tasks.push(i),
- i
- }
- ,
- e.prototype.addBinaryFileTask = function(e, t) {
- var i = new Zb(e,t);
- return this._tasks.push(i),
- i
- }
- ,
- e.prototype.addImageTask = function(e, t) {
- var i = new Jb(e,t);
- return this._tasks.push(i),
- i
- }
- ,
- e.prototype.addTextureTask = function(e, t, i, n, r) {
- void 0 === r && (r = io.TRILINEAR_SAMPLINGMODE);
- var o = new $b(e,t,i,n,r);
- return this._tasks.push(o),
- o
- }
- ,
- e.prototype.addCubeTextureTask = function(e, t, i, n, r, o) {
- var a = new eT(e,t,i,n,r,o);
- return this._tasks.push(a),
- a
- }
- ,
- e.prototype.addHDRCubeTextureTask = function(e, t, i, n, r, o, a) {
- void 0 === n && (n = !1),
- void 0 === r && (r = !0),
- void 0 === o && (o = !1),
- void 0 === a && (a = !1);
- var s = new tT(e,t,i,n,r,o,a);
- return this._tasks.push(s),
- s
- }
- ,
- e.prototype.addEquiRectangularCubeTextureAssetTask = function(e, t, i, n, r) {
- void 0 === n && (n = !1),
- void 0 === r && (r = !0);
- var o = new iT(e,t,i,n,r);
- return this._tasks.push(o),
- o
- }
- ,
- e.prototype.removeTask = function(e) {
- var t = this._tasks.indexOf(e);
- t > -1 && this._tasks.splice(t, 1)
- }
- ,
- e.prototype._decreaseWaitingTasksCount = function(e) {
- this._waitingTasksCount--;
- try {
- this.onProgress && this.onProgress(this._waitingTasksCount, this._totalTasksCount, e),
- this.onProgressObservable.notifyObservers(new Yb(this._waitingTasksCount,this._totalTasksCount,e))
- } catch (e) {
- K.Error("Error running progress callbacks."),
- console.log(e)
- }
- if (0 === this._waitingTasksCount) {
- try {
- var t = this._tasks.slice();
- this.onFinish && this.onFinish(t);
- for (var i = 0, n = t; i < n.length; i++) {
- var r = n[i];
- if (r.taskState === Wb.DONE) {
- var o = this._tasks.indexOf(r);
- o > -1 && this._tasks.splice(o, 1)
- }
- }
- this.onTasksDoneObservable.notifyObservers(this._tasks)
- } catch (e) {
- K.Error("Error running tasks-done callbacks."),
- console.log(e)
- }
- this._isLoading = !1,
- this.autoHideLoadingUI && this._scene.getEngine().hideLoadingUI()
- }
- }
- ,
- e.prototype._runTask = function(e) {
- var t = this
- , i = function(i, n) {
- e._setErrorObject(i, n),
- t.onTaskError ? t.onTaskError(e) : e.onError || K.Error(t._formatTaskErrorMessage(e)),
- t.onTaskErrorObservable.notifyObservers(e),
- t._decreaseWaitingTasksCount(e)
- };
- e.run(this._scene, (function() {
- try {
- t.onTaskSuccess && t.onTaskSuccess(e),
- t.onTaskSuccessObservable.notifyObservers(e),
- t._decreaseWaitingTasksCount(e)
- } catch (e) {
- i("Error executing task success callbacks", e)
- }
- }
- ), i)
- }
- ,
- e.prototype._formatTaskErrorMessage = function(e) {
- var t = "Unable to complete task " + e.name;
- return e.errorObject.message && (t += ": ".concat(e.errorObject.message)),
- e.errorObject.exception && (t += ": ".concat(e.errorObject.exception)),
- t
- }
- ,
- e.prototype.reset = function() {
- return this._isLoading = !1,
- this._tasks = new Array,
- this
- }
- ,
- e.prototype.load = function() {
- if (this._isLoading)
- return this;
- if (this._isLoading = !0,
- this._waitingTasksCount = this._tasks.length,
- this._totalTasksCount = this._tasks.length,
- 0 === this._waitingTasksCount)
- return this._isLoading = !1,
- this.onFinish && this.onFinish(this._tasks),
- this.onTasksDoneObservable.notifyObservers(this._tasks),
- this;
- this.useDefaultLoadingScreen && this._scene.getEngine().displayLoadingUI();
- for (var e = 0; e < this._tasks.length; e++) {
- var t = this._tasks[e];
- t.taskState === Wb.INIT && this._runTask(t)
- }
- return this
- }
- ,
- e.prototype.loadAsync = function() {
- var e = this;
- return new Promise((function(t, i) {
- e._isLoading ? t() : (e.onTasksDoneObservable.addOnce((function(e) {
- e && e.length ? i(e) : t()
- }
- )),
- e.load())
- }
- ))
- }
- ,
- e
- }()
- , rT = function() {
- function e() {
- var e = this;
- this.promise = new Promise((function(t, i) {
- e._resolve = t,
- e._reject = i
- }
- ))
- }
- return Object.defineProperty(e.prototype, "resolve", {
- get: function() {
- return this._resolve
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "reject", {
- get: function() {
- return this._reject
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }()
- , oT = function() {
- function e(e, t) {
- this._meshesOrigins = [],
- this._toCenterVectors = [],
- this._scaledDirection = x.Zero(),
- this._newPosition = x.Zero(),
- this._centerPosition = x.Zero(),
- this._meshes = e.slice(),
- t ? this._centerMesh = t : this._setCenterMesh();
- var i = this._meshes.indexOf(this._centerMesh);
- i >= 0 && this._meshes.splice(i, 1),
- this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
- for (var n = 0; n < this._meshes.length; n++)
- if (this._meshes[n]) {
- var r = this._meshes[n];
- this._meshesOrigins[n] = r.getAbsolutePosition().clone(),
- this._toCenterVectors[n] = x.Zero(),
- r.hasBoundingInfo && this._centerMesh.hasBoundingInfo && r.getBoundingInfo().boundingBox.centerWorld.subtractToRef(this._centerMesh.getBoundingInfo().boundingBox.centerWorld, this._toCenterVectors[n])
- }
- }
- return e.prototype._setCenterMesh = function() {
- for (var e = x.Zero(), t = x.Zero(), i = Number.MAX_VALUE, n = 0; n < this._meshes.length; n++)
- this._meshes[n] && (o = (r = this._meshes[n]).getBoundingInfo()) && t.addInPlace(o.boundingBox.centerWorld);
- for (e = t.scale(1 / this._meshes.length),
- n = 0; n < this._meshes.length; n++) {
- var r, o;
- if (this._meshes[n] && (o = (r = this._meshes[n]).getBoundingInfo())) {
- var a = o.boundingBox.centerWorld.subtract(e).lengthSquared();
- a < i && (this._centerMesh = r,
- i = a)
- }
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "MeshExploder"
- }
- ,
- e.prototype.getMeshes = function() {
- var e = this._meshes.slice();
- return e.unshift(this._centerMesh),
- e
- }
- ,
- e.prototype.explode = function(e) {
- void 0 === e && (e = 1);
- for (var t = 0; t < this._meshes.length; t++)
- this._meshes[t] && this._meshesOrigins[t] && this._toCenterVectors[t] && (this._toCenterVectors[t].scaleToRef(e, this._scaledDirection),
- this._meshesOrigins[t].addToRef(this._scaledDirection, this._newPosition),
- this._meshes[t].setAbsolutePosition(this._newPosition));
- this._centerMesh.setAbsolutePosition(this._centerPosition)
- }
- ,
- e
- }()
- , aT = function() {
- function e(e, t, i, n, r, o, a, s, l) {
- var c = this;
- this.onProcessFileCallback = function() {
- return !0
- }
- ,
- this.loadAsync = function(e, t) {
- return od.LoadAsync("file:", e, c._engine, t)
- }
- ,
- this._engine = e,
- this._currentScene = t,
- this._sceneLoadedCallback = i,
- this._progressCallback = n,
- this._additionalRenderLoopLogicCallback = r,
- this._textureLoadingCallback = o,
- this._startingProcessingFilesCallback = a,
- this._onReloadCallback = s,
- this._errorCallback = l
- }
- return Object.defineProperty(e, "FilesToLoad", {
- get: function() {
- return ut.FilesToLoad
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.monitorElementForDragNDrop = function(e) {
- var t = this;
- e && (this._elementToMonitor = e,
- this._dragEnterHandler = function(e) {
- t._drag(e)
- }
- ,
- this._dragOverHandler = function(e) {
- t._drag(e)
- }
- ,
- this._dropHandler = function(e) {
- t._drop(e)
- }
- ,
- this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, !1),
- this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, !1),
- this._elementToMonitor.addEventListener("drop", this._dropHandler, !1))
- }
- ,
- Object.defineProperty(e.prototype, "filesToLoad", {
- get: function() {
- return this._filesToLoad
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this._elementToMonitor && (this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler),
- this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler),
- this._elementToMonitor.removeEventListener("drop", this._dropHandler))
- }
- ,
- e.prototype._renderFunction = function() {
- if (this._additionalRenderLoopLogicCallback && this._additionalRenderLoopLogicCallback(),
- this._currentScene) {
- if (this._textureLoadingCallback) {
- var e = this._currentScene.getWaitingItemsCount();
- e > 0 && this._textureLoadingCallback(e)
- }
- this._currentScene.render()
- }
- }
- ,
- e.prototype._drag = function(e) {
- e.stopPropagation(),
- e.preventDefault()
- }
- ,
- e.prototype._drop = function(e) {
- e.stopPropagation(),
- e.preventDefault(),
- this.loadFiles(e)
- }
- ,
- e.prototype._traverseFolder = function(e, t, i, n) {
- var r = this
- , o = e.createReader()
- , a = e.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
- o.readEntries((function(e) {
- i.count += e.length;
- for (var o = 0, s = e; o < s.length; o++) {
- var l = s[o];
- l.isFile ? l.file((function(e) {
- e.correctName = a + e.name,
- t.push(e),
- 0 == --i.count && n()
- }
- )) : l.isDirectory && r._traverseFolder(l, t, i, n)
- }
- 0 == --i.count && n()
- }
- ))
- }
- ,
- e.prototype._processFiles = function(t) {
- for (var i = this, n = 0; n < t.length; n++) {
- var r = t[n].correctName.toLowerCase()
- , o = r.split(".").pop();
- this.onProcessFileCallback(t[n], r, o, (function(e) {
- return i._sceneFileToLoad = e
- }
- )) && (od.IsPluginForExtensionAvailable("." + o) && (this._sceneFileToLoad = t[n]),
- e.FilesToLoad[r] = t[n])
- }
- }
- ,
- e.prototype.loadFiles = function(e) {
- var t = this;
- if (e && e.dataTransfer && e.dataTransfer.files && (this._filesToLoad = e.dataTransfer.files),
- e && e.target && e.target.files && (this._filesToLoad = e.target.files),
- this._filesToLoad && 0 !== this._filesToLoad.length && (this._startingProcessingFilesCallback && this._startingProcessingFilesCallback(this._filesToLoad),
- this._filesToLoad && this._filesToLoad.length > 0)) {
- for (var i = new Array, n = [], r = e.dataTransfer ? e.dataTransfer.items : null, o = 0; o < this._filesToLoad.length; o++) {
- var a = this._filesToLoad[o]
- , s = a.name.toLowerCase()
- , l = void 0;
- if (a.correctName = s,
- r) {
- var c = r[o];
- c.getAsEntry ? l = c.getAsEntry() : c.webkitGetAsEntry && (l = c.webkitGetAsEntry())
- }
- l && l.isDirectory ? n.push(l) : i.push(a)
- }
- if (0 === n.length)
- this._processFiles(i),
- this._processReload();
- else
- for (var u = {
- count: n.length
- }, h = 0, d = n; h < d.length; h++) {
- var p = d[h];
- this._traverseFolder(p, i, u, (function() {
- t._processFiles(i),
- 0 === u.count && t._processReload()
- }
- ))
- }
- }
- }
- ,
- e.prototype._processReload = function() {
- this._onReloadCallback ? this._onReloadCallback(this._sceneFileToLoad) : this.reload()
- }
- ,
- e.prototype.reload = function() {
- var e = this;
- this._sceneFileToLoad ? (this._currentScene && (K.errorsCount > 0 && K.ClearLogCache(),
- this._engine.stopRenderLoop()),
- od.ShowLoadingScreen = !1,
- this._engine.displayLoadingUI(),
- this.loadAsync(this._sceneFileToLoad, this._progressCallback).then((function(t) {
- e._currentScene && e._currentScene.dispose(),
- e._currentScene = t,
- e._sceneLoadedCallback && e._sceneLoadedCallback(e._sceneFileToLoad, e._currentScene),
- e._currentScene.executeWhenReady((function() {
- e._engine.hideLoadingUI(),
- e._engine.runRenderLoop((function() {
- e._renderFunction()
- }
- ))
- }
- ))
- }
- )).catch((function(t) {
- e._engine.hideLoadingUI(),
- e._errorCallback && e._errorCallback(e._sceneFileToLoad, e._currentScene, t.message)
- }
- ))) : K.Error("Please provide a valid .babylon file.")
- }
- ,
- e
- }()
- , sT = function() {
- function e(e) {
- void 0 === e && (e = 0),
- this.priority = e
- }
- return e.prototype.getDescription = function() {
- return ""
- }
- ,
- e.prototype.apply = function(e, t) {
- return !0
- }
- ,
- e
- }()
- , lT = function(e) {
- function t(t, i, n) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 1024),
- void 0 === n && (n = .5);
- var r = e.call(this, t) || this;
- return r.priority = t,
- r.maximumSize = i,
- r.step = n,
- r
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Reducing render target texture size to " + this.maximumSize
- }
- ,
- t.prototype.apply = function(e, t) {
- for (var i = !0, n = 0; n < e.textures.length; n++) {
- var r = e.textures[n];
- if (r.canRescale && !r.getContext) {
- var o = r.getSize();
- Math.max(o.width, o.height) > this.maximumSize && (r.scale(this.step),
- i = !1)
- }
- }
- return i
- }
- ,
- t
- }(sT)
- , cT = function(e) {
- function t(t, i, n) {
- void 0 === t && (t = 0),
- void 0 === i && (i = 2),
- void 0 === n && (n = .25);
- var r = e.call(this, t) || this;
- return r.priority = t,
- r.maximumScale = i,
- r.step = n,
- r._currentScale = -1,
- r._directionOffset = 1,
- r
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Setting hardware scaling level to " + this._currentScale
- }
- ,
- t.prototype.apply = function(e, t) {
- return -1 === this._currentScale && (this._currentScale = e.getEngine().getHardwareScalingLevel(),
- this._currentScale > this.maximumScale && (this._directionOffset = -1)),
- this._currentScale += this._directionOffset * this.step,
- e.getEngine().setHardwareScalingLevel(this._currentScale),
- 1 === this._directionOffset ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale
- }
- ,
- t
- }(sT)
- , uT = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Turning shadows on/off"
- }
- ,
- t.prototype.apply = function(e, t) {
- return e.shadowsEnabled = t.isInImprovementMode,
- !0
- }
- ,
- t
- }(sT)
- , hT = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Turning post-processes on/off"
- }
- ,
- t.prototype.apply = function(e, t) {
- return e.postProcessesEnabled = t.isInImprovementMode,
- !0
- }
- ,
- t
- }(sT)
- , dT = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Turning lens flares on/off"
- }
- ,
- t.prototype.apply = function(e, t) {
- return e.lensFlaresEnabled = t.isInImprovementMode,
- !0
- }
- ,
- t
- }(sT)
- , pT = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return this.onGetDescription ? this.onGetDescription() : "Running user defined callback"
- }
- ,
- t.prototype.apply = function(e, t) {
- return !this.onApply || this.onApply(e, t)
- }
- ,
- t
- }(sT)
- , fT = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Turning particles on/off"
- }
- ,
- t.prototype.apply = function(e, t) {
- return e.particlesEnabled = t.isInImprovementMode,
- !0
- }
- ,
- t
- }(sT)
- , _T = function(e) {
- function t() {
- return null !== e && e.apply(this, arguments) || this
- }
- return U(t, e),
- t.prototype.getDescription = function() {
- return "Turning render targets off"
- }
- ,
- t.prototype.apply = function(e, t) {
- return e.renderTargetsEnabled = t.isInImprovementMode,
- !0
- }
- ,
- t
- }(sT)
- , mT = function(e) {
- function t() {
- var t = null !== e && e.apply(this, arguments) || this;
- return t._canBeMerged = function(e) {
- if (!(e instanceof Vr))
- return !1;
- var t = e;
- return !(t.isDisposed() || !t.isVisible || !t.isEnabled() || t.instances.length > 0 || t.skeleton || t.hasLODLevels)
- }
- ,
- t
- }
- return U(t, e),
- Object.defineProperty(t, "UpdateSelectionTree", {
- get: function() {
- return t._UpdateSelectionTree
- },
- set: function(e) {
- t._UpdateSelectionTree = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getDescription = function() {
- return "Merging similar meshes together"
- }
- ,
- t.prototype.apply = function(e, i, n) {
- for (var r = e.meshes.slice(0), o = r.length, a = 0; a < o; a++) {
- var s = new Array
- , l = r[a];
- if (this._canBeMerged(l)) {
- s.push(l);
- for (var c = a + 1; c < o; c++) {
- var u = r[c];
- this._canBeMerged(u) && u.material === l.material && u.checkCollisions === l.checkCollisions && (s.push(u),
- o--,
- r.splice(c, 1),
- c--)
- }
- s.length < 2 || Vr.MergeMeshes(s, void 0, !0)
- }
- }
- var h = e;
- return h.createOrUpdateSelectionOctree && (null != n ? n && h.createOrUpdateSelectionOctree() : t.UpdateSelectionTree && h.createOrUpdateSelectionOctree()),
- !0
- }
- ,
- t._UpdateSelectionTree = !1,
- t
- }(sT)
- , gT = function() {
- function e(e, t) {
- void 0 === e && (e = 60),
- void 0 === t && (t = 2e3),
- this.targetFrameRate = e,
- this.trackerDuration = t,
- this.optimizations = new Array
- }
- return e.prototype.addOptimization = function(e) {
- return this.optimizations.push(e),
- this
- }
- ,
- e.prototype.addCustomOptimization = function(e, t, i) {
- void 0 === i && (i = 0);
- var n = new pT(i);
- return n.onApply = e,
- n.onGetDescription = t,
- this.optimizations.push(n),
- this
- }
- ,
- e.LowDegradationAllowed = function(t) {
- var i = new e(t)
- , n = 0;
- return i.addOptimization(new mT(n)),
- i.addOptimization(new uT(n)),
- i.addOptimization(new dT(n)),
- n++,
- i.addOptimization(new hT(n)),
- i.addOptimization(new fT(n)),
- n++,
- i.addOptimization(new lT(n,1024)),
- i
- }
- ,
- e.ModerateDegradationAllowed = function(t) {
- var i = new e(t)
- , n = 0;
- return i.addOptimization(new mT(n)),
- i.addOptimization(new uT(n)),
- i.addOptimization(new dT(n)),
- n++,
- i.addOptimization(new hT(n)),
- i.addOptimization(new fT(n)),
- n++,
- i.addOptimization(new lT(n,512)),
- n++,
- i.addOptimization(new _T(n)),
- n++,
- i.addOptimization(new cT(n,2)),
- i
- }
- ,
- e.HighDegradationAllowed = function(t) {
- var i = new e(t)
- , n = 0;
- return i.addOptimization(new mT(n)),
- i.addOptimization(new uT(n)),
- i.addOptimization(new dT(n)),
- n++,
- i.addOptimization(new hT(n)),
- i.addOptimization(new fT(n)),
- n++,
- i.addOptimization(new lT(n,256)),
- n++,
- i.addOptimization(new _T(n)),
- n++,
- i.addOptimization(new cT(n,4)),
- i
- }
- ,
- e
- }()
- , vT = function() {
- function e(e, t, i, n) {
- void 0 === i && (i = !0),
- void 0 === n && (n = !1);
- var r = this;
- if (this._isRunning = !1,
- this._currentPriorityLevel = 0,
- this._targetFrameRate = 60,
- this._trackerDuration = 2e3,
- this._currentFrameRate = 0,
- this._improvementMode = !1,
- this.onSuccessObservable = new h,
- this.onNewOptimizationAppliedObservable = new h,
- this.onFailureObservable = new h,
- this._options = t || new gT,
- this._options.targetFrameRate && (this._targetFrameRate = this._options.targetFrameRate),
- this._options.trackerDuration && (this._trackerDuration = this._options.trackerDuration),
- i)
- for (var o = 0, a = 0, s = this._options.optimizations; a < s.length; a++)
- s[a].priority = o++;
- this._improvementMode = n,
- this._scene = e || E.LastCreatedScene,
- this._sceneDisposeObserver = this._scene.onDisposeObservable.add((function() {
- r._sceneDisposeObserver = null,
- r.dispose()
- }
- ))
- }
- return Object.defineProperty(e.prototype, "isInImprovementMode", {
- get: function() {
- return this._improvementMode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentPriorityLevel", {
- get: function() {
- return this._currentPriorityLevel
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentFrameRate", {
- get: function() {
- return this._currentFrameRate
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "targetFrameRate", {
- get: function() {
- return this._targetFrameRate
- },
- set: function(e) {
- this._targetFrameRate = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "trackerDuration", {
- get: function() {
- return this._trackerDuration
- },
- set: function(e) {
- this._trackerDuration = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "optimizations", {
- get: function() {
- return this._options.optimizations
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.stop = function() {
- this._isRunning = !1
- }
- ,
- e.prototype.reset = function() {
- this._currentPriorityLevel = 0
- }
- ,
- e.prototype.start = function() {
- var e = this;
- this._isRunning || (this._isRunning = !0,
- this._scene.executeWhenReady((function() {
- setTimeout((function() {
- e._checkCurrentState()
- }
- ), e._trackerDuration)
- }
- )))
- }
- ,
- e.prototype._checkCurrentState = function() {
- var e = this;
- if (this._isRunning) {
- var t = this._scene
- , i = this._options;
- if (this._currentFrameRate = Math.round(t.getEngine().getFps()),
- this._improvementMode && this._currentFrameRate <= this._targetFrameRate || !this._improvementMode && this._currentFrameRate >= this._targetFrameRate)
- return this._isRunning = !1,
- void this.onSuccessObservable.notifyObservers(this);
- for (var n = !0, r = !0, o = 0; o < i.optimizations.length; o++) {
- var a = i.optimizations[o];
- a.priority === this._currentPriorityLevel && (r = !1,
- n = n && a.apply(t, this),
- this.onNewOptimizationAppliedObservable.notifyObservers(a))
- }
- if (r)
- return this._isRunning = !1,
- void this.onFailureObservable.notifyObservers(this);
- n && this._currentPriorityLevel++,
- t.executeWhenReady((function() {
- setTimeout((function() {
- e._checkCurrentState()
- }
- ), e._trackerDuration)
- }
- ))
- }
- }
- ,
- e.prototype.dispose = function() {
- this.stop(),
- this.onSuccessObservable.clear(),
- this.onFailureObservable.clear(),
- this.onNewOptimizationAppliedObservable.clear(),
- this._sceneDisposeObserver && this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)
- }
- ,
- e.OptimizeAsync = function(t, i, n, r) {
- var o = new e(t,i || gT.ModerateDegradationAllowed(),!1);
- return n && o.onSuccessObservable.add((function() {
- n()
- }
- )),
- r && o.onFailureObservable.add((function() {
- r()
- }
- )),
- o.start(),
- o
- }
- ,
- e
- }()
- , yT = []
- , bT = function(e, t) {
- e.doNotSerialize || (t.vertexData.push(e.serializeVerticeData()),
- yT[e.id] = !0)
- }
- , TT = function(e, t) {
- var i = {}
- , n = e._geometry;
- return n && (e.getScene().getGeometryById(n.id) || bT(n, t.geometries)),
- e.serialize && e.serialize(i),
- i
- }
- , ET = function() {
- function e() {}
- return e.ClearCache = function() {
- yT = []
- }
- ,
- e.Serialize = function(t) {
- return e._Serialize(t)
- }
- ,
- e._Serialize = function(t, i) {
- void 0 === i && (i = !0);
- var n, r, o, s = {};
- if (i && !t.getEngine()._features.supportSyncTextureRead && io.ForceSerializeBuffers && console.warn("The serialization object may not contain the proper base64 encoded texture data! You should use the SerializeAsync method instead."),
- e.ClearCache(),
- s.useDelayedTextureLoading = t.useDelayedTextureLoading,
- s.autoClear = t.autoClear,
- s.clearColor = t.clearColor.asArray(),
- s.ambientColor = t.ambientColor.asArray(),
- s.gravity = t.gravity.asArray(),
- s.collisionsEnabled = t.collisionsEnabled,
- s.useRightHandedSystem = t.useRightHandedSystem,
- t.fogMode && 0 !== t.fogMode && (s.fogMode = t.fogMode,
- s.fogColor = t.fogColor.asArray(),
- s.fogStart = t.fogStart,
- s.fogEnd = t.fogEnd,
- s.fogDensity = t.fogDensity),
- t.isPhysicsEnabled()) {
- var l = t.getPhysicsEngine();
- l && (s.physicsEnabled = !0,
- s.physicsGravity = l.gravity.asArray(),
- s.physicsEngine = l.getPhysicsPluginName())
- }
- t.metadata && (s.metadata = t.metadata),
- s.morphTargetManagers = [];
- for (var c = 0, u = t.meshes; c < u.length; c++) {
- var h = (b = u[c]).morphTargetManager;
- h && s.morphTargetManagers.push(h.serialize())
- }
- for (s.lights = [],
- n = 0; n < t.lights.length; n++)
- (r = t.lights[n]).doNotSerialize || s.lights.push(r.serialize());
- for (s.cameras = [],
- n = 0; n < t.cameras.length; n++) {
- var d = t.cameras[n];
- d.doNotSerialize || s.cameras.push(d.serialize())
- }
- if (t.activeCamera && (s.activeCameraID = t.activeCamera.id),
- Ge.AppendSerializedAnimations(t, s),
- t.animationGroups && t.animationGroups.length > 0) {
- s.animationGroups = [];
- for (var p = 0; p < t.animationGroups.length; p++) {
- var f = t.animationGroups[p];
- s.animationGroups.push(f.serialize())
- }
- }
- if (t.reflectionProbes && t.reflectionProbes.length > 0)
- for (s.reflectionProbes = [],
- n = 0; n < t.reflectionProbes.length; n++) {
- var _ = t.reflectionProbes[n];
- s.reflectionProbes.push(_.serialize())
- }
- for (s.materials = [],
- s.multiMaterials = [],
- n = 0; n < t.materials.length; n++)
- (o = t.materials[n]).doNotSerialize || s.materials.push(o.serialize());
- for (s.multiMaterials = [],
- n = 0; n < t.multiMaterials.length; n++) {
- var m = t.multiMaterials[n];
- s.multiMaterials.push(m.serialize())
- }
- for (t.environmentTexture && (s.environmentTexture = t.environmentTexture.name,
- s.environmentTextureRotationY = t.environmentTexture.rotationY),
- s.environmentIntensity = t.environmentIntensity,
- s.skeletons = [],
- n = 0; n < t.skeletons.length; n++) {
- var g = t.skeletons[n];
- g.doNotSerialize || s.skeletons.push(g.serialize())
- }
- for (s.transformNodes = [],
- n = 0; n < t.transformNodes.length; n++)
- t.transformNodes[n].doNotSerialize || s.transformNodes.push(t.transformNodes[n].serialize());
- s.geometries = {},
- s.geometries.boxes = [],
- s.geometries.spheres = [],
- s.geometries.cylinders = [],
- s.geometries.toruses = [],
- s.geometries.grounds = [],
- s.geometries.planes = [],
- s.geometries.torusKnots = [],
- s.geometries.vertexData = [],
- yT = [];
- var v = t.getGeometries();
- for (n = 0; n < v.length; n++) {
- var y = v[n];
- y.isReady() && bT(y, s.geometries)
- }
- for (s.meshes = [],
- n = 0; n < t.meshes.length; n++) {
- var b;
- if ((b = t.meshes[n])instanceof Vr) {
- var T = b;
- T.doNotSerialize || T.delayLoadState !== a.DELAYLOADSTATE_LOADED && T.delayLoadState !== a.DELAYLOADSTATE_NONE || s.meshes.push(TT(T, s))
- }
- }
- for (s.particleSystems = [],
- n = 0; n < t.particleSystems.length; n++)
- s.particleSystems.push(t.particleSystems[n].serialize(!1));
- for (s.postProcesses = [],
- n = 0; n < t.postProcesses.length; n++)
- s.postProcesses.push(t.postProcesses[n].serialize());
- t.actionManager && (s.actions = t.actionManager.serialize("scene"));
- for (var E = 0, S = t._serializableComponents; E < S.length; E++)
- S[E].serialize(s);
- return s
- }
- ,
- e.SerializeAsync = function(t) {
- var i = e._Serialize(t, !1)
- , n = [];
- return this._CollectPromises(i, n),
- Promise.all(n).then((function() {
- return i
- }
- ))
- }
- ,
- e._CollectPromises = function(e, t) {
- if (Array.isArray(e))
- for (var i = function(i) {
- var r = e[i];
- r instanceof Promise ? t.push(r.then((function(t) {
- return e[i] = t
- }
- ))) : (r instanceof Object || Array.isArray(r)) && n._CollectPromises(r, t)
- }, n = this, r = 0; r < e.length; ++r)
- i(r);
- else if (e instanceof Object) {
- var o = function(i) {
- if (Object.prototype.hasOwnProperty.call(e, i)) {
- var n = e[i];
- n instanceof Promise ? t.push(n.then((function(t) {
- return e[i] = t
- }
- ))) : (n instanceof Object || Array.isArray(n)) && a._CollectPromises(n, t)
- }
- }
- , a = this;
- for (var s in e)
- o(s)
- }
- }
- ,
- e.SerializeMesh = function(t, i, n) {
- void 0 === i && (i = !1),
- void 0 === n && (n = !1);
- var r = {};
- if (e.ClearCache(),
- t = t instanceof Array ? t : [t],
- i || n)
- for (var o = 0; o < t.length; ++o)
- n && t[o].getDescendants().forEach((function(e) {
- e instanceof Vr && t.indexOf(e) < 0 && !e.doNotSerialize && t.push(e)
- }
- )),
- i && t[o].parent && t.indexOf(t[o].parent) < 0 && !t[o].parent.doNotSerialize && t.push(t[o].parent);
- return t.forEach((function(e) {
- !function(e, t) {
- if (e.delayLoadState === a.DELAYLOADSTATE_LOADED || e.delayLoadState === a.DELAYLOADSTATE_NONE) {
- var i = function(i) {
- t.materials = t.materials || [],
- t.materials.some((function(t) {
- return t.id === e.material.id
- }
- )) || t.materials.push(i.serialize())
- };
- if (e.material && !e.material.doNotSerialize)
- if (e.material instanceof Dr) {
- if (t.multiMaterials = t.multiMaterials || [],
- !t.multiMaterials.some((function(t) {
- return t.id === e.material.id
- }
- ))) {
- t.multiMaterials.push(e.material.serialize());
- for (var n = 0, r = e.material.subMaterials; n < r.length; n++) {
- var o = r[n];
- o && i(o)
- }
- }
- } else
- i(e.material);
- else
- e.material || i(e.getScene().defaultMaterial);
- var s = e._geometry;
- s && (t.geometries || (t.geometries = {},
- t.geometries.boxes = [],
- t.geometries.spheres = [],
- t.geometries.cylinders = [],
- t.geometries.toruses = [],
- t.geometries.grounds = [],
- t.geometries.planes = [],
- t.geometries.torusKnots = [],
- t.geometries.vertexData = []),
- bT(s, t.geometries)),
- e.skeleton && !e.skeleton.doNotSerialize && (t.skeletons = t.skeletons || [],
- t.skeletons.push(e.skeleton.serialize())),
- t.meshes = t.meshes || [],
- t.meshes.push(TT(e, t))
- }
- }(e, r)
- }
- )),
- r
- }
- ,
- e
- }()
- , ST = function() {
- function e(t, i) {
- if (void 0 === i && (i = {}),
- !e.IsSupported(t))
- throw "Your browser does not support recording so far.";
- var n = t.getRenderingCanvas();
- if (!n)
- throw "The babylon engine must have a canvas to be recorded";
- this._canvas = n,
- this._canvas.isRecording = !1,
- this._options = V(V({}, e._DefaultOptions), i);
- var r = this._canvas.captureStream(this._options.fps);
- if (this._options.audioTracks)
- for (var o = 0, a = this._options.audioTracks; o < a.length; o++) {
- var s = a[o];
- r.addTrack(s)
- }
- this._mediaRecorder = new MediaRecorder(r,{
- mimeType: this._options.mimeType
- }),
- this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this),
- this._mediaRecorder.onerror = this._handleError.bind(this),
- this._mediaRecorder.onstop = this._handleStop.bind(this)
- }
- return e.IsSupported = function(e) {
- var t = e.getRenderingCanvas();
- return !!t && "function" == typeof t.captureStream
- }
- ,
- Object.defineProperty(e.prototype, "isRecording", {
- get: function() {
- return !!this._canvas && this._canvas.isRecording
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.stopRecording = function() {
- this._canvas && this._mediaRecorder && this.isRecording && (this._canvas.isRecording = !1,
- this._mediaRecorder.stop())
- }
- ,
- e.prototype.startRecording = function(e, t) {
- var i = this;
- if (void 0 === e && (e = "babylonjs.webm"),
- void 0 === t && (t = 7),
- !this._canvas || !this._mediaRecorder)
- throw "Recorder has already been disposed";
- if (this.isRecording)
- throw "Recording already in progress";
- return t > 0 && setTimeout((function() {
- i.stopRecording()
- }
- ), 1e3 * t),
- this._fileName = e,
- this._recordedChunks = [],
- this._resolve = null,
- this._reject = null,
- this._canvas.isRecording = !0,
- this._mediaRecorder.start(this._options.recordChunckSize),
- new Promise((function(e, t) {
- i._resolve = e,
- i._reject = t
- }
- ))
- }
- ,
- e.prototype.dispose = function() {
- this._canvas = null,
- this._mediaRecorder = null,
- this._recordedChunks = [],
- this._fileName = null,
- this._resolve = null,
- this._reject = null
- }
- ,
- e.prototype._handleDataAvailable = function(e) {
- e.data.size > 0 && this._recordedChunks.push(e.data)
- }
- ,
- e.prototype._handleError = function(e) {
- if (this.stopRecording(),
- !this._reject)
- throw new e.error;
- this._reject(e.error)
- }
- ,
- e.prototype._handleStop = function() {
- this.stopRecording();
- var e = new Blob(this._recordedChunks);
- this._resolve && this._resolve(e),
- window.URL.createObjectURL(e),
- this._fileName && gi.Download(e, this._fileName)
- }
- ,
- e._DefaultOptions = {
- mimeType: "video/webm",
- fps: 25,
- recordChunckSize: 3e3
- },
- e
- }();
- function AT(e, t, i, n, r, o) {
- void 0 === r && (r = "image/png"),
- void 0 === o && (o = !1);
- var a = MT(e, t, i)
- , s = a.height
- , l = a.width;
- if (s && l) {
- gi._ScreenshotCanvas || (gi._ScreenshotCanvas = document.createElement("canvas")),
- gi._ScreenshotCanvas.width = l,
- gi._ScreenshotCanvas.height = s;
- var c = gi._ScreenshotCanvas.getContext("2d")
- , u = e.getRenderWidth() / e.getRenderHeight()
- , h = l
- , d = h / u;
- d > s && (h = (d = s) * u);
- var p = Math.max(0, l - h) / 2
- , f = Math.max(0, s - d) / 2;
- e.onEndFrameObservable.addOnce((function() {
- var t = e.getRenderingCanvas();
- c && t && c.drawImage(t, p, f, h, d),
- o ? (gi.EncodeScreenshotCanvasData(void 0, r),
- n && n("")) : gi.EncodeScreenshotCanvasData(n, r)
- }
- ))
- } else
- K.Error("Invalid 'size' parameter !")
- }
- function xT(e, t, i, n) {
- return void 0 === n && (n = "image/png"),
- new Promise((function(r, o) {
- AT(e, t, i, (function(e) {
- void 0 !== e ? r(e) : o(new Error("Data is undefined"))
- }
- ), n)
- }
- ))
- }
- function RT(e, t, i, n, r) {
- return void 0 === r && (r = "image/png"),
- new Promise((function(o) {
- AT(e, t, {
- width: i,
- height: n
- }, (function() {
- o()
- }
- ), r, !0)
- }
- ))
- }
- function CT(e, t, i, n, r, o, s, l, c, u) {
- void 0 === r && (r = "image/png"),
- void 0 === o && (o = 1),
- void 0 === s && (s = !1),
- void 0 === c && (c = !1),
- void 0 === u && (u = !1);
- var h = MT(e, t, i)
- , d = h.height
- , p = h.width
- , f = {
- width: p,
- height: d
- };
- if (d && p) {
- var _ = t.getScene()
- , m = null
- , g = _.activeCameras;
- _.activeCameras = null,
- _.activeCamera !== t && (m = _.activeCamera,
- _.activeCamera = t),
- _.render();
- var v = new ns("screenShot",f,_,!1,!1,a.TEXTURETYPE_UNSIGNED_INT,!1,io.NEAREST_SAMPLINGMODE,void 0,u,void 0,void 0,void 0,o);
- v.renderList = null,
- v.samples = o,
- v.renderSprites = c,
- e.onEndFrameObservable.addOnce((function() {
- v.readPixels(void 0, void 0, void 0, !1).then((function(e) {
- gi.DumpData(p, d, e, n, r, l, !0),
- v.dispose()
- }
- ))
- }
- ));
- var y = function() {
- _.incrementRenderId(),
- _.resetCachedMaterial(),
- v.render(!0),
- _.incrementRenderId(),
- _.resetCachedMaterial(),
- m && (_.activeCamera = m),
- _.activeCameras = g,
- t.getProjectionMatrix(!0),
- _.render()
- };
- if (s) {
- var b = new eb("antialiasing",1,_.activeCamera);
- v.addPostProcess(b),
- b.getEffect().isReady() ? y() : b.getEffect().onCompiled = function() {
- y()
- }
- } else
- y()
- } else
- K.Error("Invalid 'size' parameter !")
- }
- function PT(e, t, i, n, r, o, a, s) {
- return void 0 === n && (n = "image/png"),
- void 0 === r && (r = 1),
- void 0 === o && (o = !1),
- void 0 === s && (s = !1),
- new Promise((function(l, c) {
- CT(e, t, i, (function(e) {
- void 0 !== e ? l(e) : c(new Error("Data is undefined"))
- }
- ), n, r, o, a, s)
- }
- ))
- }
- function MT(e, t, i) {
- var n = 0
- , r = 0;
- if ("object" == typeof i) {
- var o = i.precision ? Math.abs(i.precision) : 1;
- i.width && i.height ? (n = i.height * o,
- r = i.width * o) : i.width && !i.height ? (r = i.width * o,
- n = Math.round(r / e.getAspectRatio(t))) : i.height && !i.width ? (n = i.height * o,
- r = Math.round(n * e.getAspectRatio(t))) : (r = Math.round(e.getRenderWidth() * o),
- n = Math.round(r / e.getAspectRatio(t)))
- } else
- isNaN(i) || (n = i,
- r = i);
- return r && (r = Math.floor(r)),
- n && (n = Math.floor(n)),
- {
- height: 0 | n,
- width: 0 | r
- }
- }
- var IT, OT = {
- CreateScreenshot: AT,
- CreateScreenshotAsync: xT,
- CreateScreenshotWithResizeAsync: RT,
- CreateScreenshotUsingRenderTarget: CT,
- CreateScreenshotUsingRenderTargetAsync: PT
- };
- gi.CreateScreenshot = AT,
- gi.CreateScreenshotAsync = xT,
- gi.CreateScreenshotUsingRenderTarget = CT,
- gi.CreateScreenshotUsingRenderTargetAsync = PT,
- function(e) {
- e[e.Checkbox = 0] = "Checkbox",
- e[e.Slider = 1] = "Slider",
- e[e.Vector3 = 2] = "Vector3",
- e[e.Quaternion = 3] = "Quaternion",
- e[e.Color3 = 4] = "Color3",
- e[e.String = 5] = "String",
- e[e.Button = 6] = "Button",
- e[e.Options = 7] = "Options",
- e[e.Tab = 8] = "Tab"
- }(IT || (IT = {}));
- var DT, NT = function() {
- function e(e) {
- this.byteOffset = 0,
- this.buffer = e
- }
- return e.prototype.loadAsync = function(e) {
- var t = this;
- return this.buffer.readAsync(this.byteOffset, e).then((function(e) {
- t._dataView = new DataView(e.buffer,e.byteOffset,e.byteLength),
- t._dataByteOffset = 0
- }
- ))
- }
- ,
- e.prototype.readUint32 = function() {
- var e = this._dataView.getUint32(this._dataByteOffset, !0);
- return this._dataByteOffset += 4,
- this.byteOffset += 4,
- e
- }
- ,
- e.prototype.readUint8Array = function(e) {
- var t = new Uint8Array(this._dataView.buffer,this._dataView.byteOffset + this._dataByteOffset,e);
- return this._dataByteOffset += e,
- this.byteOffset += e,
- t
- }
- ,
- e.prototype.readString = function(e) {
- return se(this.readUint8Array(e))
- }
- ,
- e.prototype.skipBytes = function(e) {
- this._dataByteOffset += e,
- this.byteOffset += e
- }
- ,
- e
- }(), LT = function() {
- function e() {}
- return e._GetStorage = function() {
- try {
- return localStorage.setItem("test", ""),
- localStorage.removeItem("test"),
- localStorage
- } catch (t) {
- var e = {};
- return {
- getItem: function(t) {
- var i = e[t];
- return void 0 === i ? null : i
- },
- setItem: function(t, i) {
- e[t] = i
- }
- }
- }
- }
- ,
- e.ReadString = function(e, t) {
- var i = this._Storage.getItem(e);
- return null !== i ? i : t
- }
- ,
- e.WriteString = function(e, t) {
- this._Storage.setItem(e, t)
- }
- ,
- e.ReadBoolean = function(e, t) {
- var i = this._Storage.getItem(e);
- return null !== i ? "true" === i : t
- }
- ,
- e.WriteBoolean = function(e, t) {
- this._Storage.setItem(e, t ? "true" : "false")
- }
- ,
- e.ReadNumber = function(e, t) {
- var i = this._Storage.getItem(e);
- return null !== i ? parseFloat(i) : t
- }
- ,
- e.WriteNumber = function(e, t) {
- this._Storage.setItem(e, t.toString())
- }
- ,
- e._Storage = e._GetStorage(),
- e
- }(), FT = function() {
- function e() {
- this._trackedScene = null
- }
- return e.prototype.track = function(e) {
- this._trackedScene = e,
- Ge.AllowLoadingUniqueId = !0,
- this._savedJSON = ET.Serialize(e),
- Ge.AllowLoadingUniqueId = !1
- }
- ,
- e.prototype.getDelta = function() {
- if (!this._trackedScene)
- return null;
- var e = io.ForceSerializeBuffers;
- io.ForceSerializeBuffers = !1,
- Ge.AllowLoadingUniqueId = !0;
- var t = ET.Serialize(this._trackedScene);
- Ge.AllowLoadingUniqueId = !1;
- var i = {};
- for (var n in t)
- this._compareCollections(n, this._savedJSON[n], t[n], i);
- return io.ForceSerializeBuffers = e,
- i
- }
- ,
- e.prototype._compareArray = function(e, t, i, n) {
- if (0 === t.length && 0 === i.length)
- return !0;
- if (t.length && !isNaN(t[0]) || i.length && !isNaN(i[0])) {
- if (t.length !== i.length)
- return !1;
- if (0 === t.length)
- return !0;
- for (var r = 0; r < t.length; r++)
- if (t[r] !== i[r])
- return n[e] = i,
- !1;
- return !0
- }
- var o = []
- , a = function(r) {
- var a = t[r]
- , l = a.uniqueId;
- o.push(l);
- var c = i.filter((function(e) {
- return e.uniqueId === l
- }
- ));
- if (c.length) {
- var u = c[0]
- , h = {};
- s._compareObjects(a, u, h) || (n[e] || (n[e] = []),
- h.__state = {
- id: u.id || u.name
- },
- n[e].push(h))
- } else
- h = {
- __state: {
- deleteId: a.id || a.name
- }
- },
- n[e].push(h)
- }
- , s = this;
- for (r = 0; r < t.length; r++)
- a(r);
- for (r = 0; r < i.length; r++) {
- var l = i[r]
- , c = l.uniqueId;
- -1 === o.indexOf(c) && (n[e] || (n[e] = []),
- n[e].push(l))
- }
- return !0
- }
- ,
- e.prototype._compareObjects = function(e, t, i) {
- var n = !1;
- for (var r in e)
- if (Object.prototype.hasOwnProperty.call(e, r)) {
- var o = e[r]
- , a = t[r]
- , s = !1;
- if (Array.isArray(o))
- s = JSON.stringify(o) !== JSON.stringify(a);
- else if (isNaN(o) && "[object String]" != Object.prototype.toString.call(o)) {
- if ("object" == typeof o && "object" == typeof a) {
- var l = {};
- this._compareObjects(o, a, l) || (i[r] = l,
- n = !0)
- }
- } else
- s = o !== a;
- s && (n = !0,
- i[r] = a)
- }
- return !n
- }
- ,
- e.prototype._compareCollections = function(e, t, i, n) {
- if (t !== i && t && i)
- if (Array.isArray(t) && Array.isArray(i)) {
- if (this._compareArray(e, t, i, n))
- return
- } else if ("object" == typeof t && "object" == typeof i) {
- var r = {};
- return void (this._compareObjects(t, i, r) || (n[e] = r))
- }
- }
- ,
- e.GetShadowGeneratorById = function(e, t) {
- for (var i = 0, n = e.lights.map((function(e) {
- return e.getShadowGenerator()
- }
- )); i < n.length; i++) {
- var r = n[i];
- if (r && r.id === t)
- return r
- }
- return null
- }
- ,
- e.ApplyDelta = function(e, t) {
- var i = this;
- "string" == typeof e && (e = JSON.parse(e));
- var n = t;
- for (var r in e) {
- var o = e[r]
- , a = n[r];
- if (Array.isArray(a) || "shadowGenerators" === r)
- switch (r) {
- case "cameras":
- this._ApplyDeltaForEntity(o, t, t.getCameraById.bind(t), (function(e) {
- return Rr.Parse(e, t)
- }
- ));
- break;
- case "lights":
- this._ApplyDeltaForEntity(o, t, t.getLightById.bind(t), (function(e) {
- return Cr.Parse(e, t)
- }
- ));
- break;
- case "shadowGenerators":
- this._ApplyDeltaForEntity(o, t, (function(e) {
- return i.GetShadowGeneratorById(t, e)
- }
- ), (function(e) {
- return r_.Parse(e, t)
- }
- ));
- break;
- case "meshes":
- this._ApplyDeltaForEntity(o, t, t.getMeshById.bind(t), (function(e) {
- return Vr.Parse(e, t, "")
- }
- ));
- break;
- case "skeletons":
- this._ApplyDeltaForEntity(o, t, t.getSkeletonById.bind(t), (function(e) {
- return Fo.Parse(e, t)
- }
- ));
- break;
- case "materials":
- this._ApplyDeltaForEntity(o, t, t.getMaterialById.bind(t), (function(e) {
- return Or.Parse(e, t, "")
- }
- ));
- break;
- case "multiMaterials":
- this._ApplyDeltaForEntity(o, t, t.getMaterialById.bind(t), (function(e) {
- return Dr.Parse(e, t, "")
- }
- ));
- break;
- case "transformNodes":
- this._ApplyDeltaForEntity(o, t, t.getTransformNodeById.bind(t), (function(e) {
- return yr.Parse(e, t, "")
- }
- ));
- break;
- case "particleSystems":
- this._ApplyDeltaForEntity(o, t, t.getParticleSystemById.bind(t), (function(e) {
- return fy.Parse(e, t, "")
- }
- ));
- break;
- case "morphTargetManagers":
- this._ApplyDeltaForEntity(o, t, t.getMorphTargetById.bind(t), (function(e) {
- return x_.Parse(e, t)
- }
- ));
- break;
- case "postProcesses":
- this._ApplyDeltaForEntity(o, t, t.getPostProcessByName.bind(t), (function(e) {
- return Ba.Parse(e, t, "")
- }
- ))
- }
- else
- isNaN(a) ? a.fromArray && a.fromArray(o) : n[r] = o
- }
- }
- ,
- e._ApplyPropertiesToEntity = function(e, t) {
- for (var i in e) {
- var n = e[i]
- , r = t[i];
- void 0 !== r && (!isNaN(r) || Array.isArray(r) ? t[i] = n : r.fromArray ? r.fromArray(n) : "object" == typeof r && null !== r && this._ApplyPropertiesToEntity(n, r))
- }
- }
- ,
- e._ApplyDeltaForEntity = function(e, t, i, n) {
- for (var r = 0, o = e; r < o.length; r++) {
- var a = o[r];
- if (a.__state && void 0 !== a.__state.id) {
- var s = i(a.__state.id);
- s && this._ApplyPropertiesToEntity(a, s)
- } else if (a.__state && void 0 !== a.__state.deleteId) {
- var l = i(a.__state.deleteId);
- null == l || l.dispose()
- } else
- n(a)
- }
- }
- ,
- e
- }();
- !function(e) {
- var t = function() {
- function e(e, t, i, n) {
- var r;
- void 0 === t && (t = null),
- void 0 === i && (i = null),
- void 0 === n && (n = null),
- t = null != t ? t : function() {
- return 1
- }
- ,
- i = null != i ? i : function() {
- return 1
- }
- ,
- n = null != n ? n : function(e, t) {
- return e === t ? 0 : 1
- }
- ,
- this._characterToIdx = new Map,
- this._insertionCosts = new Array(e.length),
- this._deletionCosts = new Array(e.length),
- this._substitutionCosts = new Array(e.length);
- for (var o = 0; o < e.length; ++o) {
- r = e[o],
- this._characterToIdx.set(r, o),
- this._insertionCosts[o] = t(r),
- this._deletionCosts[o] = i(r),
- this._substitutionCosts[o] = new Array(e.length);
- for (var a = o; a < e.length; ++a)
- this._substitutionCosts[o][a] = n(r, e[a])
- }
- }
- return e.prototype.serialize = function() {
- var e = {}
- , t = new Array(this._characterToIdx.size);
- return this._characterToIdx.forEach((function(e, i) {
- t[e] = i
- }
- )),
- e.characters = t,
- e.insertionCosts = this._insertionCosts,
- e.deletionCosts = this._deletionCosts,
- e.substitutionCosts = this._substitutionCosts,
- JSON.stringify(e)
- }
- ,
- e.Deserialize = function(t) {
- var i = JSON.parse(t)
- , n = new e(i.characters);
- return n._insertionCosts = i.insertionCosts,
- n._deletionCosts = i.deletionCosts,
- n._substitutionCosts = i.substitutionCosts,
- n
- }
- ,
- e.prototype.getCharacterIdx = function(e) {
- return this._characterToIdx.get(e)
- }
- ,
- e.prototype.getInsertionCost = function(e) {
- return this._insertionCosts[e]
- }
- ,
- e.prototype.getDeletionCost = function(e) {
- return this._deletionCosts[e]
- }
- ,
- e.prototype.getSubstitutionCost = function(e, t) {
- var i = Math.min(e, t)
- , n = Math.max(e, t);
- return this._substitutionCosts[i][n]
- }
- ,
- e
- }();
- e.Alphabet = t;
- var i = function() {
- function e(t, i) {
- var n = this;
- if (t.length > e._MAX_SEQUENCE_LENGTH)
- throw new Error("Sequences longer than " + e._MAX_SEQUENCE_LENGTH + " not supported.");
- this._alphabet = i,
- this._characters = t.map((function(e) {
- return n._alphabet.getCharacterIdx(e)
- }
- ))
- }
- return e.prototype.serialize = function() {
- return JSON.stringify(this._characters)
- }
- ,
- e.Deserialize = function(t, i) {
- var n = new e([],i);
- return n._characters = JSON.parse(t),
- n
- }
- ,
- e.prototype.distance = function(t) {
- return e._Distance(this, t)
- }
- ,
- e._Distance = function(t, i) {
- var n = t._alphabet;
- if (n !== i._alphabet)
- throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");
- var r = t._characters
- , o = i._characters
- , a = r.length
- , s = o.length
- , l = e._CostMatrix;
- l[0][0] = 0;
- for (var c = 0; c < a; ++c)
- l[c + 1][0] = l[c][0] + n.getInsertionCost(r[c]);
- for (c = 0; c < s; ++c)
- l[0][c + 1] = l[0][c] + n.getInsertionCost(o[c]);
- for (var u = 0; u < a; ++u)
- for (var h = 0; h < s; ++h)
- e._InsertionCost = l[u + 1][h] + n.getInsertionCost(o[h]),
- e._DeletionCost = l[u][h + 1] + n.getDeletionCost(r[u]),
- e._SubstitutionCost = l[u][h] + n.getSubstitutionCost(r[u], o[h]),
- l[u + 1][h + 1] = Math.min(e._InsertionCost, e._DeletionCost, e._SubstitutionCost);
- return l[a][s]
- }
- ,
- e._MAX_SEQUENCE_LENGTH = 256,
- e._CostMatrix = W([], Array(e._MAX_SEQUENCE_LENGTH + 1), !0).map((function() {
- return new Array(e._MAX_SEQUENCE_LENGTH + 1)
- }
- )),
- e
- }();
- e.Sequence = i
- }(DT || (DT = {}));
- var wT = function() {
- function e(e) {
- void 0 === e && (e = .01),
- this._points = [],
- this._segmentLength = e
- }
- return e.prototype.serialize = function() {
- return JSON.stringify(this)
- }
- ,
- e.Deserialize = function(t) {
- var i = JSON.parse(t)
- , n = new e(i._segmentLength);
- return n._points = i._points.map((function(e) {
- return new x(e._x,e._y,e._z)
- }
- )),
- n
- }
- ,
- e.prototype.getLength = function() {
- return this._points.length * this._segmentLength
- }
- ,
- e.prototype.add = function(e) {
- var t = this
- , i = this._points.length;
- if (0 === i)
- this._points.push(e.clone());
- else
- for (var n = function() {
- return t._segmentLength / x.Distance(t._points[i - 1], e)
- }, r = n(); r <= 1; r = n()) {
- var o = this._points[i - 1].scale(1 - r);
- e.scaleAndAddToRef(r, o),
- this._points.push(o),
- ++i
- }
- }
- ,
- e.prototype.resampleAtTargetResolution = function(t) {
- var i = new e(this.getLength() / t);
- return this._points.forEach((function(e) {
- i.add(e)
- }
- )),
- i
- }
- ,
- e.prototype.tokenize = function(t) {
- for (var i = [], n = new x, r = 2; r < this._points.length; ++r)
- e._TransformSegmentDirToRef(this._points[r - 2], this._points[r - 1], this._points[r], n) && i.push(e._TokenizeSegment(n, t));
- return i
- }
- ,
- e._TransformSegmentDirToRef = function(t, i, n, r) {
- return i.subtractToRef(t, e._ForwardDir),
- e._ForwardDir.normalize(),
- i.scaleToRef(-1, e._InverseFromVec),
- e._InverseFromVec.normalize(),
- !(Math.abs(x.Dot(e._ForwardDir, e._InverseFromVec)) > .98 || (x.CrossToRef(e._ForwardDir, e._InverseFromVec, e._UpDir),
- e._UpDir.normalize(),
- P.LookAtLHToRef(t, i, e._UpDir, e._LookMatrix),
- n.subtractToRef(i, e._FromToVec),
- e._FromToVec.normalize(),
- x.TransformNormalToRef(e._FromToVec, e._LookMatrix, r),
- 0))
- }
- ,
- e._TokenizeSegment = function(t, i) {
- e._BestMatch = 0,
- e._Score = x.Dot(t, i[0]),
- e._BestScore = e._Score;
- for (var n = 1; n < i.length; ++n)
- e._Score = x.Dot(t, i[n]),
- e._Score > e._BestScore && (e._BestMatch = n,
- e._BestScore = e._Score);
- return e._BestMatch
- }
- ,
- e._ForwardDir = new x,
- e._InverseFromVec = new x,
- e._UpDir = new x,
- e._FromToVec = new x,
- e._LookMatrix = new P,
- e
- }()
- , BT = function() {
- function e(e) {
- this.chars = new Array(e)
- }
- return e.Generate = function(t, i, n, r, o) {
- void 0 === t && (t = 64),
- void 0 === i && (i = 256),
- void 0 === n && (n = .1),
- void 0 === r && (r = .001),
- void 0 === o && (o = []);
- for (var a, s, l = new e(t), c = 0; c < t; ++c)
- l.chars[c] = new x(Math.random() - .5,Math.random() - .5,Math.random() - .5),
- l.chars[c].normalize();
- for (c = 0; c < o.length; ++c)
- l.chars[c].copyFrom(o[c]);
- for (var u, h = new x, d = new x, p = 0; p < i; ++p) {
- a = (1 - (u = p / (i - 1))) * n + u * r;
- var f = function(e) {
- h.copyFromFloats(0, 0, 0),
- l.chars.forEach((function(t) {
- l.chars[e].subtractToRef(t, d),
- (s = d.lengthSquared()) > 1e-6 && d.scaleAndAddToRef(1 / (d.lengthSquared() * s), h)
- }
- )),
- h.scaleInPlace(a),
- l.chars[e].addInPlace(h),
- l.chars[e].normalize()
- };
- for (c = o.length; c < l.chars.length; ++c)
- f(c)
- }
- return l
- }
- ,
- e.prototype.serialize = function() {
- return JSON.stringify(this.chars)
- }
- ,
- e.Deserialize = function(t) {
- for (var i = JSON.parse(t), n = new e(i.length), r = 0; r < i.length; ++r)
- n.chars[r] = new x(i[r]._x,i[r]._y,i[r]._z);
- return n
- }
- ,
- e
- }()
- , UT = function() {
- function e() {
- this._sequences = []
- }
- return e.prototype.serialize = function() {
- return JSON.stringify(this._sequences.map((function(e) {
- return e.serialize()
- }
- )))
- }
- ,
- e.Deserialize = function(t, i) {
- var n = new e;
- return n._sequences = JSON.parse(t).map((function(e) {
- return DT.Sequence.Deserialize(e, i)
- }
- )),
- n
- }
- ,
- e.CreateFromTrajectory = function(t, i, n) {
- return e.CreateFromTokenizationPyramid(e._GetTokenizationPyramid(t, i), n)
- }
- ,
- e.CreateFromTokenizationPyramid = function(t, i) {
- var n = new e;
- return n._sequences = t.map((function(e) {
- return new DT.Sequence(e,i)
- }
- )),
- n
- }
- ,
- e._GetTokenizationPyramid = function(t, i, n) {
- void 0 === n && (n = e._FINEST_DESCRIPTOR_RESOLUTION);
- for (var r = [], o = n; o > 4; o = Math.floor(o / 2))
- r.push(t.resampleAtTargetResolution(o).tokenize(i.chars));
- return r
- }
- ,
- e.prototype.distance = function(e) {
- for (var t = 0, i = 0; i < this._sequences.length; ++i)
- t += Math.pow(2, i) * this._sequences[i].distance(e._sequences[i]);
- return t
- }
- ,
- e._FINEST_DESCRIPTOR_RESOLUTION = 32,
- e
- }()
- , VT = function() {
- function e(e) {
- void 0 === e && (e = []),
- this._descriptors = e,
- this._centroidIdx = -1,
- this._averageDistance = 0,
- this._refreshDescription()
- }
- return e.prototype.serialize = function() {
- var e = {};
- return e.descriptors = this._descriptors.map((function(e) {
- return e.serialize()
- }
- )),
- e.centroidIdx = this._centroidIdx,
- e.averageDistance = this._averageDistance,
- JSON.stringify(e)
- }
- ,
- e.Deserialize = function(t, i) {
- var n = JSON.parse(t)
- , r = new e;
- return r._descriptors = n.descriptors.map((function(e) {
- return UT.Deserialize(e, i)
- }
- )),
- r._centroidIdx = n.centroidIdx,
- r._averageDistance = n.averageDistance,
- r
- }
- ,
- e.prototype.add = function(e) {
- this._descriptors.push(e),
- this._refreshDescription()
- }
- ,
- e.prototype.getMatchCost = function(e) {
- return e.distance(this._descriptors[this._centroidIdx]) / this._averageDistance
- }
- ,
- e.prototype.getMatchMinimumDistance = function(e) {
- return Math.min.apply(Math, this._descriptors.map((function(t) {
- return t.distance(e)
- }
- )))
- }
- ,
- e.prototype._refreshDescription = function() {
- var t, i = this;
- this._centroidIdx = -1;
- for (var n = this._descriptors.map((function(e) {
- return t = 0,
- i._descriptors.forEach((function(i) {
- t += e.distance(i)
- }
- )),
- t
- }
- )), r = 0; r < n.length; ++r)
- (this._centroidIdx < 0 || n[r] < n[this._centroidIdx]) && (this._centroidIdx = r);
- this._averageDistance = 0,
- this._descriptors.forEach((function(e) {
- i._averageDistance += e.distance(i._descriptors[i._centroidIdx])
- }
- )),
- this._descriptors.length > 0 && (this._averageDistance = Math.max(this._averageDistance / this._descriptors.length, e._MIN_AVERAGE_DISTANCE))
- }
- ,
- e._MIN_AVERAGE_DISTANCE = 1,
- e
- }()
- , kT = function() {
- function e() {
- this._maximumAllowableMatchCost = 4,
- this._nameToDescribedTrajectory = new Map
- }
- return e.prototype.serialize = function() {
- var e = {};
- return e.maximumAllowableMatchCost = this._maximumAllowableMatchCost,
- e.vector3Alphabet = this._vector3Alphabet.serialize(),
- e.levenshteinAlphabet = this._levenshteinAlphabet.serialize(),
- e.nameToDescribedTrajectory = [],
- this._nameToDescribedTrajectory.forEach((function(t, i) {
- e.nameToDescribedTrajectory.push(i),
- e.nameToDescribedTrajectory.push(t.serialize())
- }
- )),
- JSON.stringify(e)
- }
- ,
- e.Deserialize = function(t) {
- var i = JSON.parse(t)
- , n = new e;
- n._maximumAllowableMatchCost = i.maximumAllowableMatchCost,
- n._vector3Alphabet = BT.Deserialize(i.vector3Alphabet),
- n._levenshteinAlphabet = DT.Alphabet.Deserialize(i.levenshteinAlphabet);
- for (var r = 0; r < i.nameToDescribedTrajectory.length; r += 2)
- n._nameToDescribedTrajectory.set(i.nameToDescribedTrajectory[r], VT.Deserialize(i.nameToDescribedTrajectory[r + 1], n._levenshteinAlphabet));
- return n
- }
- ,
- e.Generate = function() {
- for (var t = BT.Generate(64, 256, .1, .001, [x.Forward()]), i = new Array(t.chars.length), n = 0; n < i.length; ++n)
- i[n] = n;
- var r = new DT.Alphabet(i,(function(e) {
- return 0 === e ? 0 : 1
- }
- ),(function(e) {
- return 0 === e ? 0 : 1
- }
- ),(function(e, i) {
- return Math.min(1 - x.Dot(t.chars[e], t.chars[i]), 1)
- }
- ))
- , o = new e;
- return o._vector3Alphabet = t,
- o._levenshteinAlphabet = r,
- o
- }
- ,
- e.prototype.addTrajectoryToClassification = function(e, t) {
- this._nameToDescribedTrajectory.has(t) || this._nameToDescribedTrajectory.set(t, new VT),
- this._nameToDescribedTrajectory.get(t).add(UT.CreateFromTrajectory(e, this._vector3Alphabet, this._levenshteinAlphabet))
- }
- ,
- e.prototype.deleteClassification = function(e) {
- return this._nameToDescribedTrajectory.delete(e)
- }
- ,
- e.prototype.classifyTrajectory = function(e) {
- var t = this
- , i = UT.CreateFromTrajectory(e, this._vector3Alphabet, this._levenshteinAlphabet)
- , n = [];
- if (this._nameToDescribedTrajectory.forEach((function(e, r) {
- e.getMatchCost(i) < t._maximumAllowableMatchCost && n.push(r)
- }
- )),
- 0 === n.length)
- return null;
- for (var r, o = 0, a = this._nameToDescribedTrajectory.get(n[o]).getMatchMinimumDistance(i), s = 0; s < n.length; ++s)
- (r = this._nameToDescribedTrajectory.get(n[s]).getMatchMinimumDistance(i)) < a && (a = r,
- o = s);
- return n[o]
- }
- ,
- e
- }()
- , GT = function() {
- function e(t, i, n) {
- var r = this;
- this._scene = t,
- K.Log("[Reflector] Connecting to ws://".concat(i, ":").concat(n)),
- this._webSocket = new WebSocket("ws://".concat(i, ":").concat(n)),
- this._webSocket.onmessage = function(t) {
- var i = t.data;
- if (ae(i, e._SERVER_PREFIX)) {
- var n = i.substr(e._SERVER_PREFIX.length);
- return K.Log("[Reflector] Received server message: ".concat(n.substr(0, 64))),
- void r._handleServerMessage(n)
- }
- K.Log("[Reflector] Received client message: ".concat(i.substr(0, 64))),
- r._handleClientMessage()
- }
- ,
- this._webSocket.onclose = function(e) {
- K.Log("[Reflector] Disconnected ".concat(e.code, " ").concat(e.reason))
- }
- }
- return e.prototype.close = function() {
- this._webSocket.close()
- }
- ,
- e.prototype._handleServerMessage = function(e) {
- var t = this;
- "connected" === e && ET.SerializeAsync(this._scene).then((function(e) {
- t._webSocket.send("load|".concat(JSON.stringify(e)))
- }
- ))
- }
- ,
- e.prototype._handleClientMessage = function() {}
- ,
- e._SERVER_PREFIX = "$$",
- e
- }()
- , zT = function() {
- function e(e) {
- this._view = new Float32Array(e),
- this._itemLength = 0
- }
- return Object.defineProperty(e.prototype, "itemLength", {
- get: function() {
- return this._itemLength
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.at = function(e) {
- return e < 0 || e >= this._itemLength ? NaN : this._view[e]
- }
- ,
- e.prototype.subarray = function(e, t) {
- return e >= t || e < 0 ? new Float32Array(0) : (t > this._itemLength && (t = this._itemLength),
- this._view.subarray(e, t))
- }
- ,
- e.prototype.push = function(e) {
- this._view[this._itemLength] = e,
- this._itemLength++,
- this._itemLength >= this._view.length && this._growArray()
- }
- ,
- e.prototype._growArray = function() {
- var e = Math.floor(1.5 * this._view.length)
- , t = new Float32Array(e);
- t.set(this._view),
- this._view = t
- }
- ,
- e
- }()
- , WT = 1800
- , HT = "timestamp"
- , XT = "numPoints"
- , jT = /\r/g
- , YT = "@"
- , KT = function() {
- function e(t, i) {
- var n = this;
- this._scene = t,
- this._collectDataAtFrame = function() {
- var t = ct.Now - n._startingTimestamp
- , i = n.datasets.ids.length
- , r = n.datasets.startingIndices.itemLength
- , o = 0;
- if (r > 0) {
- var a = n.datasets.startingIndices.at(r - 1);
- o = a + n.datasets.data.at(a + e.NumberOfPointsOffset) + e.SliceDataOffset
- }
- if (n.datasets.startingIndices.push(o),
- n.datasets.data.push(t),
- n.datasets.data.push(i),
- n.datasets.ids.forEach((function(e) {
- var t = n._strategies.get(e);
- t && n.datasets.data.push(t.getData())
- }
- )),
- n.datasetObservable.hasObservers()) {
- for (var s = [t, i], l = 0; l < i; l++)
- s.push(n.datasets.data.at(o + e.SliceDataOffset + l));
- n.datasetObservable.notifyObservers(s)
- }
- }
- ,
- this.datasets = {
- ids: [],
- data: new zT(WT),
- startingIndices: new zT(WT)
- },
- this._strategies = new Map,
- this._datasetMeta = new Map,
- this._eventRestoreSet = new Set,
- this._customEventObservable = new h,
- this.datasetObservable = new h,
- this.metadataObservable = new h((function(e) {
- return e.callback(n._datasetMeta, new l(0))
- }
- )),
- i && this.addCollectionStrategies.apply(this, i)
- }
- return Object.defineProperty(e, "SliceDataOffset", {
- get: function() {
- return 2
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "NumberOfPointsOffset", {
- get: function() {
- return 1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.registerEvent = function(e, t, i) {
- var n, r = this;
- if (!this._strategies.has(e) || t) {
- this._strategies.has(e) && t && (null === (n = this._strategies.get(e)) || void 0 === n || n.dispose(),
- this._strategies.delete(e));
- var o = {
- name: e
- };
- return this._eventRestoreSet.add(e),
- this.addCollectionStrategies({
- strategyCallback: function(t) {
- var i = 0
- , n = 0
- , o = t.onAfterRenderObservable.add((function() {
- n = i,
- i = 0
- }
- ))
- , a = r._customEventObservable.add((function(t) {
- e === t.name && (void 0 !== t.value ? i = t.value : i++)
- }
- ));
- return {
- id: e,
- getData: function() {
- return n
- },
- dispose: function() {
- t.onAfterRenderObservable.remove(o),
- r._customEventObservable.remove(a)
- }
- }
- },
- category: i
- }),
- o
- }
- }
- ,
- e.prototype.sendEvent = function(e) {
- this._customEventObservable.notifyObservers(e)
- }
- ,
- e.prototype._restoreStringEvents = function() {
- var e = this;
- this._eventRestoreSet.size !== this._customEventObservable.observers.length && this._eventRestoreSet.forEach((function(t) {
- e.registerEvent(t, !0)
- }
- ))
- }
- ,
- e.prototype.addCollectionStrategies = function() {
- for (var e = [], t = 0; t < arguments.length; t++)
- e[t] = arguments[t];
- for (var i = 0, n = e; i < n.length; i++) {
- var r = n[i]
- , o = r.strategyCallback
- , a = r.category
- , s = r.hidden
- , l = o(this._scene);
- this._strategies.has(l.id) ? l.dispose() : (this.datasets.ids.push(l.id),
- a && (a = a.replace(new RegExp(YT,"g"), "")),
- this._datasetMeta.set(l.id, {
- color: this._getHexColorFromId(l.id),
- category: a,
- hidden: s
- }),
- this._strategies.set(l.id, l))
- }
- this.metadataObservable.notifyObservers(this._datasetMeta)
- }
- ,
- e.prototype._getHexColorFromId = function(e) {
- for (var t = 0, i = 0; i < e.length; i++)
- t = e.charCodeAt(i) + ((t << 5) - t);
- var n = "#";
- for (i = 0; i < 24; i += 8)
- n += ("0" + (t >> i & 255).toString(16)).substr(-2);
- return n
- }
- ,
- e.prototype.getCurrentSlice = function() {
- var e = this
- , t = [ct.Now - this._startingTimestamp, this.datasets.ids.length];
- this.datasets.ids.forEach((function(i) {
- var n = e._strategies.get(i);
- n && e.datasetObservable.hasObservers() && t.push(n.getData())
- }
- )),
- this.datasetObservable.hasObservers() && this.datasetObservable.notifyObservers(t)
- }
- ,
- e.prototype.updateMetadata = function(e, t, i) {
- var n = this._datasetMeta.get(e);
- n && (n[t] = i,
- this.metadataObservable.notifyObservers(this._datasetMeta))
- }
- ,
- e.prototype.clear = function(e) {
- this.datasets.data = new zT(WT),
- this.datasets.ids.length = 0,
- this.datasets.startingIndices = new zT(WT),
- this._datasetMeta.clear(),
- this._strategies.forEach((function(e) {
- return e.dispose()
- }
- )),
- this._strategies.clear(),
- e || this._eventRestoreSet.clear(),
- this._hasLoadedData = !1
- }
- ,
- Object.defineProperty(e.prototype, "hasLoadedData", {
- get: function() {
- return this._hasLoadedData
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.loadFromFileData = function(t, i) {
- var n = t.replace(jT, "").split("\n").map((function(e) {
- return e.split(",").filter((function(e) {
- return e.length > 0
- }
- ))
- }
- )).filter((function(e) {
- return e.length > 0
- }
- ))
- , r = e.NumberOfPointsOffset;
- if (n.length < 2)
- return !1;
- var o = {
- ids: [],
- data: new zT(WT),
- startingIndices: new zT(WT)
- }
- , a = n[0]
- , s = n.slice(1);
- if (a.length < 2 || a[0] !== HT || a[r] !== XT)
- return !1;
- for (var l = new Map, c = e.SliceDataOffset; c < a.length; c++) {
- var u = a[c].split(YT)
- , h = u[0]
- , d = u[1];
- o.ids.push(h),
- l.set(h, d)
- }
- for (var p = 0, f = 0, _ = s; f < _.length; f++) {
- var m = _[f];
- if (m.length < 2)
- return !1;
- var g = parseFloat(m[0])
- , v = parseInt(m[r]);
- if (isNaN(v) || isNaN(g))
- return !1;
- if (o.data.push(g),
- o.data.push(v),
- v + e.SliceDataOffset !== m.length)
- return !1;
- for (c = e.SliceDataOffset; c < m.length; c++) {
- var y = parseFloat(m[c]);
- if (isNaN(y))
- return !1;
- o.data.push(y)
- }
- o.startingIndices.push(p),
- p += m.length
- }
- if (this.datasets.ids = o.ids,
- this.datasets.data = o.data,
- this.datasets.startingIndices = o.startingIndices,
- i || this._datasetMeta.clear(),
- this._strategies.forEach((function(e) {
- return e.dispose()
- }
- )),
- this._strategies.clear(),
- !i)
- for (var b = 0, T = this.datasets.ids; b < T.length; b++)
- h = T[b],
- d = l.get(h),
- this._datasetMeta.set(h, {
- category: d,
- color: this._getHexColorFromId(h)
- });
- return this.metadataObservable.notifyObservers(this._datasetMeta),
- this._hasLoadedData = !0,
- !0
- }
- ,
- e.prototype.exportDataToCsv = function() {
- var t = "";
- t += "".concat(HT, ",").concat(XT);
- for (var i = 0; i < this.datasets.ids.length; i++)
- if (t += ",".concat(this.datasets.ids[i]),
- this._datasetMeta) {
- var n = this._datasetMeta.get(this.datasets.ids[i]);
- (null == n ? void 0 : n.category) && (t += "".concat(YT).concat(n.category))
- }
- for (t += "\n",
- i = 0; i < this.datasets.startingIndices.itemLength; i++) {
- var r = this.datasets.startingIndices.at(i)
- , o = this.datasets.data.at(r)
- , a = this.datasets.data.at(r + e.NumberOfPointsOffset);
- t += "".concat(o, ",").concat(a);
- for (var s = 0; s < a; s++)
- t += ",".concat(this.datasets.data.at(r + e.SliceDataOffset + s));
- for (var l = 0; l < this.datasets.ids.length - a; l++)
- t += ",";
- t += "\n"
- }
- var c = "".concat((new Date).toISOString(), "-perfdata.csv");
- gi.Download(new Blob([t],{
- type: "text/csv"
- }), c)
- }
- ,
- e.prototype.start = function(e) {
- e ? void 0 === this._startingTimestamp && (this._startingTimestamp = ct.Now) : (this.datasets.data = new zT(WT),
- this.datasets.startingIndices = new zT(WT),
- this._startingTimestamp = ct.Now),
- this._scene.onAfterRenderObservable.add(this._collectDataAtFrame),
- this._restoreStringEvents(),
- this._isStarted = !0
- }
- ,
- e.prototype.stop = function() {
- this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame),
- this._isStarted = !1
- }
- ,
- Object.defineProperty(e.prototype, "isStarted", {
- get: function() {
- return this._isStarted
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this._scene.onAfterRenderObservable.removeCallback(this._collectDataAtFrame),
- this._datasetMeta.clear(),
- this._strategies.forEach((function(e) {
- e.dispose()
- }
- )),
- this.datasetObservable.clear(),
- this.metadataObservable.clear(),
- this._isStarted = !1,
- this.datasets = null
- }
- ,
- e
- }()
- , QT = function() {}
- , qT = function() {
- function e() {}
- return e.FpsStrategy = function() {
- return function(e) {
- var t = e.getEngine();
- return {
- id: "FPS",
- getData: function() {
- return t.getFps()
- },
- dispose: QT
- }
- }
- }
- ,
- e.CpuStrategy = function() {
- return function(e) {
- var t = 0
- , i = e.onComputePressureChanged.add((function(e) {
- t = e.cpuUtilization
- }
- ));
- return {
- id: "CPU utilization",
- getData: function() {
- return t
- },
- dispose: function() {
- return e.onComputePressureChanged.remove(i)
- }
- }
- }
- }
- ,
- e.TotalMeshesStrategy = function() {
- return function(e) {
- return {
- id: "Total meshes",
- getData: function() {
- return e.meshes.length
- },
- dispose: QT
- }
- }
- }
- ,
- e.ActiveMeshesStrategy = function() {
- return function(e) {
- return {
- id: "Active meshes",
- getData: function() {
- return e.getActiveMeshes().length
- },
- dispose: QT
- }
- }
- }
- ,
- e.ActiveIndicesStrategy = function() {
- return function(e) {
- return {
- id: "Active indices",
- getData: function() {
- return e.getActiveIndices()
- },
- dispose: QT
- }
- }
- }
- ,
- e.ActiveFacesStrategy = function() {
- return function(e) {
- return {
- id: "Active faces",
- getData: function() {
- return e.getActiveIndices() / 3
- },
- dispose: QT
- }
- }
- }
- ,
- e.ActiveBonesStrategy = function() {
- return function(e) {
- return {
- id: "Active bones",
- getData: function() {
- return e.getActiveBones()
- },
- dispose: QT
- }
- }
- }
- ,
- e.ActiveParticlesStrategy = function() {
- return function(e) {
- return {
- id: "Active particles",
- getData: function() {
- return e.getActiveParticles()
- },
- dispose: QT
- }
- }
- }
- ,
- e.DrawCallsStrategy = function() {
- return function(e) {
- var t = 0
- , i = e.onBeforeAnimationsObservable.add((function() {
- e.getEngine()._drawCalls.fetchNewFrame()
- }
- ))
- , n = e.onAfterRenderObservable.add((function() {
- t = e.getEngine()._drawCalls.current
- }
- ));
- return {
- id: "Draw calls",
- getData: function() {
- return t
- },
- dispose: function() {
- e.onBeforeAnimationsObservable.remove(i),
- e.onAfterRenderObservable.remove(n)
- }
- }
- }
- }
- ,
- e.TotalLightsStrategy = function() {
- return function(e) {
- return {
- id: "Total lights",
- getData: function() {
- return e.lights.length
- },
- dispose: QT
- }
- }
- }
- ,
- e.TotalVerticesStrategy = function() {
- return function(e) {
- return {
- id: "Total vertices",
- getData: function() {
- return e.getTotalVertices()
- },
- dispose: QT
- }
- }
- }
- ,
- e.TotalMaterialsStrategy = function() {
- return function(e) {
- return {
- id: "Total materials",
- getData: function() {
- return e.materials.length
- },
- dispose: QT
- }
- }
- }
- ,
- e.TotalTexturesStrategy = function() {
- return function(e) {
- return {
- id: "Total textures",
- getData: function() {
- return e.textures.length
- },
- dispose: QT
- }
- }
- }
- ,
- e.AbsoluteFpsStrategy = function() {
- return function(e) {
- var t = new Yf(e);
- return t.captureFrameTime = !0,
- {
- id: "Absolute FPS",
- getData: function() {
- return 1e3 / t.frameTimeCounter.lastSecAverage
- },
- dispose: QT
- }
- }
- }
- ,
- e.MeshesSelectionStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeActiveMeshesEvaluationObservable.add((function() {
- t = ct.Now
- }
- ))
- , r = e.onAfterActiveMeshesEvaluationObservable.add((function() {
- i = ct.Now - t
- }
- ));
- return {
- id: "Meshes Selection",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeActiveMeshesEvaluationObservable.remove(n),
- e.onAfterActiveMeshesEvaluationObservable.remove(r)
- }
- }
- }
- }
- ,
- e.RenderTargetsStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeRenderTargetsRenderObservable.add((function() {
- t = ct.Now
- }
- ))
- , r = e.onAfterRenderTargetsRenderObservable.add((function() {
- i = ct.Now - t
- }
- ));
- return {
- id: "Render Targets",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeRenderTargetsRenderObservable.remove(n),
- e.onAfterRenderTargetsRenderObservable.remove(r)
- }
- }
- }
- }
- ,
- e.ParticlesStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeParticlesRenderingObservable.add((function() {
- t = ct.Now
- }
- ))
- , r = e.onAfterParticlesRenderingObservable.add((function() {
- i = ct.Now - t
- }
- ));
- return {
- id: "Particles",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeParticlesRenderingObservable.remove(n),
- e.onAfterParticlesRenderingObservable.remove(r)
- }
- }
- }
- }
- ,
- e.SpritesStrategy = function() {
- return function(e) {
- var t, i, n = ct.Now, r = 0, o = null === (t = e.onBeforeSpritesRenderingObservable) || void 0 === t ? void 0 : t.add((function() {
- n = ct.Now
- }
- )), a = null === (i = e.onAfterSpritesRenderingObservable) || void 0 === i ? void 0 : i.add((function() {
- r = ct.Now - n
- }
- ));
- return {
- id: "Sprites",
- getData: function() {
- return r
- },
- dispose: function() {
- var t, i;
- null === (t = e.onBeforeSpritesRenderingObservable) || void 0 === t || t.remove(o),
- null === (i = e.onAfterSpritesRenderingObservable) || void 0 === i || i.remove(a)
- }
- }
- }
- }
- ,
- e.AnimationsStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeAnimationsObservable.add((function() {
- t = ct.Now
- }
- ))
- , r = e.onAfterAnimationsObservable.add((function() {
- i = ct.Now - t
- }
- ));
- return {
- id: "Animations",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeAnimationsObservable.remove(n),
- e.onAfterAnimationsObservable.remove(r)
- }
- }
- }
- }
- ,
- e.PhysicsStrategy = function() {
- return function(e) {
- var t, i, n = ct.Now, r = 0, o = null === (t = e.onBeforePhysicsObservable) || void 0 === t ? void 0 : t.add((function() {
- n = ct.Now
- }
- )), a = null === (i = e.onAfterPhysicsObservable) || void 0 === i ? void 0 : i.add((function() {
- r = ct.Now - n
- }
- ));
- return {
- id: "Physics",
- getData: function() {
- return r
- },
- dispose: function() {
- var t, i;
- null === (t = e.onBeforePhysicsObservable) || void 0 === t || t.remove(o),
- null === (i = e.onAfterPhysicsObservable) || void 0 === i || i.remove(a)
- }
- }
- }
- }
- ,
- e.RenderStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeDrawPhaseObservable.add((function() {
- t = ct.Now
- }
- ))
- , r = e.onAfterDrawPhaseObservable.add((function() {
- i = ct.Now - t
- }
- ));
- return {
- id: "Render",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeDrawPhaseObservable.remove(n),
- e.onAfterDrawPhaseObservable.remove(r)
- }
- }
- }
- }
- ,
- e.FrameTotalStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeAnimationsObservable.add((function() {
- t = ct.Now
- }
- ))
- , r = e.onAfterRenderObservable.add((function() {
- i = ct.Now - t
- }
- ));
- return {
- id: "Frame Total",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeAnimationsObservable.remove(n),
- e.onAfterRenderObservable.remove(r)
- }
- }
- }
- }
- ,
- e.InterFrameStrategy = function() {
- return function(e) {
- var t = ct.Now
- , i = 0
- , n = e.onBeforeAnimationsObservable.add((function() {
- i = ct.Now - t
- }
- ))
- , r = e.onAfterRenderObservable.add((function() {
- t = ct.Now
- }
- ));
- return {
- id: "Inter-frame",
- getData: function() {
- return i
- },
- dispose: function() {
- e.onBeforeAnimationsObservable.remove(n),
- e.onAfterRenderObservable.remove(r)
- }
- }
- }
- }
- ,
- e.GpuFrameTimeStrategy = function() {
- return function(e) {
- var t = new jf(e.getEngine());
- return t.captureGPUFrameTime = !0,
- {
- id: "GPU frame time",
- getData: function() {
- return Math.max(1e-6 * t.gpuFrameTimeCounter.current, 0)
- },
- dispose: function() {
- t.dispose()
- }
- }
- }
- }
- ,
- e
- }();
- mn.prototype.getPerfCollector = function() {
- return this._perfCollector || (this._perfCollector = new KT(this)),
- this._perfCollector
- }
- ,
- h.prototype.runCoroutineAsync = function(e) {
- if (!this._coroutineScheduler) {
- var t = (i = this,
- n = new Array,
- r = new Array,
- o = new Array,
- a = i.add((function() {
- for (var e = n.length, t = 0; t < e; t++)
- jn(n.shift(), r.shift(), o.shift())
- }
- )),
- {
- scheduler: function(e, t, i) {
- n.push(e),
- r.push(t),
- o.push(i)
- },
- dispose: function() {
- i.remove(a)
- }
- });
- this._coroutineScheduler = t.scheduler,
- this._coroutineSchedulerDispose = t.dispose
- }
- var i, n, r, o, a;
- return qn(e, this._coroutineScheduler)
- }
- ,
- h.prototype.cancelAllCoroutines = function() {
- this._coroutineSchedulerDispose && this._coroutineSchedulerDispose(),
- this._coroutineScheduler = void 0,
- this._coroutineSchedulerDispose = void 0
- }
- ;
- var ZT = function(e) {
- function t(i, n) {
- void 0 === n && (n = {});
- var r = e.call(this, i) || this;
- return r.options = n,
- r._direction = new x(0,0,-1),
- r._mat = new P,
- r._onSelectEnabled = !1,
- r._origin = new x(0,0,0),
- r.lastNativeXRHitResults = [],
- r.onHitTestResultObservable = new h,
- r._onHitTestResults = function(e) {
- var t = e.map((function(e) {
- var t = P.FromArray(e.hitMatrix);
- return r._xrSessionManager.scene.useRightHandedSystem || t.toggleModelMatrixHandInPlace(),
- r.options.worldParentNode && t.multiplyToRef(r.options.worldParentNode.getWorldMatrix(), t),
- {
- xrHitResult: e,
- transformationMatrix: t
- }
- }
- ));
- r.lastNativeXRHitResults = e,
- r.onHitTestResultObservable.notifyObservers(t)
- }
- ,
- r._onSelect = function(e) {
- r._onSelectEnabled && t.XRHitTestWithSelectEvent(e, r._xrSessionManager.referenceSpace)
- }
- ,
- r.xrNativeFeatureName = "hit-test",
- gi.Warn("A newer version of this plugin is available"),
- r
- }
- return U(t, e),
- t.XRHitTestWithRay = function(e, t, i, n) {
- return e.requestHitTest(t, i).then((function(e) {
- var t = n || function(e) {
- return !!e.hitMatrix
- }
- ;
- return e.filter(t)
- }
- ))
- }
- ,
- t.XRHitTestWithSelectEvent = function(e, t) {
- var i = e.frame.getPose(e.inputSource.targetRaySpace, t);
- if (!i)
- return Promise.resolve([]);
- var n = new XRRay(i.transform);
- return this.XRHitTestWithRay(e.frame.session, n, t)
- }
- ,
- t.prototype.attach = function() {
- return !!e.prototype.attach.call(this) && (this.options.testOnPointerDownOnly && this._xrSessionManager.session.addEventListener("select", this._onSelect, !1),
- !0)
- }
- ,
- t.prototype.detach = function() {
- return !!e.prototype.detach.call(this) && (this._onSelectEnabled = !1,
- this._xrSessionManager.session.removeEventListener("select", this._onSelect),
- !0)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onHitTestResultObservable.clear()
- }
- ,
- t.prototype._onXRFrame = function(e) {
- if (this.attached && !this.options.testOnPointerDownOnly) {
- var i = e.getViewerPose(this._xrSessionManager.referenceSpace);
- if (i) {
- P.FromArrayToRef(i.transform.matrix, 0, this._mat),
- x.TransformCoordinatesFromFloatsToRef(0, 0, 0, this._mat, this._origin),
- x.TransformCoordinatesFromFloatsToRef(0, 0, -1, this._mat, this._direction),
- this._direction.subtractInPlace(this._origin),
- this._direction.normalize();
- var n = new XRRay({
- x: this._origin.x,
- y: this._origin.y,
- z: this._origin.z,
- w: 0
- },{
- x: this._direction.x,
- y: this._direction.y,
- z: this._direction.z,
- w: 0
- });
- t.XRHitTestWithRay(this._xrSessionManager.session, n, this._xrSessionManager.referenceSpace).then(this._onHitTestResults)
- }
- }
- }
- ,
- t.Name = Io.HIT_TEST,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(ZT.Name, (function(e, t) {
- return function() {
- return new ZT(e,t)
- }
- }
- ), ZT.Version, !1);
- var JT = 0
- , $T = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n = e.call(this, t) || this;
- return n._options = i,
- n._lastFrameDetected = new Set,
- n._trackedAnchors = [],
- n._futureAnchors = [],
- n.onAnchorAddedObservable = new h,
- n.onAnchorRemovedObservable = new h,
- n.onAnchorUpdatedObservable = new h,
- n._tmpVector = new x,
- n._tmpQuaternion = new C,
- n.xrNativeFeatureName = "anchors",
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "referenceSpaceForFrameAnchors", {
- set: function(e) {
- this._referenceSpaceForFrameAnchors = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._populateTmpTransformation = function(e, t) {
- return this._tmpVector.copyFrom(e),
- this._tmpQuaternion.copyFrom(t),
- this._xrSessionManager.scene.useRightHandedSystem || (this._tmpVector.z *= -1,
- this._tmpQuaternion.z *= -1,
- this._tmpQuaternion.w *= -1),
- {
- position: this._tmpVector,
- rotationQuaternion: this._tmpQuaternion
- }
- }
- ,
- t.prototype.addAnchorPointUsingHitTestResultAsync = function(e, t, i) {
- return void 0 === t && (t = new x),
- void 0 === i && (i = new C),
- G(this, void 0, void 0, (function() {
- var n, r, o, a = this;
- return z(this, (function(s) {
- switch (s.label) {
- case 0:
- if (this._populateTmpTransformation(t, i),
- n = new XRRigidTransform({
- x: this._tmpVector.x,
- y: this._tmpVector.y,
- z: this._tmpVector.z
- },{
- x: this._tmpQuaternion.x,
- y: this._tmpQuaternion.y,
- z: this._tmpQuaternion.z,
- w: this._tmpQuaternion.w
- }),
- e.xrHitResult.createAnchor)
- return [3, 1];
- throw this.detach(),
- new Error("Anchors not enabled in this environment/browser");
- case 1:
- return s.trys.push([1, 3, , 4]),
- [4, e.xrHitResult.createAnchor(n)];
- case 2:
- return r = s.sent(),
- [2, new Promise((function(e, t) {
- a._futureAnchors.push({
- nativeAnchor: r,
- resolved: !1,
- submitted: !0,
- xrTransformation: n,
- resolve: e,
- reject: t
- })
- }
- ))];
- case 3:
- throw o = s.sent(),
- new Error(o);
- case 4:
- return [2]
- }
- }
- ))
- }
- ))
- }
- ,
- t.prototype.addAnchorAtPositionAndRotationAsync = function(e, t, i) {
- return void 0 === t && (t = new C),
- void 0 === i && (i = !1),
- G(this, void 0, void 0, (function() {
- var n, r, o, a = this;
- return z(this, (function(s) {
- switch (s.label) {
- case 0:
- return this._populateTmpTransformation(e, t),
- n = new XRRigidTransform({
- x: this._tmpVector.x,
- y: this._tmpVector.y,
- z: this._tmpVector.z
- },{
- x: this._tmpQuaternion.x,
- y: this._tmpQuaternion.y,
- z: this._tmpQuaternion.z,
- w: this._tmpQuaternion.w
- }),
- i && this.attached && this._xrSessionManager.currentFrame ? [4, this._createAnchorAtTransformation(n, this._xrSessionManager.currentFrame)] : [3, 2];
- case 1:
- return o = s.sent(),
- [3, 3];
- case 2:
- o = void 0,
- s.label = 3;
- case 3:
- return r = o,
- [2, new Promise((function(e, t) {
- a._futureAnchors.push({
- nativeAnchor: r,
- resolved: !1,
- submitted: !1,
- xrTransformation: n,
- resolve: e,
- reject: t
- })
- }
- ))]
- }
- }
- ))
- }
- ))
- }
- ,
- Object.defineProperty(t.prototype, "anchors", {
- get: function() {
- return this._trackedAnchors
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.detach = function() {
- if (!e.prototype.detach.call(this))
- return !1;
- if (!this._options.doNotRemoveAnchorsOnSessionEnded)
- for (; this._trackedAnchors.length; ) {
- var t = this._trackedAnchors.pop();
- if (t) {
- try {
- t.remove()
- } catch (e) {}
- this.onAnchorRemovedObservable.notifyObservers(t)
- }
- }
- return !0
- }
- ,
- t.prototype.dispose = function() {
- this._futureAnchors.length = 0,
- e.prototype.dispose.call(this),
- this.onAnchorAddedObservable.clear(),
- this.onAnchorRemovedObservable.clear(),
- this.onAnchorUpdatedObservable.clear()
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t = this;
- if (this.attached && e) {
- var i = e.trackedAnchors;
- if (i) {
- var n = this._trackedAnchors.filter((function(e) {
- return !i.has(e.xrAnchor)
- }
- )).map((function(e) {
- return t._trackedAnchors.indexOf(e)
- }
- ))
- , r = 0;
- n.forEach((function(e) {
- var i = t._trackedAnchors.splice(e - r, 1)[0];
- t.onAnchorRemovedObservable.notifyObservers(i),
- r++
- }
- )),
- i.forEach((function(i) {
- if (t._lastFrameDetected.has(i)) {
- var n = t._findIndexInAnchorArray(i);
- o = t._trackedAnchors[n];
- try {
- t._updateAnchorWithXRFrame(i, o, e),
- o.attachedNode && (o.attachedNode.rotationQuaternion = o.attachedNode.rotationQuaternion || new C,
- o.transformationMatrix.decompose(o.attachedNode.scaling, o.attachedNode.rotationQuaternion, o.attachedNode.position)),
- t.onAnchorUpdatedObservable.notifyObservers(o)
- } catch (e) {
- gi.Warn("Anchor could not be updated")
- }
- } else {
- var r = {
- id: JT++,
- xrAnchor: i,
- remove: function() {
- return i.delete()
- }
- }
- , o = t._updateAnchorWithXRFrame(i, r, e);
- t._trackedAnchors.push(o),
- t.onAnchorAddedObservable.notifyObservers(o);
- var a = t._futureAnchors.filter((function(e) {
- return e.nativeAnchor === i
- }
- ))[0];
- a && (a.resolve(o),
- a.resolved = !0)
- }
- }
- )),
- this._lastFrameDetected = i
- }
- this._futureAnchors.forEach((function(i) {
- i.resolved || i.submitted || (t._createAnchorAtTransformation(i.xrTransformation, e).then((function(e) {
- i.nativeAnchor = e
- }
- ), (function(e) {
- i.resolved = !0,
- i.reject(e)
- }
- )),
- i.submitted = !0)
- }
- ))
- }
- }
- ,
- t.prototype._findIndexInAnchorArray = function(e) {
- for (var t = 0; t < this._trackedAnchors.length; ++t)
- if (this._trackedAnchors[t].xrAnchor === e)
- return t;
- return -1
- }
- ,
- t.prototype._updateAnchorWithXRFrame = function(e, t, i) {
- var n = i.getPose(e.anchorSpace, this._xrSessionManager.referenceSpace);
- if (n) {
- var r = t.transformationMatrix || new P;
- P.FromArrayToRef(n.transform.matrix, 0, r),
- this._xrSessionManager.scene.useRightHandedSystem || r.toggleModelMatrixHandInPlace(),
- t.transformationMatrix = r,
- this._options.worldParentNode && r.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), r)
- }
- return t
- }
- ,
- t.prototype._createAnchorAtTransformation = function(e, t) {
- var i;
- return G(this, void 0, void 0, (function() {
- return z(this, (function(n) {
- if (!t.createAnchor)
- throw this.detach(),
- new Error("Anchors are not enabled in your browser");
- try {
- return [2, t.createAnchor(e, null !== (i = this._referenceSpaceForFrameAnchors) && void 0 !== i ? i : this._xrSessionManager.referenceSpace)]
- } catch (e) {
- throw new Error(e)
- }
- return [2]
- }
- ))
- }
- ))
- }
- ,
- t.Name = Io.ANCHOR_SYSTEM,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature($T.Name, (function(e, t) {
- return function() {
- return new $T(e,t)
- }
- }
- ), $T.Version);
- var eE = 0
- , tE = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n = e.call(this, t) || this;
- return n._options = i,
- n._detectedPlanes = [],
- n._enabled = !1,
- n._lastFrameDetected = new Set,
- n.onPlaneAddedObservable = new h,
- n.onPlaneRemovedObservable = new h,
- n.onPlaneUpdatedObservable = new h,
- n.xrNativeFeatureName = "plane-detection",
- n._xrSessionManager.session ? n._init() : n._xrSessionManager.onXRSessionInit.addOnce((function() {
- n._init()
- }
- )),
- n
- }
- return U(t, e),
- t.prototype.detach = function() {
- if (!e.prototype.detach.call(this))
- return !1;
- if (!this._options.doNotRemovePlanesOnSessionEnded)
- for (; this._detectedPlanes.length; ) {
- var t = this._detectedPlanes.pop();
- t && this.onPlaneRemovedObservable.notifyObservers(t)
- }
- return !0
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onPlaneAddedObservable.clear(),
- this.onPlaneRemovedObservable.clear(),
- this.onPlaneUpdatedObservable.clear()
- }
- ,
- t.prototype.isCompatible = function() {
- return "undefined" != typeof XRPlane
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t, i = this;
- if (this.attached && this._enabled && e) {
- var n = e.detectedPlanes || (null === (t = e.worldInformation) || void 0 === t ? void 0 : t.detectedPlanes);
- if (n) {
- for (var r = 0; r < this._detectedPlanes.length; r++) {
- var o = this._detectedPlanes[r];
- n.has(o.xrPlane) || (this._detectedPlanes.splice(r--, 1),
- this.onPlaneRemovedObservable.notifyObservers(o))
- }
- n.forEach((function(t) {
- if (i._lastFrameDetected.has(t)) {
- if (t.lastChangedTime === i._xrSessionManager.currentTimestamp) {
- var n = i._findIndexInPlaneArray(t);
- o = i._detectedPlanes[n],
- i._updatePlaneWithXRPlane(t, o, e),
- i.onPlaneUpdatedObservable.notifyObservers(o)
- }
- } else {
- var r = {
- id: eE++,
- xrPlane: t,
- polygonDefinition: []
- }
- , o = i._updatePlaneWithXRPlane(t, r, e);
- i._detectedPlanes.push(o),
- i.onPlaneAddedObservable.notifyObservers(o)
- }
- }
- )),
- this._lastFrameDetected = n
- }
- }
- }
- ,
- t.prototype._init = function() {
- var e = this
- , t = function() {
- e._enabled = !0,
- e._detectedPlanes.length && (e._detectedPlanes.length = 0)
- };
- this._xrSessionManager.isNative && this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions && this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions),
- this._xrSessionManager.session.updateWorldTrackingState ? (this._xrSessionManager.session.updateWorldTrackingState({
- planeDetectionState: {
- enabled: !0
- }
- }),
- t()) : t()
- }
- ,
- t.prototype._updatePlaneWithXRPlane = function(e, t, i) {
- var n = this;
- t.polygonDefinition = e.polygon.map((function(e) {
- var t = n._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;
- return new x(e.x,e.y,e.z * t)
- }
- ));
- var r = i.getPose(e.planeSpace, this._xrSessionManager.referenceSpace);
- if (r) {
- var o = t.transformationMatrix || new P;
- P.FromArrayToRef(r.transform.matrix, 0, o),
- this._xrSessionManager.scene.useRightHandedSystem || o.toggleModelMatrixHandInPlace(),
- t.transformationMatrix = o,
- this._options.worldParentNode && o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), o)
- }
- return t
- }
- ,
- t.prototype._findIndexInPlaneArray = function(e) {
- for (var t = 0; t < this._detectedPlanes.length; ++t)
- if (this._detectedPlanes[t].xrPlane === e)
- return t;
- return -1
- }
- ,
- t.Name = Io.PLANE_DETECTION,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(tE.Name, (function(e, t) {
- return function() {
- return new tE(e,t)
- }
- }
- ), tE.Version);
- var iE = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n = e.call(this, t) || this;
- return n.options = i,
- n.onBackgroundStateChangedObservable = new h,
- n
- }
- return U(t, e),
- t.prototype.attach = function() {
- return this._setBackgroundState(!1),
- e.prototype.attach.call(this)
- }
- ,
- t.prototype.detach = function() {
- return this._setBackgroundState(!0),
- e.prototype.detach.call(this)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onBackgroundStateChangedObservable.clear()
- }
- ,
- t.prototype._onXRFrame = function(e) {}
- ,
- t.prototype._setBackgroundState = function(e) {
- var t = this._xrSessionManager.scene;
- if (!this.options.ignoreEnvironmentHelper)
- if (this.options.environmentHelperRemovalFlags) {
- if (this.options.environmentHelperRemovalFlags.skyBox) {
- var i = t.getMeshByName("BackgroundSkybox");
- i && i.setEnabled(e)
- }
- if (this.options.environmentHelperRemovalFlags.ground) {
- var n = t.getMeshByName("BackgroundPlane");
- n && n.setEnabled(e)
- }
- } else {
- var r = t.getMeshByName("BackgroundHelper");
- r && r.setEnabled(e)
- }
- this.options.backgroundMeshes && this.options.backgroundMeshes.forEach((function(t) {
- return t.setEnabled(e)
- }
- )),
- this.onBackgroundStateChangedObservable.notifyObservers(e)
- }
- ,
- t.Name = Io.BACKGROUND_REMOVER,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(iE.Name, (function(e, t) {
- return function() {
- return new iE(e,t)
- }
- }
- ), iE.Version, !0);
- var nE = function() {}
- , rE = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n._options = i,
- n._attachController = function(e) {
- n._controllers[e.uniqueId] || (n._xrSessionManager.scene.isPhysicsEnabled() || K.Warn("physics engine not enabled, skipped. Please add this controller manually."),
- n._options.physicsProperties.useControllerMesh && e.inputSource.gamepad ? e.onMotionControllerInitObservable.addOnce((function(t) {
- t._doNotLoadControllerMesh ? n._createPhysicsImpostor(e) : t.onModelLoadedObservable.addOnce((function() {
- var i = new Vl(t.rootMesh,Vl.MeshImpostor,V({
- mass: 0
- }, n._options.physicsProperties))
- , r = e.grip || e.pointer;
- n._controllers[e.uniqueId] = {
- xrController: e,
- impostor: i,
- oldPos: r.position.clone(),
- oldRotation: r.rotationQuaternion.clone()
- }
- }
- ))
- }
- )) : n._createPhysicsImpostor(e))
- }
- ,
- n._controllers = {},
- n._debugMode = !1,
- n._delta = 0,
- n._lastTimestamp = 0,
- n._tmpQuaternion = new C,
- n._tmpVector = new x,
- n._options.physicsProperties || (n._options.physicsProperties = {}),
- n
- }
- return U(t, e),
- t.prototype._createPhysicsImpostor = function(e) {
- var t = this._options.physicsProperties.impostorType || Vl.SphereImpostor
- , i = this._options.physicsProperties.impostorSize || .1
- , n = Dl("impostor-mesh-" + e.uniqueId, {
- diameterX: "number" == typeof i ? i : i.width,
- diameterY: "number" == typeof i ? i : i.height,
- diameterZ: "number" == typeof i ? i : i.depth
- });
- n.isVisible = this._debugMode,
- n.isPickable = !1,
- n.rotationQuaternion = new C;
- var r = e.grip || e.pointer;
- n.position.copyFrom(r.position),
- n.rotationQuaternion.copyFrom(r.rotationQuaternion);
- var o = new Vl(n,t,V({
- mass: 0
- }, this._options.physicsProperties));
- this._controllers[e.uniqueId] = {
- xrController: e,
- impostor: o,
- impostorMesh: n
- }
- }
- ,
- t.prototype._enablePhysicsDebug = function() {
- var e = this;
- this._debugMode = !0,
- Object.keys(this._controllers).forEach((function(t) {
- var i = e._controllers[t];
- i.impostorMesh && (i.impostorMesh.isVisible = !0)
- }
- ))
- }
- ,
- t.prototype.addController = function(e) {
- this._attachController(e)
- }
- ,
- t.prototype.attach = function() {
- var t = this;
- if (!e.prototype.attach.call(this))
- return !1;
- if (!this._options.xrInput)
- return !0;
- if (this._options.xrInput.controllers.forEach(this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, (function(e) {
- t._detachController(e.uniqueId)
- }
- )),
- this._options.enableHeadsetImpostor) {
- var i = this._options.headsetImpostorParams || {
- impostorType: Vl.SphereImpostor,
- restitution: .8,
- impostorSize: .3
- }
- , n = i.impostorSize || .3;
- this._headsetMesh = Dl("headset-mesh", {
- diameterX: "number" == typeof n ? n : n.width,
- diameterY: "number" == typeof n ? n : n.height,
- diameterZ: "number" == typeof n ? n : n.depth
- }),
- this._headsetMesh.rotationQuaternion = new C,
- this._headsetMesh.isVisible = !1,
- this._headsetImpostor = new Vl(this._headsetMesh,i.impostorType,V({
- mass: 0
- }, i))
- }
- return !0
- }
- ,
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
- t._detachController(e)
- }
- )),
- this._headsetMesh && this._headsetMesh.dispose(),
- !0)
- }
- ,
- t.prototype.getHeadsetImpostor = function() {
- return this._headsetImpostor
- }
- ,
- t.prototype.getImpostorForController = function(e) {
- var t = "string" == typeof e ? e : e.uniqueId;
- return this._controllers[t] ? this._controllers[t].impostor : null
- }
- ,
- t.prototype.setPhysicsProperties = function(e) {
- this._options.physicsProperties = V(V({}, this._options.physicsProperties), e)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t, i, n = this;
- if (this._delta = this._xrSessionManager.currentTimestamp - this._lastTimestamp,
- this._lastTimestamp = this._xrSessionManager.currentTimestamp,
- this._headsetMesh && this._headsetImpostor) {
- if (this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.globalPosition),
- this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.absoluteRotation),
- null === (t = this._options.xrInput.xrCamera._lastXRViewerPose) || void 0 === t ? void 0 : t.linearVelocity) {
- var r = this._options.xrInput.xrCamera._lastXRViewerPose.linearVelocity;
- this._tmpVector.set(r.x, r.y, r.z),
- this._headsetImpostor.setLinearVelocity(this._tmpVector)
- }
- if (null === (i = this._options.xrInput.xrCamera._lastXRViewerPose) || void 0 === i ? void 0 : i.angularVelocity) {
- var o = this._options.xrInput.xrCamera._lastXRViewerPose.angularVelocity;
- this._tmpVector.set(o.x, o.y, o.z),
- this._headsetImpostor.setAngularVelocity(this._tmpVector)
- }
- }
- Object.keys(this._controllers).forEach((function(e) {
- var t, i, r = n._controllers[e], o = r.xrController.grip || r.xrController.pointer, a = r.oldPos || r.impostorMesh.position;
- if (null === (t = r.xrController._lastXRPose) || void 0 === t ? void 0 : t.linearVelocity) {
- var s = r.xrController._lastXRPose.linearVelocity;
- n._tmpVector.set(s.x, s.y, s.z),
- r.impostor.setLinearVelocity(n._tmpVector)
- } else
- o.position.subtractToRef(a, n._tmpVector),
- n._tmpVector.scaleInPlace(1e3 / n._delta),
- r.impostor.setLinearVelocity(n._tmpVector);
- a.copyFrom(o.position),
- n._debugMode && console.log(n._tmpVector, "linear");
- var l = r.oldRotation || r.impostorMesh.rotationQuaternion;
- if (null === (i = r.xrController._lastXRPose) || void 0 === i ? void 0 : i.angularVelocity) {
- var c = r.xrController._lastXRPose.angularVelocity;
- n._tmpVector.set(c.x, c.y, c.z),
- r.impostor.setAngularVelocity(n._tmpVector)
- } else if (!l.equalsWithEpsilon(o.rotationQuaternion)) {
- l.conjugateInPlace().multiplyToRef(o.rotationQuaternion, n._tmpQuaternion);
- var u = Math.sqrt(n._tmpQuaternion.x * n._tmpQuaternion.x + n._tmpQuaternion.y * n._tmpQuaternion.y + n._tmpQuaternion.z * n._tmpQuaternion.z);
- if (n._tmpVector.set(n._tmpQuaternion.x, n._tmpQuaternion.y, n._tmpQuaternion.z),
- u < .001)
- n._tmpVector.scaleInPlace(2);
- else {
- var h = 2 * Math.atan2(u, n._tmpQuaternion.w);
- n._tmpVector.scaleInPlace(h / (u * (n._delta / 1e3)))
- }
- r.impostor.setAngularVelocity(n._tmpVector)
- }
- l.copyFrom(o.rotationQuaternion),
- n._debugMode && console.log(n._tmpVector, n._tmpQuaternion, "angular")
- }
- ))
- }
- ,
- t.prototype._detachController = function(e) {
- var t = this._controllers[e];
- t && (t.impostorMesh && t.impostorMesh.dispose(),
- delete this._controllers[e])
- }
- ,
- t.Name = Io.PHYSICS_CONTROLLERS,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(rE.Name, (function(e, t) {
- return function() {
- return new rE(e,t)
- }
- }
- ), rE.Version, !0);
- var oE = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n = e.call(this, t) || this;
- return n.options = i,
- n._tmpMat = new P,
- n._tmpPos = new x,
- n._tmpQuat = new C,
- n._initHitTestSource = function(e) {
- if (e) {
- var t = new XRRay(n.options.offsetRay || {})
- , i = {
- space: n.options.useReferenceSpace ? e : n._xrSessionManager.viewerReferenceSpace,
- offsetRay: t
- };
- n.options.entityTypes && (i.entityTypes = n.options.entityTypes),
- i.space ? n._xrSessionManager.session.requestHitTestSource(i).then((function(e) {
- n._xrHitTestSource && n._xrHitTestSource.cancel(),
- n._xrHitTestSource = e
- }
- )) : gi.Warn("waiting for viewer reference space to initialize")
- }
- }
- ,
- n.autoCloneTransformation = !1,
- n.onHitTestResultObservable = new h,
- n.paused = !1,
- n.xrNativeFeatureName = "hit-test",
- gi.Warn("Hit test is an experimental and unstable feature."),
- n
- }
- return U(t, e),
- t.prototype.attach = function() {
- var t = this;
- if (!e.prototype.attach.call(this))
- return !1;
- if (!this._xrSessionManager.session.requestHitTestSource)
- return !1;
- if (this.options.disablePermanentHitTest || (this._xrSessionManager.referenceSpace && this._initHitTestSource(this._xrSessionManager.referenceSpace),
- this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource)),
- this.options.enableTransientHitTest) {
- var i = new XRRay(this.options.transientOffsetRay || {});
- this._xrSessionManager.session.requestHitTestSourceForTransientInput({
- profile: this.options.transientHitTestProfile || "generic-touchscreen",
- offsetRay: i,
- entityTypes: this.options.entityTypes
- }).then((function(e) {
- t._transientXrHitTestSource = e
- }
- ))
- }
- return !0
- }
- ,
- t.prototype.detach = function() {
- return !!e.prototype.detach.call(this) && (this._xrHitTestSource && (this._xrHitTestSource.cancel(),
- this._xrHitTestSource = null),
- this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource),
- this._transientXrHitTestSource && (this._transientXrHitTestSource.cancel(),
- this._transientXrHitTestSource = null),
- !0)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onHitTestResultObservable.clear()
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t = this;
- if (this.attached && !this.paused) {
- if (this._xrHitTestSource) {
- var i = e.getHitTestResults(this._xrHitTestSource);
- this._processWebXRHitTestResult(i)
- }
- this._transientXrHitTestSource && e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach((function(e) {
- t._processWebXRHitTestResult(e.results, e.inputSource)
- }
- ))
- }
- }
- ,
- t.prototype._processWebXRHitTestResult = function(e, t) {
- var i = this
- , n = [];
- e.forEach((function(e) {
- var r = e.getPose(i._xrSessionManager.referenceSpace);
- if (r) {
- var o = r.transform.position
- , a = r.transform.orientation;
- i._tmpPos.set(o.x, o.y, o.z),
- i._tmpQuat.set(a.x, a.y, a.z, a.w),
- P.FromFloat32ArrayToRefScaled(r.transform.matrix, 0, 1, i._tmpMat),
- i._xrSessionManager.scene.useRightHandedSystem || (i._tmpPos.z *= -1,
- i._tmpQuat.z *= -1,
- i._tmpQuat.w *= -1,
- i._tmpMat.toggleModelMatrixHandInPlace());
- var s = {
- position: i.autoCloneTransformation ? i._tmpPos.clone() : i._tmpPos,
- rotationQuaternion: i.autoCloneTransformation ? i._tmpQuat.clone() : i._tmpQuat,
- transformationMatrix: i.autoCloneTransformation ? i._tmpMat.clone() : i._tmpMat,
- inputSource: t,
- isTransient: !!t,
- xrHitResult: e
- };
- n.push(s)
- }
- }
- )),
- this.onHitTestResultObservable.notifyObservers(n)
- }
- ,
- t.Name = Io.HIT_TEST,
- t.Version = 2,
- t
- }(wp);
- Oo.AddWebXRFeature(oE.Name, (function(e, t) {
- return function() {
- return new oE(e,t)
- }
- }
- ), oE.Version, !1);
- var aE, sE = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i._enabled = !1,
- i._featurePointCloud = [],
- i.onFeaturePointsAddedObservable = new h,
- i.onFeaturePointsUpdatedObservable = new h,
- i.xrNativeFeatureName = "bjsfeature-points",
- i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce((function() {
- i._init()
- }
- )),
- i
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "featurePointCloud", {
- get: function() {
- return this._featurePointCloud
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.detach = function() {
- return !!e.prototype.detach.call(this) && (this.featurePointCloud.length = 0,
- !0)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._featurePointCloud.length = 0,
- this.onFeaturePointsUpdatedObservable.clear(),
- this.onFeaturePointsAddedObservable.clear()
- }
- ,
- t.prototype._onXRFrame = function(e) {
- if (this.attached && this._enabled && e) {
- var t = e.featurePointCloud;
- if (t && 0 !== t.length) {
- if (t.length % 5 != 0)
- throw new Error("Received malformed feature point cloud of length: " + t.length);
- for (var i = t.length / 5, n = new Array, r = new Array, o = 0; o < i; o++) {
- var a = 5 * o
- , s = t[a + 4];
- this._featurePointCloud[s] ? n.push(s) : (this._featurePointCloud[s] = {
- position: new x,
- confidenceValue: 0
- },
- r.push(s)),
- this._featurePointCloud[s].position.x = t[a],
- this._featurePointCloud[s].position.y = t[a + 1],
- this._featurePointCloud[s].position.z = t[a + 2],
- this._featurePointCloud[s].confidenceValue = t[a + 3]
- }
- r.length > 0 && this.onFeaturePointsAddedObservable.notifyObservers(r),
- n.length > 0 && this.onFeaturePointsUpdatedObservable.notifyObservers(n)
- }
- }
- }
- ,
- t.prototype._init = function() {
- this._xrSessionManager.session.trySetFeaturePointCloudEnabled && this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0) && (this._enabled = !0)
- }
- ,
- t.Name = Io.FEATURE_POINTS,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(sE.Name, (function(e) {
- return function() {
- return new sE(e)
- }
- }
- ), sE.Version);
- var lE = ["wrist", "thumb-metacarpal", "thumb-phalanx-proximal", "thumb-phalanx-distal", "thumb-tip", "index-finger-metacarpal", "index-finger-phalanx-proximal", "index-finger-phalanx-intermediate", "index-finger-phalanx-distal", "index-finger-tip", "middle-finger-metacarpal", "middle-finger-phalanx-proximal", "middle-finger-phalanx-intermediate", "middle-finger-phalanx-distal", "middle-finger-tip", "ring-finger-metacarpal", "ring-finger-phalanx-proximal", "ring-finger-phalanx-intermediate", "ring-finger-phalanx-distal", "ring-finger-tip", "pinky-finger-metacarpal", "pinky-finger-phalanx-proximal", "pinky-finger-phalanx-intermediate", "pinky-finger-phalanx-distal", "pinky-finger-tip"]
- , cE = ((aE = {}).wrist = ["wrist"],
- aE.thumb = ["thumb-metacarpal", "thumb-phalanx-proximal", "thumb-phalanx-distal", "thumb-tip"],
- aE.index = ["index-finger-metacarpal", "index-finger-phalanx-proximal", "index-finger-phalanx-intermediate", "index-finger-phalanx-distal", "index-finger-tip"],
- aE.middle = ["middle-finger-metacarpal", "middle-finger-phalanx-proximal", "middle-finger-phalanx-intermediate", "middle-finger-phalanx-distal", "middle-finger-tip"],
- aE.ring = ["ring-finger-metacarpal", "ring-finger-phalanx-proximal", "ring-finger-phalanx-intermediate", "ring-finger-phalanx-distal", "ring-finger-tip"],
- aE.little = ["pinky-finger-metacarpal", "pinky-finger-phalanx-proximal", "pinky-finger-phalanx-intermediate", "pinky-finger-phalanx-distal", "pinky-finger-tip"],
- aE)
- , uE = function() {
- function e(e, t, i, n, r, o, a) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !1),
- void 0 === a && (a = 1),
- this.xrController = e,
- this._jointMeshes = t,
- this._handMesh = i,
- this.rigMapping = n,
- this._leftHandedMeshes = r,
- this._jointsInvisible = o,
- this._jointScaleFactor = a,
- this._jointTransforms = new Array(lE.length),
- this._jointTransformMatrices = new Float32Array(16 * lE.length),
- this._tempJointMatrix = new P,
- this._jointRadii = new Float32Array(lE.length),
- this._scene = t[0].getScene();
- for (var s = 0; s < this._jointTransforms.length; s++)
- (this._jointTransforms[s] = new yr(lE[s],this._scene)).rotationQuaternion = new C,
- t[s].rotationQuaternion = new C;
- i && this.setHandMesh(i, n),
- this.xrController.motionController && (this.xrController.motionController.rootMesh ? this.xrController.motionController.rootMesh.setEnabled(!1) : this.xrController.motionController.onModelLoadedObservable.add((function(e) {
- e.rootMesh && e.rootMesh.setEnabled(!1)
- }
- ))),
- this.xrController.onMotionControllerInitObservable.add((function(e) {
- e.onModelLoadedObservable.add((function(e) {
- e.rootMesh && e.rootMesh.setEnabled(!1)
- }
- )),
- e.rootMesh && e.rootMesh.setEnabled(!1)
- }
- ))
- }
- return Object.defineProperty(e.prototype, "handMesh", {
- get: function() {
- return this._handMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getHandPartMeshes = function(e) {
- var t = this;
- return cE[e].map((function(e) {
- return t._jointMeshes[lE.indexOf(e)]
- }
- ))
- }
- ,
- e.prototype.getJointMesh = function(e) {
- return this._jointMeshes[lE.indexOf(e)]
- }
- ,
- e.prototype.setHandMesh = function(e, t) {
- var i = this;
- if (this._handMesh = e,
- e.alwaysSelectAsActiveMesh = !0,
- e.getChildMeshes().forEach((function(e) {
- return e.alwaysSelectAsActiveMesh = !0
- }
- )),
- this._handMesh.skeleton) {
- var n = this._handMesh.skeleton;
- lE.forEach((function(e, r) {
- var o = n.getBoneIndexByName(t ? t[e] : e);
- -1 !== o && n.bones[o].linkTransformNode(i._jointTransforms[r])
- }
- ))
- }
- }
- ,
- e.prototype.updateFromXRFrame = function(e, t) {
- var i = this
- , n = this.xrController.inputSource.hand;
- if (n) {
- var r = n
- , o = lE.map((function(e) {
- return r[e] || n.get(e)
- }
- ))
- , a = !1;
- if (e.fillPoses && e.fillJointRadii)
- a = e.fillPoses(o, t, this._jointTransformMatrices) && e.fillJointRadii(o, this._jointRadii);
- else if (e.getJointPose) {
- a = !0;
- for (var s = 0; s < o.length; s++) {
- var l = e.getJointPose(o[s], t);
- if (!l) {
- a = !1;
- break
- }
- this._jointTransformMatrices.set(l.transform.matrix, 16 * s),
- this._jointRadii[s] = l.radius || .008
- }
- }
- a && (lE.forEach((function(e, t) {
- var n = i._jointTransforms[t];
- P.FromArrayToRef(i._jointTransformMatrices, 16 * t, i._tempJointMatrix),
- i._tempJointMatrix.decompose(void 0, n.rotationQuaternion, n.position);
- var r = i._jointRadii[t] * i._jointScaleFactor
- , o = i._jointMeshes[t];
- o.isVisible = !i._handMesh && !i._jointsInvisible,
- o.position.copyFrom(n.position),
- o.rotationQuaternion.copyFrom(n.rotationQuaternion),
- o.scaling.setAll(r),
- i._scene.useRightHandedSystem || (o.position.z *= -1,
- o.rotationQuaternion.z *= -1,
- o.rotationQuaternion.w *= -1,
- i._leftHandedMeshes && i._handMesh && (n.position.z *= -1,
- n.rotationQuaternion.z *= -1,
- n.rotationQuaternion.w *= -1))
- }
- )),
- this._handMesh && (this._handMesh.isVisible = !0))
- }
- }
- ,
- e.prototype.dispose = function() {
- this._handMesh && (this._handMesh.isVisible = !1)
- }
- ,
- e
- }()
- , hE = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- n.options = i,
- n._attachedHands = {},
- n._trackingHands = {
- left: null,
- right: null
- },
- n._handResources = {
- jointMeshes: null,
- handMeshes: null,
- rigMappings: null
- },
- n.onHandAddedObservable = new h,
- n.onHandRemovedObservable = new h,
- n._attachHand = function(e) {
- var t, i, r;
- if (e.inputSource.hand && "none" != e.inputSource.handedness && n._handResources.jointMeshes) {
- var o = e.inputSource.handedness
- , a = new uE(e,n._handResources.jointMeshes[o],n._handResources.handMeshes && n._handResources.handMeshes[o],n._handResources.rigMappings && n._handResources.rigMappings[o],null === (t = n.options.handMeshes) || void 0 === t ? void 0 : t.meshesUseLeftHandedCoordinates,null === (i = n.options.jointMeshes) || void 0 === i ? void 0 : i.invisible,null === (r = n.options.jointMeshes) || void 0 === r ? void 0 : r.scaleFactor);
- n._attachedHands[e.uniqueId] = a,
- n._trackingHands[o] = a,
- n.onHandAddedObservable.notifyObservers(a)
- }
- }
- ,
- n._detachHand = function(e) {
- n._detachHandById(e.uniqueId)
- }
- ,
- n.xrNativeFeatureName = "hand-tracking";
- var r = i.jointMeshes;
- if (r && (void 0 !== r.disableDefaultHandMesh && (i.handMeshes = i.handMeshes || {},
- i.handMeshes.disableDefaultMeshes = r.disableDefaultHandMesh),
- void 0 !== r.handMeshes && (i.handMeshes = i.handMeshes || {},
- i.handMeshes.customMeshes = r.handMeshes),
- void 0 !== r.leftHandedSystemMeshes && (i.handMeshes = i.handMeshes || {},
- i.handMeshes.meshesUseLeftHandedCoordinates = r.leftHandedSystemMeshes),
- void 0 !== r.rigMapping)) {
- i.handMeshes = i.handMeshes || {};
- var o = {}
- , a = {};
- [[r.rigMapping.left, o], [r.rigMapping.right, a]].forEach((function(e) {
- var t = e[0]
- , i = e[1];
- t.forEach((function(e, t) {
- i[lE[t]] = e
- }
- ))
- }
- )),
- i.handMeshes.customRigMappings = {
- left: o,
- right: a
- }
- }
- return n
- }
- return U(t, e),
- t._GenerateTrackedJointMeshes = function(e) {
- var i = {};
- return ["left", "right"].map((function(n) {
- var r, o, a, s, l, c = [], u = (null === (r = e.jointMeshes) || void 0 === r ? void 0 : r.sourceMesh) || Lv("jointParent", t._ICOSPHERE_PARAMS);
- u.isVisible = !!(null === (o = e.jointMeshes) || void 0 === o ? void 0 : o.keepOriginalVisible);
- for (var h = 0; h < lE.length; ++h) {
- var d = u.createInstance("".concat(n, "-handJoint-").concat(h));
- if (null === (a = e.jointMeshes) || void 0 === a ? void 0 : a.onHandJointMeshGenerated) {
- var p = e.jointMeshes.onHandJointMeshGenerated(d, h, n);
- p && p !== d && (d.dispose(),
- d = p)
- }
- if (d.isPickable = !1,
- null === (s = e.jointMeshes) || void 0 === s ? void 0 : s.enablePhysics) {
- var f = (null === (l = e.jointMeshes) || void 0 === l ? void 0 : l.physicsProps) || {};
- d.scaling.setAll(.02);
- var _ = void 0 !== f.impostorType ? f.impostorType : Vl.SphereImpostor;
- d.physicsImpostor = new Vl(d,_,V({
- mass: 0
- }, f))
- }
- d.rotationQuaternion = new C,
- d.isVisible = !1,
- c.push(d)
- }
- i[n] = c
- }
- )),
- {
- left: i.left,
- right: i.right
- }
- }
- ,
- t._GenerateDefaultHandMeshesAsync = function(e, i) {
- var n = this;
- return new Promise((function(r) {
- return G(n, void 0, void 0, (function() {
- var n, o, s, l, c, u, h, d, p, f, _;
- return z(this, (function(m) {
- switch (m.label) {
- case 0:
- return n = {},
- (null === (d = null === (h = t._RightHandGLB) || void 0 === h ? void 0 : h.meshes[1]) || void 0 === d ? void 0 : d.isDisposed()) && (t._RightHandGLB = null),
- (null === (f = null === (p = t._LeftHandGLB) || void 0 === p ? void 0 : p.meshes[1]) || void 0 === f ? void 0 : f.isDisposed()) && (t._LeftHandGLB = null),
- o = !(!t._RightHandGLB || !t._LeftHandGLB),
- [4, Promise.all([t._RightHandGLB || od.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_RIGHT_FILENAME, e), t._LeftHandGLB || od.ImportMeshAsync("", t.DEFAULT_HAND_MODEL_BASE_URL, t.DEFAULT_HAND_MODEL_LEFT_FILENAME, e)])];
- case 1:
- return s = m.sent(),
- t._RightHandGLB = s[0],
- t._LeftHandGLB = s[1],
- [4, (l = new Of("handShader",e,{
- emitComments: !1
- })).loadAsync(t.DEFAULT_HAND_MODEL_SHADER_URL)];
- case 2:
- return m.sent(),
- l.needDepthPrePass = !0,
- l.transparencyMode = Or.MATERIAL_ALPHABLEND,
- l.alphaMode = a.ALPHA_COMBINE,
- l.build(!1),
- c = V({
- base: D.FromInts(116, 63, 203),
- fresnel: D.FromInts(149, 102, 229),
- fingerColor: D.FromInts(177, 130, 255),
- tipFresnel: D.FromInts(220, 200, 255)
- }, null === (_ = null == i ? void 0 : i.handMeshes) || void 0 === _ ? void 0 : _.customColors),
- (u = {
- base: l.getBlockByName("baseColor"),
- fresnel: l.getBlockByName("fresnelColor"),
- fingerColor: l.getBlockByName("fingerColor"),
- tipFresnel: l.getBlockByName("tipFresnelColor")
- }).base.value = c.base,
- u.fresnel.value = c.fresnel,
- u.fingerColor.value = c.fingerColor,
- u.tipFresnel.value = c.tipFresnel,
- ["left", "right"].forEach((function(i) {
- var r = "left" == i ? t._LeftHandGLB : t._RightHandGLB;
- if (!r)
- throw new Error("Could not load hand model");
- var a = r.meshes[1];
- a._internalAbstractMeshDataInfo._computeBonesUsingShaders = !0,
- a.material = l.clone("".concat(i, "HandShaderClone"), !0),
- a.isVisible = !1,
- n[i] = a,
- o || e.useRightHandedSystem || r.transformNodes[0].rotate(vn.Y, Math.PI)
- }
- )),
- l.dispose(),
- r({
- left: n.left,
- right: n.right
- }),
- [2]
- }
- }
- ))
- }
- ))
- }
- ))
- }
- ,
- t._GenerateDefaultHandMeshRigMapping = function(e) {
- var t, i = "right" == e ? "R" : "L";
- return (t = {}).wrist = "wrist_".concat(i),
- t["thumb-metacarpal"] = "thumb_metacarpal_".concat(i),
- t["thumb-phalanx-proximal"] = "thumb_proxPhalanx_".concat(i),
- t["thumb-phalanx-distal"] = "thumb_distPhalanx_".concat(i),
- t["thumb-tip"] = "thumb_tip_".concat(i),
- t["index-finger-metacarpal"] = "index_metacarpal_".concat(i),
- t["index-finger-phalanx-proximal"] = "index_proxPhalanx_".concat(i),
- t["index-finger-phalanx-intermediate"] = "index_intPhalanx_".concat(i),
- t["index-finger-phalanx-distal"] = "index_distPhalanx_".concat(i),
- t["index-finger-tip"] = "index_tip_".concat(i),
- t["middle-finger-metacarpal"] = "middle_metacarpal_".concat(i),
- t["middle-finger-phalanx-proximal"] = "middle_proxPhalanx_".concat(i),
- t["middle-finger-phalanx-intermediate"] = "middle_intPhalanx_".concat(i),
- t["middle-finger-phalanx-distal"] = "middle_distPhalanx_".concat(i),
- t["middle-finger-tip"] = "middle_tip_".concat(i),
- t["ring-finger-metacarpal"] = "ring_metacarpal_".concat(i),
- t["ring-finger-phalanx-proximal"] = "ring_proxPhalanx_".concat(i),
- t["ring-finger-phalanx-intermediate"] = "ring_intPhalanx_".concat(i),
- t["ring-finger-phalanx-distal"] = "ring_distPhalanx_".concat(i),
- t["ring-finger-tip"] = "ring_tip_".concat(i),
- t["pinky-finger-metacarpal"] = "little_metacarpal_".concat(i),
- t["pinky-finger-phalanx-proximal"] = "little_proxPhalanx_".concat(i),
- t["pinky-finger-phalanx-intermediate"] = "little_intPhalanx_".concat(i),
- t["pinky-finger-phalanx-distal"] = "little_distPhalanx_".concat(i),
- t["pinky-finger-tip"] = "little_tip_".concat(i),
- t
- }
- ,
- t.prototype.isCompatible = function() {
- return "undefined" != typeof XRHand
- }
- ,
- t.prototype.getHandByControllerId = function(e) {
- return this._attachedHands[e]
- }
- ,
- t.prototype.getHandByHandedness = function(e) {
- return "none" == e ? null : this._trackingHands[e]
- }
- ,
- t.prototype.attach = function() {
- var i, n, r, o, a = this;
- return !!e.prototype.attach.call(this) && (this._handResources = {
- jointMeshes: t._GenerateTrackedJointMeshes(this.options),
- handMeshes: (null === (i = this.options.handMeshes) || void 0 === i ? void 0 : i.customMeshes) || null,
- rigMappings: (null === (n = this.options.handMeshes) || void 0 === n ? void 0 : n.customRigMappings) || null
- },
- (null === (r = this.options.handMeshes) || void 0 === r ? void 0 : r.customMeshes) || (null === (o = this.options.handMeshes) || void 0 === o ? void 0 : o.disableDefaultMeshes) || t._GenerateDefaultHandMeshesAsync(E.LastCreatedScene, this.options).then((function(e) {
- var i, n;
- a._handResources.handMeshes = e,
- a._handResources.rigMappings = {
- left: t._GenerateDefaultHandMeshRigMapping("left"),
- right: t._GenerateDefaultHandMeshRigMapping("right")
- },
- null === (i = a._trackingHands.left) || void 0 === i || i.setHandMesh(a._handResources.handMeshes.left, a._handResources.rigMappings.left),
- null === (n = a._trackingHands.right) || void 0 === n || n.setHandMesh(a._handResources.handMeshes.right, a._handResources.rigMappings.right)
- }
- )),
- this.options.xrInput.controllers.forEach(this._attachHand),
- this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable, this._attachHand),
- this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable, this._detachHand),
- !0)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t, i;
- null === (t = this._trackingHands.left) || void 0 === t || t.updateFromXRFrame(e, this._xrSessionManager.referenceSpace),
- null === (i = this._trackingHands.right) || void 0 === i || i.updateFromXRFrame(e, this._xrSessionManager.referenceSpace)
- }
- ,
- t.prototype._detachHandById = function(e) {
- var t, i = this.getHandByControllerId(e);
- if (i) {
- var n = "left" == i.xrController.inputSource.handedness ? "left" : "right";
- (null === (t = this._trackingHands[n]) || void 0 === t ? void 0 : t.xrController.uniqueId) === e && (this._trackingHands[n] = null),
- this.onHandRemovedObservable.notifyObservers(i),
- i.dispose(),
- delete this._attachedHands[e]
- }
- }
- ,
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (Object.keys(this._attachedHands).forEach((function(e) {
- return t._detachHandById(e)
- }
- )),
- !0)
- }
- ,
- t.prototype.dispose = function() {
- var i;
- e.prototype.dispose.call(this),
- this.onHandAddedObservable.clear(),
- this.onHandRemovedObservable.clear(),
- this._handResources.handMeshes && !(null === (i = this.options.handMeshes) || void 0 === i ? void 0 : i.customMeshes) && (this._handResources.handMeshes.left.dispose(),
- this._handResources.handMeshes.right.dispose(),
- t._RightHandGLB = null,
- t._LeftHandGLB = null),
- this._handResources.jointMeshes && (this._handResources.jointMeshes.left.forEach((function(e) {
- return e.dispose()
- }
- )),
- this._handResources.jointMeshes.right.forEach((function(e) {
- return e.dispose()
- }
- )))
- }
- ,
- t.Name = Io.HAND_TRACKING,
- t.Version = 1,
- t.DEFAULT_HAND_MODEL_BASE_URL = "https://assets.babylonjs.com/meshes/HandMeshes/",
- t.DEFAULT_HAND_MODEL_RIGHT_FILENAME = "r_hand_rhs.glb",
- t.DEFAULT_HAND_MODEL_LEFT_FILENAME = "l_hand_rhs.glb",
- t.DEFAULT_HAND_MODEL_SHADER_URL = "https://assets.babylonjs.com/meshes/HandMeshes/handsShader.json",
- t._ICOSPHERE_PARAMS = {
- radius: .5,
- flat: !1,
- subdivisions: 2
- },
- t._RightHandGLB = null,
- t._LeftHandGLB = null,
- t
- }(wp);
- Oo.AddWebXRFeature(hE.Name, (function(e, t) {
- return function() {
- return new hE(e,t)
- }
- }
- ), hE.Version, !1);
- var dE = 0
- , pE = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n = e.call(this, t) || this;
- return n._options = i,
- n._detectedMeshes = new Map,
- n.onMeshAddedObservable = new h,
- n.onMeshRemovedObservable = new h,
- n.onMeshUpdatedObservable = new h,
- n.xrNativeFeatureName = "mesh-detection",
- n._xrSessionManager.session ? n._init() : n._xrSessionManager.onXRSessionInit.addOnce((function() {
- n._init()
- }
- )),
- n
- }
- return U(t, e),
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (this._xrSessionManager.isNative && this._xrSessionManager.session.trySetMeshDetectorEnabled && this._xrSessionManager.session.trySetMeshDetectorEnabled(!1),
- this._options.doNotRemoveMeshesOnSessionEnded || (this._detectedMeshes.forEach((function(e) {
- t.onMeshRemovedObservable.notifyObservers(e)
- }
- )),
- this._detectedMeshes.clear()),
- !0)
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onMeshAddedObservable.clear(),
- this.onMeshRemovedObservable.clear(),
- this.onMeshUpdatedObservable.clear()
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t, i = this;
- try {
- if (!this.attached || !e)
- return;
- var n = null === (t = e.worldInformation) || void 0 === t ? void 0 : t.detectedMeshes;
- if (n) {
- var r = new Set;
- this._detectedMeshes.forEach((function(e, t) {
- n.has(t) || r.add(t)
- }
- )),
- r.forEach((function(e) {
- var t = i._detectedMeshes.get(e);
- t && (i.onMeshRemovedObservable.notifyObservers(t),
- i._detectedMeshes.delete(e))
- }
- )),
- n.forEach((function(t) {
- if (i._detectedMeshes.has(t))
- t.lastChangedTime === i._xrSessionManager.currentTimestamp && (r = i._detectedMeshes.get(t)) && (i._updateVertexDataWithXRMesh(t, r, e),
- i.onMeshUpdatedObservable.notifyObservers(r));
- else {
- var n = {
- id: dE++,
- xrMesh: t
- }
- , r = i._updateVertexDataWithXRMesh(t, n, e);
- i._detectedMeshes.set(t, r),
- i.onMeshAddedObservable.notifyObservers(r)
- }
- }
- ))
- }
- } catch (e) {
- console.log(e.stack)
- }
- }
- ,
- t.prototype._init = function() {
- this._xrSessionManager.isNative && (this._xrSessionManager.session.trySetMeshDetectorEnabled && this._xrSessionManager.session.trySetMeshDetectorEnabled(!0),
- this._options.preferredDetectorOptions && this._xrSessionManager.session.trySetPreferredMeshDetectorOptions && this._xrSessionManager.session.trySetPreferredMeshDetectorOptions(this._options.preferredDetectorOptions))
- }
- ,
- t.prototype._updateVertexDataWithXRMesh = function(e, t, i) {
- if (t.xrMesh = e,
- t.worldParentNode = this._options.worldParentNode,
- this._options.convertCoordinateSystems) {
- if (this._xrSessionManager.scene.useRightHandedSystem)
- t.positions = e.positions,
- t.normals = e.normals;
- else {
- t.positions = new Float32Array(e.positions.length);
- for (var n = 0; n < e.positions.length; n += 3)
- t.positions[n] = e.positions[n],
- t.positions[n + 1] = e.positions[n + 1],
- t.positions[n + 2] = -1 * e.positions[n + 2];
- if (e.normals)
- for (t.normals = new Float32Array(e.normals.length),
- n = 0; n < e.normals.length; n += 3)
- t.normals[n] = e.normals[n],
- t.normals[n + 1] = e.normals[n + 1],
- t.normals[n + 2] = -1 * e.normals[n + 2]
- }
- t.indices = e.indices;
- var r = i.getPose(e.meshSpace, this._xrSessionManager.referenceSpace);
- if (r) {
- var o = t.transformationMatrix || new P;
- P.FromArrayToRef(r.transform.matrix, 0, o),
- this._xrSessionManager.scene.useRightHandedSystem || o.toggleModelMatrixHandInPlace(),
- t.transformationMatrix = o,
- this._options.worldParentNode && o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), o)
- }
- }
- return t
- }
- ,
- t.Name = Io.MESH_DETECTION,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(pE.Name, (function(e, t) {
- return function() {
- return new pE(e,t)
- }
- }
- ), pE.Version, !1);
- var fE = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.options = i,
- n.onUntrackableImageFoundObservable = new h,
- n.onTrackableImageFoundObservable = new h,
- n.onTrackedImageUpdatedObservable = new h,
- n._trackableScoresReceived = !1,
- n._trackedImages = [],
- n.xrNativeFeatureName = "image-tracking",
- n
- }
- return U(t, e),
- t.prototype.attach = function() {
- return e.prototype.attach.call(this)
- }
- ,
- t.prototype.detach = function() {
- return e.prototype.detach.call(this)
- }
- ,
- t.prototype.isCompatible = function() {
- return "undefined" != typeof XRImageTrackingResult
- }
- ,
- t.prototype.getTrackedImageById = function(e) {
- return this._trackedImages[e] || null
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._trackedImages.forEach((function(e) {
- e.originalBitmap.close()
- }
- )),
- this._trackedImages.length = 0,
- this.onTrackableImageFoundObservable.clear(),
- this.onUntrackableImageFoundObservable.clear(),
- this.onTrackedImageUpdatedObservable.clear()
- }
- ,
- t.prototype.getXRSessionInitExtension = function() {
- return G(this, void 0, void 0, (function() {
- var e, t, i = this;
- return z(this, (function(n) {
- switch (n.label) {
- case 0:
- if (!this.options.images || !this.options.images.length)
- return [2, {}];
- e = this.options.images.map((function(e) {
- return "string" == typeof e.src ? i._xrSessionManager.scene.getEngine().createImageBitmapFromSource(e.src) : Promise.resolve(e.src)
- }
- )),
- n.label = 1;
- case 1:
- return n.trys.push([1, 3, , 4]),
- [4, Promise.all(e)];
- case 2:
- return t = n.sent(),
- this._originalTrackingRequest = t.map((function(e, t) {
- return {
- image: e,
- widthInMeters: i.options.images[t].estimatedRealWorldWidth
- }
- }
- )),
- [2, {
- trackedImages: this._originalTrackingRequest
- }];
- case 3:
- return n.sent(),
- gi.Error("Error loading images for tracking, WebXRImageTracking disabled for this session."),
- [2, {}];
- case 4:
- return [2]
- }
- }
- ))
- }
- ))
- }
- ,
- t.prototype._onXRFrame = function(e) {
- if (e.getImageTrackingResults && (this._trackableScoresReceived || (this._checkScores(),
- this._trackableScoresReceived)))
- for (var t = 0, i = e.getImageTrackingResults(); t < i.length; t++) {
- var n = i[t]
- , r = !1
- , o = n.index
- , a = this._trackedImages[o];
- if (a) {
- a.xrTrackingResult = n,
- a.realWorldWidth !== n.measuredWidthInMeters && (a.realWorldWidth = n.measuredWidthInMeters,
- r = !0);
- var s = e.getPose(n.imageSpace, this._xrSessionManager.referenceSpace);
- if (s) {
- var l = a.transformationMatrix;
- P.FromArrayToRef(s.transform.matrix, 0, l),
- this._xrSessionManager.scene.useRightHandedSystem || l.toggleModelMatrixHandInPlace(),
- r = !0
- }
- var c = "emulated" === n.trackingState;
- a.emulated !== c && (a.emulated = c,
- r = !0),
- r && this.onTrackedImageUpdatedObservable.notifyObservers(a)
- }
- }
- }
- ,
- t.prototype._checkScores = function() {
- if (this._xrSessionManager.session.getTrackedImageScores && !this._trackableScoresReceived) {
- for (var e = this._xrSessionManager.session.getTrackedImageScores(), t = 0; t < e.length; ++t)
- if ("untrackable" == e[t])
- this.onUntrackableImageFoundObservable.notifyObservers(t);
- else {
- var i = this._originalTrackingRequest[t].image
- , n = {
- id: t,
- originalBitmap: i,
- transformationMatrix: new P,
- ratio: i.width / i.height
- };
- this._trackedImages[t] = n,
- this.onTrackableImageFoundObservable.notifyObservers(n)
- }
- this._trackableScoresReceived || (this._trackableScoresReceived = e.length > 0)
- }
- }
- ,
- t.Name = Io.IMAGE_TRACKING,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(fE.Name, (function(e, t) {
- return function() {
- return new fE(e,t)
- }
- }
- ), fE.Version, !1);
- var _E = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.options = i,
- n._domOverlayType = null,
- n._beforeXRSelectListener = null,
- n._element = null,
- n.xrNativeFeatureName = "dom-overlay",
- gi.Warn("dom-overlay is an experimental and unstable feature."),
- n
- }
- return U(t, e),
- t.prototype.attach = function() {
- return !(!e.prototype.attach.call(this) || !this._xrSessionManager.session.domOverlayState || null === this._xrSessionManager.session.domOverlayState.type || (this._domOverlayType = this._xrSessionManager.session.domOverlayState.type,
- null !== this._element && !0 === this.options.supressXRSelectEvents && (this._beforeXRSelectListener = function(e) {
- e.preventDefault()
- }
- ,
- this._element.addEventListener("beforexrselect", this._beforeXRSelectListener)),
- 0))
- }
- ,
- Object.defineProperty(t.prototype, "domOverlayType", {
- get: function() {
- return this._domOverlayType
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- null !== this._element && this._beforeXRSelectListener && this._element.removeEventListener("beforexrselect", this._beforeXRSelectListener)
- }
- ,
- t.prototype._onXRFrame = function(e) {}
- ,
- t.prototype.getXRSessionInitExtension = function() {
- return G(this, void 0, void 0, (function() {
- var e;
- return z(this, (function(t) {
- if (void 0 === this.options.element)
- return gi.Warn('"element" option must be provided to attach xr-dom-overlay feature.'),
- [2, {}];
- if ("string" == typeof this.options.element) {
- if (null === (e = document.querySelector(this.options.element)))
- return gi.Warn("element not found '".concat(this.options.element, "' (not requesting xr-dom-overlay)")),
- [2, {}];
- this._element = e
- } else
- this._element = this.options.element;
- return [2, {
- domOverlay: {
- root: this._element
- }
- }]
- }
- ))
- }
- ))
- }
- ,
- t.Name = Io.DOM_OVERLAY,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(_E.Name, (function(e, t) {
- return function() {
- return new _E(e,t)
- }
- }
- ), _E.Version, !1);
- var mE = function(e) {
- function t(i, n) {
- var r, o, a, s, l, c, u = this;
- return (u = e.call(this, i) || this)._controllers = {},
- u._currentRegistrationConfigurations = [],
- u._movementDirection = null,
- u._tmpRotationMatrix = P.Identity(),
- u._tmpTranslationDirection = new x,
- u._tmpMovementTranslation = new x,
- u._attachController = function(e) {
- if (!u._controllers[e.uniqueId]) {
- u._controllers[e.uniqueId] = {
- xrController: e,
- registeredComponents: []
- };
- var t = u._controllers[e.uniqueId];
- if ("tracked-pointer" === t.xrController.inputSource.targetRayMode && t.xrController.inputSource.gamepad) {
- var i = function() {
- if (e.motionController)
- for (var i = function(i) {
- var n = null;
- if (i.allowedComponentTypes)
- for (var r = 0, o = i.allowedComponentTypes; r < o.length; r++) {
- var a = o[r]
- , s = e.motionController.getComponentOfType(a);
- if (null !== s) {
- n = s;
- break
- }
- }
- if (i.mainComponentOnly) {
- var l = e.motionController.getMainComponent();
- if (null === l)
- return "continue";
- n = l
- }
- if ("function" == typeof i.componentSelectionPredicate && (n = i.componentSelectionPredicate(e)),
- n && i.forceHandedness && e.inputSource.handedness !== i.forceHandedness)
- return "continue";
- if (null === n)
- return "continue";
- var c = {
- registrationConfiguration: i,
- component: n
- };
- t.registeredComponents.push(c),
- "axisChangedHandler"in i && (c.onAxisChangedObserver = n.onAxisValueChangedObservable.add((function(e) {
- i.axisChangedHandler(e, u._movementState, u._featureContext, u._xrInput)
- }
- ))),
- "buttonChangedhandler"in i && (c.onButtonChangedObserver = n.onButtonStateChangedObservable.add((function() {
- n.changes.pressed && i.buttonChangedhandler(n.changes.pressed, u._movementState, u._featureContext, u._xrInput)
- }
- )))
- }, n = 0, r = u._currentRegistrationConfigurations; n < r.length; n++)
- i(r[n])
- };
- e.motionController ? i() : e.onMotionControllerInitObservable.addOnce((function() {
- i()
- }
- ))
- }
- }
- }
- ,
- n && void 0 !== n.xrInput ? (Array.isArray(n.customRegistrationConfigurations) ? u._currentRegistrationConfigurations = n.customRegistrationConfigurations : u._currentRegistrationConfigurations = t.REGISTRATIONS.default,
- u._featureContext = {
- movementEnabled: n.movementEnabled || !0,
- movementOrientationFollowsViewerPose: null === (r = n.movementOrientationFollowsViewerPose) || void 0 === r || r,
- movementSpeed: null !== (o = n.movementSpeed) && void 0 !== o ? o : 1,
- movementThreshold: null !== (a = n.movementThreshold) && void 0 !== a ? a : .25,
- rotationEnabled: null === (s = n.rotationEnabled) || void 0 === s || s,
- rotationSpeed: null !== (l = n.rotationSpeed) && void 0 !== l ? l : 1,
- rotationThreshold: null !== (c = n.rotationThreshold) && void 0 !== c ? c : .25
- },
- u._movementState = {
- moveX: 0,
- moveY: 0,
- rotateX: 0,
- rotateY: 0
- },
- u._xrInput = n.xrInput,
- u) : (gi.Error('WebXRControllerMovement feature requires "xrInput" option.'),
- u)
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "movementDirection", {
- get: function() {
- return this._movementDirection
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "movementEnabled", {
- get: function() {
- return this._featureContext.movementEnabled
- },
- set: function(e) {
- this._featureContext.movementEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "movementOrientationFollowsViewerPose", {
- get: function() {
- return this._featureContext.movementOrientationFollowsViewerPose
- },
- set: function(e) {
- this._featureContext.movementOrientationFollowsViewerPose = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "movementSpeed", {
- get: function() {
- return this._featureContext.movementSpeed
- },
- set: function(e) {
- this._featureContext.movementSpeed = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "movementThreshold", {
- get: function() {
- return this._featureContext.movementThreshold
- },
- set: function(e) {
- this._featureContext.movementThreshold = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationEnabled", {
- get: function() {
- return this._featureContext.rotationEnabled
- },
- set: function(e) {
- this._featureContext.rotationEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationSpeed", {
- get: function() {
- return this._featureContext.rotationSpeed
- },
- set: function(e) {
- this._featureContext.rotationSpeed = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "rotationThreshold", {
- get: function() {
- return this._featureContext.rotationThreshold
- },
- set: function(e) {
- this._featureContext.rotationThreshold = e
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.attach = function() {
- var t = this;
- return !!e.prototype.attach.call(this) && (this._xrInput.controllers.forEach(this._attachController),
- this._addNewAttachObserver(this._xrInput.onControllerAddedObservable, this._attachController),
- this._addNewAttachObserver(this._xrInput.onControllerRemovedObservable, (function(e) {
- t._detachController(e.uniqueId)
- }
- )),
- !0)
- }
- ,
- t.prototype.detach = function() {
- var t = this;
- return !!e.prototype.detach.call(this) && (Object.keys(this._controllers).forEach((function(e) {
- t._detachController(e)
- }
- )),
- this._controllers = {},
- !0)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- if (this.attach) {
- if (null === this._movementDirection && (this._movementDirection = this._xrInput.xrCamera.rotationQuaternion.clone()),
- 0 !== this._movementState.rotateX && this._featureContext.rotationEnabled) {
- var t = .001 * this._xrSessionManager.scene.getEngine().getDeltaTime() * this._featureContext.rotationSpeed * this._movementState.rotateX * (this._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
- !0 === this._featureContext.movementOrientationFollowsViewerPose ? (this._xrInput.xrCamera.cameraRotation.y += t,
- this._movementDirection = this._xrInput.xrCamera.rotationQuaternion.multiply(C.RotationYawPitchRoll(t, 0, 0))) : this._movementDirection.multiplyInPlace(C.RotationYawPitchRoll(3 * t, 0, 0))
- } else
- !0 === this._featureContext.movementOrientationFollowsViewerPose && this._movementDirection.copyFrom(this._xrInput.xrCamera.rotationQuaternion);
- 0 === this._movementState.moveX && 0 === this._movementState.moveY || !this._featureContext.movementEnabled || (P.FromQuaternionToRef(this._movementDirection, this._tmpRotationMatrix),
- this._tmpTranslationDirection.set(this._movementState.moveX, 0, this._movementState.moveY * (this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
- x.TransformCoordinatesToRef(this._tmpTranslationDirection, this._tmpRotationMatrix, this._tmpMovementTranslation),
- this._tmpMovementTranslation.scaleInPlace(this._xrInput.xrCamera._computeLocalCameraSpeed() * this._featureContext.movementSpeed),
- this._xrInput.xrCamera.cameraDirection.addInPlace(this._tmpMovementTranslation))
- }
- }
- ,
- t.prototype._detachController = function(e) {
- var t = this._controllers[e];
- if (t) {
- for (var i = 0, n = t.registeredComponents; i < n.length; i++) {
- var r = n[i];
- r.onAxisChangedObserver && r.component.onAxisValueChangedObservable.remove(r.onAxisChangedObserver),
- r.onButtonChangedObserver && r.component.onButtonStateChangedObservable.remove(r.onButtonChangedObserver)
- }
- delete this._controllers[e]
- }
- }
- ,
- t.Name = Io.MOVEMENT,
- t.REGISTRATIONS = {
- default: [{
- allowedComponentTypes: [Ap.THUMBSTICK_TYPE, Ap.TOUCHPAD_TYPE],
- forceHandedness: "left",
- axisChangedHandler: function(e, t, i) {
- t.rotateX = Math.abs(e.x) > i.rotationThreshold ? e.x : 0,
- t.rotateY = Math.abs(e.y) > i.rotationThreshold ? e.y : 0
- }
- }, {
- allowedComponentTypes: [Ap.THUMBSTICK_TYPE, Ap.TOUCHPAD_TYPE],
- forceHandedness: "right",
- axisChangedHandler: function(e, t, i) {
- t.moveX = Math.abs(e.x) > i.movementThreshold ? e.x : 0,
- t.moveY = Math.abs(e.y) > i.movementThreshold ? e.y : 0
- }
- }]
- },
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(mE.Name, (function(e, t) {
- return function() {
- return new mE(e,t)
- }
- }
- ), mE.Version, !0);
- var gE = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n.options = i,
- n._canvasContext = null,
- n._reflectionCubeMap = null,
- n._xrLightEstimate = null,
- n._xrLightProbe = null,
- n._xrWebGLBinding = null,
- n._lightDirection = x.Up().negateInPlace(),
- n._lightColor = D.White(),
- n._intensity = 1,
- n._sphericalHarmonics = new Cc,
- n._cubeMapPollTime = Date.now(),
- n._lightEstimationPollTime = Date.now(),
- n._reflectionCubeMapTextureSize = 16,
- n.directionalLight = null,
- n.onReflectionCubeMapUpdatedObservable = new h,
- n._updateReflectionCubeMap = function() {
- var e;
- if (n._xrLightProbe) {
- if (n.options.cubeMapPollInterval) {
- var t = Date.now();
- if (t - n._cubeMapPollTime < n.options.cubeMapPollInterval)
- return;
- n._cubeMapPollTime = t
- }
- var i = n._getXRGLBinding().getReflectionCubeMap(n._xrLightProbe);
- if (i && n._reflectionCubeMap) {
- if (n._reflectionCubeMap._texture)
- null === (e = n._reflectionCubeMap._texture._hardwareTexture) || void 0 === e || e.set(i),
- n._reflectionCubeMap._texture.getEngine().resetTextureCache();
- else {
- var r = new Lt(n._xrSessionManager.scene.getEngine(),At.Unknown);
- r.isCube = !0,
- r.invertY = !1,
- r._useSRGBBuffer = "srgba8" === n.options.reflectionFormat,
- r.format = a.TEXTUREFORMAT_RGBA,
- r.generateMipMaps = !0,
- r.type = "srgba8" !== n.options.reflectionFormat ? a.TEXTURETYPE_HALF_FLOAT : a.TEXTURETYPE_UNSIGNED_BYTE,
- r.samplingMode = a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,
- r.width = n._reflectionCubeMapTextureSize,
- r.height = n._reflectionCubeMapTextureSize,
- r._cachedWrapU = a.TEXTURE_WRAP_ADDRESSMODE,
- r._cachedWrapV = a.TEXTURE_WRAP_ADDRESSMODE,
- r._hardwareTexture = new kt(i,n._getCanvasContext()),
- n._reflectionCubeMap._texture = r
- }
- n._reflectionCubeMap._texture.isReady = !0,
- n._xrSessionManager.scene.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag),
- n.onReflectionCubeMapUpdatedObservable.notifyObservers(n._reflectionCubeMap)
- }
- }
- }
- ,
- n.xrNativeFeatureName = "light-estimation",
- n.options.createDirectionalLightSource && (n.directionalLight = new Rd("light estimation directional",n._lightDirection,n._xrSessionManager.scene),
- n.directionalLight.position = new x(0,8,0),
- n.directionalLight.intensity = 0,
- n.directionalLight.falloffType = fn.FALLOFF_GLTF),
- gi.Warn("light-estimation is an experimental and unstable feature."),
- n
- }
- return U(t, e),
- Object.defineProperty(t.prototype, "reflectionCubeMapTexture", {
- get: function() {
- return this._reflectionCubeMap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "xrLightingEstimate", {
- get: function() {
- return this._xrLightEstimate ? {
- lightColor: this._lightColor,
- lightDirection: this._lightDirection,
- lightIntensity: this._intensity,
- sphericalHarmonics: this._sphericalHarmonics
- } : this._xrLightEstimate
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype._getCanvasContext = function() {
- return null === this._canvasContext && (this._canvasContext = this._xrSessionManager.scene.getEngine()._gl),
- this._canvasContext
- }
- ,
- t.prototype._getXRGLBinding = function() {
- if (null === this._xrWebGLBinding) {
- var e = this._getCanvasContext();
- this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session,e)
- }
- return this._xrWebGLBinding
- }
- ,
- t.prototype.attach = function() {
- var t, i = this;
- if (!e.prototype.attach.call(this))
- return !1;
- var n = null !== (t = this.options.reflectionFormat) && void 0 !== t ? t : this._xrSessionManager.session.preferredReflectionFormat || "srgba8";
- return this.options.reflectionFormat = n,
- this._xrSessionManager.session.requestLightProbe({
- reflectionFormat: n
- }).then((function(e) {
- i._xrLightProbe = e,
- i.options.disableCubeMapReflection || (i._reflectionCubeMap || (i._reflectionCubeMap = new Zr(i._xrSessionManager.scene),
- i._reflectionCubeMap.isCube = !0,
- i._reflectionCubeMap.coordinatesMode = a.TEXTURE_CUBIC_MODE,
- i.options.setSceneEnvironmentTexture && (i._xrSessionManager.scene.environmentTexture = i._reflectionCubeMap)),
- i._xrLightProbe.addEventListener("reflectionchange", i._updateReflectionCubeMap))
- }
- )),
- !0
- }
- ,
- t.prototype.detach = function() {
- var t = e.prototype.detach.call(this);
- return null === this._xrLightProbe || this.options.disableCubeMapReflection || (this._xrLightProbe.removeEventListener("reflectionchange", this._updateReflectionCubeMap),
- this._xrLightProbe = null),
- this._canvasContext = null,
- this._xrLightEstimate = null,
- this._xrWebGLBinding = null,
- t
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this.onReflectionCubeMapUpdatedObservable.clear(),
- this.directionalLight && (this.directionalLight.dispose(),
- this.directionalLight = null),
- null !== this._reflectionCubeMap && (this._reflectionCubeMap._texture && this._reflectionCubeMap._texture.dispose(),
- this._reflectionCubeMap.dispose(),
- this._reflectionCubeMap = null)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t;
- if (null !== this._xrLightProbe) {
- if (this.options.lightEstimationPollInterval) {
- var i = Date.now();
- if (i - this._lightEstimationPollTime < this.options.lightEstimationPollInterval)
- return;
- this._lightEstimationPollTime = i
- }
- if (this._xrLightEstimate = e.getLightEstimate(this._xrLightProbe),
- this._xrLightEstimate) {
- this._intensity = Math.max(1, this._xrLightEstimate.primaryLightIntensity.x, this._xrLightEstimate.primaryLightIntensity.y, this._xrLightEstimate.primaryLightIntensity.z);
- var n = this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;
- this.options.disableVectorReuse && (this._lightDirection = new x,
- this._lightColor = new D,
- this.directionalLight && (this.directionalLight.direction = this._lightDirection,
- this.directionalLight.diffuse = this._lightColor)),
- this._lightDirection.copyFromFloats(this._xrLightEstimate.primaryLightDirection.x, this._xrLightEstimate.primaryLightDirection.y, this._xrLightEstimate.primaryLightDirection.z * n),
- this._lightColor.copyFromFloats(this._xrLightEstimate.primaryLightIntensity.x / this._intensity, this._xrLightEstimate.primaryLightIntensity.y / this._intensity, this._xrLightEstimate.primaryLightIntensity.z / this._intensity),
- this._sphericalHarmonics.updateFromFloatsArray(this._xrLightEstimate.sphericalHarmonicsCoefficients),
- this._reflectionCubeMap && !this.options.disableSphericalPolynomial && (this._reflectionCubeMap.sphericalPolynomial = this._reflectionCubeMap.sphericalPolynomial || new Pc,
- null === (t = this._reflectionCubeMap.sphericalPolynomial) || void 0 === t || t.updateFromHarmonics(this._sphericalHarmonics)),
- this._lightDirection.negateInPlace(),
- this.directionalLight && (this.directionalLight.direction.copyFrom(this._lightDirection),
- this.directionalLight.intensity = Math.min(this._intensity, 1),
- this.directionalLight.diffuse.copyFrom(this._lightColor))
- }
- }
- }
- ,
- t.Name = Io.LIGHT_ESTIMATION,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(gE.Name, (function(e, t) {
- return function() {
- return new gE(e,t)
- }
- }
- ), gE.Version, !1);
- var vE = function(e) {
- function t(t) {
- var i = e.call(this, t) || this;
- return i.onEyeTrackingStartedObservable = new h,
- i.onEyeTrackingEndedObservable = new h,
- i.onEyeTrackingFrameUpdateObservable = new h,
- i._eyeTrackingStartListener = function(e) {
- i._latestEyeSpace = e.gazeSpace,
- i._gazeRay = new _o(x.Zero(),x.Forward()),
- i.onEyeTrackingStartedObservable.notifyObservers(i._gazeRay)
- }
- ,
- i._eyeTrackingEndListener = function() {
- i._latestEyeSpace = null,
- i._gazeRay = null,
- i.onEyeTrackingEndedObservable.notifyObservers()
- }
- ,
- i.xrNativeFeatureName = "eye-tracking",
- i._xrSessionManager.session ? i._init() : i._xrSessionManager.onXRSessionInit.addOnce((function() {
- i._init()
- }
- )),
- i
- }
- return U(t, e),
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this),
- this._xrSessionManager.session.removeEventListener("eyetrackingstart", this._eyeTrackingStartListener),
- this._xrSessionManager.session.removeEventListener("eyetrackingend", this._eyeTrackingEndListener),
- this.onEyeTrackingStartedObservable.clear(),
- this.onEyeTrackingEndedObservable.clear(),
- this.onEyeTrackingFrameUpdateObservable.clear()
- }
- ,
- Object.defineProperty(t.prototype, "isEyeGazeValid", {
- get: function() {
- return !!this._gazeRay
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.getEyeGaze = function() {
- return this._gazeRay
- }
- ,
- t.prototype._onXRFrame = function(e) {
- if (this.attached && e && this._latestEyeSpace && this._gazeRay) {
- var t = e.getPose(this._latestEyeSpace, this._xrSessionManager.referenceSpace);
- if (t) {
- this._gazeRay.origin.set(t.transform.position.x, t.transform.position.y, t.transform.position.z);
- var i = t.transform.orientation;
- I.Quaternion[0].set(i.x, i.y, i.z, i.w),
- this._xrSessionManager.scene.useRightHandedSystem ? x.RightHandedForwardReadOnly.rotateByQuaternionToRef(I.Quaternion[0], this._gazeRay.direction) : (this._gazeRay.origin.z *= -1,
- I.Quaternion[0].z *= -1,
- I.Quaternion[0].w *= -1,
- x.LeftHandedForwardReadOnly.rotateByQuaternionToRef(I.Quaternion[0], this._gazeRay.direction)),
- this.onEyeTrackingFrameUpdateObservable.notifyObservers(this._gazeRay)
- }
- }
- }
- ,
- t.prototype._init = function() {
- this._xrSessionManager.isNative && (this._xrSessionManager.session.addEventListener("eyetrackingstart", this._eyeTrackingStartListener),
- this._xrSessionManager.session.addEventListener("eyetrackingend", this._eyeTrackingEndListener))
- }
- ,
- t.Name = Io.EYE_TRACKING,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(vE.Name, (function(e) {
- return function() {
- return new vE(e)
- }
- }
- ), vE.Version, !1);
- var yE = function() {
- function e(e, t) {
- this._samples = [],
- this._idx = 0;
- for (var i = 0; i < e; ++i)
- this._samples.push(t ? t() : A.Zero())
- }
- return Object.defineProperty(e.prototype, "length", {
- get: function() {
- return this._samples.length
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.push = function(e, t) {
- this._idx = (this._idx + this._samples.length - 1) % this._samples.length,
- this.at(0).copyFromFloats(e, t)
- }
- ,
- e.prototype.at = function(e) {
- if (e >= this._samples.length)
- throw new Error("Index out of bounds");
- return this._samples[(this._idx + e) % this._samples.length]
- }
- ,
- e
- }()
- , bE = function() {
- function e() {
- this._samples = new yE(20),
- this._entropy = 0,
- this.onFirstStepDetected = new h
- }
- return e.prototype.update = function(e, t, i, n) {
- this._samples.push(e, t);
- var r = this._samples.at(0);
- if (this._entropy *= this._entropyDecayFactor,
- this._entropy += A.Distance(r, this._samples.at(1)),
- !(this._entropy > this._entropyThreshold)) {
- var o;
- for (o = this._samePointCheckStartIdx; o < this._samples.length && !(A.DistanceSquared(r, this._samples.at(o)) < this._samePointSquaredDistanceThreshold); ++o)
- ;
- if (o !== this._samples.length) {
- for (var a = -1, s = 0, l = void 0, c = 1; c < o; ++c)
- (l = A.DistanceSquared(r, this._samples.at(c))) > a && (s = c,
- a = l);
- if (!(a < this._apexSquaredDistanceThreshold)) {
- var u = this._samples.at(s)
- , h = u.subtract(r);
- h.normalize();
- var d, p = I.Vector2[0], f = 0;
- for (c = 1; c < o; ++c)
- this._samples.at(c).subtractToRef(r, p),
- d = A.Dot(h, p),
- f += p.lengthSquared() - d * d;
- if (!(f > o * this._squaredProjectionDistanceThreshold)) {
- var _ = I.Vector3[0];
- _.set(i, n, 0);
- var m = I.Vector3[1];
- m.set(h.x, h.y, 0);
- var g = x.Cross(_, m).z > 0
- , v = r.clone()
- , y = r.clone();
- u.subtractToRef(r, h),
- g ? (h.scaleAndAddToRef(this._axisToApexShrinkFactor, v),
- h.scaleAndAddToRef(this._axisToApexExtendFactor, y)) : (h.scaleAndAddToRef(this._axisToApexExtendFactor, v),
- h.scaleAndAddToRef(this._axisToApexShrinkFactor, y)),
- this.onFirstStepDetected.notifyObservers({
- leftApex: v,
- rightApex: y,
- currentPosition: r,
- currentStepDirection: g ? "right" : "left"
- })
- }
- }
- }
- }
- }
- ,
- e.prototype.reset = function() {
- for (var e = 0; e < this._samples.length; ++e)
- this._samples.at(e).copyFromFloats(0, 0)
- }
- ,
- Object.defineProperty(e.prototype, "_samePointCheckStartIdx", {
- get: function() {
- return Math.floor(this._samples.length / 3)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_samePointSquaredDistanceThreshold", {
- get: function() {
- return 9e-4
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_apexSquaredDistanceThreshold", {
- get: function() {
- return .0081
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_squaredProjectionDistanceThreshold", {
- get: function() {
- return 9e-4
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_axisToApexShrinkFactor", {
- get: function() {
- return .8
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_axisToApexExtendFactor", {
- get: function() {
- return -1.6
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_entropyDecayFactor", {
- get: function() {
- return .93
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_entropyThreshold", {
- get: function() {
- return .4
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }()
- , TE = function() {
- function e(e, t, i, n) {
- this._leftApex = new A,
- this._rightApex = new A,
- this._currentPosition = new A,
- this._axis = new A,
- this._axisLength = -1,
- this._forward = new A,
- this._steppingLeft = !1,
- this._t = -1,
- this._maxT = -1,
- this._maxTPosition = new A,
- this._vitality = 0,
- this.onMovement = new h,
- this.onFootfall = new h,
- this._reset(e, t, i, "left" === n)
- }
- return e.prototype._reset = function(e, t, i, n) {
- this._leftApex.copyFrom(e),
- this._rightApex.copyFrom(t),
- this._steppingLeft = n,
- this._steppingLeft ? (this._leftApex.subtractToRef(this._rightApex, this._axis),
- this._forward.copyFromFloats(-this._axis.y, this._axis.x)) : (this._rightApex.subtractToRef(this._leftApex, this._axis),
- this._forward.copyFromFloats(this._axis.y, -this._axis.x)),
- this._axisLength = this._axis.length(),
- this._forward.scaleInPlace(1 / this._axisLength),
- this._updateTAndVitality(i.x, i.y),
- this._maxT = this._t,
- this._maxTPosition.copyFrom(i),
- this._vitality = 1
- }
- ,
- e.prototype._updateTAndVitality = function(e, t) {
- this._currentPosition.copyFromFloats(e, t),
- this._steppingLeft ? this._currentPosition.subtractInPlace(this._rightApex) : this._currentPosition.subtractInPlace(this._leftApex);
- var i = this._t
- , n = A.Dot(this._currentPosition, this._axis);
- this._t = n / (this._axisLength * this._axisLength);
- var r = this._currentPosition.lengthSquared() - n / this._axisLength * (n / this._axisLength);
- this._vitality *= .92 - 100 * Math.max(r - .0016, 0) + Math.max(this._t - i, 0)
- }
- ,
- e.prototype.update = function(e, t) {
- if (this._vitality < this._vitalityThreshold)
- return !1;
- var i = this._t;
- return this._updateTAndVitality(e, t),
- this._t > this._maxT && (this._maxT = this._t,
- this._maxTPosition.copyFromFloats(e, t)),
- !(this._vitality < this._vitalityThreshold || (this._t > i && (this.onMovement.notifyObservers({
- deltaT: this._t - i
- }),
- i < .5 && this._t >= .5 && this.onFootfall.notifyObservers({
- foot: this._steppingLeft ? "left" : "right"
- })),
- this._t < .95 * this._maxT && (this._currentPosition.copyFromFloats(e, t),
- this._steppingLeft ? this._leftApex.copyFrom(this._maxTPosition) : this._rightApex.copyFrom(this._maxTPosition),
- this._reset(this._leftApex, this._rightApex, this._currentPosition, !this._steppingLeft)),
- this._axisLength < .03))
- }
- ,
- Object.defineProperty(e.prototype, "_vitalityThreshold", {
- get: function() {
- return .1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "forward", {
- get: function() {
- return this._forward
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }()
- , EE = function() {
- function e(t) {
- var i = this;
- this._detector = new bE,
- this._walker = null,
- this._movement = new A,
- this._millisecondsSinceLastUpdate = e._MillisecondsPerUpdate,
- this.movementThisFrame = x.Zero(),
- this._engine = t,
- this._detector.onFirstStepDetected.add((function(e) {
- i._walker || (i._walker = new TE(e.leftApex,e.rightApex,e.currentPosition,e.currentStepDirection),
- i._walker.onFootfall.add((function() {
- console.log("Footfall!")
- }
- )),
- i._walker.onMovement.add((function(e) {
- i._walker.forward.scaleAndAddToRef(.024 * e.deltaT, i._movement)
- }
- )))
- }
- ))
- }
- return Object.defineProperty(e, "_MillisecondsPerUpdate", {
- get: function() {
- return 1e3 / 15
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function(t, i) {
- i.y = 0,
- i.normalize(),
- this._millisecondsSinceLastUpdate += this._engine.getDeltaTime(),
- this._millisecondsSinceLastUpdate >= e._MillisecondsPerUpdate && (this._millisecondsSinceLastUpdate -= e._MillisecondsPerUpdate,
- this._detector.update(t.x, t.z, i.x, i.z),
- this._walker && (this._walker.update(t.x, t.z) || (this._walker = null)),
- this._movement.scaleInPlace(.85)),
- this.movementThisFrame.set(this._movement.x, 0, this._movement.y)
- }
- ,
- e
- }()
- , SE = function(e) {
- function t(t, i) {
- var n = e.call(this, t) || this;
- return n._up = new x,
- n._forward = new x,
- n._position = new x,
- n._movement = new x,
- n._sessionManager = t,
- n.locomotionTarget = i.locomotionTarget,
- n._isLocomotionTargetWebXRCamera && K.Warn("Using walking locomotion directly on a WebXRCamera may have unintended interactions with other XR techniques. Using an XR space parent is highly recommended"),
- n
- }
- return U(t, e),
- Object.defineProperty(t, "Name", {
- get: function() {
- return Io.WALKING_LOCOMOTION
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t, "Version", {
- get: function() {
- return 1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(t.prototype, "locomotionTarget", {
- get: function() {
- return this._locomotionTarget
- },
- set: function(e) {
- this._locomotionTarget = e,
- this._isLocomotionTargetWebXRCamera = "WebXRCamera" === this._locomotionTarget.getClassName()
- },
- enumerable: !1,
- configurable: !0
- }),
- t.prototype.isCompatible = function() {
- return void 0 === this._sessionManager.sessionMode || "immersive-vr" === this._sessionManager.sessionMode
- }
- ,
- t.prototype.attach = function() {
- return !(!this.isCompatible || !e.prototype.attach.call(this) || (this._walker = new EE(this._sessionManager.scene.getEngine()),
- 0))
- }
- ,
- t.prototype.detach = function() {
- return !!e.prototype.detach.call(this) && (this._walker = null,
- !0)
- }
- ,
- t.prototype._onXRFrame = function(e) {
- var t = e.getViewerPose(this._sessionManager.baseReferenceSpace);
- if (t) {
- var i = this.locomotionTarget.getScene().useRightHandedSystem ? 1 : -1
- , n = t.transform.matrix;
- this._up.copyFromFloats(n[4], n[5], i * n[6]),
- this._forward.copyFromFloats(n[8], n[9], i * n[10]),
- this._position.copyFromFloats(n[12], n[13], i * n[14]),
- this._forward.scaleAndAddToRef(.05, this._position),
- this._up.scaleAndAddToRef(-.05, this._position),
- this._walker.update(this._position, this._forward),
- this._movement.copyFrom(this._walker.movementThisFrame),
- this._isLocomotionTargetWebXRCamera || x.TransformNormalToRef(this._movement, this.locomotionTarget.getWorldMatrix(), this._movement),
- this.locomotionTarget.position.addInPlace(this._movement)
- }
- }
- ,
- t
- }(wp);
- Oo.AddWebXRFeature(SE.Name, (function(e, t) {
- return function() {
- return new SE(e,t)
- }
- }
- ), SE.Version, !1);
- var AE = function(e) {
- function t(t, i, n, r, o, a) {
- var s = e.call(this, t, i, n, r, a) || this;
- return s.getWidth = t,
- s.getHeight = i,
- s.layer = n,
- s.layerType = r,
- s.isMultiview = o,
- s.createRTTProvider = a,
- s
- }
- return U(t, e),
- t
- }(ws)
- , xE = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t.scene, n) || this;
- return r._xrSessionManager = t,
- r._xrWebGLBinding = i,
- r.layerWrapper = n,
- r._lastSubImages = new Map,
- r._compositionLayer = n.layer,
- r
- }
- return U(t, e),
- t.prototype._getRenderTargetForSubImage = function(e, t) {
- var i = this._lastSubImages.get(t)
- , n = "left" == t ? 0 : 1;
- return this._renderTargetTextures[n] && (null == i ? void 0 : i.textureWidth) === e.textureWidth && (null == i ? void 0 : i.textureHeight) == e.textureHeight || (this._renderTargetTextures[n] = this._createRenderTargetTexture(e.textureWidth, e.textureHeight, null, e.colorTexture, e.depthStencilTexture, this.layerWrapper.isMultiview),
- this._framebufferDimensions = {
- framebufferWidth: e.textureWidth,
- framebufferHeight: e.textureHeight
- }),
- this._lastSubImages.set(t, e),
- this._renderTargetTextures[n]
- }
- ,
- t.prototype._getSubImageForEye = function(e) {
- var t = this._xrSessionManager.currentFrame;
- return t ? this._xrWebGLBinding.getSubImage(this._compositionLayer, t, e) : null
- }
- ,
- t.prototype.getRenderTargetTextureForEye = function(e) {
- var t = this._getSubImageForEye(e);
- return t ? this._getRenderTargetForSubImage(t, e) : null
- }
- ,
- t.prototype.getRenderTargetTextureForView = function(e) {
- return this.getRenderTargetTextureForEye(e.eye)
- }
- ,
- t.prototype._setViewportForSubImage = function(e, t) {
- var i = t.textureWidth
- , n = t.textureHeight
- , r = t.viewport;
- e.x = r.x / i,
- e.y = r.y / n,
- e.width = r.width / i,
- e.height = r.height / n
- }
- ,
- t.prototype.trySetViewportForView = function(e, t) {
- var i = this._lastSubImages.get(t.eye) || this._getSubImageForEye(t.eye);
- return !!i && (this._setViewportForSubImage(e, i),
- !0)
- }
- ,
- t
- }(Bs)
- , RE = function(e) {
- function t(t, i, n) {
- var r = e.call(this, (function() {
- return t.textureWidth
- }
- ), (function() {
- return t.textureHeight
- }
- ), t, "XRProjectionLayer", i, (function(e) {
- return new CE(e,n,r)
- }
- )) || this;
- return r.layer = t,
- r
- }
- return U(t, e),
- t
- }(AE)
- , CE = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, i, n) || this;
- return r.layerWrapper = n,
- r._projectionLayer = n.layer,
- r
- }
- return U(t, e),
- t.prototype._getSubImageForView = function(e) {
- return this._xrWebGLBinding.getViewSubImage(this._projectionLayer, e)
- }
- ,
- t.prototype.getRenderTargetTextureForView = function(e) {
- return this._getRenderTargetForSubImage(this._getSubImageForView(e), e.eye)
- }
- ,
- t.prototype.getRenderTargetTextureForEye = function(e) {
- var t = this._lastSubImages.get(e);
- return t ? this._getRenderTargetForSubImage(t, e) : null
- }
- ,
- t.prototype.trySetViewportForView = function(e, t) {
- var i = this._lastSubImages.get(t.eye) || this._getSubImageForView(t);
- return !!i && (this._setViewportForSubImage(e, i),
- !0)
- }
- ,
- t
- }(xE)
- , PE = {}
- , ME = {
- textureType: "texture",
- colorFormat: 6408,
- depthFormat: 35056,
- scaleFactor: 1
- }
- , IE = function(e) {
- function t(t, i) {
- void 0 === i && (i = {});
- var n = e.call(this, t) || this;
- return n._options = i,
- n._existingLayers = [],
- n.xrNativeFeatureName = "layers",
- n
- }
- return U(t, e),
- t.prototype.attach = function() {
- if (!e.prototype.attach.call(this))
- return !1;
- var t = this._xrSessionManager.scene.getEngine();
- this._glContext = t._gl,
- this._xrWebGLBinding = new XRWebGLBinding(this._xrSessionManager.session,this._glContext),
- this._existingLayers = [];
- var i = V({}, ME)
- , n = this._options.preferMultiviewOnInit && t.getCaps().multiview;
- return n && (i.textureType = "texture-array"),
- this.addXRSessionLayer(this.createProjectionLayer(i, n)),
- !0
- }
- ,
- t.prototype.detach = function() {
- return !!e.prototype.detach.call(this) && (this._existingLayers.length = 0,
- !0)
- }
- ,
- t.prototype.createXRWebGLLayer = function(e) {
- void 0 === e && (e = PE);
- var t = new XRWebGLLayer(this._xrSessionManager.session,this._glContext,e);
- return new Us(t)
- }
- ,
- t.prototype.createProjectionLayer = function(e, t) {
- if (void 0 === e && (e = ME),
- void 0 === t && (t = !1),
- t && "texture-array" !== e.textureType)
- throw new Error("Projection layers can only be made multiview if they use texture arrays. Set the textureType parameter to 'texture-array'.");
- if (!t && "texture-array" === e.textureType)
- throw new Error("We currently only support multiview rendering when the textureType parameter is set to 'texture-array'.");
- var i = this._xrWebGLBinding.createProjectionLayer(e);
- return new RE(i,t,this._xrWebGLBinding)
- }
- ,
- t.prototype.addXRSessionLayer = function(e) {
- this.setXRSessionLayers(W(W([], this._existingLayers, !0), [e], !1))
- }
- ,
- t.prototype.setXRSessionLayers = function(e) {
- this._existingLayers = e;
- var t = V({}, this._xrSessionManager.session.renderState);
- t.baseLayer = void 0,
- t.layers = e.map((function(e) {
- return e.layer
- }
- )),
- this._xrSessionManager.updateRenderState(t),
- this._xrSessionManager._setBaseLayerWrapper(e.length > 0 ? e[0] : null)
- }
- ,
- t.prototype.isCompatible = function() {
- return !this._xrSessionManager.isNative && "undefined" != typeof XRWebGLBinding && !!XRWebGLBinding.prototype.createProjectionLayer
- }
- ,
- t.prototype.dispose = function() {
- e.prototype.dispose.call(this)
- }
- ,
- t.prototype._onXRFrame = function(e) {}
- ,
- t.Name = Io.LAYERS,
- t.Version = 1,
- t
- }(wp);
- Oo.AddWebXRFeature(IE.Name, (function(e, t) {
- return function() {
- return new IE(e,t)
- }
- }
- ), IE.Version, !1);
- var OE = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, DE[n], i, n, !0) || this;
- return r.profileId = "generic-hand-select-grasp",
- r
- }
- return U(t, e),
- t.prototype._getFilenameAndPath = function() {
- return {
- filename: "generic.babylon",
- path: "https://controllers.babylonjs.com/generic/"
- }
- }
- ,
- t.prototype._getModelLoadingConstraints = function() {
- return !0
- }
- ,
- t.prototype._processLoadedModel = function(e) {}
- ,
- t.prototype._setRootMesh = function(e) {}
- ,
- t.prototype._updateModel = function() {}
- ,
- t
- }(xp);
- Ip.RegisterController("generic-hand-select-grasp", (function(e, t) {
- return new OE(t,e.gamepad,e.handedness)
- }
- ));
- var DE = {
- left: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr-standard-trigger",
- visualResponses: {}
- },
- grasp: {
- type: "trigger",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "grasp",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "generic-hand-select-grasp-left",
- assetPath: "left.glb"
- },
- right: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr-standard-trigger",
- visualResponses: {}
- },
- grasp: {
- type: "trigger",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "grasp",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "generic-hand-select-grasp-right",
- assetPath: "right.glb"
- },
- none: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr-standard-trigger",
- visualResponses: {}
- },
- grasp: {
- type: "trigger",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "grasp",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "generic-hand-select-grasp-none",
- assetPath: "none.glb"
- }
- }
- , NE = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, LE["left-right"], i, n) || this;
- return r._mapping = {
- defaultButton: {
- valueNodeName: "VALUE",
- unpressedNodeName: "UNPRESSED",
- pressedNodeName: "PRESSED"
- },
- defaultAxis: {
- valueNodeName: "VALUE",
- minNodeName: "MIN",
- maxNodeName: "MAX"
- },
- buttons: {
- "xr-standard-trigger": {
- rootNodeName: "SELECT",
- componentProperty: "button",
- states: ["default", "touched", "pressed"]
- },
- "xr-standard-squeeze": {
- rootNodeName: "GRASP",
- componentProperty: "state",
- states: ["pressed"]
- },
- "xr-standard-touchpad": {
- rootNodeName: "TOUCHPAD_PRESS",
- labelAnchorNodeName: "squeeze-label",
- touchPointNodeName: "TOUCH"
- },
- "xr-standard-thumbstick": {
- rootNodeName: "THUMBSTICK_PRESS",
- componentProperty: "state",
- states: ["pressed"]
- }
- },
- axes: {
- "xr-standard-touchpad": {
- "x-axis": {
- rootNodeName: "TOUCHPAD_TOUCH_X"
- },
- "y-axis": {
- rootNodeName: "TOUCHPAD_TOUCH_Y"
- }
- },
- "xr-standard-thumbstick": {
- "x-axis": {
- rootNodeName: "THUMBSTICK_X"
- },
- "y-axis": {
- rootNodeName: "THUMBSTICK_Y"
- }
- }
- }
- },
- r.profileId = "microsoft-mixed-reality",
- r
- }
- return U(t, e),
- t.prototype._getFilenameAndPath = function() {
- return {
- filename: "left" === this.handedness ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
- path: t.MODEL_BASE_URL + "default/"
- }
- }
- ,
- t.prototype._getModelLoadingConstraints = function() {
- var e = od.IsPluginForExtensionAvailable(".glb");
- return e || K.Warn("glTF / glb loaded was not registered, using generic controller instead"),
- e
- }
- ,
- t.prototype._processLoadedModel = function(e) {
- var t = this;
- this.rootMesh && (this.getComponentIds().forEach((function(e, i) {
- if (!t.disableAnimation && e && t.rootMesh) {
- var n = t._mapping.buttons[e]
- , r = n.rootNodeName;
- if (!r)
- return void K.Log("Skipping unknown button at index: " + i + " with mapped name: " + e);
- var o = t._getChildByName(t.rootMesh, r);
- if (!o)
- return void K.Warn("Missing button mesh with name: " + r);
- if (n.valueMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.valueNodeName),
- n.pressedMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.pressedNodeName),
- n.unpressedMesh = t._getImmediateChildByName(o, t._mapping.defaultButton.unpressedNodeName),
- n.valueMesh && n.pressedMesh && n.unpressedMesh) {
- var a = t.getComponent(e);
- a && a.onButtonStateChangedObservable.add((function(e) {
- t._lerpTransform(n, e.value)
- }
- ), void 0, !0)
- } else
- K.Warn("Missing button submesh under mesh with name: " + r)
- }
- }
- )),
- this.getComponentIds().forEach((function(e) {
- var i = t.getComponent(e);
- i.isAxes() && ["x-axis", "y-axis"].forEach((function(n) {
- if (t.rootMesh) {
- var r = t._mapping.axes[e][n]
- , o = t._getChildByName(t.rootMesh, r.rootNodeName);
- o ? (r.valueMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.valueNodeName),
- r.minMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.minNodeName),
- r.maxMesh = t._getImmediateChildByName(o, t._mapping.defaultAxis.maxNodeName),
- r.valueMesh && r.minMesh && r.maxMesh ? i && i.onAxisValueChangedObservable.add((function(e) {
- var i = "x-axis" === n ? e.x : e.y;
- t._lerpTransform(r, i, !0)
- }
- ), void 0, !0) : K.Warn("Missing axis submesh under mesh with name: " + r.rootNodeName)) : K.Warn("Missing axis mesh with name: " + r.rootNodeName)
- }
- }
- ))
- }
- )))
- }
- ,
- t.prototype._setRootMesh = function(e) {
- var t;
- this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
- this.rootMesh.isPickable = !1;
- for (var i = 0; i < e.length; i++) {
- var n = e[i];
- n.isPickable = !1,
- n.parent || (t = n)
- }
- t && t.setParent(this.rootMesh),
- this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0))
- }
- ,
- t.prototype._updateModel = function() {}
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/microsoft/",
- t.MODEL_LEFT_FILENAME = "left.glb",
- t.MODEL_RIGHT_FILENAME = "right.glb",
- t
- }(xp);
- Ip.RegisterController("windows-mixed-reality", (function(e, t) {
- return new NE(t,e.gamepad,e.handedness)
- }
- ));
- var LE = {
- left: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {
- xr_standard_trigger_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_trigger_pressed_value",
- minNodeName: "xr_standard_trigger_pressed_min",
- maxNodeName: "xr_standard_trigger_pressed_max"
- }
- }
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {
- xr_standard_squeeze_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_squeeze_pressed_value",
- minNodeName: "xr_standard_squeeze_pressed_min",
- maxNodeName: "xr_standard_squeeze_pressed_max"
- }
- }
- },
- "xr-standard-touchpad": {
- type: "touchpad",
- gamepadIndices: {
- button: 2,
- xAxis: 0,
- yAxis: 1
- },
- rootNodeName: "xr_standard_touchpad",
- visualResponses: {
- xr_standard_touchpad_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_pressed_value",
- minNodeName: "xr_standard_touchpad_pressed_min",
- maxNodeName: "xr_standard_touchpad_pressed_max"
- },
- xr_standard_touchpad_xaxis_pressed: {
- componentProperty: "xAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_xaxis_pressed_value",
- minNodeName: "xr_standard_touchpad_xaxis_pressed_min",
- maxNodeName: "xr_standard_touchpad_xaxis_pressed_max"
- },
- xr_standard_touchpad_yaxis_pressed: {
- componentProperty: "yAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_yaxis_pressed_value",
- minNodeName: "xr_standard_touchpad_yaxis_pressed_min",
- maxNodeName: "xr_standard_touchpad_yaxis_pressed_max"
- },
- xr_standard_touchpad_xaxis_touched: {
- componentProperty: "xAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_xaxis_touched_value",
- minNodeName: "xr_standard_touchpad_xaxis_touched_min",
- maxNodeName: "xr_standard_touchpad_xaxis_touched_max"
- },
- xr_standard_touchpad_yaxis_touched: {
- componentProperty: "yAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_yaxis_touched_value",
- minNodeName: "xr_standard_touchpad_yaxis_touched_min",
- maxNodeName: "xr_standard_touchpad_yaxis_touched_max"
- },
- xr_standard_touchpad_axes_touched: {
- componentProperty: "state",
- states: ["touched", "pressed"],
- valueNodeProperty: "visibility",
- valueNodeName: "xr_standard_touchpad_axes_touched_value"
- }
- },
- touchPointNodeName: "xr_standard_touchpad_axes_touched_value"
- },
- "xr-standard-thumbstick": {
- type: "thumbstick",
- gamepadIndices: {
- button: 3,
- xAxis: 2,
- yAxis: 3
- },
- rootNodeName: "xr_standard_thumbstick",
- visualResponses: {
- xr_standard_thumbstick_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_thumbstick_pressed_value",
- minNodeName: "xr_standard_thumbstick_pressed_min",
- maxNodeName: "xr_standard_thumbstick_pressed_max"
- },
- xr_standard_thumbstick_xaxis_pressed: {
- componentProperty: "xAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value",
- minNodeName: "xr_standard_thumbstick_xaxis_pressed_min",
- maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max"
- },
- xr_standard_thumbstick_yaxis_pressed: {
- componentProperty: "yAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value",
- minNodeName: "xr_standard_thumbstick_yaxis_pressed_min",
- maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max"
- }
- }
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "microsoft-mixed-reality-left",
- assetPath: "left.glb"
- },
- right: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {
- xr_standard_trigger_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_trigger_pressed_value",
- minNodeName: "xr_standard_trigger_pressed_min",
- maxNodeName: "xr_standard_trigger_pressed_max"
- }
- }
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {
- xr_standard_squeeze_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_squeeze_pressed_value",
- minNodeName: "xr_standard_squeeze_pressed_min",
- maxNodeName: "xr_standard_squeeze_pressed_max"
- }
- }
- },
- "xr-standard-touchpad": {
- type: "touchpad",
- gamepadIndices: {
- button: 2,
- xAxis: 0,
- yAxis: 1
- },
- rootNodeName: "xr_standard_touchpad",
- visualResponses: {
- xr_standard_touchpad_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_pressed_value",
- minNodeName: "xr_standard_touchpad_pressed_min",
- maxNodeName: "xr_standard_touchpad_pressed_max"
- },
- xr_standard_touchpad_xaxis_pressed: {
- componentProperty: "xAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_xaxis_pressed_value",
- minNodeName: "xr_standard_touchpad_xaxis_pressed_min",
- maxNodeName: "xr_standard_touchpad_xaxis_pressed_max"
- },
- xr_standard_touchpad_yaxis_pressed: {
- componentProperty: "yAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_yaxis_pressed_value",
- minNodeName: "xr_standard_touchpad_yaxis_pressed_min",
- maxNodeName: "xr_standard_touchpad_yaxis_pressed_max"
- },
- xr_standard_touchpad_xaxis_touched: {
- componentProperty: "xAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_xaxis_touched_value",
- minNodeName: "xr_standard_touchpad_xaxis_touched_min",
- maxNodeName: "xr_standard_touchpad_xaxis_touched_max"
- },
- xr_standard_touchpad_yaxis_touched: {
- componentProperty: "yAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_touchpad_yaxis_touched_value",
- minNodeName: "xr_standard_touchpad_yaxis_touched_min",
- maxNodeName: "xr_standard_touchpad_yaxis_touched_max"
- },
- xr_standard_touchpad_axes_touched: {
- componentProperty: "state",
- states: ["touched", "pressed"],
- valueNodeProperty: "visibility",
- valueNodeName: "xr_standard_touchpad_axes_touched_value"
- }
- },
- touchPointNodeName: "xr_standard_touchpad_axes_touched_value"
- },
- "xr-standard-thumbstick": {
- type: "thumbstick",
- gamepadIndices: {
- button: 3,
- xAxis: 2,
- yAxis: 3
- },
- rootNodeName: "xr_standard_thumbstick",
- visualResponses: {
- xr_standard_thumbstick_pressed: {
- componentProperty: "button",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_thumbstick_pressed_value",
- minNodeName: "xr_standard_thumbstick_pressed_min",
- maxNodeName: "xr_standard_thumbstick_pressed_max"
- },
- xr_standard_thumbstick_xaxis_pressed: {
- componentProperty: "xAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_thumbstick_xaxis_pressed_value",
- minNodeName: "xr_standard_thumbstick_xaxis_pressed_min",
- maxNodeName: "xr_standard_thumbstick_xaxis_pressed_max"
- },
- xr_standard_thumbstick_yaxis_pressed: {
- componentProperty: "yAxis",
- states: ["default", "touched", "pressed"],
- valueNodeProperty: "transform",
- valueNodeName: "xr_standard_thumbstick_yaxis_pressed_value",
- minNodeName: "xr_standard_thumbstick_yaxis_pressed_min",
- maxNodeName: "xr_standard_thumbstick_yaxis_pressed_max"
- }
- }
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "microsoft-mixed-reality-right",
- assetPath: "right.glb"
- }
- }
- , FE = function(e) {
- function t(t, i, n, r, o) {
- void 0 === r && (r = !1),
- void 0 === o && (o = !1);
- var a = e.call(this, t, wE[n], i, n) || this;
- return a._forceLegacyControllers = o,
- a.profileId = "oculus-touch",
- a
- }
- return U(t, e),
- t.prototype._getFilenameAndPath = function() {
- return {
- filename: "left" === this.handedness ? t.MODEL_LEFT_FILENAME : t.MODEL_RIGHT_FILENAME,
- path: this._isQuest() ? t.QUEST_MODEL_BASE_URL : t.MODEL_BASE_URL
- }
- }
- ,
- t.prototype._getModelLoadingConstraints = function() {
- return !0
- }
- ,
- t.prototype._processLoadedModel = function(e) {
- var t = this
- , i = this._isQuest()
- , n = "right" === this.handedness ? -1 : 1;
- this.getComponentIds().forEach((function(e) {
- var r = e && t.getComponent(e);
- r && r.onButtonStateChangedObservable.add((function(r) {
- if (t.rootMesh && !t.disableAnimation)
- switch (e) {
- case "xr-standard-trigger":
- return void (i || (t._modelRootNode.getChildren()[3].rotation.x = .2 * -r.value,
- t._modelRootNode.getChildren()[3].position.y = .005 * -r.value,
- t._modelRootNode.getChildren()[3].position.z = .005 * -r.value));
- case "xr-standard-squeeze":
- return void (i || (t._modelRootNode.getChildren()[4].position.x = n * r.value * .0035));
- case "xr-standard-thumbstick":
- return;
- case "a-button":
- case "x-button":
- return void (i || (r.pressed ? t._modelRootNode.getChildren()[1].position.y = -.001 : t._modelRootNode.getChildren()[1].position.y = 0));
- case "b-button":
- case "y-button":
- return void (i || (r.pressed ? t._modelRootNode.getChildren()[2].position.y = -.001 : t._modelRootNode.getChildren()[2].position.y = 0))
- }
- }
- ), void 0, !0)
- }
- ))
- }
- ,
- t.prototype._setRootMesh = function(e) {
- this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
- this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0)),
- e.forEach((function(e) {
- e.isPickable = !1
- }
- )),
- this._isQuest() ? this._modelRootNode = e[0] : (this._modelRootNode = e[1],
- this.rootMesh.position.y = .034,
- this.rootMesh.position.z = .052),
- this._modelRootNode.parent = this.rootMesh
- }
- ,
- t.prototype._updateModel = function() {}
- ,
- t.prototype._isQuest = function() {
- return !!navigator.userAgent.match(/Quest/gi) && !this._forceLegacyControllers
- }
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/oculus/",
- t.MODEL_LEFT_FILENAME = "left.babylon",
- t.MODEL_RIGHT_FILENAME = "right.babylon",
- t.QUEST_MODEL_BASE_URL = "https://controllers.babylonjs.com/oculusQuest/",
- t
- }(xp);
- Ip.RegisterController("oculus-touch", (function(e, t) {
- return new FE(t,e.gamepad,e.handedness)
- }
- )),
- Ip.RegisterController("oculus-touch-legacy", (function(e, t) {
- return new FE(t,e.gamepad,e.handedness,!0)
- }
- ));
- var wE = {
- left: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {}
- },
- "xr-standard-thumbstick": {
- type: "thumbstick",
- gamepadIndices: {
- button: 3,
- xAxis: 2,
- yAxis: 3
- },
- rootNodeName: "xr_standard_thumbstick",
- visualResponses: {}
- },
- "x-button": {
- type: "button",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "x_button",
- visualResponses: {}
- },
- "y-button": {
- type: "button",
- gamepadIndices: {
- button: 5
- },
- rootNodeName: "y_button",
- visualResponses: {}
- },
- thumbrest: {
- type: "button",
- gamepadIndices: {
- button: 6
- },
- rootNodeName: "thumbrest",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "oculus-touch-v2-left",
- assetPath: "left.glb"
- },
- right: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {}
- },
- "xr-standard-thumbstick": {
- type: "thumbstick",
- gamepadIndices: {
- button: 3,
- xAxis: 2,
- yAxis: 3
- },
- rootNodeName: "xr_standard_thumbstick",
- visualResponses: {}
- },
- "a-button": {
- type: "button",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "a_button",
- visualResponses: {}
- },
- "b-button": {
- type: "button",
- gamepadIndices: {
- button: 5
- },
- rootNodeName: "b_button",
- visualResponses: {}
- },
- thumbrest: {
- type: "button",
- gamepadIndices: {
- button: 6
- },
- rootNodeName: "thumbrest",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "oculus-touch-v2-right",
- assetPath: "right.glb"
- }
- }
- , BE = function(e) {
- function t(t, i, n) {
- var r = e.call(this, t, UE[n], i, n) || this;
- return r.profileId = "htc-vive",
- r
- }
- return U(t, e),
- t.prototype._getFilenameAndPath = function() {
- return {
- filename: t.MODEL_FILENAME,
- path: t.MODEL_BASE_URL
- }
- }
- ,
- t.prototype._getModelLoadingConstraints = function() {
- return !0
- }
- ,
- t.prototype._processLoadedModel = function(e) {
- var t = this;
- this.getComponentIds().forEach((function(e) {
- var i = e && t.getComponent(e);
- i && i.onButtonStateChangedObservable.add((function(i) {
- if (t.rootMesh && !t.disableAnimation)
- switch (e) {
- case "xr-standard-trigger":
- return void (t._modelRootNode.getChildren()[6].rotation.x = .15 * -i.value);
- case "xr-standard-touchpad":
- case "xr-standard-squeeze":
- return
- }
- }
- ), void 0, !0)
- }
- ))
- }
- ,
- t.prototype._setRootMesh = function(e) {
- this.rootMesh = new Vr(this.profileId + " " + this.handedness,this.scene),
- e.forEach((function(e) {
- e.isPickable = !1
- }
- )),
- this._modelRootNode = e[1],
- this._modelRootNode.parent = this.rootMesh,
- this.scene.useRightHandedSystem || (this.rootMesh.rotationQuaternion = C.FromEulerAngles(0, Math.PI, 0))
- }
- ,
- t.prototype._updateModel = function() {}
- ,
- t.MODEL_BASE_URL = "https://controllers.babylonjs.com/vive/",
- t.MODEL_FILENAME = "wand.babylon",
- t
- }(xp);
- Ip.RegisterController("htc-vive", (function(e, t) {
- return new BE(t,e.gamepad,e.handedness)
- }
- ));
- var UE = {
- left: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {}
- },
- "xr-standard-touchpad": {
- type: "touchpad",
- gamepadIndices: {
- button: 2,
- xAxis: 0,
- yAxis: 1
- },
- rootNodeName: "xr_standard_touchpad",
- visualResponses: {}
- },
- menu: {
- type: "button",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "menu",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "htc_vive_none",
- assetPath: "none.glb"
- },
- right: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {}
- },
- "xr-standard-touchpad": {
- type: "touchpad",
- gamepadIndices: {
- button: 2,
- xAxis: 0,
- yAxis: 1
- },
- rootNodeName: "xr_standard_touchpad",
- visualResponses: {}
- },
- menu: {
- type: "button",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "menu",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "htc_vive_none",
- assetPath: "none.glb"
- },
- none: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- },
- "xr-standard-squeeze": {
- type: "squeeze",
- gamepadIndices: {
- button: 1
- },
- rootNodeName: "xr_standard_squeeze",
- visualResponses: {}
- },
- "xr-standard-touchpad": {
- type: "touchpad",
- gamepadIndices: {
- button: 2,
- xAxis: 0,
- yAxis: 1
- },
- rootNodeName: "xr_standard_touchpad",
- visualResponses: {}
- },
- menu: {
- type: "button",
- gamepadIndices: {
- button: 4
- },
- rootNodeName: "menu",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "htc-vive-none",
- assetPath: "none.glb"
- }
- }
- , VE = function() {
- function e(e) {
- this._nativeImpl = e,
- this._xrTransform = new XRRigidTransform,
- this._xrPose = {
- transform: this._xrTransform,
- emulatedPosition: !1
- },
- this._xrPoseVectorData = new Float32Array(8),
- this.fillPoses = this._nativeImpl.fillPoses.bind(this._nativeImpl),
- this.getViewerPose = this._nativeImpl.getViewerPose.bind(this._nativeImpl),
- this.getHitTestResults = this._nativeImpl.getHitTestResults.bind(this._nativeImpl),
- this.getHitTestResultsForTransientInput = function() {
- throw new Error("XRFrame.getHitTestResultsForTransientInput not supported on native.")
- }
- ,
- this.createAnchor = this._nativeImpl.createAnchor.bind(this._nativeImpl),
- this.getJointPose = this._nativeImpl.getJointPose.bind(this._nativeImpl),
- this.fillJointRadii = this._nativeImpl.fillJointRadii.bind(this._nativeImpl),
- this.getLightEstimate = function() {
- throw new Error("XRFrame.getLightEstimate not supported on native.")
- }
- ,
- this.getImageTrackingResults = this._nativeImpl.getImageTrackingResults.bind(this._nativeImpl)
- }
- return Object.defineProperty(e.prototype, "session", {
- get: function() {
- return this._nativeImpl.session
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getPose = function(e, t) {
- if (this._nativeImpl.getPoseData(e, t, this._xrPoseVectorData.buffer, this._xrTransform.matrix.buffer)) {
- var i = this._xrTransform.position;
- i.x = this._xrPoseVectorData[0],
- i.y = this._xrPoseVectorData[1],
- i.z = this._xrPoseVectorData[2],
- i.w = this._xrPoseVectorData[3];
- var n = this._xrTransform.orientation;
- return n.x = this._xrPoseVectorData[4],
- n.y = this._xrPoseVectorData[5],
- n.z = this._xrPoseVectorData[6],
- n.w = this._xrPoseVectorData[7],
- this._xrPose
- }
- }
- ,
- Object.defineProperty(e.prototype, "trackedAnchors", {
- get: function() {
- return this._nativeImpl.trackedAnchors
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldInformation", {
- get: function() {
- return this._nativeImpl.worldInformation
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "detectedPlanes", {
- get: function() {
- return this._nativeImpl.detectedPlanes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "featurePointCloud", {
- get: function() {
- return this._nativeImpl.featurePointCloud
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }();
- ou("NativeXRFrame", VE);
- var kE = void 0 !== e.g ? e.g : "undefined" != typeof window ? window : void 0;
- if (void 0 !== kE) {
- kE.BABYLON = kE.BABYLON || {};
- var GE = kE.BABYLON;
- GE.Debug = GE.Debug || {};
- var zE = [];
- for (var WE in i)
- GE.Debug[WE] = i[WE],
- zE.push(WE);
- for (var WE in n)
- GE[WE] = n[WE]
- }
- var HE = {
- AxesViewer: xl,
- BoneAxesViewer: Rl,
- PhysicsViewer: Wl,
- SkeletonViewer: cc
- };
- const XE = r;
- return t.default
- }
- )()
- }
- ));
- //# sourceMappingURL=babylon.js.map
|